aktion-runtime 0.5.11 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -28
- package/dist/aktion.iife.js +79 -78
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +6390 -5469
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +79 -78
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/language.js +1054 -121
- package/dist/language.js.map +1 -1
- package/dist/system_prompt.txt +43 -0
- package/dist/testing.js +1230 -232
- package/dist/testing.js.map +1 -1
- package/dist/types/language/index.d.ts +3 -2
- package/dist/types/language/namespaces.d.ts +102 -0
- package/dist/types/language-api.d.ts +1 -1
- package/dist/types/library/components/interop.d.ts +3 -0
- package/dist/types/runtime/evaluator.d.ts +15 -0
- package/dist/types/runtime/head.d.ts +17 -0
- package/dist/types/runtime/interop.d.ts +59 -0
- package/dist/types/runtime/ssr.d.ts +12 -0
- package/dist/types/tooling/index.d.ts +1 -1
- package/dist/types/tooling/schema.d.ts +32 -0
- package/package.json +1 -1
package/dist/aktion.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Aktion=function(
|
|
1
|
+
var Aktion=function(E){"use strict";var N0=Object.defineProperty;var I0=(E,_e,ht)=>_e in E?N0(E,_e,{enumerable:!0,configurable:!0,writable:!0,value:ht}):E[_e]=ht;var O=(E,_e,ht)=>I0(E,typeof _e!="symbol"?_e+"":_e,ht);const _e=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"]),ht=new Set(["(",")","[","]","{","}",",",":","?","."]),dc={true:"Boolean",false:"Boolean",null:"Null"};function Ha(t){const e=[];let r=0,n=1,a=1;const i=(l=0)=>t[r+l],o=(l,c,d,p)=>{e.push({type:l,value:c,line:d,column:p})},s=()=>{const l=t[r];return r+=1,l===`
|
|
2
2
|
`?(n+=1,a=1):a+=1,l};for(;r<t.length;){const l=i();if(l===void 0)break;if(l===`
|
|
3
3
|
`){const h=n,g=a;s(),o("Newline",`
|
|
4
4
|
`,h,g);continue}if(l===" "||l===" "||l==="\r"){s();continue}if(l==="/"&&i(1)==="/"){for(;r<t.length&&i()!==`
|
|
@@ -6,68 +6,68 @@ var Aktion=function(z){"use strict";var sw=Object.defineProperty;var lw=(z,je,pt
|
|
|
6
6
|
`;break;case"t":v+=" ";break;case"r":v+="\r";break;case"\\":v+="\\";break;case'"':v+='"';break;case"'":v+="'";break;case"`":v+="`";break;default:v+=x??""}continue}if(i()===`
|
|
7
7
|
`)break;v+=s()}i()===h&&s(),o("String",v,g,y);continue}if(l==="`"){const h=n,g=a;s();const y=[];let v="",x=!1;for(;r<t.length&&i()!=="`";){if(i()==="\\"&&i(1)!==void 0){s();const w=s();switch(w){case"n":v+=`
|
|
8
8
|
`;break;case"t":v+=" ";break;case"r":v+="\r";break;case"\\":v+="\\";break;case'"':v+='"';break;case"'":v+="'";break;case"`":v+="`";break;case"$":v+="$";break;default:v+=w??""}continue}if(i()==="$"&&i(1)==="{"){y.push({kind:"str",text:v}),v="";const w=n,k=a;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 C=$;for(S+=s();r<t.length&&i()!==C;){if(i()==="\\"&&i(1)!==void 0){S+=s(),S+=s();continue}if(i()===`
|
|
9
|
-
`)break;S+=s()}i()===C&&(S+=s());continue}if($==="{"){A+=1,S+=s();continue}if($==="}"){if(A-=1,A===0){s();break}S+=s();continue}S+=s()}y.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}v+=s()}if(i()==="`"&&s(),y.push({kind:"str",text:v}),!x){o("String",v,h,g);continue}e.push({type:"TemplateString",value:"",line:h,column:g,parts:y});continue}const u=e[e.length-1],d=!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(We(l)||l==="-"&&We(i(1)??"")&&d||l==="."&&We(i(1)??"")&&d){const h=n,g=a;let y="";l==="-"&&(y+=s());const v=i(1);if(i()==="0"&&(v==="x"||v==="X"||v==="b"||v==="B"||v==="o"||v==="O")){for(y+=s(),y+=s();r<t.length;){const k=i()??"";if(Ta(k)){y+=s();continue}if(k==="_"&&Ta(i(1)??"")){y+=s();continue}break}o("Number",y,h,g);continue}let x=!1,w=!1;for(;r<t.length;){const k=i()??"";if(We(k)){y+=s();continue}if(k==="_"&&We(i(1)??"")){y+=s();continue}if(k==="."&&!x&&!w&&We(i(1)??"")){x=!0,y+=s();continue}if((k==="e"||k==="E")&&!w){const A=i(1)??"",S=A==="+"||A==="-"?i(2)??"":A;if(We(S)){w=!0,y+=s(),(i()==="+"||i()==="-")&&(y+=s());continue}}break}o("Number",y,h,g);continue}if(l==="$"){const h=n,g=a;s();let y="";for(;r<t.length&&Na(i()??"");)y+=s();o("StateIdentifier",y,h,g);continue}if(Ma(l)){const h=n,g=a;let y="";for(;r<t.length&&Na(i()??"");)y+=s();const v=_l[y];v==="Boolean"?o("Boolean",y,h,g):v==="Null"?o("Null",y,h,g):je.has(y)?o("Keyword",y,h,g):o("Identifier",y,h,g);continue}if(l==="."&&i(1)==="."&&i(2)==="."){const h=n,g=a;s(),s(),s(),o("Operator","...",h,g);continue}const p=l+(i(1)??""),f=p+(i(2)??""),b=f+(i(3)??"");if(b===">>>="){const h=n,g=a;s(),s(),s(),s(),o("Operator",b,h,g);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const h=n,g=a;s(),s(),s(),o("Operator",f,h,g);continue}if(p==="=="||p==="!="||p===">="||p==="<="||p==="&&"||p==="||"||p==="??"||p==="?."||p==="->"||p==="=>"||p==="**"||p==="%="||p==="+="||p==="-="||p==="*="||p==="/="||p==="++"||p==="--"||p==="<<"||p===">>"||p==="&="||p==="|="||p==="^="){const h=n,g=a;s(),s(),o("Operator",p,h,g);continue}if("+-*/%!=<>&|^~".includes(l)){const h=n,g=a;s(),o("Operator",l,h,g);continue}if(pt.has(l)){const h=n,g=a;s(),o("Punctuation",l,h,g);continue}s()}return e.push({type:"EOF",value:"",line:n,column:a}),e}function We(t){return t>="0"&&t<="9"}function Ta(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}function Ma(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function Na(t){return Ma(t)||We(t)}function xe(t){const e=Aa(t),r=new Kl(e),n=[],a=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=Gt(r,!0);i&&n.push(i)}catch(i){const o=i;a.push(o),r.recoverToNextLine()}return{statements:n,errors:a}}function Gt(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return Hl(t);if(r.type==="Keyword")switch(r.value){case"function":return Kt(t);case"import":return Yl(t);case"export":return Xl(t);case"await":return Wl(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),Kt(t);break}case"return":return Gl(t);case"let":case"const":case"var":return _r(t);case"if":return Wa(t);case"switch":return nc(t);case"for":return ac(t);case"while":return oc(t);case"do":return sc(t);case"break":return lc(t);case"continue":return cc(t);case"throw":return uc(t);case"try":return dc(t)}const n=t.snapshot();if(Ia(t))try{return Ra(t)}catch(a){if(a&&typeof a=="object"&&a.__definitive)throw a;t.restore(n)}return Ul(t)}function Ia(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 Ul(t){const e=t.peek();let r=G(t);const n=t.peek();if(n.type==="Operator"&&Pa(n.value)){if(Ea(r)){t.consume();const a=G(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,a,{kind:"Literal",value:n.value}],loc:{line:n.line,column:n.column}}}}else n.type==="Operator"&&(n.value==="++"||n.value==="--")&&Ea(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:n.value}],loc:{line:n.line,column:n.column}});return se(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function Pa(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function Ea(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function Kt(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",n=r?t.consume():t.expect("Identifier"),a=za(t),i=tt(t);return se(t),r?{kind:"HookDeclaration",name:n.value,params:a,body:i,loc:{line:e.line,column:e.column}}:n.value.length>0&&n.value[0]>="A"&&n.value[0]<="Z"?{kind:"ComponentDeclaration",name:n.value,params:a,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:n.value,params:a,body:i,loc:{line:e.line,column:e.column}}}function za(t){t.expect("Punctuation","(");const e=[];if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){D(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const n=t.peek();if(!r&&n.type==="Punctuation"&&(n.value==="{"||n.value==="[")){const a=Ur(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=G(t));const o={name:"",pattern:a};i&&(o.defaultValue=i),e.push(o)}else if(n.type==="Identifier"||n.type==="Keyword"){const a=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=G(t));const o={name:a.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${n.type} "${n.value}"`,line:n.line,column:n.column};if(D(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(),D(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function Hl(t){const e=t.consume();t.expect("Punctuation","("),D(t);const r=G(t);let n;r.kind==="Lambda"?n=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:n={kind:"Block",body:[]};const a=[];let i;if(D(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)ql(t,a,s=>{i=s}),D(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),D(t));t.expect("Punctuation","]")}else G(t);D(t),t.expect("Punctuation",")"),se(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:a,body:n,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function ql(t,e,r){const n=t.peek();if(n.type==="StateIdentifier"){t.consume();let a=n.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(),a+="."+i.value}e.push({kind:"state",name:a});return}if(n.type==="String"){t.consume();const a=n.value;if(a==="mount"||a==="unmount"){e.push({kind:"lifecycle",name:a});return}const i=a.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=a.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=a.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${a}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:n.line,column:n.column}}throw{message:`Unexpected ${n.type} "${n.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:n.line,column:n.column}}function _r(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return Vl(t,e);let n="",a=!1;if(r.type==="StateIdentifier")n=t.consume().value,a=!0;else if(r.type==="Identifier")n=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=G(t);return se(t),{kind:"Assignment",identifier:n,isState:a,expression:i,loc:{line:e.line,column:e.column}}}function Vl(t,e){const r=Ur(t);t.expect("Operator","=");const n=G(t);return se(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:n,loc:{line:e.line,column:e.column}}}function Ur(t){const r=t.consume().value==="["?"array":"object",n=[];if(r==="array"){for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){n.push({name:""}),t.consume(),D(t);continue}let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.expect("Identifier");let o;!a&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=G(t));const s={name:i.value};if(a&&(s.rest=!0),o&&(s.defaultValue=o),n.push(s),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),D(t);continue}break}t.expect("Punctuation","]")}else{for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.expect("Identifier");let o=i.value,s;if(!a&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const d=t.expect("Identifier");s=i.value,o=d.value}let l;!a&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),l=G(t));const u={name:o};if(s&&(u.sourceKey=s),a&&(u.rest=!0),l&&(u.defaultValue=l),n.push(u),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),D(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:n}}function tt(t){const e=t.expect("Punctuation","{"),r=[];for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const n=Gt(t);n&&r.push(n),D(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function mt(t){if(D(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return tt(t);const e=t.peek(),r=Gt(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function Wl(t){const e=t.expect("Keyword","await"),r=G(t);return se(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function Gl(t){const e=t.expect("Keyword","return");let r;const n=t.peek();return n.type!=="Newline"&&n.type!=="Semicolon"&&!(n.type==="Punctuation"&&n.value==="}")&&(r=G(t)),se(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class Kl{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 n=this.peek();return n.type!==e||r!==void 0&&n.value!==r?!1:(this.consume(),!0)}expect(e,r){const n=this.peek();if(n.type!==e||r!==void 0&&n.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${n.type} "${n.value}"`,line:n.line,column:n.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 Ra(t){const e=t.peek();let r="",n=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,n=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const a=t.expect("Operator","="),i=G(t);return se(t),{kind:"Assignment",identifier:r,isState:n,expression:i,loc:{line:a.line,column:a.column}}}function Yl(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 l=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const u=t.peek();let d=!1;if(u.type==="StateIdentifier")l=t.consume().value,d=!0;else if(u.type==="Identifier")l=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${u.type} "${u.value}"`,line:u.line,column:u.column};if(d!==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:l,isState:!0}:{imported:o,local:l}),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}t.expect("Punctuation","}");const n=t.peek();if(!(n.type==="Identifier"&&n.value==="from"))throw{message:`Expected \`from\` after import specifiers, got ${n.type} "${n.value}"`,line:n.line,column:n.column};t.consume();const a=t.expect("String");return se(t),{kind:"Import",specifiers:r,source:a.value,loc:{line:e.line,column:e.column}}}function Xl(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 n;if(r.type==="Keyword"&&r.value==="function")n=Kt(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),n=Kt(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(n=_r(t),n&&n.kind==="DestructureStatement")throw{message:"`export` of a destructuring declaration is not supported — export named bindings individually.",line:r.line,column:r.column}}else if(Ia(t))n=Ra(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(n&&(n.kind==="Assignment"||n.kind==="ComponentDeclaration"||n.kind==="ActionDeclaration"||n.kind==="HookDeclaration"))return n.exported=!0,n;throw{message:"`export` must be followed by a declaration or assignment.",line:e.line,column:e.column}}function G(t){return Ql(t)}function Zl(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function be(t,e){const{token:r,skipped:n}=Zl(t);if(!e(r))return!1;for(let a=0;a<n;a+=1)t.consume();return!0}function Ql(t){const e=Jl(t);if(be(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),D(t);const r=G(t);D(t),t.expect("Punctuation",":"),D(t);const n=G(t);return{kind:"Ternary",test:e,consequent:r,alternate:n}}return e}function Jl(t){let e=La(t);for(;be(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;D(t);const n=La(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function La(t){let e=Da(t);for(;be(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),D(t);const r=Da(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Da(t){let e=ja(t);for(;be(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),D(t);const r=ja(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function ja(t){let e=Ba(t);for(;be(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),D(t);const r=Ba(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function Ba(t){let e=Oa(t);for(;be(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),D(t);const r=Oa(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function Oa(t){let e=Fa(t);for(;be(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;D(t);const n=Fa(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function Fa(t){let e=Hr(t);for(;;){if(be(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;D(t);const n=Hr(t);e={kind:"Binary",operator:r,left:e,right:n};continue}if(be(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;D(t);const n=Hr(t);e={kind:"Binary",operator:r,left:e,right:n};continue}break}return e}function Hr(t){let e=_a(t);for(;be(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;D(t);const n=_a(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function _a(t){let e=Ua(t);for(;be(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;D(t);const n=Ua(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function Ua(t){let e=qr(t);for(;be(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;D(t);const n=qr(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function qr(t){const e=Ct(t);if(be(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),D(t);const r=qr(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function Ct(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=Ct(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:[Ct(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:[Ct(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=Ct(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=qa(t),n=[];if(r.kind==="Call")n=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=G(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),n=Be(t),t.expect("Punctuation",")"))}const a={kind:"New",callee:r,arguments:n,loc:{line:e.line,column:e.column}};return Ha(t,a)}return ec(t)}function ec(t){const e=tc(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 tc(t){return Ha(t,qa(t))}function Ha(t,e){let r=e;for(;;){be(t,a=>a.type==="Punctuation"&&a.value==="."||a.type==="Operator"&&a.value==="?.");const n=t.peek();if(n.type==="Punctuation"&&n.value==="."){t.consume();const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword"&&a.type!=="StateIdentifier")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Be(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:a.value,arguments:o,loc:{line:a.line,column:a.column}};continue}r={kind:"Member",object:r,property:a.value};continue}if(n.type==="Operator"&&n.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const a=G(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:a,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const a=Be(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:a,optional:!0,loc:{line:n.line,column:n.column}}}else{const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword"&&a.type!=="StateIdentifier")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Be(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:a.value,arguments:o,optional:!0,loc:{line:a.line,column:a.column}};continue}r={kind:"Member",object:r,property:a.value,optional:!0}}continue}if(n.type==="Punctuation"&&n.value==="["){t.consume();const a=G(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:a};continue}if(n.type==="Punctuation"&&n.value==="("){t.consume();const a=Be(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:a,loc:{line:n.line,column:n.column}};continue}break}return r}function qa(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.`,n={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw n.__definitive=!0,n}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),n=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&n.type==="Punctuation"&&n.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=za(t),s=tt(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=Be(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:fc(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],n=[],a=[];let i="",o=!1;const s=()=>{n.push(i),i="",o=!1};for(const l of r){if(l.kind==="str"){i+=l.text,o=!0;continue}o?s():n.push("");const d=xe(`__rui_tmpl__ = ${l.source}`).statements[0];d&&d.kind==="Assignment"?a.push(d.expression):a.push({kind:"Literal",value:""})}for((o||n.length===0)&&n.push(i);n.length<=a.length;)n.push("");return{kind:"Template",quasis:n,expressions:a,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(),rc(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=Ga(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=Be(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=Be(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=mc(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),n=pc(t);if(n)return n;t.restore(r),t.consume();const a=G(t);return t.expect("Punctuation",")"),a}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function rc(t,e){t.consume();const r=Be(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Be(t){const e=[];if(D(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(Va(t)),D(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),D(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(Va(t)),D(t);return D(t),e}function Va(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:G(t),loc:{line:e.line,column:e.column}}}return G(t)}function Wa(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=G(t);t.expect("Punctuation",")");const n=mt(t);let a;return D(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),D(t),t.peek().type==="Keyword"&&t.peek().value==="if"?a=Wa(t):a=mt(t)),se(t),{kind:"IfStatement",test:r,consequent:n,alternate:a,loc:{line:e.line,column:e.column}}}function nc(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=G(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const n=[];for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let a=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),a=G(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),a=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",":"),D(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=Gt(t);o&&i.push(o),D(t)}n.push({test:a,body:i}),D(t)}return t.expect("Punctuation","}"),se(t),{kind:"SwitchStatement",discriminant:r,cases:n,loc:{line:e.line,column:e.column}}}function ac(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),D(t);const r=t.snapshot();let n="for-of";{let u=1,d=0;for(;;){const p=t.peek(d);if(p.type==="EOF")break;if(p.type==="Punctuation"&&p.value==="(")u+=1;else if(p.type==="Punctuation"&&p.value===")"){if(u-=1,u===0)break}else if(u===1&&p.type==="Semicolon"){n="classic";break}else if(u===1&&p.type==="Keyword"&&p.value==="of"){n="for-of";break}else if(u===1&&p.type==="Keyword"&&p.value==="in"){n="for-in";break}d+=1}}if(t.restore(r),n==="classic")return ic(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),D(t);let a,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),a=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","}"),a="__row",o=u}else a=t.expect("Identifier").value;n==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=G(t);t.expect("Punctuation",")");const l=mt(t);return se(t),n==="for-in"?{kind:"ForInStatement",item:a,iterable:s,body:l,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:a,index:i,destructure:o,iterable:s,body:l,loc:{line:e.line,column:e.column}}}function ic(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=_r(t);o.kind==="Assignment"&&(r=o),D(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:G(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),D(t)}else t.expect("Semicolon"),D(t);let n;t.peek().type!=="Semicolon"&&(n=G(t)),t.expect("Semicolon"),D(t);let a;t.peek().type==="Punctuation"&&t.peek().value===")"||(a=Ka(t)),t.expect("Punctuation",")");const i=mt(t);return se(t),{kind:"ForClassicStatement",init:r,test:n,update:a,body:i,loc:{line:e.line,column:e.column}}}function oc(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=G(t);t.expect("Punctuation",")");const n=mt(t);return se(t),{kind:"WhileStatement",test:r,body:n,loc:{line:e.line,column:e.column}}}function sc(t){const e=t.expect("Keyword","do"),r=mt(t);D(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const n=G(t);return t.expect("Punctuation",")"),se(t),{kind:"DoWhileStatement",test:n,body:r,loc:{line:e.line,column:e.column}}}function lc(t){const e=t.expect("Keyword","break");return se(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function cc(t){const e=t.expect("Keyword","continue");return se(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function uc(t){const e=t.expect("Keyword","throw"),r=G(t);return se(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function dc(t){const e=t.expect("Keyword","try"),r=tt(t);let n,a,i;return D(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(n=t.consume().value),t.expect("Punctuation",")")),a=tt(t),D(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=tt(t)),se(t),{kind:"TryStatement",block:r,catchParam:n,catchBlock:a,finallyBlock:i,loc:{line:e.line,column:e.column}}}function pc(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){D(t);let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.peek();if(!a&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=Ur(t)}catch{return null}const l={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{l.defaultValue=G(t)}catch{return null}}if(r.push(l),D(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(a&&(o.rest=!0),!a&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=G(t)}catch{return null}}if(r.push(o),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(a)return null;t.consume();continue}break}if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const n=Ga(t);return{kind:"Lambda",params:r,body:n,loc:{line:e.line,column:e.column}}}function Ga(t){return D(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?tt(t):Ka(t)}function Ka(t){const e=G(t),r=t.peek();if(r.type==="Operator"){if(Pa(r.value)){t.consume();const n=G(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,n,{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 mc(t){const e=[];if(D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){D(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const l=G(t);if(e.push({key:"",value:l,spread:!0}),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let n,a;if(r.type==="Punctuation"&&r.value==="[")t.consume(),D(t),a=G(t),D(t),t.expect("Punctuation","]"),n="";else if(r.type==="Number")n=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")n=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;!a&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:n,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=G(t));const s={key:n,value:o};if(a&&(s.computedKey=a),e.push(s),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return D(t),e}function D(t){for(;t.match("Newline")||t.match("Semicolon"););}function se(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function fc(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 gc(t){const e=xe(t);return Ya(t,e)}function Ya(t,e){const r=new Set(e.errors.map(s=>s.line)),n=[],a=[];for(const s of e.statements){const l=s.loc?.line??0;if(r.has(l)){a.push(s);continue}n.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(d=>d.line)),l=bc(t,s);i=l.before,o=l.after;const u=n.findIndex(d=>(d.loc?.line??0)>=s);if(u>=0)for(const d of n.splice(u))a.push(d)}return{committedSource:i,draftingSource:o,committedBindings:n.map(Xa).filter(s=>s!==null),uncommittedBindings:a.map(Xa).filter(s=>s!==null),committedStatements:n,errors:e.errors}}function hc(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const n of e)if(!r.has(n))return!1;return!0}function Xa(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function bc(t,e){if(e<=1)return{before:"",after:t};let r=0,n=1;for(;r<t.length&&n<e;)t[r]===`
|
|
10
|
-
`&&(n+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}const
|
|
9
|
+
`)break;S+=s()}i()===C&&(S+=s());continue}if($==="{"){A+=1,S+=s();continue}if($==="}"){if(A-=1,A===0){s();break}S+=s();continue}S+=s()}y.push({kind:"expr",source:S,line:w,column:k}),x=!0;continue}v+=s()}if(i()==="`"&&s(),y.push({kind:"str",text:v}),!x){o("String",v,h,g);continue}e.push({type:"TemplateString",value:"",line:h,column:g,parts:y});continue}const c=e[e.length-1],d=!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(Xe(l)||l==="-"&&Xe(i(1)??"")&&d||l==="."&&Xe(i(1)??"")&&d){const h=n,g=a;let y="";l==="-"&&(y+=s());const v=i(1);if(i()==="0"&&(v==="x"||v==="X"||v==="b"||v==="B"||v==="o"||v==="O")){for(y+=s(),y+=s();r<t.length;){const k=i()??"";if(qa(k)){y+=s();continue}if(k==="_"&&qa(i(1)??"")){y+=s();continue}break}o("Number",y,h,g);continue}let x=!1,w=!1;for(;r<t.length;){const k=i()??"";if(Xe(k)){y+=s();continue}if(k==="_"&&Xe(i(1)??"")){y+=s();continue}if(k==="."&&!x&&!w&&Xe(i(1)??"")){x=!0,y+=s();continue}if((k==="e"||k==="E")&&!w){const A=i(1)??"",S=A==="+"||A==="-"?i(2)??"":A;if(Xe(S)){w=!0,y+=s(),(i()==="+"||i()==="-")&&(y+=s());continue}}break}o("Number",y,h,g);continue}if(l==="$"){const h=n,g=a;s();let y="";for(;r<t.length&&Wa(i()??"");)y+=s();o("StateIdentifier",y,h,g);continue}if(Va(l)){const h=n,g=a;let y="";for(;r<t.length&&Wa(i()??"");)y+=s();const v=dc[y];v==="Boolean"?o("Boolean",y,h,g):v==="Null"?o("Null",y,h,g):_e.has(y)?o("Keyword",y,h,g):o("Identifier",y,h,g);continue}if(l==="."&&i(1)==="."&&i(2)==="."){const h=n,g=a;s(),s(),s(),o("Operator","...",h,g);continue}const p=l+(i(1)??""),f=p+(i(2)??""),b=f+(i(3)??"");if(b===">>>="){const h=n,g=a;s(),s(),s(),s(),o("Operator",b,h,g);continue}if(f==="==="||f==="!=="||f==="**="||f==="??="||f==="&&="||f==="||="||f===">>>"||f===">>="||f==="<<="){const h=n,g=a;s(),s(),s(),o("Operator",f,h,g);continue}if(p==="=="||p==="!="||p===">="||p==="<="||p==="&&"||p==="||"||p==="??"||p==="?."||p==="->"||p==="=>"||p==="**"||p==="%="||p==="+="||p==="-="||p==="*="||p==="/="||p==="++"||p==="--"||p==="<<"||p===">>"||p==="&="||p==="|="||p==="^="){const h=n,g=a;s(),s(),o("Operator",p,h,g);continue}if("+-*/%!=<>&|^~".includes(l)){const h=n,g=a;s(),o("Operator",l,h,g);continue}if(ht.has(l)){const h=n,g=a;s(),o("Punctuation",l,h,g);continue}s()}return e.push({type:"EOF",value:"",line:n,column:a}),e}function Xe(t){return t>="0"&&t<="9"}function qa(t){return t>="0"&&t<="9"||t>="a"&&t<="f"||t>="A"&&t<="F"}function Va(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_"}function Wa(t){return Va(t)||Xe(t)}function Se(t){const e=Ha(t),r=new vc(e),n=[],a=[];for(;!r.isEnd();)if(!(r.match("Newline")||r.match("Semicolon")))try{const i=Zt(r,!0);i&&n.push(i)}catch(i){const o=i;a.push(o),r.recoverToNextLine()}return{statements:n,errors:a}}function Zt(t,e){const r=t.peek();if(r.type==="StateIdentifier"&&r.value==="effect"&&t.peek(1).type==="Punctuation"&&t.peek(1).value==="(")return mc(t);if(r.type==="Keyword")switch(r.value){case"function":return er(t);case"import":return yc(t);case"export":return xc(t);case"await":return hc(t);case"async":{if(t.peek(1).type==="Keyword"&&t.peek(1).value==="function")return t.consume(),er(t);break}case"return":return bc(t);case"let":case"const":case"var":return Jr(t);case"if":return ci(t);case"switch":return Tc(t);case"for":return Mc(t);case"while":return Ic(t);case"do":return Pc(t);case"break":return Rc(t);case"continue":return Ec(t);case"throw":return Lc(t);case"try":return zc(t)}const n=t.snapshot();if(Ga(t))try{return Ja(t)}catch(a){if(a&&typeof a=="object"&&a.__definitive)throw a;t.restore(n)}return pc(t)}function Ga(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 pc(t){const e=t.peek();let r=X(t);const n=t.peek();if(n.type==="Operator"&&Ka(n.value)){if(Ya(r)){t.consume();const a=X(t);r={kind:"BuiltinCall",name:"__rui_assign__",arguments:[r,a,{kind:"Literal",value:n.value}],loc:{line:n.line,column:n.column}}}}else n.type==="Operator"&&(n.value==="++"||n.value==="--")&&Ya(r)&&(t.consume(),r={kind:"BuiltinCall",name:"__rui_postfix__",arguments:[r,{kind:"Literal",value:n.value}],loc:{line:n.line,column:n.column}});return ue(t),{kind:"ExpressionStatement",expression:r,loc:{line:e.line,column:e.column}}}function Ka(t){return t==="="||t==="+="||t==="-="||t==="*="||t==="/="||t==="%="||t==="**="||t==="??="||t==="&&="||t==="||="||t==="&="||t==="|="||t==="^="||t==="<<="||t===">>="||t===">>>="}function Ya(t){return t.kind==="Member"||t.kind==="StateRef"||t.kind==="Identifier"}function er(t){const e=t.expect("Keyword","function"),r=t.peek().type==="StateIdentifier",n=r?t.consume():t.expect("Identifier"),a=Xa(t),i=it(t);return ue(t),r?{kind:"HookDeclaration",name:n.value,params:a,body:i,loc:{line:e.line,column:e.column}}:n.value.length>0&&n.value[0]>="A"&&n.value[0]<="Z"?{kind:"ComponentDeclaration",name:n.value,params:a,slots:[],body:i,loc:{line:e.line,column:e.column}}:{kind:"ActionDeclaration",name:n.value,params:a,body:i,loc:{line:e.line,column:e.column}}}function Xa(t){t.expect("Punctuation","(");const e=[];if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){D(t);let r=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),r=!0);const n=t.peek();if(!r&&n.type==="Punctuation"&&(n.value==="{"||n.value==="[")){const a=Qr(t);let i;t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=X(t));const o={name:"",pattern:a};i&&(o.defaultValue=i),e.push(o)}else if(n.type==="Identifier"||n.type==="Keyword"){const a=t.consume();let i;!r&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),i=X(t));const o={name:a.value};i&&(o.defaultValue=i),r&&(o.rest=!0),e.push(o)}else throw{message:`Expected parameter name, got ${n.type} "${n.value}"`,line:n.line,column:n.column};if(D(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(),D(t),t.peek().type==="Punctuation"&&t.peek().value===")")break;continue}break}return t.expect("Punctuation",")"),e}function mc(t){const e=t.consume();t.expect("Punctuation","("),D(t);const r=X(t);let n;r.kind==="Lambda"?n=r.body.kind==="Block"?r.body:{kind:"Block",body:[{kind:"ExpressionStatement",expression:r.body}]}:n={kind:"Block",body:[]};const a=[];let i;if(D(t),t.peek().type==="Punctuation"&&t.peek().value===",")if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="["){for(t.consume(),D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");)fc(t,a,s=>{i=s}),D(t),t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),D(t));t.expect("Punctuation","]")}else X(t);D(t),t.expect("Punctuation",")"),ue(t);const o={kind:"EffectDeclaration",name:`__effect_L${e.line}_C${e.column}`,triggers:a,body:n,loc:{line:e.line,column:e.column}};return i&&(o.rateLimit=i),o}function fc(t,e,r){const n=t.peek();if(n.type==="StateIdentifier"){t.consume();let a=n.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(),a+="."+i.value}e.push({kind:"state",name:a});return}if(n.type==="String"){t.consume();const a=n.value;if(a==="mount"||a==="unmount"){e.push({kind:"lifecycle",name:a});return}const i=a.match(/^every\((\d+)\)$/);if(i){e.push({kind:"every",intervalMs:Number(i[1])});return}const o=a.match(/^debounce\((\d+)\)$/);if(o){r({kind:"debounce",ms:Number(o[1])});return}const s=a.match(/^throttle\((\d+)\)$/);if(s){r({kind:"throttle",ms:Number(s[1])});return}throw{message:`Unknown effect dependency string "${a}". Expected "mount", "unmount", "every(N)", "debounce(N)", or "throttle(N)".`,line:n.line,column:n.column}}throw{message:`Unexpected ${n.type} "${n.value}" inside effect dependency array. Expected $state or a string token ("mount", "unmount", "every(N)", etc.).`,line:n.line,column:n.column}}function Jr(t){const e=t.consume(),r=t.peek();if(r.type==="Punctuation"&&(r.value==="["||r.value==="{"))return gc(t,e);let n="",a=!1;if(r.type==="StateIdentifier")n=t.consume().value,a=!0;else if(r.type==="Identifier")n=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=X(t);return ue(t),{kind:"Assignment",identifier:n,isState:a,expression:i,loc:{line:e.line,column:e.column}}}function gc(t,e){const r=Qr(t);t.expect("Operator","=");const n=X(t);return ue(t),{kind:"DestructureStatement",patternKind:r.kind,bindings:r.bindings,expression:n,loc:{line:e.line,column:e.column}}}function Qr(t){const r=t.consume().value==="["?"array":"object",n=[];if(r==="array"){for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="]");){if(t.peek().type==="Punctuation"&&t.peek().value===","){n.push({name:""}),t.consume(),D(t);continue}let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.expect("Identifier");let o;!a&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),o=X(t));const s={name:i.value};if(a&&(s.rest=!0),o&&(s.defaultValue=o),n.push(s),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),D(t);continue}break}t.expect("Punctuation","]")}else{for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.expect("Identifier");let o=i.value,s;if(!a&&t.peek().type==="Punctuation"&&t.peek().value===":"){t.consume();const d=t.expect("Identifier");s=i.value,o=d.value}let l;!a&&t.peek().type==="Operator"&&t.peek().value==="="&&(t.consume(),l=X(t));const c={name:o};if(s&&(c.sourceKey=s),a&&(c.rest=!0),l&&(c.defaultValue=l),n.push(c),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume(),D(t);continue}break}t.expect("Punctuation","}")}return{kind:r,bindings:n}}function it(t){const e=t.expect("Punctuation","{"),r=[];for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){const n=Zt(t);n&&r.push(n),D(t)}return t.expect("Punctuation","}"),{kind:"Block",body:r,loc:{line:e.line,column:e.column}}}function bt(t){if(D(t),t.peek().type==="Punctuation"&&t.peek().value==="{")return it(t);const e=t.peek(),r=Zt(t);return{kind:"Block",body:r?[r]:[],loc:{line:e.line,column:e.column}}}function hc(t){const e=t.expect("Keyword","await"),r=X(t);return ue(t),{kind:"Await",argument:r,loc:{line:e.line,column:e.column}}}function bc(t){const e=t.expect("Keyword","return");let r;const n=t.peek();return n.type!=="Newline"&&n.type!=="Semicolon"&&!(n.type==="Punctuation"&&n.value==="}")&&(r=X(t)),ue(t),{kind:"Return",argument:r,loc:{line:e.line,column:e.column}}}class vc{constructor(e){O(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 n=this.peek();return n.type!==e||r!==void 0&&n.value!==r?!1:(this.consume(),!0)}expect(e,r){const n=this.peek();if(n.type!==e||r!==void 0&&n.value!==r)throw{message:`Expected ${e}${r!==void 0?` "${r}"`:""} but got ${n.type} "${n.value}"`,line:n.line,column:n.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 Ja(t){const e=t.peek();let r="",n=!1;if(e.type==="Identifier")r=t.consume().value;else if(e.type==="StateIdentifier")r=t.consume().value,n=!0;else throw{message:`Expected identifier at start of statement, got ${e.type} "${e.value}"`,line:e.line,column:e.column};const a=t.expect("Operator","="),i=X(t);return ue(t),{kind:"Assignment",identifier:r,isState:n,expression:i,loc:{line:a.line,column:a.column}}}function yc(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 l=o;if(t.peek().type==="Identifier"&&t.peek().value==="as"){t.consume();const c=t.peek();let d=!1;if(c.type==="StateIdentifier")l=t.consume().value,d=!0;else if(c.type==="Identifier")l=t.consume().value;else throw{message:`Expected an alias after \`as\`, got ${c.type} "${c.value}"`,line:c.line,column:c.column};if(d!==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:l,isState:!0}:{imported:o,local:l}),t.peek().type==="Punctuation"&&t.peek().value===","){t.consume();continue}break}t.expect("Punctuation","}");const n=t.peek();if(!(n.type==="Identifier"&&n.value==="from"))throw{message:`Expected \`from\` after import specifiers, got ${n.type} "${n.value}"`,line:n.line,column:n.column};t.consume();const a=t.expect("String");return ue(t),{kind:"Import",specifiers:r,source:a.value,loc:{line:e.line,column:e.column}}}function xc(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 n;if(r.type==="Keyword"&&r.value==="function")n=er(t);else if(r.type==="Keyword"&&r.value==="async"&&t.peek(1).type==="Keyword"&&t.peek(1).value==="function")t.consume(),n=er(t);else if(r.type==="Keyword"&&(r.value==="let"||r.value==="const"||r.value==="var")){if(n=Jr(t),n&&n.kind==="DestructureStatement")throw{message:"`export` of a destructuring declaration is not supported — export named bindings individually.",line:r.line,column:r.column}}else if(Ga(t))n=Ja(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(n&&(n.kind==="Assignment"||n.kind==="ComponentDeclaration"||n.kind==="ActionDeclaration"||n.kind==="HookDeclaration"))return n.exported=!0,n;throw{message:"`export` must be followed by a declaration or assignment.",line:e.line,column:e.column}}function X(t){return kc(t)}function wc(t){let e=0;for(;;){const r=t.peek(e);if(r.type==="Newline"){e+=1;continue}return{token:r,skipped:e}}}function xe(t,e){const{token:r,skipped:n}=wc(t);if(!e(r))return!1;for(let a=0;a<n;a+=1)t.consume();return!0}function kc(t){const e=Sc(t);if(xe(t,r=>r.type==="Punctuation"&&r.value==="?")){t.consume(),D(t);const r=X(t);D(t),t.expect("Punctuation",":"),D(t);const n=X(t);return{kind:"Ternary",test:e,consequent:r,alternate:n}}return e}function Sc(t){let e=Qa(t);for(;xe(t,r=>r.type==="Operator"&&(r.value==="||"||r.value==="??"));){const r=t.consume().value;D(t);const n=Qa(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function Qa(t){let e=Za(t);for(;xe(t,r=>r.type==="Operator"&&r.value==="&&");){t.consume(),D(t);const r=Za(t);e={kind:"Binary",operator:"&&",left:e,right:r}}return e}function Za(t){let e=ei(t);for(;xe(t,r=>r.type==="Operator"&&r.value==="|");){t.consume(),D(t);const r=ei(t);e={kind:"Binary",operator:"|",left:e,right:r}}return e}function ei(t){let e=ti(t);for(;xe(t,r=>r.type==="Operator"&&r.value==="^");){t.consume(),D(t);const r=ti(t);e={kind:"Binary",operator:"^",left:e,right:r}}return e}function ti(t){let e=ri(t);for(;xe(t,r=>r.type==="Operator"&&r.value==="&");){t.consume(),D(t);const r=ri(t);e={kind:"Binary",operator:"&",left:e,right:r}}return e}function ri(t){let e=ni(t);for(;xe(t,r=>r.type==="Operator"&&(r.value==="=="||r.value==="!="||r.value==="==="||r.value==="!=="));){const r=t.consume().value;D(t);const n=ni(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function ni(t){let e=Zr(t);for(;;){if(xe(t,r=>r.type==="Operator"&&(r.value===">"||r.value==="<"||r.value===">="||r.value==="<="))){const r=t.consume().value;D(t);const n=Zr(t);e={kind:"Binary",operator:r,left:e,right:n};continue}if(xe(t,r=>r.type==="Keyword"&&(r.value==="instanceof"||r.value==="in"))){const r=t.consume().value;D(t);const n=Zr(t);e={kind:"Binary",operator:r,left:e,right:n};continue}break}return e}function Zr(t){let e=ai(t);for(;xe(t,r=>r.type==="Operator"&&(r.value==="<<"||r.value===">>"||r.value===">>>"));){const r=t.consume().value;D(t);const n=ai(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function ai(t){let e=ii(t);for(;xe(t,r=>r.type==="Operator"&&(r.value==="+"||r.value==="-"));){const r=t.consume().value;D(t);const n=ii(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function ii(t){let e=en(t);for(;xe(t,r=>r.type==="Operator"&&(r.value==="*"||r.value==="/"||r.value==="%"));){const r=t.consume().value;D(t);const n=en(t);e={kind:"Binary",operator:r,left:e,right:n}}return e}function en(t){const e=Pt(t);if(xe(t,r=>r.type==="Operator"&&r.value==="**")){t.consume(),D(t);const r=en(t);return{kind:"Binary",operator:"**",left:e,right:r}}return e}function Pt(t){const e=t.peek();if(e.type==="Operator"&&(e.value==="!"||e.value==="-"||e.value==="+"||e.value==="~")){t.consume();const r=Pt(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:[Pt(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:[Pt(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=Pt(t);return{kind:"Unary",operator:e.value,argument:r}}if(e.type==="Keyword"&&e.value==="new"){t.consume();let r=si(t),n=[];if(r.kind==="Call")n=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=X(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:o};continue}break}t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),n=Ue(t),t.expect("Punctuation",")"))}const a={kind:"New",callee:r,arguments:n,loc:{line:e.line,column:e.column}};return oi(t,a)}return $c(t)}function $c(t){const e=Cc(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 Cc(t){return oi(t,si(t))}function oi(t,e){let r=e;for(;;){xe(t,a=>a.type==="Punctuation"&&a.value==="."||a.type==="Operator"&&a.value==="?.");const n=t.peek();if(n.type==="Punctuation"&&n.value==="."){t.consume();const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword"&&a.type!=="StateIdentifier")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Ue(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:a.value,arguments:o,loc:{line:a.line,column:a.column}};continue}r={kind:"Member",object:r,property:a.value};continue}if(n.type==="Operator"&&n.value==="?."){if(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="["){t.consume();const a=X(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:a,optional:!0}}else if(t.peek().type==="Punctuation"&&t.peek().value==="("){t.consume();const a=Ue(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:a,optional:!0,loc:{line:n.line,column:n.column}}}else{const a=t.consume();if(a.type!=="Identifier"&&a.type!=="Keyword"&&a.type!=="StateIdentifier")throw{message:`Expected Identifier but got ${a.type} "${a.value}"`,line:a.line,column:a.column};const i=t.peek();if(i.type==="Punctuation"&&i.value==="("){t.consume();const o=Ue(t);t.expect("Punctuation",")"),r={kind:"MethodCall",object:r,method:a.value,arguments:o,optional:!0,loc:{line:a.line,column:a.column}};continue}r={kind:"Member",object:r,property:a.value,optional:!0}}continue}if(n.type==="Punctuation"&&n.value==="["){t.consume();const a=X(t);t.expect("Punctuation","]"),r={kind:"Member",object:r,computed:a};continue}if(n.type==="Punctuation"&&n.value==="("){t.consume();const a=Ue(t);t.expect("Punctuation",")"),r={kind:"Invoke",callee:r,arguments:a,loc:{line:n.line,column:n.column}};continue}break}return r}function si(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.`,n={message:`\`${e.value}\` is a statement, not an expression. ${r}`,line:e.line,column:e.column};throw n.__definitive=!0,n}if(e.type==="Keyword"){if(e.value==="function"){const r=t.peek(1),n=t.peek(2);if(r.type==="Punctuation"&&r.value==="("||r.type==="Identifier"&&n.type==="Punctuation"&&n.value==="("){const i=e;t.consume(),t.peek().type==="Identifier"&&t.consume();const o=Xa(t),s=it(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=Ue(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:Oc(e.value)};if(e.type==="String")return t.consume(),{kind:"Literal",value:e.value};if(e.type==="TemplateString"){t.consume();const r=e.parts??[],n=[],a=[];let i="",o=!1;const s=()=>{n.push(i),i="",o=!1};for(const l of r){if(l.kind==="str"){i+=l.text,o=!0;continue}o?s():n.push("");const d=Se(`__rui_tmpl__ = ${l.source}`).statements[0];d&&d.kind==="Assignment"?a.push(d.expression):a.push({kind:"Literal",value:""})}for((o||n.length===0)&&n.push(i);n.length<=a.length;)n.push("");return{kind:"Template",quasis:n,expressions:a,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(),Ac(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=ui(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=Ue(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=Ue(t);return t.expect("Punctuation","]"),{kind:"Array",elements:r}}if(e.type==="Punctuation"&&e.value==="{"){t.consume();const r=Dc(t);return t.expect("Punctuation","}"),{kind:"Object",properties:r}}if(e.type==="Punctuation"&&e.value==="("){const r=t.snapshot(),n=jc(t);if(n)return n;t.restore(r),t.consume();const a=X(t);return t.expect("Punctuation",")"),a}throw{message:`Unexpected token ${e.type} "${e.value}"`,line:e.line,column:e.column}}function Ac(t,e){t.consume();const r=Ue(t);return t.expect("Punctuation",")"),{kind:"Call",callee:e.value,arguments:r,loc:{line:e.line,column:e.column}}}function Ue(t){const e=[];if(D(t),t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]"))return e;for(e.push(li(t)),D(t);t.peek().type==="Punctuation"&&t.peek().value===","&&(t.consume(),D(t),!(t.peek().type==="Punctuation"&&(t.peek().value===")"||t.peek().value==="]")));)e.push(li(t)),D(t);return D(t),e}function li(t){if(t.peek().type==="Operator"&&t.peek().value==="..."){const e=t.consume();return{kind:"Spread",argument:X(t),loc:{line:e.line,column:e.column}}}return X(t)}function ci(t){const e=t.expect("Keyword","if");t.expect("Punctuation","(");const r=X(t);t.expect("Punctuation",")");const n=bt(t);let a;return D(t),t.peek().type==="Keyword"&&t.peek().value==="else"&&(t.consume(),D(t),t.peek().type==="Keyword"&&t.peek().value==="if"?a=ci(t):a=bt(t)),ue(t),{kind:"IfStatement",test:r,consequent:n,alternate:a,loc:{line:e.line,column:e.column}}}function Tc(t){const e=t.expect("Keyword","switch");t.expect("Punctuation","(");const r=X(t);t.expect("Punctuation",")"),t.expect("Punctuation","{");const n=[];for(D(t);!(t.peek().type==="Punctuation"&&t.peek().value==="}");){let a=null;if(t.peek().type==="Keyword"&&t.peek().value==="case")t.consume(),a=X(t);else if(t.peek().type==="Keyword"&&t.peek().value==="default")t.consume(),a=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",":"),D(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=Zt(t);o&&i.push(o),D(t)}n.push({test:a,body:i}),D(t)}return t.expect("Punctuation","}"),ue(t),{kind:"SwitchStatement",discriminant:r,cases:n,loc:{line:e.line,column:e.column}}}function Mc(t){const e=t.expect("Keyword","for");t.expect("Punctuation","("),D(t);const r=t.snapshot();let n="for-of";{let c=1,d=0;for(;;){const p=t.peek(d);if(p.type==="EOF")break;if(p.type==="Punctuation"&&p.value==="(")c+=1;else if(p.type==="Punctuation"&&p.value===")"){if(c-=1,c===0)break}else if(c===1&&p.type==="Semicolon"){n="classic";break}else if(c===1&&p.type==="Keyword"&&p.value==="of"){n="for-of";break}else if(c===1&&p.type==="Keyword"&&p.value==="in"){n="for-in";break}d+=1}}if(t.restore(r),n==="classic")return Nc(t,e);t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")&&t.consume(),D(t);let a,i,o;if(t.peek().type==="Punctuation"&&t.peek().value==="[")t.consume(),a=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","}"),a="__row",o=c}else a=t.expect("Identifier").value;n==="for-in"?t.expect("Keyword","in"):t.expect("Keyword","of");const s=X(t);t.expect("Punctuation",")");const l=bt(t);return ue(t),n==="for-in"?{kind:"ForInStatement",item:a,iterable:s,body:l,loc:{line:e.line,column:e.column}}:{kind:"ForOfStatement",item:a,index:i,destructure:o,iterable:s,body:l,loc:{line:e.line,column:e.column}}}function Nc(t,e){let r;if(t.peek().type!=="Semicolon")if(t.peek().type==="Keyword"&&(t.peek().value==="let"||t.peek().value==="const"||t.peek().value==="var")){const o=Jr(t);o.kind==="Assignment"&&(r=o),D(t)}else{const o=t.peek();r={kind:"ExpressionStatement",expression:X(t),loc:{line:o.line,column:o.column}},t.expect("Semicolon"),D(t)}else t.expect("Semicolon"),D(t);let n;t.peek().type!=="Semicolon"&&(n=X(t)),t.expect("Semicolon"),D(t);let a;t.peek().type==="Punctuation"&&t.peek().value===")"||(a=di(t)),t.expect("Punctuation",")");const i=bt(t);return ue(t),{kind:"ForClassicStatement",init:r,test:n,update:a,body:i,loc:{line:e.line,column:e.column}}}function Ic(t){const e=t.expect("Keyword","while");t.expect("Punctuation","(");const r=X(t);t.expect("Punctuation",")");const n=bt(t);return ue(t),{kind:"WhileStatement",test:r,body:n,loc:{line:e.line,column:e.column}}}function Pc(t){const e=t.expect("Keyword","do"),r=bt(t);D(t),t.expect("Keyword","while"),t.expect("Punctuation","(");const n=X(t);return t.expect("Punctuation",")"),ue(t),{kind:"DoWhileStatement",test:n,body:r,loc:{line:e.line,column:e.column}}}function Rc(t){const e=t.expect("Keyword","break");return ue(t),{kind:"BreakStatement",loc:{line:e.line,column:e.column}}}function Ec(t){const e=t.expect("Keyword","continue");return ue(t),{kind:"ContinueStatement",loc:{line:e.line,column:e.column}}}function Lc(t){const e=t.expect("Keyword","throw"),r=X(t);return ue(t),{kind:"ThrowStatement",argument:r,loc:{line:e.line,column:e.column}}}function zc(t){const e=t.expect("Keyword","try"),r=it(t);let n,a,i;return D(t),t.peek().type==="Keyword"&&t.peek().value==="catch"&&(t.consume(),t.peek().type==="Punctuation"&&t.peek().value==="("&&(t.consume(),t.peek().type==="Identifier"&&(n=t.consume().value),t.expect("Punctuation",")")),a=it(t),D(t)),t.peek().type==="Keyword"&&t.peek().value==="finally"&&(t.consume(),i=it(t)),ue(t),{kind:"TryStatement",block:r,catchParam:n,catchBlock:a,finallyBlock:i,loc:{line:e.line,column:e.column}}}function jc(t){const e=t.peek();if(e.type!=="Punctuation"||e.value!=="(")return null;t.consume();const r=[];if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")"))for(;;){D(t);let a=!1;t.peek().type==="Operator"&&t.peek().value==="..."&&(t.consume(),a=!0);const i=t.peek();if(!a&&i.type==="Punctuation"&&(i.value==="{"||i.value==="[")){let s;try{s=Qr(t)}catch{return null}const l={name:"",pattern:s};if(t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{l.defaultValue=X(t)}catch{return null}}if(r.push(l),D(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(a&&(o.rest=!0),!a&&t.peek().type==="Operator"&&t.peek().value==="="){t.consume();try{o.defaultValue=X(t)}catch{return null}}if(r.push(o),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(a)return null;t.consume();continue}break}if(D(t),!(t.peek().type==="Punctuation"&&t.peek().value===")")||(t.consume(),!(t.peek().type==="Operator"&&t.peek().value==="=>")))return null;t.consume();const n=ui(t);return{kind:"Lambda",params:r,body:n,loc:{line:e.line,column:e.column}}}function ui(t){return D(t),t.peek().type==="Punctuation"&&t.peek().value==="{"?it(t):di(t)}function di(t){const e=X(t),r=t.peek();if(r.type==="Operator"){if(Ka(r.value)){t.consume();const n=X(t);return{kind:"BuiltinCall",name:"__rui_assign__",arguments:[e,n,{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 Dc(t){const e=[];if(D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")return e;for(;;){D(t);const r=t.peek();if(r.type==="Operator"&&r.value==="..."){t.consume();const l=X(t);if(e.push({key:"",value:l,spread:!0}),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}let n,a;if(r.type==="Punctuation"&&r.value==="[")t.consume(),D(t),a=X(t),D(t),t.expect("Punctuation","]"),n="";else if(r.type==="Number")n=t.consume().value;else if(r.type==="Identifier"||r.type==="String"||r.type==="Keyword")n=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;!a&&r.type==="Identifier"&&i.type==="Punctuation"&&(i.value===","||i.value==="}")?o={kind:"Identifier",name:n,loc:{line:r.line,column:r.column}}:(t.expect("Punctuation",":"),o=X(t));const s={key:n,value:o};if(a&&(s.computedKey=a),e.push(s),D(t),t.peek().type==="Punctuation"&&t.peek().value===","){if(t.consume(),D(t),t.peek().type==="Punctuation"&&t.peek().value==="}")break;continue}break}return D(t),e}function D(t){for(;t.match("Newline")||t.match("Semicolon"););}function ue(t){t.isEnd()||t.match("Newline")||t.match("Semicolon")}function Oc(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 Bc(t){const e=Se(t);return pi(t,e)}function pi(t,e){const r=new Set(e.errors.map(s=>s.line)),n=[],a=[];for(const s of e.statements){const l=s.loc?.line??0;if(r.has(l)){a.push(s);continue}n.push(s)}let i=t,o="";if(e.errors.length>0){const s=Math.min(...e.errors.map(d=>d.line)),l=_c(t,s);i=l.before,o=l.after;const c=n.findIndex(d=>(d.loc?.line??0)>=s);if(c>=0)for(const d of n.splice(c))a.push(d)}return{committedSource:i,draftingSource:o,committedBindings:n.map(mi).filter(s=>s!==null),uncommittedBindings:a.map(mi).filter(s=>s!==null),committedStatements:n,errors:e.errors}}function Fc(t,e){if(e.length===0)return!0;const r=new Set(t.committedBindings);for(const n of e)if(!r.has(n))return!1;return!0}function mi(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function _c(t,e){if(e<=1)return{before:"",after:t};let r=0,n=1;for(;r<t.length&&n<e;)t[r]===`
|
|
10
|
+
`&&(n+=1),r+=1;return{before:t.slice(0,r),after:t.slice(r)}}const tr=1;function fi(t){if(!t||typeof t!="object")return!1;const e=t;return e.__aktionCompiled===tr&&typeof e.source=="string"&&typeof e.path=="string"&&!!e.program&&Array.isArray(e.program.statements)}function Uc(t){return t}function Hc(t,e={}){const r=Se(t);return{__aktionCompiled:tr,program:r,source:t,path:e.path??"<inline>"}}const Oe=" ",gi=/^[A-Za-z_$][A-Za-z0-9_$]*$/,qc=/[\\"]/;function Vc(t){const e=[];let r=null;for(const n of t.statements)r&&Wc(r,n)&&e.push(""),e.push(vt(n,0)),r=n;return e.join(`
|
|
11
11
|
`)+`
|
|
12
|
-
`}function
|
|
12
|
+
`}function Wc(t,e){const r=new Set(["ComponentDeclaration","EffectDeclaration","ActionDeclaration","HookDeclaration"]);return!!(r.has(t.kind)||r.has(e.kind))}function vt(t,e){const r=Oe.repeat(e),n="exported"in t&&t.exported?"export ":"";switch(t.kind){case"Import":{const a=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 { ${a} } from "${t.source}"`}case"Assignment":{const a=t.isState?`$${t.identifier}`:t.identifier,i=J(t.expression,e);return`${r}${n}${a} = ${i}`}case"ComponentDeclaration":{const a=t.params.map(tn).join(", "),i=`${r}${n}function ${t.name}(${a}) {`,o=be(t.body.body,e+1);return o.length>0?`${i}
|
|
13
13
|
${o}
|
|
14
14
|
${r}}`:`${i}
|
|
15
|
-
${r}}`}case"EffectDeclaration":{const a=t.triggers.map(
|
|
15
|
+
${r}}`}case"EffectDeclaration":{const a=t.triggers.map(Gc).filter(s=>s.length>0);t.rateLimit&&a.push(`"${t.rateLimit.kind}(${t.rateLimit.ms})"`);const i=be(t.body.body,e+1),o=`[${a.join(", ")}]`;return`${r}$effect(() => {
|
|
16
16
|
${i}
|
|
17
|
-
${r}}, ${o})`}case"ActionDeclaration":{const a=t.params.map(
|
|
17
|
+
${r}}, ${o})`}case"ActionDeclaration":{const a=t.params.map(tn).join(", "),i=`${r}${n}function ${t.name}(${a}) {`,o=be(t.body.body,e+1);return`${i}
|
|
18
18
|
${o}
|
|
19
|
-
${r}}`}case"HookDeclaration":{const a=t.params.map(
|
|
19
|
+
${r}}`}case"HookDeclaration":{const a=t.params.map(tn).join(", "),i=`${r}${n}function $${t.name}(${a}) {`,o=be(t.body.body,e+1);return`${i}
|
|
20
20
|
${o}
|
|
21
|
-
${r}}`}case"Await":return`${r}await ${
|
|
22
|
-
${
|
|
23
|
-
${r}}`;if(!t.alternate)return`${r}if (${a}) ${i}`;const o=t.alternate.kind==="IfStatement"?
|
|
24
|
-
${
|
|
25
|
-
${r}}`;return`${r}if (${a}) ${i} else ${o}`}case"SwitchStatement":{const a=
|
|
21
|
+
${r}}`}case"Await":return`${r}await ${J(t.argument,e)}`;case"Return":return t.argument?`${r}return ${J(t.argument,e)}`:`${r}return`;case"ExpressionStatement":return`${r}${J(t.expression,e)}`;case"IfStatement":{const a=J(t.test,e),i=`{
|
|
22
|
+
${be(t.consequent.body,e+1)}
|
|
23
|
+
${r}}`;if(!t.alternate)return`${r}if (${a}) ${i}`;const o=t.alternate.kind==="IfStatement"?vt(t.alternate,e).trimStart():`{
|
|
24
|
+
${be(t.alternate.body,e+1)}
|
|
25
|
+
${r}}`;return`${r}if (${a}) ${i} else ${o}`}case"SwitchStatement":{const a=J(t.discriminant,e),i=t.cases.map(o=>Kc(o,e+1)).join(`
|
|
26
26
|
`);return`${r}switch (${a}) {
|
|
27
27
|
${i}
|
|
28
|
-
${r}}`}case"ForOfStatement":{const a=
|
|
29
|
-
${
|
|
30
|
-
${r}}`;return`${r}for (let ${t.item} of ${a}) ${i}`}case"ForClassicStatement":{const a=t.init?
|
|
31
|
-
${
|
|
32
|
-
${r}}`;return`${r}for (${a}; ${i}; ${o}) ${s}`}case"WhileStatement":{const a=
|
|
33
|
-
${
|
|
34
|
-
${r}}`;return`${r}while (${a}) ${i}`}case"DoWhileStatement":{const a=
|
|
35
|
-
${
|
|
36
|
-
${r}}`;return`${r}do ${i} while (${a})`}case"ForInStatement":{const a=
|
|
37
|
-
${
|
|
38
|
-
${r}}`;return`${r}for (let ${t.item} in ${a}) ${i}`}case"DestructureStatement":{const a=t.patternKind==="array"?"[":"{",i=t.patternKind==="array"?"]":"}",o=t.bindings.map(l=>{const
|
|
39
|
-
${
|
|
28
|
+
${r}}`}case"ForOfStatement":{const a=J(t.iterable,e),i=`{
|
|
29
|
+
${be(t.body.body,e+1)}
|
|
30
|
+
${r}}`;return`${r}for (let ${t.item} of ${a}) ${i}`}case"ForClassicStatement":{const a=t.init?vt(t.init,0).trimStart():"",i=t.test?J(t.test,e):"",o=t.update?J(t.update,e):"",s=`{
|
|
31
|
+
${be(t.body.body,e+1)}
|
|
32
|
+
${r}}`;return`${r}for (${a}; ${i}; ${o}) ${s}`}case"WhileStatement":{const a=J(t.test,e),i=`{
|
|
33
|
+
${be(t.body.body,e+1)}
|
|
34
|
+
${r}}`;return`${r}while (${a}) ${i}`}case"DoWhileStatement":{const a=J(t.test,e),i=`{
|
|
35
|
+
${be(t.body.body,e+1)}
|
|
36
|
+
${r}}`;return`${r}do ${i} while (${a})`}case"ForInStatement":{const a=J(t.iterable,e),i=`{
|
|
37
|
+
${be(t.body.body,e+1)}
|
|
38
|
+
${r}}`;return`${r}for (let ${t.item} in ${a}) ${i}`}case"DestructureStatement":{const a=t.patternKind==="array"?"[":"{",i=t.patternKind==="array"?"]":"}",o=t.bindings.map(l=>{const c=l.rest?"...":"",d=l.sourceKey?`${l.sourceKey}: ${l.name}`:l.name||"",p=l.defaultValue?` = ${J(l.defaultValue,e)}`:"";return`${c}${d}${p}`}),s=J(t.expression,e);return`${r}let ${a}${o.join(", ")}${i} = ${s}`}case"BreakStatement":return`${r}break`;case"ContinueStatement":return`${r}continue`;case"ThrowStatement":return`${r}throw ${J(t.argument,e)}`;case"TryStatement":{const a=`{
|
|
39
|
+
${be(t.block.body,e+1)}
|
|
40
40
|
${r}}`;let i=`${r}try ${a}`;if(t.catchBlock){const o=t.catchParam?` (${t.catchParam})`:"",s=`{
|
|
41
|
-
${
|
|
41
|
+
${be(t.catchBlock.body,e+1)}
|
|
42
42
|
${r}}`;i+=` catch${o} ${s}`}if(t.finallyBlock){const o=`{
|
|
43
|
-
${
|
|
44
|
-
${r}}`;i+=` finally ${o}`}return i}}}function
|
|
45
|
-
`)}function
|
|
46
|
-
`)))return n;const a=
|
|
43
|
+
${be(t.finallyBlock.body,e+1)}
|
|
44
|
+
${r}}`;i+=` finally ${o}`}return i}}}function tn(t){return t.defaultValue?`${t.name} = ${J(t.defaultValue,0)}`:t.name}function Gc(t){return t.kind==="lifecycle"?`"${t.name}"`:t.kind==="every"?`"every(${t.intervalMs})"`:t.kind==="state"?`$${t.name}`:""}function be(t,e){return t.map(r=>vt(r,e)).join(`
|
|
45
|
+
`)}function J(t,e){switch(t.kind){case"Literal":return Xc(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=>J(i,e)),n=`[${r.join(", ")}]`;if(n.length<=80&&!r.some(i=>i.includes(`
|
|
46
|
+
`)))return n;const a=Oe.repeat(e+1);return`[
|
|
47
47
|
${r.map(i=>`${a}${i}`).join(`,
|
|
48
48
|
`)}
|
|
49
|
-
${
|
|
50
|
-
`)))return n;const a=
|
|
49
|
+
${Oe.repeat(e)}]`}case"Object":{if(t.properties.length===0)return"{}";const r=t.properties.map(i=>Yc(i,e)),n=`{ ${r.join(", ")} }`;if(n.length<=80&&!r.some(i=>i.includes(`
|
|
50
|
+
`)))return n;const a=Oe.repeat(e+1);return`{
|
|
51
51
|
${r.map(i=>`${a}${i}`).join(`,
|
|
52
52
|
`)}
|
|
53
|
-
${
|
|
54
|
-
${
|
|
55
|
-
${
|
|
56
|
-
`)))return a;const i=
|
|
53
|
+
${Oe.repeat(e)}}`}case"Member":{const r=J(t.object,e),n=t.optional?"?.":".";if(t.property)return`${r}${n}${t.property}`;if(t.computed){const a=J(t.computed,e);return t.optional?`${r}?.[${a}]`:`${r}[${a}]`}return r}case"Unary":return`${t.operator}${J(t.argument,e)}`;case"Binary":return`${J(t.left,e)} ${t.operator} ${J(t.right,e)}`;case"Ternary":return`${J(t.test,e)} ? ${J(t.consequent,e)} : ${J(t.alternate,e)}`;case"Call":return Rt(t.callee,t.arguments,e);case"MethodCall":{const r=J(t.object,e),n=t.optional?"?.":".";return Rt(`${r}${n}${t.method}`,t.arguments,e)}case"Invoke":{const r=J(t.callee,e),n=t.optional?"?.":"";return Rt(`${r}${n}`,t.arguments,e)}case"New":{const r=J(t.callee,e);return`new ${Rt(r,t.arguments,e)}`}case"BuiltinCall":return Rt(`@${t.name}`,t.arguments,e);case"Template":return Jc(t.quasis,t.expressions,e);case"Spread":return`...${J(t.argument,e)}`;case"Lambda":{const r=t.params.map(a=>{const i=a.rest?"...":"";return a.defaultValue?`${i}${a.name} = ${J(a.defaultValue,e)}`:`${i}${a.name}`}).join(", ");return`${t.params.length===1&&!t.params[0].defaultValue&&!t.params[0].rest?t.params[0].name:`(${r})`} => ${J(t.body,e)}`}case"Block":return`{
|
|
54
|
+
${be(t.body,e+1)}
|
|
55
|
+
${Oe.repeat(e)}}`}}function Rt(t,e,r){if(e.length===0)return`${t}()`;const n=e.map(o=>J(o,r)),a=`${t}(${n.join(", ")})`;if(a.length<=80&&!n.some(o=>o.includes(`
|
|
56
|
+
`)))return a;const i=Oe.repeat(r+1);return`${t}(
|
|
57
57
|
${n.map(o=>`${i}${o}`).join(`,
|
|
58
58
|
`)}
|
|
59
|
-
${
|
|
59
|
+
${Oe.repeat(r)})`}function Kc(t,e){const r=Oe.repeat(e),n=t.body.map(a=>vt(a,e+1)).join(`
|
|
60
60
|
`);return t.test===null?`${r}default:
|
|
61
61
|
${n}
|
|
62
|
-
${
|
|
62
|
+
${vt({kind:"ExpressionStatement",expression:{kind:"Identifier",name:"break"}},e+1)}`:`${r}case ${J(t.test,e)}:
|
|
63
63
|
${n}
|
|
64
|
-
${
|
|
64
|
+
${Oe.repeat(e+1)}break`}function Yc(t,e){if(t.spread)return`...${J(t.value,e)}`;const r=J(t.value,e);return t.value.kind==="Identifier"&&t.value.name===t.key&&gi.test(t.key)?t.key:`${gi.test(t.key)?t.key:hi(t.key)}: ${r}`}function Xc(t){return t===null?"null":typeof t=="string"?hi(t):typeof t=="boolean"?t?"true":"false":String(t)}function hi(t){return qc.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`"${t}"`}function Jc(t,e,r){const n=[];for(let a=0;a<t.length;a+=1)n.push(t[a]??""),a<e.length&&(n.push("${"),n.push(J(e[a],r)),n.push("}"));return`\`${n.join("")}\``}function bi(t,e,r){const n=new Map,a=[],i=new Set,o=[];let s=0;const l=(f,b,h,g)=>{o.push({line:b,column:h,message:f===e?g:`${f}: ${g}`,severity:"error"})};function c(f,b){const h=n.get(f);if(h)return h;if(i.has(f))return;i.add(f);let g;if(b!==null)g=b;else try{g=r.load(f)}catch{i.delete(f),l(e,0,0,`Failed to load imported module "${f}".`);return}const y=Se(g),v={id:s++,path:f,program:y,edges:[],declaredPlain:new Set,declaredState:new Set,exportedPlain:new Set,exportedState:new Set,renamePlain:new Map,renameState:new Map};n.set(f,v),Qc(v);for(const x of y.statements){if(x.kind!=="Import")continue;const w=r.resolve(x.source,f);if(v.edges.push({stmt:x,resolvedPath:w}),w===null){l(f,x.loc?.line??0,x.loc?.column??0,`Cannot resolve import "${x.source}".`);continue}c(w,null)}return i.delete(f),a.push(f),v}c(e,t);for(const f of n.values())if(f.path!==e){for(const b of f.declaredPlain)f.renamePlain.set(b,`__a${f.id}_${b}`);for(const b of f.declaredState)f.renameState.set(b,`__a${f.id}_${b}`)}for(const f of n.values())for(const{stmt:b,resolvedPath:h}of f.edges){if(h===null)continue;const g=n.get(h);if(g)for(const y of b.specifiers){const v=b.loc?.line??0,x=b.loc?.column??0;if(y.isState){if(!g.exportedState.has(y.imported)){l(f.path,v,x,`"${b.source}" does not export \`$${y.imported}\`.`);continue}f.renameState.set(y.local,g.renameState.get(y.imported)??`__a${g.id}_${y.imported}`)}else{if(!g.exportedPlain.has(y.imported)){l(f.path,v,x,`"${b.source}" does not export \`${y.imported}\`.`);continue}f.renamePlain.set(y.local,g.renamePlain.get(y.imported)??`__a${g.id}_${y.imported}`)}}}const d=[];for(const f of a){const b=n.get(f),h=eu(b);for(const g of b.program.statements)g.kind!=="Import"&&(h.renameTopLevel(g),Zc(g),g.kind==="EffectDeclaration"&&b.path!==e&&(g.name=`__effect_a${b.id}_${g.name.replace(/^__effect_/,"")}`),d.push(g))}const p=n.get(e);return{program:{statements:d,errors:p?p.program.errors:[]},diagnostics:o,dependencies:a.filter(f=>f!==e)}}function Qc(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 Zc(t){(t.kind==="Assignment"||t.kind==="ComponentDeclaration"||t.kind==="ActionDeclaration"||t.kind==="HookDeclaration")&&delete t.exported}function eu(t){const e=[],r=g=>{for(const y of e)if(y.has(g))return!0;return!1},n=g=>r(g)?g:t.renamePlain.get(g)??g,a=g=>t.renameState.get(g)??g,i=g=>{e.push(new Set(g))},o=()=>{e.pop()},s=g=>g.bindings.map(y=>y.name).filter(y=>!!y),l=g=>{const y=[];for(const v of g)v.name&&y.push(v.name),v.pattern&&y.push(...s(v.pattern));return y},c=g=>{for(const y of g)y.defaultValue&&d(y.defaultValue)};function d(g){switch(g.kind){case"Literal":return;case"Identifier":g.name=n(g.name);return;case"StateRef":g.name=a(g.name);return;case"Array":for(const y of g.elements)d(y);return;case"Object":for(const y of g.properties)y.computedKey&&d(y.computedKey),d(y.value);return;case"Member":d(g.object),g.computed&&d(g.computed);return;case"Unary":d(g.argument);return;case"Binary":d(g.left),d(g.right);return;case"Ternary":d(g.test),d(g.consequent),d(g.alternate);return;case"Call":g.callee=n(g.callee);for(const y of g.arguments)d(y);return;case"MethodCall":d(g.object);for(const y of g.arguments)d(y);return;case"Invoke":d(g.callee);for(const y of g.arguments)d(y);return;case"BuiltinCall":for(const y of g.arguments)d(y);return;case"New":d(g.callee);for(const y of g.arguments)d(y);return;case"Template":for(const y of g.expressions)d(y);return;case"Spread":d(g.argument);return;case"Lambda":i(l(g.params)),c(g.params),d(g.body),o();return;case"Block":p(g);return}}function p(g){i([]);const y=e[e.length-1];for(const v of g.body)h(v,!1),f(v,y);o()}function f(g,y){if(g.kind==="DestructureStatement")for(const v of g.bindings)v.name&&y.add(v.name);else(g.kind==="ComponentDeclaration"||g.kind==="ActionDeclaration")&&y.add(g.name)}function b(g){if(g.kind==="DestructureStatement"){d(g.expression);for(const y of g.bindings)y.defaultValue&&d(y.defaultValue),y.name=n(y.name);return}h(g,!0)}function h(g,y){switch(g.kind){case"Import":return;case"Assignment":g.identifier=g.isState?a(g.identifier):n(g.identifier),d(g.expression);return;case"ComponentDeclaration":case"ActionDeclaration":g.name=n(g.name),i(l(g.params)),c(g.params),p(g.body),o();return;case"HookDeclaration":g.name=a(g.name),i(l(g.params)),c(g.params),p(g.body),o();return;case"EffectDeclaration":for(const v of g.triggers)v.kind==="state"&&(v.name=a(v.name));p(g.body);return;case"Await":d(g.argument);return;case"Return":g.argument&&d(g.argument);return;case"ExpressionStatement":d(g.expression);return;case"IfStatement":d(g.test),p(g.consequent),g.alternate&&(g.alternate.kind==="IfStatement"?h(g.alternate,!1):p(g.alternate));return;case"SwitchStatement":d(g.discriminant);for(const v of g.cases){v.test&&d(v.test);for(const x of v.body)h(x,!1)}return;case"ForOfStatement":{d(g.iterable);const v=[g.item];g.index&&v.push(g.index),g.destructure&&v.push(...g.destructure),i(v),p(g.body),o();return}case"ForInStatement":d(g.iterable),i([g.item]),p(g.body),o();return;case"ForClassicStatement":{const v=[];g.init&&g.init.kind==="Assignment"&&g.init.identifier&&v.push(g.init.identifier),i(v),g.init&&h(g.init,!1),g.test&&d(g.test),g.update&&d(g.update),p(g.body),o();return}case"WhileStatement":case"DoWhileStatement":d(g.test),p(g.body);return;case"DestructureStatement":d(g.expression);for(const v of g.bindings)v.defaultValue&&d(v.defaultValue);if(y)for(const v of g.bindings)v.name=n(v.name);return;case"ThrowStatement":d(g.argument);return;case"TryStatement":p(g.block),g.catchBlock&&(i(g.catchParam?[g.catchParam]:[]),p(g.catchBlock),o()),g.finallyBlock&&p(g.finallyBlock);return;case"BreakStatement":case"ContinueStatement":return}}return{renameTopLevel:b}}function rn(t){return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)}function vi(t){const e=[];for(const r of t)r===""||r==="."||(r===".."?e.pop():e.push(r));return e.join("/")}function tu(t){const e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function nn(t,e){if(rn(t))try{return new URL(t).href}catch{return null}if(rn(e))try{return new URL(t,e).href}catch{return null}return t.startsWith("/")?vi(t.split("/")):t.startsWith("./")||t.startsWith("../")?vi(`${tu(e)}/${t}`.split("/")):null}function yi(t){return{resolve:(e,r)=>nn(e,r),load:e=>{const r=t[e];if(r===void 0)throw new Error(`not found: ${e}`);return r}}}async function ru(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 xi(t){const{entry:e,files:r}=t,n=t.fetch??ru,a=[],i={...r},o=new Set;async function s(d){if(o.has(d))return;if(o.add(d),i[d]===void 0)if(rn(d))try{i[d]=await n(d)}catch(b){a.push({line:0,column:0,message:`Failed to fetch module "${d}": ${b.message??b}`,severity:"error"});return}else return;let p;try{p=Se(i[d])}catch{return}const f=[];for(const b of p.statements){if(b.kind!=="Import")continue;const h=nn(b.source,d);h!==null&&f.push(s(h))}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 l=bi(i[e],e,yi(i));let c;try{c=Vc(l.program)}catch{c=i[e]}return{program:l.program,source:c,diagnostics:[...a,...l.diagnostics],dependencies:l.dependencies}}function nu(t,e){const r=[],n={};let a=t;for(const i of e){if(i.kind==="patch"){n[i.target]=i.value;continue}const o=au(a,i);a=o.programText,o.warning&&r.push(o.warning)}return{programText:a,stateUpdates:n,warnings:r}}function au(t,e){const r=Se(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 n=Se(e.source);if(n.errors.length>0||n.statements.length===0)return{programText:t,warning:`delta(new): could not parse "${wi(e.source)}" — op skipped`};const a=t.endsWith(`
|
|
65
65
|
`)?"":`
|
|
66
66
|
`;return{programText:t+a+e.source.trim()+`
|
|
67
|
-
`}}case"delete":{const n=
|
|
68
|
-
`),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,l=o?(o.loc?.line??a.length+1)-1:a.length,
|
|
69
|
-
`):[...
|
|
70
|
-
`)}function Se(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(Se).join(", ")})`;case"MethodCall":return`${Se(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(Se).join(", ")})`;case"Array":return`[${t.elements.map(Se).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${Se(e.value)}`:`${e.key}: ${Se(e.value)}`).join(", ")} }`;case"Member":{const e=Se(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${Se(t.computed)}]`:e}case"Binary":return`${Se(t.left)} ${t.operator} ${Se(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(Se(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function ai(t){return t.length>40?`${t.slice(0,37)}...`:t}const ii=new WeakMap;function Dc(t){let e=ii.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);ii.set(t.components,e)}return e}function oi(t,e){const r=new Map;for(const n of t.components)r.set(n.name,n);for(const n of e.components)r.set(n.name,n);return{root:e.root??t.root,components:[...r.values()],componentGroups:t.componentGroups}}function Pe(t,e){return Dc(t).get(e)}const jc="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",si="6.7.2",li="data-rui-font-awesome",Bc=new Set(["solid","regular","brands"]),ci="solid";function Oc(t){typeof document<"u"&&ui(document.head,document),ui(t,t.ownerDocument??document)}function ui(t,e){if(Fc()||t.querySelector(`link[${li}="${si}"]`))return;const n=e.createElement("link");n.rel="stylesheet",n.href=jc,n.setAttribute(li,si);try{t.appendChild(n)}catch{}}function Fc(){return typeof globalThis.happyDOM<"u"}function Xt(t){if(typeof t!="string")return[];const e=Uc(t).trim();if(!e)return[];if(!qc(e))return[];const[r,n]=Hc(e);return n?[`fa-${r}`,`fa-${n}`]:[]}const _c=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function Uc(t){return t.replace(_c,"")}function Hc(t){const e=t.indexOf(":");if(e===-1)return[ci,t];const r=t.slice(0,e).trim().toLowerCase(),n=t.slice(e+1).trim();return Bc.has(r)?[r,n]:[ci,n||t]}function qc(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const Vc=["xs","sm","md","lg","xl"],di=new Map,Wc=/<script|<foreignObject|on\w+\s*=|javascript\s*:|<!ENTITY|<iframe|<embed|<object/i,Gc=/^[a-zA-Z0-9:_-]+$/;function Kc(t){const e=typeof t=="string"?t:"";return!e||e.length>16384||Wc.test(e)?"":e}function pi(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=[];for(const[r,n]of Object.entries(t)){if(!Gc.test(r))continue;const a=Kc(n);a&&(di.set(r,a),e.push(r))}return e}function Yc(t){return typeof t!="string"?null:di.get(t.trim())??null}function c(t,e,r){const n=document.createElement(t);if(e)for(const[a,i]of Object.entries(e))i==null||i===!1||(a==="class"?n.setAttribute("class",String(i)):a==="html"?n.innerHTML=String(i):i===!0?n.setAttribute(a,""):n.setAttribute(a,String(i)));if(r)for(const a of r)a!=null&&n.append(typeof a=="string"?document.createTextNode(a):a);return n}function T(t){return Array.isArray(t)?t:t==null?[]:[t]}function m(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function N(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function I(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 ue=["none","3xs","2xs","xs","sm","md","lg","xl","2xl","3xl"],Xc={s:"sm",m:"md",l:"lg",small:"sm",normal:"md",large:"lg"};function Xr(t){const e=typeof t=="string"?t.trim():"";return Xc[e]??e}function ge(t,e=""){const r=Xr(t);return ue.includes(r)?r:e}function mi(t){const e=ge(t);return e?e==="none"?"0":`var(--rui-spacing-${e==="sm"?"s":e==="md"?"m":e==="lg"?"l":e})`:""}const gt=["base","sm","md","lg","xl"];function $e(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let n=!1;for(const[a,i]of e)gt.includes(a)&&(r[a]=i,n=!0);return n?{kind:"responsive",values:r}:{kind:"single",value:t}}const Zc=/["'\\\n\r<>;{}]/g;function Qc(t){return t?t.replace(Zc,"").trim():""}const Jc=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function X(t,e){const r=(m(t)??"").trim();return!r||r.length>64||!Jc.test(r)?e:r}const eu=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function Oe(t){const e=m(t).trim();return!e||e.length>64||!eu.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const tu=new Set(["http","https","mailto","tel"]);function Fe(t,e="#"){const r=m(t).trim();if(!r)return e;const n=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!n||n.startsWith("//"))return e;if(n.startsWith("#")||n.startsWith("/")||n.startsWith("?")||n.startsWith("."))return n;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(n);if(!a)return n;const i=a[1].toLowerCase();return tu.has(i)?n:e}const ru=new Set(["http","https","data","blob"]);function re(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 n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!n)return r;const a=n[1].toLowerCase();return!ru.has(a)||a==="data"&&!/^data:image\//i.test(r)?"":r}function nu(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function Zr(t,e,r,n,a,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,n)}catch(u){console.error("[aktion] Col render() threw",u),s=null}const l=u=>{nu(u)?t.append(a.renderNode(u)):u!=null&&t.append(document.createTextNode(i(u,o)))};if(Array.isArray(s))for(const u of s)l(u);else l(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const u=d=>d.target?.closest("input,button,a,label,select,textarea")?!1:(d.stopPropagation(),a.invoke(e.onClick,r,n),!0);t.onclick=d=>{u(d)},t.onkeydown=d=>{d.key!=="Enter"&&d.key!==" "||u(d)&&d.preventDefault()}}}function L(t,e={}){const r=m(t);if(!r)return null;const n=e.color?Oe(e.color):"",a=n?`color:${n};`:null,i=["rui-icon",e.className].filter(Boolean).join(" "),o=Yc(r);if(o){const l=c("span",{class:`${i} rui-icon-custom`,"data-icon-size":e.size??null,style:a,"aria-hidden":"true"});if(/^\s*<svg[\s>]/i.test(o))l.innerHTML=o;else{const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("viewBox","0 0 24 24"),d.setAttribute("fill","currentColor"),d.innerHTML=o,l.appendChild(d)}return l}const s=Xt(r);return s.length===0?c("span",{class:i,"data-icon-size":e.size??null,style:a},[r]):c("i",{class:`${i} ${s.join(" ")}`,"data-icon-size":e.size??null,style:a,"aria-hidden":"true"})}const au={base:0,sm:640,md:768,lg:1024,xl:1280},fi={base:0,sm:1,md:2,lg:3,xl:4};let ht;const Zt=new Map;let gi=0;function Qr(){if(ht!==void 0)return ht;try{return typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype)?(ht=null,null):(ht=new CSSStyleSheet,ht)}catch{return ht=null,null}}function iu(t){const e=Qr();if(!e)return null;const r=[...t].filter(o=>o.decls.length>0).sort((o,s)=>(fi[o.bp]??0)-(fi[s.bp]??0));if(r.length===0)return null;const n=r.map(o=>`${o.bp}{${o.decls.map(([s,l])=>`${s}:${l}`).join(";")}}`).join("|"),a=Zt.get(n);if(a)return a;const i=`ak-r${(gi++).toString(36)}`;for(const o of r){const s=o.decls.map(([d,p])=>`${d}:${p}`).join(";"),l=au[o.bp]??0,u=l>0?`@media (min-width:${l}px){.${i}{${s}}}`:`.${i}{${s}}`;try{e.insertRule(u,e.cssRules.length)}catch{}}return Zt.set(n,i),i}function ou(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return"base"in e||"sm"in e||"md"in e||"lg"in e||"xl"in e}const hi={hover:":hover",focus:":focus","focus-visible":":focus-visible","focus-within":":focus-within",active:":active",disabled:":disabled, &[disabled], &[data-disabled='true']",checked:":checked, &[aria-checked='true']","group-hover":""};function su(t){const e=Qr();if(!e)return null;const r=t.filter(o=>o.decls.length>0&&o.state in hi);if(r.length===0)return null;const n="S|"+r.map(o=>`${o.state}{${o.decls.map(([s,l])=>`${s}:${l}`).join(";")}}`).join("|"),a=Zt.get(n);if(a)return a;const i=`ak-s${(gi++).toString(36)}`;try{e.insertRule(`.${i}{transition:background .15s ease,color .15s ease,box-shadow .15s ease,transform .15s ease,opacity .15s ease,border-color .15s ease;}`,e.cssRules.length)}catch{}for(const o of r){const s=o.decls.map(([u,d])=>`${u}:${d}`).join(";");let l;o.state==="group-hover"?l=`.ak-group:hover .${i}{${s}}`:o.state==="disabled"?l=`.${i}:disabled,.${i}[disabled],.${i}[data-disabled="true"]{${s}}`:o.state==="checked"?l=`.${i}:checked,.${i}[aria-checked="true"]{${s}}`:l=`.${i}${hi[o.state]}{${s}}`;try{e.insertRule(l,e.cssRules.length)}catch{}}return Zt.set(n,i),i}const bi={none:"0","3xs":"var(--rui-spacing-3xs)","2xs":"var(--rui-spacing-2xs)",xs:"var(--rui-spacing-xs)",s:"var(--rui-spacing-s)",sm:"var(--rui-spacing-s)",m:"var(--rui-spacing-m)",md:"var(--rui-spacing-m)",l:"var(--rui-spacing-l)",lg:"var(--rui-spacing-l)",xl:"var(--rui-spacing-xl)","2xl":"var(--rui-spacing-2xl)","3xl":"var(--rui-spacing-3xl)",auto:"auto",safe:"env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)","safe-top":"env(safe-area-inset-top)","safe-right":"env(safe-area-inset-right)","safe-bottom":"env(safe-area-inset-bottom)","safe-left":"env(safe-area-inset-left)"},vi={bg:"var(--rui-color-bg)","bg-subtle":"var(--rui-color-bg-subtle)",surface:"var(--rui-color-surface)","surface-muted":"var(--rui-color-surface-muted)",border:"var(--rui-color-border)","border-subtle":"var(--rui-color-border-subtle)",text:"var(--rui-color-text)","text-muted":"var(--rui-color-text-muted)",muted:"var(--rui-color-text-muted)",primary:"var(--rui-color-primary)","primary-hover":"var(--rui-color-primary-hover)","primary-text":"var(--rui-color-primary-text)",accent:"var(--rui-color-accent)",success:"var(--rui-color-success)",warning:"var(--rui-color-warning)",danger:"var(--rui-color-danger)",info:"var(--rui-color-info)",transparent:"transparent",current:"currentColor"},bt={none:"0",xs:"var(--rui-radius-xs)",sm:"var(--rui-radius-sm)",md:"var(--rui-radius-md)",lg:"var(--rui-radius-lg)",pill:"var(--rui-radius-pill)",full:"9999px",circle:"50%"},vt={none:"none",sm:"var(--rui-shadow-sm)",md:"var(--rui-shadow-md)",lg:"var(--rui-shadow-lg)"},yi={full:"100%",half:"50%",screen:"100vh","screen-w":"100vw","screen-h":"100vh",dvh:"100dvh",min:"min-content",max:"max-content",fit:"fit-content",auto:"auto"},Qt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},Jt={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly",stretch:"stretch"},er={base:"var(--rui-z-base, 0)",raised:"var(--rui-z-raised, 10)",dropdown:"var(--rui-z-dropdown, 1000)",sticky:"var(--rui-z-sticky, 1100)",banner:"var(--rui-z-banner, 1200)",overlay:"var(--rui-z-overlay, 1250)",modal:"var(--rui-z-modal, 1300)",popover:"var(--rui-z-popover, 1350)",toast:"var(--rui-z-toast, 1400)",tooltip:"var(--rui-z-tooltip, 1500)"},xi={xs:"0.75rem",sm:"var(--rui-font-size-sm)",base:"var(--rui-font-size-base)",md:"var(--rui-font-size-base)",lg:"var(--rui-font-size-lg)",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},lu=new Set(["100","200","300","400","500","600","700","800","900","normal","bold"]),wi=new Set(["flex","grid","block","inline","inline-flex","inline-block","none","contents"]),ki=new Set(["row","column","row-reverse","column-reverse"]),Si=new Set(["relative","absolute","fixed","sticky","static"]),$i=new Set(["hidden","auto","scroll","visible","clip"]),Ci=new Set(["pointer","default","not-allowed","grab","grabbing","text","move","wait","help","none"]),Ai=new Set(["left","center","right","justify","start","end"]);function V(t){const e=m(t).trim();return e?e in bi?bi[e]:X(e,"")||null:null}function ie(t){const e=m(t).trim();return e?e in yi?yi[e]:X(e,"")||null:null}function _e(t){const e=m(t).trim();return e?e in vi?vi[e]:e.startsWith("gradient.")?`var(--rui-gradient-${en(e.slice(9))})`:Oe(e)||null:null}function Jr(t){const e=m(t).trim();return e.startsWith("gradient.")?`var(--rui-gradient-${en(e.slice(9))})`:_e(t)}function en(t){return t.replace(/[^a-zA-Z0-9-]/g,"").slice(0,40)}function we(t){if(typeof t=="number"&&Number.isFinite(t))return String(t);const e=m(t).trim();return/^-?\d+(\.\d+)?$/.test(e)?e:null}function Ti(t){const e=m(t).trim();return e?e in xi?xi[e]:X(e,"")||null:null}function Mi(t){const e=m(t).trim();return lu.has(e)?e:null}function cu(t){const e=t.replace(/["'\\\n\r<>;{})(]/g,"").trim();return!e||e.length>512?null:/^(https?:)?\/\//i.test(e)||/^data:image\//i.test(e)?e:/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?null:e}function uu(t){const e=m(t).trim();if(!e)return null;if(e.startsWith("gradient."))return`var(--rui-gradient-${en(e.slice(9))})`;const r=_e(e);return r?`linear-gradient(${r}, ${r})`:null}function du(t){if(t&&typeof t=="object"&&!Array.isArray(t)){const e=t;if("base"in e||"sm"in e||"md"in e||"lg"in e||"xl"in e)return e.base??e.sm??e.md??e.lg??e.xl}return t}const pu={p:t=>W("padding",V(t)),px:t=>W("padding-inline",V(t)),py:t=>{const e=V(t);return e?[["padding-top",e],["padding-bottom",e]]:[]},pt:t=>W("padding-top",V(t)),pr:t=>W("padding-right",V(t)),pb:t=>W("padding-bottom",V(t)),pl:t=>W("padding-left",V(t)),ps:t=>W("padding-inline-start",V(t)),pe:t=>W("padding-inline-end",V(t)),m:t=>W("margin",V(t)),mx:t=>W("margin-inline",V(t)),my:t=>{const e=V(t);return e?[["margin-top",e],["margin-bottom",e]]:[]},mt:t=>W("margin-top",V(t)),mr:t=>W("margin-right",V(t)),mb:t=>W("margin-bottom",V(t)),ml:t=>W("margin-left",V(t)),ms:t=>W("margin-inline-start",V(t)),me:t=>W("margin-inline-end",V(t)),gap:t=>W("gap",V(t)),w:t=>W("width",ie(t)),h:t=>W("height",ie(t)),minW:t=>W("min-width",ie(t)),maxW:t=>W("max-width",ie(t)),minH:t=>W("min-height",ie(t)),maxH:t=>W("max-height",ie(t)),bg:t=>W("background",Jr(t)),color:t=>W("color",_e(t)),radius:t=>{const e=m(t).trim();return W("border-radius",e in bt?bt[e]:X(e,"")||null)},shadow:t=>{const e=m(t).trim();return e in vt?[["box-shadow",vt[e]]]:[]},display:t=>{const e=m(t).trim();return wi.has(e)?[["display",e]]:[]},direction:t=>{const e=m(t).trim();return ki.has(e)?[["flex-direction",e]]:[]},align:t=>{const e=m(t).trim();return e in Qt?[["align-items",Qt[e]]]:[]},justify:t=>{const e=m(t).trim();return e in Jt?[["justify-content",Jt[e]]]:[]},textAlign:t=>{const e=m(t).trim();return Ai.has(e)?[["text-align",e]]:[]},columns:t=>{const e=we(t);return e?[["grid-template-columns",`repeat(${e}, minmax(0, 1fr))`]]:[]},border:t=>Ii(t),borderColor:t=>W("border-color",_e(t)),opacity:t=>W("opacity",we(t)),zIndex:t=>{const e=m(t).trim();return W("z-index",e in er?er[e]:we(e))},overflow:t=>{const e=m(t).trim();return $i.has(e)?[["overflow",e]]:[]},grow:t=>W("flex-grow",we(t)),shrink:t=>W("flex-shrink",we(t)),basis:t=>W("flex-basis",ie(t)),wrap:t=>t===!0||m(t)==="true"?[["flex-wrap","wrap"]]:t===!1||m(t)==="false"?[["flex-wrap","nowrap"]]:[],position:t=>{const e=m(t).trim();return Si.has(e)?[["position",e]]:[]},top:t=>W("top",ie(t)),right:t=>W("right",ie(t)),bottom:t=>W("bottom",ie(t)),left:t=>W("left",ie(t)),inset:t=>{const e=m(t).trim();return W("inset",e==="0"?"0":X(e,"")||null)},fontSize:t=>W("font-size",Ti(t)),weight:t=>W("font-weight",Mi(t)),textDecoration:t=>{const e=m(t).trim();return Ni.has(e)?[["text-decoration",e]]:[]}},Ni=new Set(["underline","none","line-through","overline"]);function Ii(t){const e=m(t).trim();if(!e)return[];if(e==="none")return[["border","none"]];if(e==="subtle")return[["border","1px solid var(--rui-color-border-subtle)"]];if(e==="strong")return[["border","1px solid var(--rui-color-text)"]];if(e==="true"||e==="default")return[["border","1px solid var(--rui-color-border)"]];const r=_e(e);return r?[["border",`1px solid ${r}`]]:[]}function W(t,e){return e?[[t,e]]:[]}function mu(t,e){const r=new Set;for(const[n,a]of Object.entries(pu)){const i=t[n];if(!ou(i))continue;const o=[];for(const l of["base","sm","md","lg","xl"]){if(!(l in i))continue;const u=a(i[l]);u.length>0&&o.push({bp:l,decls:u})}if(o.length===0)continue;const s=iu(o);s&&(e.push(s),r.add(n))}return r}function fu(t){const e=[];if(!t||typeof t!="object"||Array.isArray(t))return{style:"",classes:e};const r=t,n=mu(r,e),a=[],i=O=>n.has(O)?void 0:du(r[O]);a.push(["padding",V(i("p"))]),a.push(["padding-inline",V(i("px"))]),a.push(["padding-top",V(i("py"))],["padding-bottom",V(i("py"))]),a.push(["padding-top",V(i("pt"))]),a.push(["padding-right",V(i("pr"))]),a.push(["padding-bottom",V(i("pb"))]),a.push(["padding-left",V(i("pl"))]),a.push(["padding-inline-start",V(i("ps"))]),a.push(["padding-inline-end",V(i("pe"))]),a.push(["margin",V(i("m"))]),a.push(["margin-inline",V(i("mx"))]),a.push(["margin-top",V(i("my"))],["margin-bottom",V(i("my"))]),a.push(["margin-top",V(i("mt"))]),a.push(["margin-right",V(i("mr"))]),a.push(["margin-bottom",V(i("mb"))]),a.push(["margin-left",V(i("ml"))]),a.push(["margin-inline-start",V(i("ms"))]),a.push(["margin-inline-end",V(i("me"))]),a.push(["gap",V(i("gap"))]),a.push(["width",ie(i("w"))]),a.push(["height",ie(i("h"))]),a.push(["min-width",ie(i("minW"))]),a.push(["max-width",ie(i("maxW"))]),a.push(["min-height",ie(i("minH"))]),a.push(["max-height",ie(i("maxH"))]);const o=Jr(i("bg"));o&&a.push(["background",o]),a.push(["color",_e(i("color"))]);const s=i("border");if(s!=null)for(const O of Ii(s))a.push(O);const l=_e(i("borderColor"));l&&a.push(["border-color",l]);const u=i("radius");if(u!=null){const O=m(u).trim();a.push(["border-radius",O in bt?bt[O]:X(O,"")||null])}const d=i("shadow");if(d!=null){const O=m(d).trim();O in vt&&a.push(["box-shadow",vt[O]])}const p=we(i("opacity"));p&&a.push(["opacity",p]);const f=m(i("display")).trim();wi.has(f)&&a.push(["display",f]);const b=m(i("direction")).trim();ki.has(b)&&a.push(["flex-direction",b]);const h=m(i("align")).trim();h in Qt&&a.push(["align-items",Qt[h]]);const g=m(i("justify")).trim();g in Jt&&a.push(["justify-content",Jt[g]]),(i("wrap")===!0||m(i("wrap"))==="true")&&a.push(["flex-wrap","wrap"]);const y=we(i("grow"));y&&a.push(["flex-grow",y]);const v=we(i("shrink"));v&&a.push(["flex-shrink",v]);const x=ie(i("basis"));x&&a.push(["flex-basis",x]);const w=we(i("columns"));w&&a.push(["grid-template-columns",`repeat(${w}, minmax(0, 1fr))`]);const k=m(i("position")).trim();Si.has(k)&&a.push(["position",k]),a.push(["top",ie(i("top"))]),a.push(["right",ie(i("right"))]),a.push(["bottom",ie(i("bottom"))]),a.push(["left",ie(i("left"))]);const A=i("inset");if(A!=null){const O=m(A).trim();a.push(["inset",O==="0"?"0":X(O,"")||null])}const S=i("zIndex");if(S!=null){const O=m(S).trim();a.push(["z-index",O in er?er[O]:we(O)])}a.push(["font-size",Ti(i("fontSize"))]),a.push(["font-weight",Mi(i("weight"))]);const $=m(i("textDecoration")).trim();Ni.has($)&&a.push(["text-decoration",$]);const C=m(i("overflow")).trim();$i.has(C)&&a.push(["overflow",C]);const M=m(i("cursor")).trim();Ci.has(M)&&a.push(["cursor",M]);const E=m(i("textAlign")).trim();Ai.has(E)&&a.push(["text-align",E]),m(i("backdrop")).trim()==="blur"&&(a.push(["backdrop-filter","blur(12px)"]),a.push(["-webkit-backdrop-filter","blur(12px)"]));const _=m(i("bgImage")).trim(),B=uu(i("bgOverlay"));if(_){const O=cu(_);if(O){const Q=`url("${O}")`;a.push(["background-image",B?`${B}, ${Q}`:Q]),a.push(["background-size",m(i("bgSize")).trim()==="contain"?"contain":"cover"]),a.push(["background-position","center"])}}else B&&a.push(["background-image",B]);return Ei(i("hover"),"hover",e),Ei(i("focus"),"focus",e),hu(r,e),{style:a.filter(O=>O[1]!=null&&O[1]!=="").map(([O,Q])=>`${O}:${Q}`).join(";"),classes:e}}const Pi=new Set(["lift","grow","glow","bright","border","underline","scale"]);function Ei(t,e,r){if(t!=null){if(typeof t=="string"){Pi.has(t)&&r.push(`ak-${e}-${t}`);return}if(typeof t=="object"&&!Array.isArray(t))for(const[n,a]of Object.entries(t))a&&Pi.has(n)&&r.push(`ak-${e}-${n}`)}}const gu=new Set(["hover","focus","focus-visible","focus-within","active","disabled","checked","group-hover"]);function hu(t,e){const r=[],n=(o,s)=>{if(!s||typeof s!="object"||Array.isArray(s))return;const l=bu(s);l.length>0&&r.push({state:o,decls:l})},a=t.states;if(a&&typeof a=="object"&&!Array.isArray(a))for(const[o,s]of Object.entries(a))gu.has(o)&&n(o,s);if(n("hover",t.hover),n("focus",t.focus),r.length===0)return;const i=su(r);i&&e.push(i)}function bu(t){const e=[],r=(u,d)=>{d&&e.push([u,d])},n=[];if(r("background",Jr(t.bg)),r("color",_e(t.color)),r("border-color",_e(t.borderColor)),t.shadow!=null){const u=m(t.shadow).trim();u in vt&&r("box-shadow",vt[u])}if(t.radius!=null){const u=m(t.radius).trim();r("border-radius",u in bt?bt[u]:X(u,"")||null)}const a=we(t.opacity);a&&r("opacity",a);const i=m(t.cursor).trim();if(Ci.has(i)&&r("cursor",i),t.textDecoration!=null){const u=m(t.textDecoration).trim();["underline","none","line-through","overline"].includes(u)&&r("text-decoration",u)}const o=we(t.scale);o&&n.push(`scale(${o})`);const s=X(m(t.translateY),"");s&&n.push(`translateY(${s})`);const l=X(m(t.translateX),"");if(l&&n.push(`translateX(${l})`),t.rotate!=null){const u=I(t.rotate);Number.isFinite(u)&&Math.abs(u)<=360&&n.push(`rotate(${u}deg)`)}return n.length>0&&r("transform",n.join(" ")),e}const vu=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","zoom-in","slide-up","slide-down","slide-left","slide-right","pulse","float","shimmer","bounce","spin","ping","wiggle"]);function yu(t){const e=[],r=[];if(!t)return{classes:e,style:""};let n="",a=null,i=null,o=null;if(typeof t=="string")n=t.trim();else if(typeof t=="object"&&!Array.isArray(t)){const s=t;n=m(s.preset??s.name).trim(),s.delay!=null&&(a=I(s.delay)),s.duration!=null&&(i=I(s.duration)),o=s.repeat}if(!vu.has(n))return{classes:e,style:""};if(e.push("ak-anim",`ak-anim-${n}`),a!=null&&a>=0&&a<=2e4&&r.push(`animation-delay:${Math.round(a)}ms`),i!=null&&i>0&&i<=2e4&&r.push(`animation-duration:${Math.round(i)}ms`),o==="infinite"||o===!0)r.push("animation-iteration-count:infinite");else{const s=we(o);s&&r.push(`animation-iteration-count:${s}`)}return{classes:e,style:r.join(";")}}const tn=new Set(["sx","animate","id","anchor","className","class","style","aria","data","tooltip","hidden"]),xu=/^[A-Za-z_][\w-]*$/;function zi(t){const e=[],r=n=>{const a=m(n).trim();for(const i of a.split(/\s+/))i&&xu.test(i)&&e.push(i)};return Array.isArray(t)?t.forEach(r):r(t),e}const wu=/<\/?\w|expression\s*\(|javascript\s*:|@import\b|url\s*\(\s*['"]?\s*(javascript|data:text)/i;function ku(t){const e=m(t).trim();return!e||e.length>2048||wu.test(e)?"":e}const Su=/^[a-z][a-z-]{1,32}$/;function $u(t,e){if(!e||!(t instanceof Element))return;const r=t,n=[],a=[];if(e.sx!=null){const{style:l,classes:u}=fu(e.sx);l&&n.push(l),a.push(...u)}if(e.animate!=null){const{classes:l,style:u}=yu(e.animate);a.push(...l),u&&n.push(u)}const i=ku(e.style);if(i&&n.push(i),n.length>0){const u=[r.getAttribute("style"),n.join(";")].filter(Boolean).join(";");r.setAttribute("style",u)}a.push(...zi(e.className)),a.push(...zi(e.class));for(const l of a)r.classList.add(l);const o=m(e.id??e.anchor).trim();o&&/^[A-Za-z][\w-]*$/.test(o)&&r.setAttribute("id",o),e.hidden===!0&&r.setAttribute("hidden","");const s=m(e.tooltip).trim();if(s&&r.setAttribute("title",s),e.aria&&typeof e.aria=="object")for(const[l,u]of Object.entries(e.aria)){const d=l.toLowerCase();Su.test(d)&&u!=null&&r.setAttribute(d.startsWith("aria-")?d:`aria-${d}`,m(u))}if(e.data&&typeof e.data=="object")for(const[l,u]of Object.entries(e.data)){const d=l.toLowerCase().replace(/[^a-z0-9-]/g,"");d&&u!=null&&r.setAttribute(`data-${d}`,m(u))}}function tr(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function rn(t){const e=tr(t);return e>=0?t.props[e]:void 0}function Ri(t){for(const e of t){const r=e.props.filter(n=>n.positional===!0);if(r.length>1){const n=r.map(a=>a.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${n}). Aktion 0.5 §19.1 allows at most one.`)}}}function Tt(t){return/\bobject\b|\bRecord\b|\{|\bany\b/i.test(t.type)}function Li(t){const e=new Set;for(const r of t.props)if(e.add(r.name),r.aliases)for(const n of r.aliases)e.add(n);return e.add("key"),e}function nn(t,e){const r=tr(t);if(r<0)return null;const n=new Set;let a=-1;for(let i=0;i<=e;i+=1){if(i===0)a=r;else{let o=0;for(;o<t.props.length&&n.has(o);)o+=1;if(o>=t.props.length)return null;a=o}n.add(a)}return t.props[a]??null}function an(t,e){let r=-1;for(let d=t.length-1;d>=0;d-=1)if(t[d].objectKeys!==null){r=d;break}if(r<0)return-1;const n=t[r].objectKeys,a=Li(e),i=n.reduce((d,p)=>d+(a.has(p)||tn.has(p)?1:0),0),o=n.length>0&&i===n.length,s=i>0,l=rn(e);if(t.length===1)return e.props.length===1?Tt(e.props[0])?-1:o?0:-1:o?0:!s&&l&&Tt(l)?-1:0;if(r!==t.length-1)return s?r:-1;if(s||n.length===0)return r;const u=nn(e,t.length-1);return u&&Tt(u)?-1:r}function on(t){return t.map(e=>({objectKeys:e.kind==="Object"&&e.properties?e.properties.filter(r=>!r.spread).map(r=>r.key):null}))}function rr(t,e){const r={};return t.props.forEach((n,a)=>{a<e.length&&(r[n.name]=e[a])}),r}function Cu(t,e){const r=xe(t),n=sn(r,e);return n.length>0&&(r.errors=[...r.errors,...n]),r}function sn(t,e){const r=[];ln=Au(t);try{for(const n of t.statements)de(n,e,r)}finally{ln=Di}return r}const Di=new Set;let ln=Di;function Au(t){const e=new Set,r=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(const i of n)r(i);return}const a=n;a.kind==="ComponentDeclaration"&&typeof a.name=="string"&&e.add(a.name);for(const i of Object.keys(a))i!=="loc"&&r(a[i])};return r(t.statements),e}function de(t,e,r){switch(t.kind){case"Assignment":Y(t.expression,e,r);return;case"ExpressionStatement":Y(t.expression,e,r);return;case"ComponentDeclaration":Tu(t,e,r);for(const n of t.body.body)de(n,e,r);return;case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const n of t.body.body)de(n,e,r);return;case"Return":t.argument&&Y(t.argument,e,r);return;case"Await":Y(t.argument,e,r);return;case"IfStatement":Y(t.test,e,r);for(const n of t.consequent.body)de(n,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")de(t.alternate,e,r);else for(const n of t.alternate.body)de(n,e,r);return;case"SwitchStatement":Y(t.discriminant,e,r);for(const n of t.cases){n.test&&Y(n.test,e,r);for(const a of n.body)de(a,e,r)}return;case"ForOfStatement":Y(t.iterable,e,r);for(const n of t.body.body)de(n,e,r);return;case"ForClassicStatement":t.init&&de(t.init,e,r),t.test&&Y(t.test,e,r),t.update&&Y(t.update,e,r);for(const n of t.body.body)de(n,e,r);return;case"WhileStatement":case"DoWhileStatement":Y(t.test,e,r);for(const n of t.body.body)de(n,e,r);return;case"ForInStatement":Y(t.iterable,e,r);for(const n of t.body.body)de(n,e,r);return;case"DestructureStatement":Y(t.expression,e,r);for(const n of t.bindings)n.defaultValue&&Y(n.defaultValue,e,r);return;case"TryStatement":for(const n of t.block.body)de(n,e,r);if(t.catchBlock)for(const n of t.catchBlock.body)de(n,e,r);if(t.finallyBlock)for(const n of t.finallyBlock.body)de(n,e,r);return;case"ThrowStatement":Y(t.argument,e,r);return;default:return}}function Y(t,e,r){if(t)switch(t.kind){case"Call":{Mu(t,e,r);for(const n of t.arguments)Y(n,e,r);return}case"MethodCall":{Y(t.object,e,r);for(const n of t.arguments)Y(n,e,r);return}case"BuiltinCall":{for(const n of t.arguments)Y(n,e,r);return}case"Array":for(const n of t.elements)Y(n,e,r);return;case"Object":for(const n of t.properties)Y(n.value,e,r);return;case"Template":for(const n of t.expressions)Y(n,e,r);return;case"Binary":Y(t.left,e,r),Y(t.right,e,r);return;case"Unary":Y(t.argument,e,r);return;case"Ternary":Y(t.test,e,r),Y(t.consequent,e,r),Y(t.alternate,e,r);return;case"Member":Y(t.object,e,r),t.computed&&Y(t.computed,e,r);return;case"Spread":Y(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&Pu(t,r),Y(t.callee,e,r);for(const n of t.arguments)Y(n,e,r);return;case"New":Y(t.callee,e,r);for(const n of t.arguments)Y(n,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const n of t.body.body)de(n,e,r);else Y(t.body,e,r);return;case"Block":for(const n of t.body)de(n,e,r);return;default:return}}function Tu(t,e,r){Pe(e,t.name)&&(cn(t.body,t.name)||r.push({message:`function ${t.name}(...) — "${t.name}" is a built-in component name. Rename the custom component (e.g. "App${t.name}"), or call ${t.name}(...) inside the body to wrap the built-in (inside its own body the name refers to the built-in component).`,line:t.loc?.line??0,column:t.loc?.column??0}))}function cn(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t))return t.some(n=>cn(n,e));const r=t;if(r.kind==="Call"&&r.callee===e)return!0;for(const n of Object.keys(r))if(n!=="loc"&&cn(r[n],e))return!0;return!1}function Mu(t,e,r){if(ln.has(t.callee))return;const n=Pe(e,t.callee);if(!n)return;const a=new Set;for(const d of n.props)if(a.add(d.name),d.aliases)for(const p of d.aliases)a.add(p);a.add("key");const i=t.arguments,o=an(on(i),n),s=o>=0?i[o]:null,l=[];for(let d=0;d<i.length;d++)d!==o&&l.push(i[d]);l.length>n.props.length&&r.push({message:`${t.callee}(...) — takes at most ${n.props.length} positional argument${n.props.length===1?"":"s"} (${n.props.map(d=>d.name).join(", ")}); got ${l.length}.`,line:t.loc?.line??0,column:t.loc?.column??0}),l.forEach((d,p)=>{const f=nn(n,p);if(f){if(f.enum&&d.kind==="Literal"&&typeof d.value=="string"){const b=d.value;!f.enum.includes(b)&&!f.enum.includes(Xr(b))&&r.push({message:`<${t.callee}> ${f.name}="${b}" — 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})}d.kind==="Object"&&!Tt(f)&&r.push({message:`<${t.callee}> — object passed positionally for "${f.name}" (${f.type}). Use named props from: ${n.props.map(b=>b.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}});const u=[];if(s)for(const d of s.properties)d.spread||u.push({name:d.key,value:d.value,loc:d.value.loc??s.loc});for(const d of u){if(!a.has(d.name)){if(tn.has(d.name))continue;r.push({message:`Unknown prop "${d.name}" on <${t.callee}>. Known props: ${n.props.map(f=>f.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0});continue}const p=n.props.find(f=>f.name===d.name||(f.aliases?.includes(d.name)??!1));if(p?.enum&&d.value.kind==="Literal"&&typeof d.value.value=="string"){const f=d.value.value;!p.enum.includes(f)&&!p.enum.includes(Xr(f))&&r.push({message:`<${t.callee}> ${d.name}="${f}" — must be one of ${p.enum.map(b=>`"${b}"`).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}}}const Nu=new Set(["colors","radius","font","fonts","spacing","shadows","gradients","icons","zIndex","motion"]),Iu=new Set(["name","direction"]);function Pu(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const n of r.properties){if(n.spread||Nu.has(n.key)||Iu.has(n.key))continue;const a=Eu(n.key),i=n.key.startsWith("--")?`$theme({"${n.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`:`$theme({${n.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${a}.`;e.push({message:i,line:t.loc?.line??0,column:t.loc?.column??0})}}function Eu(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"}];for(const{prefix:r,group:n}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const a=t.slice(r.length),i=a.charAt(0).toLowerCase()+a.slice(1);return`$theme({ ${n}: { ${i}: ... } })`}return"$theme({ colors: {...}, radius: {...}, font: {...} })"}const nr={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:"$"}},ji={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"
|
|
67
|
+
`}}case"delete":{const n=an(r,e.binding);return n<0?{programText:t,warning:`delta(delete): binding "${e.binding}" not found — op skipped`}:{programText:on(t,r,n,null)}}case"replace":{const n=an(r,e.binding);return n<0?{programText:t,warning:`delta(replace): binding "${e.binding}" not found — op skipped`}:Se(`${e.binding} = ${e.source}`).errors.length>0?{programText:t,warning:`delta(replace): could not parse new source for "${e.binding}" — op skipped`}:{programText:on(t,r,n,`${e.binding} = ${e.source.trim()}`)}}case"append":{const n=an(r,e.binding);if(n<0)return{programText:t,warning:`delta(append): binding "${e.binding}" not found — op skipped`};const a=r.statements[n];if(a.kind!=="Assignment"||a.expression.kind!=="Array")return{programText:t,warning:`delta(append): binding "${e.binding}" is not an array literal — op skipped`};const i=Se(`__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 "${wi(e.item)}" — op skipped`};const s=a.expression.elements,l=`${e.binding} = [${[...s.map(Ae),e.item.trim()].join(", ")}]`;return{programText:on(t,r,n,l)}}}}function an(t,e){return t.statements.findIndex(r=>iu(r)===e)}function iu(t){switch(t.kind){case"Assignment":return t.identifier;case"ComponentDeclaration":case"EffectDeclaration":case"ActionDeclaration":case"HookDeclaration":return t.name;default:return null}}function on(t,e,r,n){const a=t.split(`
|
|
68
|
+
`),i=e.statements[r],o=e.statements[r+1],s=(i.loc?.line??1)-1,l=o?(o.loc?.line??a.length+1)-1:a.length,c=a.slice(0,s),d=a.slice(l);return n===null?[...c,...d].join(`
|
|
69
|
+
`):[...c,n,...d].join(`
|
|
70
|
+
`)}function Ae(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(Ae).join(", ")})`;case"MethodCall":return`${Ae(t.object)}${t.optional?"?.":"."}${t.method}(${t.arguments.map(Ae).join(", ")})`;case"Array":return`[${t.elements.map(Ae).join(", ")}]`;case"Object":return`{ ${t.properties.map(e=>e.spread?`...${Ae(e.value)}`:`${e.key}: ${Ae(e.value)}`).join(", ")} }`;case"Member":{const e=Ae(t.object);return t.property?`${e}${t.optional?"?.":"."}${t.property}`:t.computed?`${e}${t.optional?"?.":""}[${Ae(t.computed)}]`:e}case"Binary":return`${Ae(t.left)} ${t.operator} ${Ae(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(Ae(t.expressions[r])),e.push("}"));return`\`${e.join("")}\``}default:return"/* unprintable */"}}function wi(t){return t.length>40?`${t.slice(0,37)}...`:t}const ki=new WeakMap;function ou(t){let e=ki.get(t.components);if(!e){e=new Map;for(const r of t.components)r?.name&&e.set(r.name,r);ki.set(t.components,e)}return e}function Si(t,e){const r=new Map;for(const n of t.components)r.set(n.name,n);for(const n of e.components)r.set(n.name,n);return{root:e.root??t.root,components:[...r.values()],componentGroups:t.componentGroups}}function Le(t,e){return ou(t).get(e)}const su="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css",$i="6.7.2",Ci="data-rui-font-awesome",lu=new Set(["solid","regular","brands"]),Ai="solid";function cu(t){typeof document<"u"&&Ti(document.head,document),Ti(t,t.ownerDocument??document)}function Ti(t,e){if(uu()||t.querySelector(`link[${Ci}="${$i}"]`))return;const n=e.createElement("link");n.rel="stylesheet",n.href=su,n.setAttribute(Ci,$i);try{t.appendChild(n)}catch{}}function uu(){return typeof globalThis.happyDOM<"u"}function rr(t){if(typeof t!="string")return[];const e=pu(t).trim();if(!e)return[];if(!fu(e))return[];const[r,n]=mu(e);return n?[`fa-${r}`,`fa-${n}`]:[]}const du=/[\uFE0E\uFE0F\u200D\u200C\uFEFF]/g;function pu(t){return t.replace(du,"")}function mu(t){const e=t.indexOf(":");if(e===-1)return[Ai,t];const r=t.slice(0,e).trim().toLowerCase(),n=t.slice(e+1).trim();return lu.has(r)?[r,n]:[Ai,n||t]}function fu(t){return/^[a-zA-Z0-9:_-]+$/.test(t)}const gu=["xs","sm","md","lg","xl"],Mi=new Map,hu=/<script|<foreignObject|on\w+\s*=|javascript\s*:|<!ENTITY|<iframe|<embed|<object/i,bu=/^[a-zA-Z0-9:_-]+$/;function vu(t){const e=typeof t=="string"?t:"";return!e||e.length>16384||hu.test(e)?"":e}function Ni(t){if(!t||typeof t!="object"||Array.isArray(t))return[];const e=[];for(const[r,n]of Object.entries(t)){if(!bu.test(r))continue;const a=vu(n);a&&(Mi.set(r,a),e.push(r))}return e}function yu(t){return typeof t!="string"?null:Mi.get(t.trim())??null}function u(t,e,r){const n=document.createElement(t);if(e)for(const[a,i]of Object.entries(e))i==null||i===!1||(a==="class"?n.setAttribute("class",String(i)):a==="html"?n.innerHTML=String(i):i===!0?n.setAttribute(a,""):n.setAttribute(a,String(i)));if(r)for(const a of r)a!=null&&n.append(typeof a=="string"?document.createTextNode(a):a);return n}function T(t){return Array.isArray(t)?t:t==null?[]:[t]}function m(t,e=""){return t==null?e:typeof t=="string"?t:String(t)}function I(t,e=!1){return typeof t=="boolean"?t:t==="true"?!0:t==="false"?!1:t==null?e:!!t}function P(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 me=["none","3xs","2xs","xs","sm","md","lg","xl","2xl","3xl"],xu={s:"sm",m:"md",l:"lg",small:"sm",normal:"md",large:"lg"};function sn(t){const e=typeof t=="string"?t.trim():"";return xu[e]??e}function ve(t,e=""){const r=sn(t);return me.includes(r)?r:e}function Ii(t){const e=ve(t);return e?e==="none"?"0":`var(--rui-spacing-${e==="sm"?"s":e==="md"?"m":e==="lg"?"l":e})`:""}const yt=["base","sm","md","lg","xl"];function Te(t){if(t==null||typeof t!="object"||Array.isArray(t))return{kind:"single",value:t??null};const e=Object.entries(t),r={};let n=!1;for(const[a,i]of e)yt.includes(a)&&(r[a]=i,n=!0);return n?{kind:"responsive",values:r}:{kind:"single",value:t}}const wu=/["'\\\n\r<>;{}]/g;function ku(t){return t?t.replace(wu,"").trim():""}const Su=/^[a-zA-Z0-9.%+\-*/\s(),]+$/;function Z(t,e){const r=(m(t)??"").trim();return!r||r.length>64||!Su.test(r)?e:r}const $u=/^[a-zA-Z0-9#%.,()\s+\-]+$/;function He(t){const e=m(t).trim();return!e||e.length>64||!$u.test(e)||/\burl\s*\(|\bexpression\s*\(|javascript\s*:|@import\b/i.test(e)?"":e}const Cu=new Set(["http","https","mailto","tel"]);function qe(t,e="#"){const r=m(t).trim();if(!r)return e;const n=r.replace(/[\u0000-\u001F\u007F]/g,"");if(!n||n.startsWith("//"))return e;if(n.startsWith("#")||n.startsWith("/")||n.startsWith("?")||n.startsWith("."))return n;const a=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(n);if(!a)return n;const i=a[1].toLowerCase();return Cu.has(i)?n:e}const Au=new Set(["http","https","data","blob"]);function ie(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 n=/^([a-zA-Z][a-zA-Z0-9+.\-]*):/.exec(r);if(!n)return r;const a=n[1].toLowerCase();return!Au.has(a)||a==="data"&&!/^data:image\//i.test(r)?"":r}function Tu(t){if(t===null||typeof t!="object")return!1;const e=t.__kind;return e==="Component"||e==="UserComponent"}function ln(t,e,r,n,a,i){const o=e.format??"text";let s=r;if(typeof e.render=="function")try{s=e.render(r,n)}catch(c){console.error("[aktion] Col render() threw",c),s=null}const l=c=>{Tu(c)?t.append(a.renderNode(c)):c!=null&&t.append(document.createTextNode(i(c,o)))};if(Array.isArray(s))for(const c of s)l(c);else l(s);if(typeof e.onClick=="function"){t.setAttribute("data-clickable","true"),t.setAttribute("role","button"),t.tabIndex=0;const c=d=>d.target?.closest("input,button,a,label,select,textarea")?!1:(d.stopPropagation(),a.invoke(e.onClick,r,n),!0);t.onclick=d=>{c(d)},t.onkeydown=d=>{d.key!=="Enter"&&d.key!==" "||c(d)&&d.preventDefault()}}}function j(t,e={}){const r=m(t);if(!r)return null;const n=e.color?He(e.color):"",a=n?`color:${n};`:null,i=["rui-icon",e.className].filter(Boolean).join(" "),o=yu(r);if(o){const l=u("span",{class:`${i} rui-icon-custom`,"data-icon-size":e.size??null,style:a,"aria-hidden":"true"});if(/^\s*<svg[\s>]/i.test(o))l.innerHTML=o;else{const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("viewBox","0 0 24 24"),d.setAttribute("fill","currentColor"),d.innerHTML=o,l.appendChild(d)}return l}const s=rr(r);return s.length===0?u("span",{class:i,"data-icon-size":e.size??null,style:a},[r]):u("i",{class:`${i} ${s.join(" ")}`,"data-icon-size":e.size??null,style:a,"aria-hidden":"true"})}const Mu={base:0,sm:640,md:768,lg:1024,xl:1280},Pi={base:0,sm:1,md:2,lg:3,xl:4};let xt;const nr=new Map;let Ri=0;function cn(){if(xt!==void 0)return xt;try{return typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype)?(xt=null,null):(xt=new CSSStyleSheet,xt)}catch{return xt=null,null}}function Nu(t){const e=cn();if(!e)return null;const r=[...t].filter(o=>o.decls.length>0).sort((o,s)=>(Pi[o.bp]??0)-(Pi[s.bp]??0));if(r.length===0)return null;const n=r.map(o=>`${o.bp}{${o.decls.map(([s,l])=>`${s}:${l}`).join(";")}}`).join("|"),a=nr.get(n);if(a)return a;const i=`ak-r${(Ri++).toString(36)}`;for(const o of r){const s=o.decls.map(([d,p])=>`${d}:${p}`).join(";"),l=Mu[o.bp]??0,c=l>0?`@media (min-width:${l}px){.${i}{${s}}}`:`.${i}{${s}}`;try{e.insertRule(c,e.cssRules.length)}catch{}}return nr.set(n,i),i}function Iu(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return"base"in e||"sm"in e||"md"in e||"lg"in e||"xl"in e}const Ei={hover:":hover",focus:":focus","focus-visible":":focus-visible","focus-within":":focus-within",active:":active",disabled:":disabled, &[disabled], &[data-disabled='true']",checked:":checked, &[aria-checked='true']","group-hover":""};function Pu(t){const e=cn();if(!e)return null;const r=t.filter(o=>o.decls.length>0&&o.state in Ei);if(r.length===0)return null;const n="S|"+r.map(o=>`${o.state}{${o.decls.map(([s,l])=>`${s}:${l}`).join(";")}}`).join("|"),a=nr.get(n);if(a)return a;const i=`ak-s${(Ri++).toString(36)}`;try{e.insertRule(`.${i}{transition:background .15s ease,color .15s ease,box-shadow .15s ease,transform .15s ease,opacity .15s ease,border-color .15s ease;}`,e.cssRules.length)}catch{}for(const o of r){const s=o.decls.map(([c,d])=>`${c}:${d}`).join(";");let l;o.state==="group-hover"?l=`.ak-group:hover .${i}{${s}}`:o.state==="disabled"?l=`.${i}:disabled,.${i}[disabled],.${i}[data-disabled="true"]{${s}}`:o.state==="checked"?l=`.${i}:checked,.${i}[aria-checked="true"]{${s}}`:l=`.${i}${Ei[o.state]}{${s}}`;try{e.insertRule(l,e.cssRules.length)}catch{}}return nr.set(n,i),i}const Li={none:"0","3xs":"var(--rui-spacing-3xs)","2xs":"var(--rui-spacing-2xs)",xs:"var(--rui-spacing-xs)",s:"var(--rui-spacing-s)",sm:"var(--rui-spacing-s)",m:"var(--rui-spacing-m)",md:"var(--rui-spacing-m)",l:"var(--rui-spacing-l)",lg:"var(--rui-spacing-l)",xl:"var(--rui-spacing-xl)","2xl":"var(--rui-spacing-2xl)","3xl":"var(--rui-spacing-3xl)",auto:"auto",safe:"env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)","safe-top":"env(safe-area-inset-top)","safe-right":"env(safe-area-inset-right)","safe-bottom":"env(safe-area-inset-bottom)","safe-left":"env(safe-area-inset-left)"},zi={bg:"var(--rui-color-bg)","bg-subtle":"var(--rui-color-bg-subtle)",surface:"var(--rui-color-surface)","surface-muted":"var(--rui-color-surface-muted)",border:"var(--rui-color-border)","border-subtle":"var(--rui-color-border-subtle)",text:"var(--rui-color-text)","text-muted":"var(--rui-color-text-muted)",muted:"var(--rui-color-text-muted)",primary:"var(--rui-color-primary)","primary-hover":"var(--rui-color-primary-hover)","primary-text":"var(--rui-color-primary-text)",accent:"var(--rui-color-accent)",success:"var(--rui-color-success)",warning:"var(--rui-color-warning)",danger:"var(--rui-color-danger)",info:"var(--rui-color-info)",transparent:"transparent",current:"currentColor"},wt={none:"0",xs:"var(--rui-radius-xs)",sm:"var(--rui-radius-sm)",md:"var(--rui-radius-md)",lg:"var(--rui-radius-lg)",pill:"var(--rui-radius-pill)",full:"9999px",circle:"50%"},kt={none:"none",sm:"var(--rui-shadow-sm)",md:"var(--rui-shadow-md)",lg:"var(--rui-shadow-lg)"},ji={full:"100%",half:"50%",screen:"100vh","screen-w":"100vw","screen-h":"100vh",dvh:"100dvh",min:"min-content",max:"max-content",fit:"fit-content",auto:"auto"},ar={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},ir={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly",stretch:"stretch"},or={base:"var(--rui-z-base, 0)",raised:"var(--rui-z-raised, 10)",dropdown:"var(--rui-z-dropdown, 1000)",sticky:"var(--rui-z-sticky, 1100)",banner:"var(--rui-z-banner, 1200)",overlay:"var(--rui-z-overlay, 1250)",modal:"var(--rui-z-modal, 1300)",popover:"var(--rui-z-popover, 1350)",toast:"var(--rui-z-toast, 1400)",tooltip:"var(--rui-z-tooltip, 1500)"},Di={xs:"0.75rem",sm:"var(--rui-font-size-sm)",base:"var(--rui-font-size-base)",md:"var(--rui-font-size-base)",lg:"var(--rui-font-size-lg)",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},Ru=new Set(["100","200","300","400","500","600","700","800","900","normal","bold"]),Oi=new Set(["flex","grid","block","inline","inline-flex","inline-block","none","contents"]),Bi=new Set(["row","column","row-reverse","column-reverse"]),Fi=new Set(["relative","absolute","fixed","sticky","static"]),_i=new Set(["hidden","auto","scroll","visible","clip"]),Ui=new Set(["pointer","default","not-allowed","grab","grabbing","text","move","wait","help","none"]),Hi=new Set(["left","center","right","justify","start","end"]);function K(t){const e=m(t).trim();return e?e in Li?Li[e]:Z(e,"")||null:null}function le(t){const e=m(t).trim();return e?e in ji?ji[e]:Z(e,"")||null:null}function Ve(t){const e=m(t).trim();return e?e in zi?zi[e]:e.startsWith("gradient.")?`var(--rui-gradient-${dn(e.slice(9))})`:He(e)||null:null}function un(t){const e=m(t).trim();return e.startsWith("gradient.")?`var(--rui-gradient-${dn(e.slice(9))})`:Ve(t)}function dn(t){return t.replace(/[^a-zA-Z0-9-]/g,"").slice(0,40)}function $e(t){if(typeof t=="number"&&Number.isFinite(t))return String(t);const e=m(t).trim();return/^-?\d+(\.\d+)?$/.test(e)?e:null}function qi(t){const e=m(t).trim();return e?e in Di?Di[e]:Z(e,"")||null:null}function Vi(t){const e=m(t).trim();return Ru.has(e)?e:null}function Eu(t){const e=t.replace(/["'\\\n\r<>;{})(]/g,"").trim();return!e||e.length>512?null:/^(https?:)?\/\//i.test(e)||/^data:image\//i.test(e)?e:/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?null:e}function Lu(t){const e=m(t).trim();if(!e)return null;if(e.startsWith("gradient."))return`var(--rui-gradient-${dn(e.slice(9))})`;const r=Ve(e);return r?`linear-gradient(${r}, ${r})`:null}function zu(t){if(t&&typeof t=="object"&&!Array.isArray(t)){const e=t;if("base"in e||"sm"in e||"md"in e||"lg"in e||"xl"in e)return e.base??e.sm??e.md??e.lg??e.xl}return t}const ju={p:t=>Y("padding",K(t)),px:t=>Y("padding-inline",K(t)),py:t=>{const e=K(t);return e?[["padding-top",e],["padding-bottom",e]]:[]},pt:t=>Y("padding-top",K(t)),pr:t=>Y("padding-right",K(t)),pb:t=>Y("padding-bottom",K(t)),pl:t=>Y("padding-left",K(t)),ps:t=>Y("padding-inline-start",K(t)),pe:t=>Y("padding-inline-end",K(t)),m:t=>Y("margin",K(t)),mx:t=>Y("margin-inline",K(t)),my:t=>{const e=K(t);return e?[["margin-top",e],["margin-bottom",e]]:[]},mt:t=>Y("margin-top",K(t)),mr:t=>Y("margin-right",K(t)),mb:t=>Y("margin-bottom",K(t)),ml:t=>Y("margin-left",K(t)),ms:t=>Y("margin-inline-start",K(t)),me:t=>Y("margin-inline-end",K(t)),gap:t=>Y("gap",K(t)),w:t=>Y("width",le(t)),h:t=>Y("height",le(t)),minW:t=>Y("min-width",le(t)),maxW:t=>Y("max-width",le(t)),minH:t=>Y("min-height",le(t)),maxH:t=>Y("max-height",le(t)),bg:t=>Y("background",un(t)),color:t=>Y("color",Ve(t)),radius:t=>{const e=m(t).trim();return Y("border-radius",e in wt?wt[e]:Z(e,"")||null)},shadow:t=>{const e=m(t).trim();return e in kt?[["box-shadow",kt[e]]]:[]},display:t=>{const e=m(t).trim();return Oi.has(e)?[["display",e]]:[]},direction:t=>{const e=m(t).trim();return Bi.has(e)?[["flex-direction",e]]:[]},align:t=>{const e=m(t).trim();return e in ar?[["align-items",ar[e]]]:[]},justify:t=>{const e=m(t).trim();return e in ir?[["justify-content",ir[e]]]:[]},textAlign:t=>{const e=m(t).trim();return Hi.has(e)?[["text-align",e]]:[]},columns:t=>{const e=$e(t);return e?[["grid-template-columns",`repeat(${e}, minmax(0, 1fr))`]]:[]},border:t=>Gi(t),borderColor:t=>Y("border-color",Ve(t)),opacity:t=>Y("opacity",$e(t)),zIndex:t=>{const e=m(t).trim();return Y("z-index",e in or?or[e]:$e(e))},overflow:t=>{const e=m(t).trim();return _i.has(e)?[["overflow",e]]:[]},grow:t=>Y("flex-grow",$e(t)),shrink:t=>Y("flex-shrink",$e(t)),basis:t=>Y("flex-basis",le(t)),wrap:t=>t===!0||m(t)==="true"?[["flex-wrap","wrap"]]:t===!1||m(t)==="false"?[["flex-wrap","nowrap"]]:[],position:t=>{const e=m(t).trim();return Fi.has(e)?[["position",e]]:[]},top:t=>Y("top",le(t)),right:t=>Y("right",le(t)),bottom:t=>Y("bottom",le(t)),left:t=>Y("left",le(t)),inset:t=>{const e=m(t).trim();return Y("inset",e==="0"?"0":Z(e,"")||null)},fontSize:t=>Y("font-size",qi(t)),weight:t=>Y("font-weight",Vi(t)),textDecoration:t=>{const e=m(t).trim();return Wi.has(e)?[["text-decoration",e]]:[]}},Wi=new Set(["underline","none","line-through","overline"]);function Gi(t){const e=m(t).trim();if(!e)return[];if(e==="none")return[["border","none"]];if(e==="subtle")return[["border","1px solid var(--rui-color-border-subtle)"]];if(e==="strong")return[["border","1px solid var(--rui-color-text)"]];if(e==="true"||e==="default")return[["border","1px solid var(--rui-color-border)"]];const r=Ve(e);return r?[["border",`1px solid ${r}`]]:[]}function Y(t,e){return e?[[t,e]]:[]}function Du(t,e){const r=new Set;for(const[n,a]of Object.entries(ju)){const i=t[n];if(!Iu(i))continue;const o=[];for(const l of["base","sm","md","lg","xl"]){if(!(l in i))continue;const c=a(i[l]);c.length>0&&o.push({bp:l,decls:c})}if(o.length===0)continue;const s=Nu(o);s&&(e.push(s),r.add(n))}return r}function Ou(t){const e=[];if(!t||typeof t!="object"||Array.isArray(t))return{style:"",classes:e};const r=t,n=Du(r,e),a=[],i=_=>n.has(_)?void 0:zu(r[_]);a.push(["padding",K(i("p"))]),a.push(["padding-inline",K(i("px"))]),a.push(["padding-top",K(i("py"))],["padding-bottom",K(i("py"))]),a.push(["padding-top",K(i("pt"))]),a.push(["padding-right",K(i("pr"))]),a.push(["padding-bottom",K(i("pb"))]),a.push(["padding-left",K(i("pl"))]),a.push(["padding-inline-start",K(i("ps"))]),a.push(["padding-inline-end",K(i("pe"))]),a.push(["margin",K(i("m"))]),a.push(["margin-inline",K(i("mx"))]),a.push(["margin-top",K(i("my"))],["margin-bottom",K(i("my"))]),a.push(["margin-top",K(i("mt"))]),a.push(["margin-right",K(i("mr"))]),a.push(["margin-bottom",K(i("mb"))]),a.push(["margin-left",K(i("ml"))]),a.push(["margin-inline-start",K(i("ms"))]),a.push(["margin-inline-end",K(i("me"))]),a.push(["gap",K(i("gap"))]),a.push(["width",le(i("w"))]),a.push(["height",le(i("h"))]),a.push(["min-width",le(i("minW"))]),a.push(["max-width",le(i("maxW"))]),a.push(["min-height",le(i("minH"))]),a.push(["max-height",le(i("maxH"))]);const o=un(i("bg"));o&&a.push(["background",o]),a.push(["color",Ve(i("color"))]);const s=i("border");if(s!=null)for(const _ of Gi(s))a.push(_);const l=Ve(i("borderColor"));l&&a.push(["border-color",l]);const c=i("radius");if(c!=null){const _=m(c).trim();a.push(["border-radius",_ in wt?wt[_]:Z(_,"")||null])}const d=i("shadow");if(d!=null){const _=m(d).trim();_ in kt&&a.push(["box-shadow",kt[_]])}const p=$e(i("opacity"));p&&a.push(["opacity",p]);const f=m(i("display")).trim();Oi.has(f)&&a.push(["display",f]);const b=m(i("direction")).trim();Bi.has(b)&&a.push(["flex-direction",b]);const h=m(i("align")).trim();h in ar&&a.push(["align-items",ar[h]]);const g=m(i("justify")).trim();g in ir&&a.push(["justify-content",ir[g]]),(i("wrap")===!0||m(i("wrap"))==="true")&&a.push(["flex-wrap","wrap"]);const y=$e(i("grow"));y&&a.push(["flex-grow",y]);const v=$e(i("shrink"));v&&a.push(["flex-shrink",v]);const x=le(i("basis"));x&&a.push(["flex-basis",x]);const w=$e(i("columns"));w&&a.push(["grid-template-columns",`repeat(${w}, minmax(0, 1fr))`]);const k=m(i("position")).trim();Fi.has(k)&&a.push(["position",k]),a.push(["top",le(i("top"))]),a.push(["right",le(i("right"))]),a.push(["bottom",le(i("bottom"))]),a.push(["left",le(i("left"))]);const A=i("inset");if(A!=null){const _=m(A).trim();a.push(["inset",_==="0"?"0":Z(_,"")||null])}const S=i("zIndex");if(S!=null){const _=m(S).trim();a.push(["z-index",_ in or?or[_]:$e(_)])}a.push(["font-size",qi(i("fontSize"))]),a.push(["font-weight",Vi(i("weight"))]);const $=m(i("textDecoration")).trim();Wi.has($)&&a.push(["text-decoration",$]);const C=m(i("overflow")).trim();_i.has(C)&&a.push(["overflow",C]);const M=m(i("cursor")).trim();Ui.has(M)&&a.push(["cursor",M]);const L=m(i("textAlign")).trim();Hi.has(L)&&a.push(["text-align",L]),m(i("backdrop")).trim()==="blur"&&(a.push(["backdrop-filter","blur(12px)"]),a.push(["-webkit-backdrop-filter","blur(12px)"]));const H=m(i("bgImage")).trim(),F=Lu(i("bgOverlay"));if(H){const _=Eu(H);if(_){const te=`url("${_}")`;a.push(["background-image",F?`${F}, ${te}`:te]),a.push(["background-size",m(i("bgSize")).trim()==="contain"?"contain":"cover"]),a.push(["background-position","center"])}}else F&&a.push(["background-image",F]);return Yi(i("hover"),"hover",e),Yi(i("focus"),"focus",e),Fu(r,e),{style:a.filter(_=>_[1]!=null&&_[1]!=="").map(([_,te])=>`${_}:${te}`).join(";"),classes:e}}const Ki=new Set(["lift","grow","glow","bright","border","underline","scale"]);function Yi(t,e,r){if(t!=null){if(typeof t=="string"){Ki.has(t)&&r.push(`ak-${e}-${t}`);return}if(typeof t=="object"&&!Array.isArray(t))for(const[n,a]of Object.entries(t))a&&Ki.has(n)&&r.push(`ak-${e}-${n}`)}}const Bu=new Set(["hover","focus","focus-visible","focus-within","active","disabled","checked","group-hover"]);function Fu(t,e){const r=[],n=(o,s)=>{if(!s||typeof s!="object"||Array.isArray(s))return;const l=_u(s);l.length>0&&r.push({state:o,decls:l})},a=t.states;if(a&&typeof a=="object"&&!Array.isArray(a))for(const[o,s]of Object.entries(a))Bu.has(o)&&n(o,s);if(n("hover",t.hover),n("focus",t.focus),r.length===0)return;const i=Pu(r);i&&e.push(i)}function _u(t){const e=[],r=(c,d)=>{d&&e.push([c,d])},n=[];if(r("background",un(t.bg)),r("color",Ve(t.color)),r("border-color",Ve(t.borderColor)),t.shadow!=null){const c=m(t.shadow).trim();c in kt&&r("box-shadow",kt[c])}if(t.radius!=null){const c=m(t.radius).trim();r("border-radius",c in wt?wt[c]:Z(c,"")||null)}const a=$e(t.opacity);a&&r("opacity",a);const i=m(t.cursor).trim();if(Ui.has(i)&&r("cursor",i),t.textDecoration!=null){const c=m(t.textDecoration).trim();["underline","none","line-through","overline"].includes(c)&&r("text-decoration",c)}const o=$e(t.scale);o&&n.push(`scale(${o})`);const s=Z(m(t.translateY),"");s&&n.push(`translateY(${s})`);const l=Z(m(t.translateX),"");if(l&&n.push(`translateX(${l})`),t.rotate!=null){const c=P(t.rotate);Number.isFinite(c)&&Math.abs(c)<=360&&n.push(`rotate(${c}deg)`)}return n.length>0&&r("transform",n.join(" ")),e}const Uu=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","zoom-in","slide-up","slide-down","slide-left","slide-right","pulse","float","shimmer","bounce","spin","ping","wiggle"]);function Hu(t){const e=[],r=[];if(!t)return{classes:e,style:""};let n="",a=null,i=null,o=null;if(typeof t=="string")n=t.trim();else if(typeof t=="object"&&!Array.isArray(t)){const s=t;n=m(s.preset??s.name).trim(),s.delay!=null&&(a=P(s.delay)),s.duration!=null&&(i=P(s.duration)),o=s.repeat}if(!Uu.has(n))return{classes:e,style:""};if(e.push("ak-anim",`ak-anim-${n}`),a!=null&&a>=0&&a<=2e4&&r.push(`animation-delay:${Math.round(a)}ms`),i!=null&&i>0&&i<=2e4&&r.push(`animation-duration:${Math.round(i)}ms`),o==="infinite"||o===!0)r.push("animation-iteration-count:infinite");else{const s=$e(o);s&&r.push(`animation-iteration-count:${s}`)}return{classes:e,style:r.join(";")}}const pn=new Set(["sx","animate","id","anchor","className","class","style","aria","data","tooltip","hidden"]),qu=/^[A-Za-z_][\w-]*$/;function Xi(t){const e=[],r=n=>{const a=m(n).trim();for(const i of a.split(/\s+/))i&&qu.test(i)&&e.push(i)};return Array.isArray(t)?t.forEach(r):r(t),e}const Vu=/<\/?\w|expression\s*\(|javascript\s*:|@import\b|url\s*\(\s*['"]?\s*(javascript|data:text)/i;function Wu(t){const e=m(t).trim();return!e||e.length>2048||Vu.test(e)?"":e}const Gu=/^[a-z][a-z-]{1,32}$/;function Ku(t,e){if(!e||!(t instanceof Element))return;const r=t,n=[],a=[];if(e.sx!=null){const{style:l,classes:c}=Ou(e.sx);l&&n.push(l),a.push(...c)}if(e.animate!=null){const{classes:l,style:c}=Hu(e.animate);a.push(...l),c&&n.push(c)}const i=Wu(e.style);if(i&&n.push(i),n.length>0){const c=[r.getAttribute("style"),n.join(";")].filter(Boolean).join(";");r.setAttribute("style",c)}a.push(...Xi(e.className)),a.push(...Xi(e.class));for(const l of a)r.classList.add(l);const o=m(e.id??e.anchor).trim();o&&/^[A-Za-z][\w-]*$/.test(o)&&r.setAttribute("id",o),e.hidden===!0&&r.setAttribute("hidden","");const s=m(e.tooltip).trim();if(s&&r.setAttribute("title",s),e.aria&&typeof e.aria=="object")for(const[l,c]of Object.entries(e.aria)){const d=l.toLowerCase();Gu.test(d)&&c!=null&&r.setAttribute(d.startsWith("aria-")?d:`aria-${d}`,m(c))}if(e.data&&typeof e.data=="object")for(const[l,c]of Object.entries(e.data)){const d=l.toLowerCase().replace(/[^a-z0-9-]/g,"");d&&c!=null&&r.setAttribute(`data-${d}`,m(c))}}function sr(t){const e=t.props.findIndex(r=>r.positional===!0);return e>=0?e:t.props.length>0?0:-1}function mn(t){const e=sr(t);return e>=0?t.props[e]:void 0}function Ji(t){for(const e of t){const r=e.props.filter(n=>n.positional===!0);if(r.length>1){const n=r.map(a=>a.name).join(", ");throw new SyntaxError(`Component "${e.name}" declares ${r.length} positional props (${n}). Aktion 0.5 §19.1 allows at most one.`)}}}function Et(t){return/\bobject\b|\bRecord\b|\{|\bany\b/i.test(t.type)}function Qi(t){const e=new Set;for(const r of t.props)if(e.add(r.name),r.aliases)for(const n of r.aliases)e.add(n);return e.add("key"),e}function fn(t,e){const r=sr(t);if(r<0)return null;const n=new Set;let a=-1;for(let i=0;i<=e;i+=1){if(i===0)a=r;else{let o=0;for(;o<t.props.length&&n.has(o);)o+=1;if(o>=t.props.length)return null;a=o}n.add(a)}return t.props[a]??null}function gn(t,e){let r=-1;for(let d=t.length-1;d>=0;d-=1)if(t[d].objectKeys!==null){r=d;break}if(r<0)return-1;const n=t[r].objectKeys,a=Qi(e),i=n.reduce((d,p)=>d+(a.has(p)||pn.has(p)?1:0),0),o=n.length>0&&i===n.length,s=i>0,l=mn(e);if(t.length===1)return e.props.length===1?Et(e.props[0])?-1:o?0:-1:o?0:!s&&l&&Et(l)?-1:0;if(r!==t.length-1)return s?r:-1;if(s||n.length===0)return r;const c=fn(e,t.length-1);return c&&Et(c)?-1:r}function hn(t){return t.map(e=>({objectKeys:e.kind==="Object"&&e.properties?e.properties.filter(r=>!r.spread).map(r=>r.key):null}))}function lr(t,e){const r={};return t.props.forEach((n,a)=>{a<e.length&&(r[n.name]=e[a])}),r}function Yu(t,e){const r=Se(t),n=bn(r,e);return n.length>0&&(r.errors=[...r.errors,...n]),r}function bn(t,e){const r=[];vn=Xu(t);try{for(const n of t.statements)fe(n,e,r)}finally{vn=Zi}return r}const Zi=new Set;let vn=Zi;function Xu(t){const e=new Set,r=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){for(const i of n)r(i);return}const a=n;a.kind==="ComponentDeclaration"&&typeof a.name=="string"&&e.add(a.name);for(const i of Object.keys(a))i!=="loc"&&r(a[i])};return r(t.statements),e}function fe(t,e,r){switch(t.kind){case"Assignment":Q(t.expression,e,r);return;case"ExpressionStatement":Q(t.expression,e,r);return;case"ComponentDeclaration":Ju(t,e,r);for(const n of t.body.body)fe(n,e,r);return;case"ActionDeclaration":case"EffectDeclaration":case"HookDeclaration":for(const n of t.body.body)fe(n,e,r);return;case"Return":t.argument&&Q(t.argument,e,r);return;case"Await":Q(t.argument,e,r);return;case"IfStatement":Q(t.test,e,r);for(const n of t.consequent.body)fe(n,e,r);if(t.alternate)if(t.alternate.kind==="IfStatement")fe(t.alternate,e,r);else for(const n of t.alternate.body)fe(n,e,r);return;case"SwitchStatement":Q(t.discriminant,e,r);for(const n of t.cases){n.test&&Q(n.test,e,r);for(const a of n.body)fe(a,e,r)}return;case"ForOfStatement":Q(t.iterable,e,r);for(const n of t.body.body)fe(n,e,r);return;case"ForClassicStatement":t.init&&fe(t.init,e,r),t.test&&Q(t.test,e,r),t.update&&Q(t.update,e,r);for(const n of t.body.body)fe(n,e,r);return;case"WhileStatement":case"DoWhileStatement":Q(t.test,e,r);for(const n of t.body.body)fe(n,e,r);return;case"ForInStatement":Q(t.iterable,e,r);for(const n of t.body.body)fe(n,e,r);return;case"DestructureStatement":Q(t.expression,e,r);for(const n of t.bindings)n.defaultValue&&Q(n.defaultValue,e,r);return;case"TryStatement":for(const n of t.block.body)fe(n,e,r);if(t.catchBlock)for(const n of t.catchBlock.body)fe(n,e,r);if(t.finallyBlock)for(const n of t.finallyBlock.body)fe(n,e,r);return;case"ThrowStatement":Q(t.argument,e,r);return;default:return}}function Q(t,e,r){if(t)switch(t.kind){case"Call":{Qu(t,e,r);for(const n of t.arguments)Q(n,e,r);return}case"MethodCall":{Q(t.object,e,r);for(const n of t.arguments)Q(n,e,r);return}case"BuiltinCall":{for(const n of t.arguments)Q(n,e,r);return}case"Array":for(const n of t.elements)Q(n,e,r);return;case"Object":for(const n of t.properties)Q(n.value,e,r);return;case"Template":for(const n of t.expressions)Q(n,e,r);return;case"Binary":Q(t.left,e,r),Q(t.right,e,r);return;case"Unary":Q(t.argument,e,r);return;case"Ternary":Q(t.test,e,r),Q(t.consequent,e,r),Q(t.alternate,e,r);return;case"Member":Q(t.object,e,r),t.computed&&Q(t.computed,e,r);return;case"Spread":Q(t.argument,e,r);return;case"Invoke":t.callee.kind==="StateRef"&&t.callee.name==="theme"&&td(t,r),Q(t.callee,e,r);for(const n of t.arguments)Q(n,e,r);return;case"New":Q(t.callee,e,r);for(const n of t.arguments)Q(n,e,r);return;case"Lambda":if(t.body.kind==="Block")for(const n of t.body.body)fe(n,e,r);else Q(t.body,e,r);return;case"Block":for(const n of t.body)fe(n,e,r);return;default:return}}function Ju(t,e,r){Le(e,t.name)&&(yn(t.body,t.name)||r.push({message:`function ${t.name}(...) — "${t.name}" is a built-in component name. Rename the custom component (e.g. "App${t.name}"), or call ${t.name}(...) inside the body to wrap the built-in (inside its own body the name refers to the built-in component).`,line:t.loc?.line??0,column:t.loc?.column??0}))}function yn(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t))return t.some(n=>yn(n,e));const r=t;if(r.kind==="Call"&&r.callee===e)return!0;for(const n of Object.keys(r))if(n!=="loc"&&yn(r[n],e))return!0;return!1}function Qu(t,e,r){if(vn.has(t.callee))return;const n=Le(e,t.callee);if(!n)return;const a=new Set;for(const d of n.props)if(a.add(d.name),d.aliases)for(const p of d.aliases)a.add(p);a.add("key");const i=t.arguments,o=gn(hn(i),n),s=o>=0?i[o]:null,l=[];for(let d=0;d<i.length;d++)d!==o&&l.push(i[d]);l.length>n.props.length&&r.push({message:`${t.callee}(...) — takes at most ${n.props.length} positional argument${n.props.length===1?"":"s"} (${n.props.map(d=>d.name).join(", ")}); got ${l.length}.`,line:t.loc?.line??0,column:t.loc?.column??0}),l.forEach((d,p)=>{const f=fn(n,p);if(f){if(f.enum&&d.kind==="Literal"&&typeof d.value=="string"){const b=d.value;!f.enum.includes(b)&&!f.enum.includes(sn(b))&&r.push({message:`<${t.callee}> ${f.name}="${b}" — 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})}d.kind==="Object"&&!Et(f)&&r.push({message:`<${t.callee}> — object passed positionally for "${f.name}" (${f.type}). Use named props from: ${n.props.map(b=>b.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}});const c=[];if(s)for(const d of s.properties)d.spread||c.push({name:d.key,value:d.value,loc:d.value.loc??s.loc});for(const d of c){if(!a.has(d.name)){if(pn.has(d.name))continue;r.push({message:`Unknown prop "${d.name}" on <${t.callee}>. Known props: ${n.props.map(f=>f.name).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0});continue}const p=n.props.find(f=>f.name===d.name||(f.aliases?.includes(d.name)??!1));if(p?.enum&&d.value.kind==="Literal"&&typeof d.value.value=="string"){const f=d.value.value;!p.enum.includes(f)&&!p.enum.includes(sn(f))&&r.push({message:`<${t.callee}> ${d.name}="${f}" — must be one of ${p.enum.map(b=>`"${b}"`).join(", ")}.`,line:d.loc?.line??t.loc?.line??0,column:d.loc?.column??t.loc?.column??0})}}}const Zu=new Set(["colors","radius","font","fonts","spacing","shadows","gradients","icons","zIndex","motion"]),ed=new Set(["name","direction"]);function td(t,e){const r=t.arguments[0];if(!(!r||r.kind!=="Object"))for(const n of r.properties){if(n.spread||Zu.has(n.key)||ed.has(n.key))continue;const a=rd(n.key),i=n.key.startsWith("--")?`$theme({"${n.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).`:`$theme({${n.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${a}.`;e.push({message:i,line:t.loc?.line??0,column:t.loc?.column??0})}}function rd(t){const e=[{prefix:"color",group:"colors"},{prefix:"radius",group:"radius"},{prefix:"font",group:"font"}];for(const{prefix:r,group:n}of e)if(t!==r&&t.startsWith(r)&&t.length>r.length){const a=t.slice(r.length),i=a.charAt(0).toLowerCase()+a.slice(1);return`$theme({ ${n}: { ${i}: ... } })`}return"$theme({ colors: {...}, radius: {...}, font: {...} })"}const cr={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:"$"}},eo={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
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
72
|
return Card([CardHeader(title)])
|
|
73
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(() => {
|
|
@@ -93,23 +93,24 @@ import { $count } from "./store.aktion"`},export:{summary:"Mark a top-level decl
|
|
|
93
93
|
risky()
|
|
94
94
|
} catch (e) {
|
|
95
95
|
log(e)
|
|
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 Bi(t=nr){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=p=>({...p}),n=new Set(t.atoms),a=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,l=new Set([...t.operators.join(""),..."=<>!&|"]),u=(p,f)=>{for(;!p.eol();){const b=p.next();if(!b)return;if(b==="\\"){p.next();continue}if(b===f)return}};return{startState:e,copyState:r,token:(p,f)=>{if(f.inBacktick){for(;!p.eol();){const h=p.next();if(h==="\\"){p.next();continue}if(h==="`")return f.inBacktick=!1,"string"}return"string"}if(f.inBlockComment){for(;!p.eol();){if(p.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";p.next()}return"comment"}if(p.eatWhile(/[ \t]/))return null;if(p.match(t.comments.line,!0))return p.skipToEnd(),"comment";if(p.match(t.comments.blockStart,!0)){for(f.inBlockComment=!0;!p.eol();){if(p.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";p.next()}return"comment"}const b=p.peek();if(b==null)return null;if(t.strings.singleLineQuotes.includes(b)){const h=b;return p.next(),u(p,h),"string"}if(b===t.strings.multiLineQuote){for(p.next();!p.eol();){const h=p.next();if(h==="\\"){p.next();continue}if(h==="`")return"string"}return f.inBacktick=!0,"string"}if(b>="0"&&b<="9"&&p.match(s,!0)||b==="-"&&p.match(/^-\d+(?:\.\d+)?/,!1)&&p.match(s,!0))return"number";if(b===t.sigils.state)return p.next(),p.peek()===t.sigils.state&&p.next(),p.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(b)){if(p.match(i,!0))return"component";const g=p.match(o,!0);if(g){const y=g[0];return n.has(y)?"atom":a.has(y)?"keyword":p.peek()==="."?"loopvar":"identifier"}}for(const h of t.operatorsLong)if(p.match(h,!0))return"operator";return b==="."?(p.next(),p.peek()&&t.identifier.start.test(p.peek())?(p.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(b)?(p.next(),"punctuation"):l.has(b)?(p.next(),"operator"):(p.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const Oi={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},ar=[{name:"state",sigil:"$state",category:"hook",signature:"$state(initial)",summary:"Hook: per-instance state → [value, setValue] (like React's useState)."},{name:"memo",sigil:"$memo",category:"hook",signature:"$memo(() => value, [deps])",summary:"Hook: value recomputed only when a dependency changes (like useMemo)."},{name:"ref",sigil:"$ref",category:"hook",signature:"$ref(initial)",summary:"Hook: stable { current } box; writing .current does not re-render (like useRef)."},{name:"reducer",sigil:"$reducer",category:"hook",signature:"$reducer((state, action) => next, initial)",summary:"Hook: [state, dispatch] (like useReducer)."},{name:"id",sigil:"$id",category:"hook",signature:"$id(prefix?)",summary:"Hook: stable unique id per component instance (like useId)."},{name:"effect",sigil:"$effect",category:"effect",signature:"$effect(() => { … }, [deps])",summary:'Declarative side effect; deps mix $state, "mount"/"unmount", "every(N)", "debounce(N)".'},{name:"optimistic",sigil:"$optimistic",category:"effect",signature:"$optimistic(() => { … })",summary:"Run optimistic writes; auto-rolls back state if the callback throws or rejects."},{name:"store",sigil:"$store",category:"effect",signature:"$store({ ...state, ...methods })",summary:'Global store: shared state + actions (like Zustand/Pinia). persist: "key" mirrors data to localStorage (persistIn: "session" for sessionStorage); history: true|depth adds undo()/redo()/clearHistory() + reactive canUndo/canRedo.'},{name:"form",sigil:"$form",category:"effect",signature:"$form({ values, rules, onSubmit })",summary:"Reactive form engine: values/errors/touched/dirty/valid/submitting/validating + field()/validate()/touch()/setField()/submit() (alias handleSubmit())/reset(). Async rules ($util.rules.asyncCustom) are awaited before submit; submitting stays true until an async onSubmit settles."},{name:"http",sigil:"$http",category:"data",signature:"$http({ url, method, … })",summary:"Reactive HTTP resource bag — { data, loading, error, refetch }."},{name:"query",sigil:"$query",category:"data",signature:"$query({ url, key, ttl })",summary:"Cached + deduplicated HTTP read. Polling via refetchInterval/refetchOnFocus/refetchOnReconnect; pagination via infinite: { param, limit, mode } (→ .loadMore()/.hasMore/.loadingMore); GraphQL via gql + variables."},{name:"mutation",sigil:"$mutation",category:"data",signature:"$mutation({ url, method })",summary:"Deferred write; fires on .mutate(overrides?). optimistic: (vars) => {…} applies instantly (auto-rollback on failure); invalidates: [keys] refetches matching cached queries; gql for GraphQL."},{name:"socket",sigil:"$socket",category:"data",signature:"$socket({ url, reconnect? })",summary:'Reactive WebSocket — { status: "connecting"|"open"|"closed", connected, last, messages, attempts, send, close }. reconnect: true|n retries with exponential backoff; sends queue while connecting and flush on open; close() stops for good.'},{name:"sse",sigil:"$sse",category:"data",signature:"$sse({ url, event })",summary:'Reactive Server-Sent Events stream — { status, connected, last, messages, close }. EventSource reconnects natively (status reads "connecting" while it does).'},{name:"app",sigil:"$app",category:"app",signature:"$app(root)",summary:"Register the root of the rendered UI tree — every program needs one."},{name:"router",sigil:"$router",category:"routing",signature:"$router({ '/': Home(), default: NotFound() })",summary:"Outlet-first router: maps path patterns to component trees."},{name:"theme",sigil:"$theme",category:"theme",signature:"$theme({ colors, radius, font, … })",summary:"In-script theme override merged on top of the active base theme. Structured groups: colors/radius/font/spacing/shadows/gradients/zIndex/motion/fonts (web-font import)/icons (custom inline SVG), plus name/direction metadata."},{name:"emit",sigil:"$emit",category:"event",signature:"$emit('name', detail)",summary:"Dispatch a CustomEvent from the host element."},{name:"util",sigil:"$util",category:"namespace",signature:"$util",summary:"Runtime helper + reactive-environment namespace: data helpers ($util.format/.sum/.range/.groupBy…), formatting ($util.slugify/.truncate/.initials/.currency/.percent/.bytes/.relativeTime), misc ($util.copy — async, resolves true on real success —/.sleep/.uuid/.debounceFn/.throttleFn — leading+trailing), styling ($util.style.cx/.gradient/.alpha/.clamp/.token/.toStyle), validators ($util.rules.required/.email/.url/.min/.max/.minLength/.maxLength/.pattern/.oneOf/.matches/.custom/.asyncCustom + .validate/.validateAll), computed ($util.derived(fn)), hooks ($util.onError/.onNavigate/.onRequest/.onResponse/.invalidate), reactive env ($util.scroll/.viewport/.breakpoint/.media/.mouse/.url incl. .url.setQuery/.removeQuery), device ($util.vibrate/.share/.readClipboard/.geolocate/.isOnline/.deviceType/.nativeShell/.isNativeApp), and platform ($util.worker/.registerServiceWorker/.webManifest).",namespace:!0},{name:"storage",sigil:"$storage",category:"namespace",signature:"$storage",summary:"Persistent storage namespace ($storage.local, $storage.session, …).",namespace:!0},{name:"console",sigil:"$console",category:"namespace",signature:"$console",summary:"Console namespace ($console.log, $console.warn, …).",namespace:!0},{name:"toast",sigil:"$toast",category:"namespace",signature:"$toast",summary:"Imperative toasts: $toast.show/.success/.error/.dismiss; reactive .items.",namespace:!0},{name:"i18n",sigil:"$i18n",category:"data",signature:"$i18n({ translations, … })",summary:"Translation bundle → { t, setCurrentLanguage, getCurrentLanguage }."}],Fi=new Set(ar.map(t=>t.name)),_i=Object.freeze(Object.fromEntries(ar.map(t=>[t.name,t])));function zu(t){return _i[t]}function Ru(t){return Fi.has(t)}const Mt=12,Lu={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Du={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function ju(t){return Lu[t]??"stretch"}function Bu(t){return Du[t]??"flex-start"}function Ui(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function rt(t,e,r){for(const n of gt){const a=e.values[n];a&&t.push(`${r}-${n}:${mi(a)||`var(--rui-spacing-${a}, ${a})`}`)}}function Ou(t,e,r,n){for(const a of gt){const i=e.values[a];i&&t.push(`${r}-${a}:${n(String(i))}`)}}function Hi(t,e,r,n){const a=$e(t);if(a.kind==="single"){const i=a.value?String(a.value):n.defaultToken;r[n.attrName]=i;return}r[n.attrName]="responsive",r[n.responsiveFlag]="true",Ou(e,a,n.cssVarPrefix,n.mapper)}function Fu(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function _u(t){const e=$e(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const Uu={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 n={class:"rui-stack-item"},a=[];e.grow!==void 0&&e.grow!==null&&(n["data-grow"]=String(I(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(n["data-shrink"]=String(I(e.shrink,1)));const i=m(e.basis);i==="auto"||i==="0"?n["data-basis"]=i:i&&a.push(`flex-basis:${X(i,i)}`);const o=m(e.alignSelf);if(o&&(n["data-align-self"]=o),e.order!==void 0&&e.order!==null){const d=I(e.order,0);n["data-order"]=String(d),a.push(`order:${d}`)}const s=m(e.minWidth);s&&a.push(`min-width:${X(s,s)}`);const l=m(e.maxWidth);l&&a.push(`max-width:${X(l,l)}`),a.length>0&&(n.style=a.join(";"));const u=c("div",n);return u.append(r.renderNode(e.child)),u}};function un(t,e,r,n,a){const i=$e(t),o=$e(n.gap),s=$e(n.padding),l=N(n.reverse),u={class:"rui-stack","data-wrap":N(n.wrap)?"true":null,"data-reverse":l?"true":null,"data-uniform":e?"true":"false","data-inline":N(n.inline)?"true":null},d=[];if(i.kind==="single"){const b=i.value?String(i.value):"column";u["data-direction"]=Ui(b,l)}else{u["data-direction"]="responsive",u["data-responsive-dir"]="true";for(const b of gt){const h=i.values[b];h&&d.push(`--rui-stack-dir-${b}:${Ui(String(h),l)}`)}}o.kind==="single"?u["data-gap"]=o.value?ge(o.value,String(o.value)):"md":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",rt(d,o,"--rui-stack-gap")),Hi(n.align,d,u,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:ju}),Hi(n.justify,d,u,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:Bu});const p=m(n.alignContent);if(p&&(u["data-align-content"]=p),s.kind==="single"){const b=s.value?ge(s.value,String(s.value)):null;b&&(u["data-padding"]=b)}else u["data-padding"]="responsive",u["data-responsive-padding"]="true",rt(d,s,"--rui-stack-padding");d.length>0&&(u.style=d.join(";"));const f=c("div",u);for(const b of T(n.children))f.append(a.renderNode(b));return f}const Hu={name:"gap",type:"string | object",optional:!0,enum:ue,description:"Spacing between children. May be a responsive map."},dn={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},pn={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},mn={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},fn={name:"padding",type:"string | object",optional:!0,enum:ue,description:"Inner padding token. May be a responsive map."},gn={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},qi={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},qu={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:ue,description:"Horizontal spacing between children (default `md`). 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."},{...dn},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...pn},{...mn},{...fn},{...gn},{...qi}],render:(t,e,r)=>un("row",N(e.grow),"center",e,r)},Vu={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:ue,description:"Vertical spacing between children (default `md`). 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."},{...dn},{...pn},{...mn},{...fn},{...gn}],render:(t,e,r)=>un("column",!1,"stretch",e,r)},Wu={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"}`.'},{...Hu},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...dn},{...qi},{...pn},{...mn},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...gn},{...fn}],render:(t,e,r)=>{const a=_u(e)==="row",i=e.uniform===void 0?a:N(e.uniform,a);return un(e.direction,i,"stretch",e,r)}},Gu={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:ue,description:"Spacing between stacked children (default `md`)"},{name:"padding",type:"string",optional:!0,enum:ue,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 n={class:"rui-center","data-axis":m(e.axis,"both"),"data-gap":ge(e.gap,"md"),"data-inline":N(e.inline)?"true":null},a=ge(e.padding,m(e.padding));a&&(n["data-padding"]=a);const i=[],o=m(e.minHeight);o&&i.push(`min-height:${X(o,o)}`),i.length>0&&(n.style=i.join(";"));const s=c("div",n);for(const l of T(e.children))s.append(r.renderNode(l));return s}},Ku={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 n=c("div",{class:"rui-card","data-variant":m(e.variant,"default")});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Yu={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=c("header",{class:"rui-card-header"});r.append(c("h3",{class:"rui-card-title"},[m(e.title)]));const n=m(e.subtitle);return n&&r.append(c("p",{class:"rui-card-subtitle"},[n])),r}},Xu={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const n=c("footer",{class:"rui-card-footer"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Zu={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"),n=N(e.decorative,!0),a=m(e.label);return a&&r==="horizontal"?c("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:n?"presentation":"separator","aria-orientation":n?null:r},[c("span",{class:"rui-separator-line"}),c("span",{class:"rui-separator-label"},[a]),c("span",{class:"rui-separator-line"})]):c("div",{class:"rui-separator","data-orientation":r,role:n?"presentation":"separator","aria-orientation":n?null:r})}},Vi=(t,e,r=!1)=>{const n=c("li",{class:"rui-steps-item","data-active":r?"true":"false"});return n.append(c("div",{class:"rui-steps-title"},[t])),e&&n.append(c("div",{class:"rui-steps-details"},[e])),n},Qu={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 n=c("ol",{class:"rui-steps"});for(const a of T(e.items)){if(a&&typeof a=="object"&&a.__kind==="Component"){n.append(r.renderNode(a));continue}if(a&&typeof a=="object"){const i=a;n.append(Vi(m(i.title),m(i.details),N(i.active)));continue}n.append(Vi(m(a),""))}return n}},Ju={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 n=c("div",{class:"rui-tab-content",role:"tabpanel","data-value":m(e.value),"data-active":"false"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},ed={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 n=T(e.items),a=m(e.orientation,"horizontal"),i=c("div",{class:"rui-tabs","data-orientation":a}),o=c("div",{class:"rui-tab-list",role:"tablist","aria-orientation":a}),s=c("div",{class:"rui-tab-panels"});let l=m(e.defaultValue);if(!l&&n.length>0){const f=n[0];l=m(f?.args?.[0],"tab-0")}const u=r.useInstanceState("activeTab",l);m(e.defaultValue)&&m(e.defaultValue)!==l&&u.set(m(e.defaultValue)),new Set(n.map((f,b)=>m(f.args?.[0],`tab-${b}`))).has(u.get())||u.set(l);const p=(f,b)=>{const h=u.get();u.set(f);const g=b.closest(".rui-tabs");g&&(g.querySelectorAll(".rui-tab-trigger").forEach(y=>{const v=y.getAttribute("data-value")===f;y.setAttribute("aria-selected",v?"true":"false"),y.tabIndex=v?0:-1}),g.querySelectorAll(".rui-tab-content").forEach(y=>{y.setAttribute("data-active",y.getAttribute("data-value")===f?"true":"false")})),h!==f&&r.invoke(e.onChange,f)};return n.forEach((f,b)=>{const h=f,g=m(h.args?.[0],`tab-${b}`),y=m(h.args?.[1],`Tab ${b+1}`),v=m(h.args?.[3]),x=m(h.args?.[4]),w=g===u.get(),k=c("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":g,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),A=x?td(x):null;A&&k.append(A),k.append(c("span",{class:"rui-tab-trigger-label"},[y])),v&&k.append(c("span",{class:"rui-tab-trigger-badge"},[v])),k.onclick=$=>{const C=$.currentTarget??$.target;p(g,C)},k.onkeydown=$=>{const C=$,M=a!=="vertical",E=M?C.key==="ArrowRight":C.key==="ArrowDown",R=M?C.key==="ArrowLeft":C.key==="ArrowUp";if(!E&&!R&&C.key!=="Home"&&C.key!=="End")return;C.preventDefault();const _=C.currentTarget??C.target,B=_.closest(".rui-tab-list");if(!B)return;const U=Array.from(B.querySelectorAll(".rui-tab-trigger"));if(U.length===0)return;const O=U.indexOf(_);let Q=O;C.key==="Home"?Q=0:C.key==="End"?Q=U.length-1:E?Q=(O+1)%U.length:R&&(Q=(O-1+U.length)%U.length);const ye=U[Q];if(!ye)return;ye.focus();const Re=ye.getAttribute("data-value")??"";Re&&p(Re,ye)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",g),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function td(t){return L(t,{className:"rui-tab-trigger-icon"})}const rd={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 n=e.showArrow!==void 0&&e.showArrow!==null,a=c("details",{class:"rui-accordion-item","data-show-arrow":n?N(e.showArrow)?"true":"false":null});N(e.open)&&a.setAttribute("open","");const i=c("summary",{class:"rui-accordion-trigger"});i.append(c("span",{class:"rui-accordion-title"},[m(e.title)])),i.append(c("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),a.append(i);const o=c("div",{class:"rui-accordion-body"});for(const s of T(e.children))o.append(r.renderNode(s));return a.append(o),a}},nd={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 n=c("div",{class:"rui-accordion","data-show-arrow":N(e.showArrow)?"true":"false"});for(const a of T(e.items))n.append(r.renderNode(a));return n}},ir=t=>Math.max(1,Math.min(Mt,Math.round(t)));function hn(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,n]=e.split("/"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return ir(Math.round(Mt*a/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:ir(I(t,12))}function ad(t){const e=m(t.minChildWidth)||m(t.minItemWidth);return X(e||"220px","220px")}const id={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 n=hn(e.span??12),a=$e(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(Mt-1,Math.round(I(e.offset,0)))),o={class:"rui-grid-item","data-span":String(n)},s=[`--rui-grid-item-span:${n}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),a.kind==="responsive"){o["data-responsive-span"]="true";for(const u of gt){const d=a.values[u];if(d!==void 0){const p=hn(d);s.push(`--rui-grid-item-span-${u}:${p}`)}}}else if(a.kind==="single"&&a.value!=null){const u=hn(a.value);s.push(`--rui-grid-item-span:${u}`),o["data-span"]=String(u)}o.style=s.join(";");const l=c("div",o);return l.append(r.renderNode(e.child)),l}},od={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:ue,description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:ue,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 n=$e(e.padding),a=$e(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:${X(s,s)}`),n.kind==="single"){const u=n.value?ge(n.value,String(n.value)):null;u&&(i["data-padding"]=u)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",rt(o,n,"--rui-box-padding");if(a.kind==="single"){const u=a.value?ge(a.value,String(a.value)):null;u&&(i["data-margin"]=u)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",rt(o,a,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const l=c("div",i);for(const u of T(e.children))l.append(r.renderNode(u));return l}},sd={name:"Fragment",description:"Groups several siblings into one value WITHOUT adding a layout box — the wrapper is `display: contents`, so the children participate in the parent's flex/grid layout directly. Use to return multiple nodes from a component, or to conditionally group siblings, without a stray `div` that would break a Grid/Stack's spacing.",props:[{name:"children",type:"Node[]",description:"Sibling nodes to group"}],render:(t,e,r)=>{const n=c("div",{class:"rui-fragment",style:"display:contents;"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Wi={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:ue,description:"Gap on both axes (default `md`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:ue,description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:ue,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 n=T(e.children),a=n.some(y=>Fu(y,"GridItem")),i=$e(e.columns),o=$e(e.gap),s=$e(e.rowGap),l=$e(e.columnGap),u={class:"rui-grid"},d=[];let p=!1,f=!1;if(i.kind==="single"){const y=i.value===null?0:I(i.value,0),v=y>0?ir(y):0;if(v===Mt?p=!0:v>0&&(f=!0),v>0){u["data-columns"]=String(v);const x=m(e.minChildWidth)||m(e.minItemWidth);x&&(u["data-min-child-width"]="true",d.push(`--rui-grid-min-child:${X(x,"220px")}`))}else d.push(`--rui-grid-min-item:${ad(e)}`)}else{u["data-responsive-cols"]="true";for(const y of gt){const v=i.values[y];if(v===void 0)continue;const x=ir(I(v,0));x===Mt?p=!0:x>0&&(f=!0),d.push(`--rui-grid-cols-${y}:${x}`)}}a&&!f&&(p=!0),p&&(u["data-grid-mode"]="12"),o.kind==="single"?u["data-gap"]=o.value?ge(o.value,String(o.value)):"md":(u["data-gap"]="responsive",u["data-responsive-gap"]="true",rt(d,o,"--rui-grid-gap")),s.kind==="single"&&s.value?u["data-row-gap"]=ge(s.value,String(s.value)):s.kind==="responsive"&&(u["data-row-gap"]="responsive",u["data-responsive-row-gap"]="true",rt(d,s,"--rui-grid-row-gap")),l.kind==="single"&&l.value?u["data-column-gap"]=ge(l.value,String(l.value)):l.kind==="responsive"&&(u["data-column-gap"]="responsive",u["data-responsive-column-gap"]="true",rt(d,l,"--rui-grid-column-gap"));const b=m(e.alignItems);b&&(u["data-align-items"]=b);const h=m(e.justifyItems);h&&(u["data-justify-items"]=h),N(e.dense)&&(u["data-dense"]="true"),d.length>0&&(u.style=d.join(";"));const g=c("div",u);for(const y of n)g.append(r.renderNode(y));return g}},ld={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 n=cd(m(e.ratio,"16:9")),a=c("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${n};`});for(const i of T(e.children))a.append(r.renderNode(i));return a}};function cd(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i!==0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const ud={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 n=c("div",{class:"rui-scroll-area","data-direction":m(e.direction,"vertical"),style:`max-height:${X(e.maxHeight,"320px")};`});for(const a of T(e.children))n.append(r.renderNode(a));return n}},dd=["sm","md","lg","xl","full"],Gi='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let pd=0;function Ki(t){return t.getRootNode().activeElement??null}const md={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). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",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:dd,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 n=m(e.size,"md"),a=e.closable===void 0?!0:N(e.closable),i=c("div",{class:"rui-modal-overlay","data-open":N(e.open)?"true":"false"}),o=r.useInstanceState("rui-modal-title-id","");o.get()||o.set(`rui-modal-title-${pd+=1}`);const s=o.get(),l=c("div",{class:"rui-modal",role:"dialog","aria-modal":"true","aria-labelledby":s,tabindex:"-1","data-size":n}),u=c("header",{class:"rui-modal-header"});u.append(c("h3",{class:"rui-modal-title",id:s},[m(e.title)]));const d=t.argMeta?.[1]?.stateRef,p=()=>{d&&r.setState(d,!1),r.invoke(e.onClose)};if(a){const v=c("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);v.onclick=x=>{x.stopPropagation(),p()},u.append(v)}l.append(u);const f=c("div",{class:"rui-modal-body"});for(const v of T(e.children))f.append(r.renderNode(v));l.append(f);const b=T(e.footer);if(b.length>0){const v=c("footer",{class:"rui-modal-footer"});for(const x of b)v.append(r.renderNode(x));l.append(v)}i.append(l),N(e.closeOnBackdrop)&&(i.onclick=v=>{v.target===i&&p()});const h=N(e.open);l.addEventListener("keydown",v=>{if(v.key==="Escape"&&a){v.stopPropagation(),p();return}if(v.key!=="Tab")return;const x=[...l.querySelectorAll(Gi)];if(x.length===0){v.preventDefault(),l.focus();return}const w=x[0],k=x[x.length-1],A=Ki(l);v.shiftKey&&A===w?(v.preventDefault(),k.focus()):!v.shiftKey&&A===k&&(v.preventDefault(),w.focus())});const g=r.useInstanceState("rui-modal-focus",{open:!1,prev:null}),y=g.get();if(h&&!y.open){const v=Ki(l);g.set({open:!0,prev:v});const x=()=>{([...l.querySelectorAll(Gi)][0]??l).focus()};typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}else if(!h&&y.open){const v=y.prev;if(g.set({open:!1,prev:null}),v&&typeof v.focus=="function"){const x=()=>v.focus();typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}}return i}},Yi={js:new Set(["const","let","var","function","return","if","else","for","while","do","switch","case","break","continue","new","class","extends","super","this","import","export","from","default","try","catch","finally","throw","typeof","instanceof","in","of","await","async","yield","delete","void","null","undefined","true","false","interface","type","enum","public","private","protected","readonly","static","as","implements","namespace"]),py:new Set(["def","return","if","elif","else","for","while","import","from","as","class","try","except","finally","raise","with","lambda","yield","pass","break","continue","and","or","not","in","is","None","True","False","global","nonlocal","async","await","self"]),css:new Set([]),json:new Set(["true","false","null"])};function Xi(t){const e=t.toLowerCase();return["js","jsx","ts","tsx","javascript","typescript","mjs","cjs","aktion"].includes(e)?"js":["py","python"].includes(e)?"py":["css","scss","less"].includes(e)?"css":["json","jsonc"].includes(e)?"json":["html","xml","svg","vue"].includes(e)?"html":"generic"}const Zi=/[A-Za-z_$][\w$]*/y,Qi=/0[xX][0-9a-fA-F]+|\d*\.?\d+(?:[eE][+-]?\d+)?/y,Ji=/\s+/y;function fd(t,e,r){const n=Xi(e);if(n==="html")return gd(t);const a=[],i=Yi[n==="generic"?"js":n]??Yi.js;let o=0;const s=t.length,l=(u,d)=>{u&&a.push({text:u,cls:d})};for(;o<s;){if(r.inBlockComment){const h=t.indexOf("*/",o);if(h===-1){l(t.slice(o),"comment"),o=s;break}l(t.slice(o,h+2),"comment"),o=h+2,r.inBlockComment=!1;continue}const u=t[o],d=t.slice(o,o+2);if(n==="py"&&u==="#"||(n==="js"||n==="css"||n==="generic")&&d==="//"){l(t.slice(o),"comment");break}if((n==="js"||n==="css"||n==="generic")&&d==="/*"){const h=t.indexOf("*/",o+2);if(h===-1){l(t.slice(o),"comment"),r.inBlockComment=!0,o=s;break}l(t.slice(o,h+2),"comment"),o=h+2;continue}if(u==='"'||u==="'"||u==="`"){let h=o+1;for(;h<s;){if(t[h]==="\\"){h+=2;continue}if(t[h]===u){h+=1;break}h+=1}l(t.slice(o,h),"string"),o=h;continue}Ji.lastIndex=o;const p=Ji.exec(t);if(p&&p.index===o){l(p[0],null),o+=p[0].length;continue}Qi.lastIndex=o;const f=Qi.exec(t);if(f&&f.index===o&&f[0]){l(f[0],"number"),o+=f[0].length;continue}Zi.lastIndex=o;const b=Zi.exec(t);if(b&&b.index===o){const h=b[0],g=t[o+h.length];i.has(h)?l(h,"keyword"):g==="("?l(h,"fn"):l(h,null),o+=h.length;continue}l(u,"punct"),o+=1}return a}function gd(t){const e=[],r=/(<\/?[\w-]+)|(\/?>)|([\w-]+)(?==)|("[^"]*"|'[^']*')|(<!--.*?-->)/g;let n=0,a;for(;(a=r.exec(t))!==null;)a.index>n&&e.push({text:t.slice(n,a.index),cls:null}),a[1]?e.push({text:a[1],cls:"tag"}):a[2]?e.push({text:a[2],cls:"tag"}):a[3]?e.push({text:a[3],cls:"attr"}):a[4]?e.push({text:a[4],cls:"string"}):a[5]&&e.push({text:a[5],cls:"comment"}),n=r.lastIndex;return n<t.length&&e.push({text:t.slice(n),cls:null}),e}function hd(t){return Xi(t)!=="generic"||t.length>0}function eo(t,e,r,n){const a=fd(e,r,n);for(const i of a)i.cls?t.append(c("span",{class:`rui-hl-${i.cls}`},[i.text])):t.append(document.createTextNode(i.text))}const bd=["solid","regular","brands"],or=["xs","sm","md","lg","xl"],vd=["default","neutral","primary","success","warning","danger","info"];function bn(t,e="md"){const r=m(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":or.includes(r)?r:e:e}const yd={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:bd},{name:"size",type:"string",optional:!0,enum:Vc},{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),n=m(e.variant,""),a=m(e.size,"md"),i=m(e.color,""),o=n?`${n}:${r}`:r,s=L(o,{size:a,color:i});return s||c("span",{class:"rui-icon","data-icon-size":a},[r])}},xd=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function wd(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const to=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:xd},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"align",type:"string",optional:!0,enum:["left","center","right"],description:"Horizontal text alignment — the text becomes its own block-level line"},{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;").'}],ro=(t,e)=>{const r=m(e.variant,"body"),n=m(e.tone,"default"),a=m(e.align),i=wd(e.style);return c("span",{class:"rui-text","data-variant":r,"data-color":n,"data-align":a||null,style:i||null},[m(e.value)])},kd={name:"Text",description:'Renders plain text with a typographic variant. `align` (left|center|right) sets the horizontal alignment (the text renders as its own block). Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:to,render:ro},Sd={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:to,render:ro},$d={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` (and it reserves space to avoid layout shift). `fit` controls how the image fills that box. `placeholder: "blur"` fades the image in once loaded; `sizes`/`srcset` enable responsive loading; `loading: "eager"` opts out of lazy-loading. When `src` is missing/unsafe or fails to load it shows the `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/errored"},{name:"placeholder",type:"string",optional:!0,enum:["blur","none"],description:"`blur` fades the image in on load"},{name:"loading",type:"string",optional:!0,enum:["lazy","eager"],description:"Native loading strategy (default lazy)"},{name:"sizes",type:"string",optional:!0,description:"Responsive `sizes` attribute"},{name:"srcset",type:"string",optional:!0,aliases:["srcSet"],description:"Responsive `srcset` candidates"}],render:(t,e)=>{const r=c("figure",{class:"rui-image","data-fit":m(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Cd(m(e.ratio))};`:null}),n=re(e.src),a=()=>{const o=c("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),s=m(e.fallback);if(s){const l=L(s,{className:"rui-image-fallback-icon"});l?o.append(l):o.append(c("span",{class:"rui-image-fallback-text"},[s]))}return o};if(n){const o=m(e.placeholder)==="blur",s=c("img",{src:n,alt:m(e.alt),loading:m(e.loading,"lazy")==="eager"?"eager":"lazy",decoding:"async",sizes:m(e.sizes)||null,srcset:m(e.srcset)||null,"data-blur":o?"true":null});o&&(s.complete?s.setAttribute("data-loaded","true"):s.addEventListener("load",()=>s.setAttribute("data-loaded","true"),{once:!0})),s.addEventListener("error",()=>{s.replaceWith(a())},{once:!0}),r.append(s)}else r.append(a());const i=m(e.caption);return i&&r.append(c("figcaption",{class:"rui-image-caption"},[i])),r}};function Cd(t){if(!t)return"auto";if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const no=["neutral","primary","success","warning","danger","info"],Ad={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:no,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:or}],render:(t,e)=>{const r=m(e.tone,"neutral"),n=bn(e.size,"md"),a=c("span",{class:"rui-badge","data-variant":r,"data-size":n}),i=L(e.icon,{className:"rui-badge-icon"});i&&a.append(i);const o=m(e.label);return o&&a.append(c("span",{class:"rui-badge-label"},[o])),a}},Td={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:no,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:or}],render:(t,e)=>{const r=m(e.tone,"neutral"),n=bn(e.size,"md"),a=c("div",{class:"rui-badge-list"});for(const i of T(e.labels)){const o=m(i);if(!o)continue;const s=c("span",{class:"rui-badge","data-variant":r,"data-size":n});s.append(c("span",{class:"rui-badge-label"},[o])),a.append(s)}return a}},Md={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"),n=N(e.compact),a=c("div",{class:"rui-callout","data-variant":r,"data-compact":n?"true":"false"}),i=m(e.icon)||Id(r),o=L(i,{className:"rui-callout-icon"});o&&a.append(o);const s=c("div",{class:"rui-callout-body"});s.append(c("div",{class:"rui-callout-title"},[m(e.title)]));const l=m(e.description);return l&&s.append(c("div",{class:"rui-callout-description"},[l])),a.append(s),a}},sr={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. `header=false` renders a chromeless variant — no language label or copy button, no border or rounding — that fills its container (100%×100%), for embedding in your own frame (CodeWindow uses it). `width`/`height` set an explicit size; overflowing code scrolls either way.',props:[{name:"language",type:"string",optional:!0,description:"Display label + syntax highlighting (e.g. aktion, 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,description:'Highlight ranges, e.g. "3-5,8"'},{name:"highlight",type:"boolean",optional:!0,description:"Syntax-highlight tokens when a language is set (default true)"},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"},{name:"header",type:"boolean",optional:!0,description:"Show the header bar (default true); false = chromeless, fills its container"},{name:"width",type:"string",optional:!0,description:"Explicit width (CSS length)"},{name:"height",type:"string",optional:!0,description:"Explicit height (CSS length); overflowing code scrolls"}],render:(t,e)=>{const r=m(e.language),n=m(e.codeString),a=N(e.showLineNumbers),i=Nd(m(e.highlightLines)),o=e.copy===void 0?!0:N(e.copy),s=e.header===void 0?!0:N(e.header),l=X(e.width,""),u=X(e.height,""),d=[l?`width:${l}`:"",u?`height:${u}`:""].filter(Boolean).join(";"),p=c("div",{class:"rui-code-block","data-headerless":s?null:"true",style:d||null});if(s&&(r||o)){const h=c("div",{class:"rui-code-block-head"});if(r&&h.append(c("span",{class:"rui-code-block-language"},[r])),o){const g=c("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),y=L("copy",{className:"rui-code-block-copy-icon"});y&&g.append(y),g.append(c("span",{class:"rui-code-block-copy-label"},["Copy"])),g.onclick=v=>{const x=v.currentTarget??v.target,k=x.closest(".rui-code-block")?.querySelector("code")?.textContent??n,S=(typeof navigator<"u"?navigator:null)?.clipboard;S?.writeText&&S.writeText(k).catch(()=>{});const $=x.querySelector(".rui-code-block-copy-label");if($){const C=$.textContent??"Copy";$.textContent="Copied",setTimeout(()=>{$.textContent=C},1500)}},h.append(g)}p.append(h)}const f=c("pre",{class:"rui-code-block-pre","data-line-numbers":a?"true":"false"}),b=(e.highlight===void 0?!0:N(e.highlight))&&!!r&&hd(r);if(a||i.size>0){const h=n.split(/\r?\n/),g=c("code",{}),y={inBlockComment:!1};h.forEach((v,x)=>{const w=x+1,k=c("span",{class:"rui-code-block-line","data-line":String(w),"data-highlight":i.has(w)?"true":null});a&&k.append(c("span",{class:"rui-code-block-gutter"},[String(w)]));const A=c("span",{class:"rui-code-block-code"});b?eo(A,v,r,y):A.append(document.createTextNode(v)),k.append(A),g.append(k)}),f.append(g)}else if(b){const h=c("code",{}),g={inBlockComment:!1},y=n.split(/\r?\n/);y.forEach((v,x)=>{eo(h,v,r,g),x<y.length-1&&h.append(document.createTextNode(`
|
|
97
|
-
`))}),f.append(h)}else f.append(
|
|
98
|
-
`))}</code></pre>`),l=[],s="",o=!1};for(const b of r){const h=/^```\s*(.*)$/.exec(b.trim());if(o){if(h){p();continue}l.push(b);continue}if(h){u(),d(),o=!0,s=h[1]??"";continue}const g=/^\s*(#{1,3})\s+(.+)$/.exec(b);if(g){u(),d();const w=g[1].length;n.push(`<h${w} class="rui-markdown-h${w}">${f(e(g[2]))}</h${w}>`);continue}const y=/^\s*>\s?(.*)$/.exec(b);if(y){u(),i||(n.push('<blockquote class="rui-markdown-quote">'),i=!0),n.push(`<p>${f(e(y[1]??""))}</p>`);continue}else i&&b.trim()!==""&&d();const v=/^\s*[-*]\s+(.*)$/.exec(b);if(v){d(),a!=="ul"&&(u(),n.push("<ul>"),a="ul"),n.push(`<li>${f(e(v[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(b);if(x){d(),a!=="ol"&&(u(),n.push("<ol>"),a="ol"),n.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(b.trim()===""){u(),d();continue}u(),d(),n.push(`<p>${f(e(b))}</p>`)}return o&&p(),u(),d(),n.join("");function f(b){let h=b.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(g,y,v)=>{const x=re(v);return x?`<img class="rui-markdown-image" src="${lr(x)}" alt="${y}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${y}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(g,y,v)=>`<a class="rui-link" href="${ao(v)}" target="_blank" rel="noopener noreferrer">${y}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,g=>`<a class="rui-link" href="${ao(g)}" target="_blank" rel="noopener noreferrer">${g}</a>`),h}}function ao(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return lr(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return lr(e);const n=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(n)?lr(e):"#"}function lr(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Nt(t,e,r){const n=c("span",{class:"rui-avatar","data-size":r,role:"img"}),a=re(t);if(a){const i=c("img",{src:a,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(c("span",{class:"rui-avatar-fallback"},[yt(e)]))},n.append(i)}else n.append(c("span",{class:"rui-avatar-fallback"},[yt(e)]));return n}function yt(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(n=>n.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const cr=new WeakMap;function xt(t){const{liveRoot:e,onDismiss:r}=t,n=cr.get(e);n&&n.dispose();const a=e.getRootNode();let i=!1;const o=p=>{const f=p.target;f&&e.contains(f)||(d.dispose(),r())},s=p=>{p.key==="Escape"&&(d.dispose(),r())},l=e.ownerDocument;let u=null;if(l&&typeof MutationObserver<"u"){u=new MutationObserver(()=>{e.isConnected||d.dispose()});const p=e.getRootNode();(p instanceof Element||p instanceof Document||p instanceof ShadowRoot)&&u.observe(p,{childList:!0,subtree:!0})}const d={dispose:()=>{i||(i=!0,a.removeEventListener("click",o,!0),a.removeEventListener("keydown",s,!0),u?.disconnect(),cr.delete(e))}};return setTimeout(()=>{i||(a.addEventListener("click",o,!0),a.addEventListener("keydown",s,!0))},0),cr.set(e,d),d}function Ue(t){if(!t)return;const e=cr.get(t);e&&e.dispose()}const io="a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])";function vn(t,e){return r=>{const n=r.currentTarget??r.target;if(!n)return;if(r.key==="Escape"){r.stopPropagation(),e(n);return}if(r.key!=="Tab")return;const a=n.querySelector(t);if(!a)return;const i=Array.from(a.querySelectorAll(io));if(i.length===0){r.preventDefault();return}const s=n.getRootNode().activeElement,l=i[0],u=i[i.length-1];r.shiftKey&&(s===l||!a.contains(s))?(r.preventDefault(),u.focus()):!r.shiftKey&&s===u&&(r.preventDefault(),l.focus())}}function yn(t,e,r){typeof MutationObserver>"u"||setTimeout(()=>{if(!t.isConnected)return;let n=null;const a=s=>{const l=t.getRootNode();if(s){n=l.activeElement??null;const u=t.querySelector(e);u&&!u.contains(l.activeElement)&&(u.querySelector(io)??u).focus?.()}else n?.focus?.(),n=null};let i=t.getAttribute("data-open")==="true";i&&a(!0);const o=new MutationObserver(()=>{const s=t.getAttribute("data-open")==="true";s!==i&&(i=s,a(s))});o.observe(t,{attributes:!0,attributeFilter:["data-open"]}),r.registerDisposer(()=>o.disconnect(),"rui-dialog-focus")},0)}const Fd=[{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 oo(t){if(!t)return null;for(const e of Fd)if(e.match.test(t))return e.icon;return null}const _d={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function Ud(t){return t?_d[t.toLowerCase()]??null:null}function Hd(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 ur(t,e,r={}){const n=m(e.label),a=m(e.hint),i=m(e.error),o=N(e.required);if(!n&&!a&&!i&&!o)return t;const s=m(e[r.idKey??"id"])||m(t.getAttribute("id"));o&&t.setAttribute("required",""),i&&t.setAttribute("aria-invalid","true");const l=c("div",{class:"rui-field","data-invalid":i?"true":null});if(n){const u=c("label",{class:"rui-field-label",for:s||null},[n]);o&&u.append(c("span",{class:"rui-field-required","aria-hidden":"true"},["*"])),l.append(u)}if(l.append(t),i){const u=s?`${s}-error`:null,d=c("div",{class:"rui-field-error",id:u,role:"alert"},[i]);u&&t.setAttribute("aria-describedby",u),l.append(d)}else if(a){const u=s?`${s}-hint`:null,d=c("div",{class:"rui-field-hint",id:u},[a]);u&&t.setAttribute("aria-describedby",u),l.append(d)}return l}const xn=[{name:"label",type:"string",optional:!0,description:"Field label rendered above the control"},{name:"hint",type:"string",optional:!0,description:"Helper text rendered below the control"},{name:"error",type:"string",optional:!0,description:"Validation error rendered below the control (marks it invalid)"},{name:"required",type:"boolean",optional:!0,description:"Mark the field required (adds a `*` and the `required` attribute)"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Called with the current value when focus leaves the control (validate-on-blur, `form.touch`)"},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Called when the control gains focus"}];function dr(t,e,r,n=a=>a.value){e.onBlur!=null&&(t.onblur=a=>{const i=a.currentTarget??a.target;r.invoke(e.onBlur,n(i))}),e.onFocus!=null&&(t.onfocus=a=>{const i=a.currentTarget??a.target;r.invoke(e.onFocus,n(i))})}function so(t){return T(t).map(r=>{if(r&&typeof r=="object"){const a=r;if(a.__kind==="Component"&&Array.isArray(a.args)){const i=m(a.args[0]);return{value:i,label:m(a.args[1],i)}}if(a.value!==void 0||a.label!==void 0){const i=m(a.value);return{value:i,label:m(a.label,i)}}}const n=m(r);return{value:n,label:n}}).filter(r=>r.value!==""||r.label!=="")}function nt(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=c("span",{class:"rui-wrapper-fragment"});for(const n of e)n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function pr(t,e){return c("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function qd(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const Vd=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function Wd(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&&Vd.test(r))}const Gd={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 n=pr("rui-on-click",{role:"button",tabindex:"0"});n.append(nt(r,e.child));const a=N(e.disabled),i=N(e.stopPropagation),o=s=>{a||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return n.addEventListener("click",o),n.addEventListener("keydown",s=>{const l=s;(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o(l))}),n}},Kd=[{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"}],Yd={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 n=pr("rui-on-mouse");N(e.draggable)&&n.setAttribute("draggable","true"),n.append(nt(r,e.child));const a=e.passiveScroll===void 0?!0:N(e.passiveScroll);for(const{prop:i,event:o}of Kd){const s=e[i];if(s==null)continue;const u=o==="scroll"||o==="wheel"?{passive:a}:{};n.addEventListener(o,d=>{r.invoke(s,d)},u)}return n}},Xd=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],Zd={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 n=e.focusable===void 0?!0:N(e.focusable),a=pr("rui-on-keyboard",n?{tabindex:"0"}:{});a.append(nt(r,e.child));for(const{prop:i,event:o}of Xd){const s=e[i];s!=null&&a.addEventListener(o,l=>{r.invoke(s,l)})}return a}},Qd={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 n=pr("rui-on-focus");return n.append(nt(r,e.child)),e.onFocus!=null&&n.addEventListener("focusin",a=>r.invoke(e.onFocus,a)),e.onBlur!=null&&n.addEventListener("focusout",a=>r.invoke(e.onBlur,a)),n}},Jd={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 n=c("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});n.append(nt(r,e.child));const a=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!a)return n;const i=Math.max(0,Math.min(1,I(e.threshold,.05))),o=m(e.rootMargin),s=N(e.once);let l=null;const u=new a(d=>{for(const p of d){const f=p.isIntersecting;if(f!==l&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,p),!f&&l===!0&&e.onLeave!=null&&r.invoke(e.onLeave,p),l=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:p.intersectionRatio}),s&&f){u.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return u.observe(n),r.registerDisposer(()=>u.disconnect(),"rui-onintersect-io"),n}},ep={name:"OnMount",description:"Run imperative code against the wrapped component's rendered DOM node. `onMount(node)` fires once, on a microtask after the child is attached to the DOM — the Aktion way to get a DOM ref (measure an element, focus it, or hand it to an imperative library such as a chart / map / editor). `onUnmount(node)` fires when the component leaves the tree. Pair with `$ref(...)` to stash the node across renders.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onMount",type:"callable",optional:!0,description:"`(node) => void` — fired once after the wrapped element is attached."},{name:"onUnmount",type:"callable",optional:!0,description:"`(node) => void` — fired when the wrapped element leaves the tree."}],render:(t,e,r)=>{const n=c("span",{class:"rui-wrapper rui-on-mount",style:"display: contents;"});n.append(nt(r,e.child));const a=r.useInstanceState("rui-on-mount",!1);if(!a.get()){a.set(!0);const i=()=>{const o=n.firstElementChild??n;e.onMount!=null&&r.invoke(e.onMount,o),e.onUnmount!=null&&r.registerDisposer(()=>{const s=()=>r.invoke(e.onUnmount,o);typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s)},"rui-on-mount-unmount")};typeof queueMicrotask=="function"?queueMicrotask(i):Promise.resolve().then(i)}return n}};function tp(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 lo={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 n=m(e.to),a=N(e.external),i=n||m(e.href),o=n?i.startsWith("/")||i.startsWith("#")?i:Fe(i,"#"):Fe(e.href,"#"),s=m(e.variant,"default"),l=c("a",{class:"rui-link","data-variant":s,href:o,target:a?"_blank":null,rel:a?"noopener noreferrer":null});for(const u of tp(r,e.label))l.append(u);return n&&!a&&l.addEventListener("click",u=>{u.defaultPrevented||u.button===0&&(u.metaKey||u.ctrlKey||u.shiftKey||u.altKey||(u.preventDefault(),r.router.navigate(n)))}),l}},rp={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 n=nt(r,e.child),a=n instanceof HTMLElement?n:(()=>{const s=c("span",{class:"rui-css"});return s.append(n),s})(),i=Wd(e.class);for(const s of i)a.classList.add(s);const o=qd(e.style);if(o){const s=a.getAttribute("style");a.setAttribute("style",s?`${s};${o}`:o)}return a}};function ce(t,e,r,n){if(e==null)return;const a=n.event??"change";t.addEventListener(a,()=>{r.invoke(e,n.getValue(t))})}const np=["primary","secondary","outline","ghost","link","danger","default"],ap=["xs","sm","md","lg","xl"],ip=["text","email","password","number","tel","url","date"];function op(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"}function sp(t){if(!Number.isFinite(t)||t<=0)return"";const e=["B","KB","MB","GB"];let r=t,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r>=10||n===0?Math.round(r):r.toFixed(1)} ${e[n]}`}const lp={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:np,description:"Visual style — `primary` solid brand button (`default` is its alias), `secondary` surface + border, `outline` transparent with primary border, `ghost` bare, `link` text-only (underlines on hover), `danger` destructive"},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:ap,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 n=N(e.loading),a=N(e.iconOnly),i=m(e.iconPosition,"leading"),o=m(e.label),s=c("button",{class:"rui-button",type:m(e.type,"button"),"data-variant":m(e.variant,"primary"),"data-size":op(e.size),"data-icon-position":i,"data-icon-only":a?"true":null,"data-full-width":N(e.fullWidth)?"true":null,"data-loading":n?"true":null,"aria-label":a?o:null,disabled:N(e.disabled)||n?"":null}),l=c("span",{class:"rui-button-label"},[o]),u=L(e.icon,{className:"rui-button-icon"}),p=(n?L("spinner",{className:"rui-button-spinner"}):null)??u;return a?p&&s.append(p):i==="trailing"?(s.append(l),p&&s.append(p)):(p&&s.append(p),s.append(l)),s.onclick=()=>{n||r.invoke(e.onClick)},s}},cp={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 n=c("div",{class:"rui-buttons","data-direction":m(e.direction,"row")});for(const a of T(e.items))n.append(r.renderNode(a));return n}},up={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. Pass `label`/`hint`/`error`/`required` to render a labelled field shell with validation messaging.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:ip},{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"},...xn],render:(t,e,r)=>{const n=c("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 at(n,t,4,r),ce(n,e.onChange,r,{event:"input",getValue:a=>a.value}),dr(n,e,r),Mp(n,e.validations),ur(n,e)}},dp={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text. Pass `label`/`hint`/`error`/`required` for a labelled field shell.",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"},...xn],render:(t,e,r)=>{const n=c("textarea",{class:"rui-textarea",id:m(e.id),name:m(e.id),placeholder:m(e.placeholder),rows:String(Number(e.rows??4)||4)});return n.value=m(e.value),at(n,t,3,r),ce(n,e.onChange,r,{event:"input",getValue:a=>a.value}),dr(n,e,r,a=>a.value),ur(n,e)}},pp={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>c("option",{value:m(e.value)},[m(e.label)])},mp={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"},{name:"hint",type:"string",optional:!0,description:"Helper text rendered below the control"},{name:"error",type:"string",optional:!0,description:"Validation error rendered below the control (marks it invalid)"},{name:"required",type:"boolean",optional:!0,description:"Mark the field required"}],render:(t,e,r)=>{if(N(e.searchable))return Tp(t,e,r);const n=c("select",{class:"rui-select",id:m(e.id),name:m(e.id)}),a=m(e.placeholder);a&&n.append(c("option",{value:"",disabled:"",selected:""},[a]));for(const i of T(e.items))n.append(r.renderNode(i));return n.value=m(e.value),at(n,t,4,r),ce(n,e.onChange,r,{event:"change",getValue:i=>i.value}),dr(n,e,r,i=>i.value),ur(n,e)}},fp={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 n=c("label",{class:"rui-checkbox"}),a=N(e.value),i=c("input",{type:"checkbox",id:m(e.id),name:m(e.id),checked:a?"":null});return i.checked=a,at(i,t,2,r),ce(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),n.append(i,c("span",{class:"rui-checkbox-label"},[m(e.label)])),n}},gp={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),n=m(e.label),a=m(e.description),i=N(e.defaultChecked),o=c("label",{class:"rui-checkbox-item","data-name":r}),s=c("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const l=c("div",{class:"rui-checkbox-item-text"});return l.append(c("div",{class:"rui-checkbox-item-label"},[n])),a&&l.append(c("div",{class:"rui-checkbox-item-description"},[a])),o.append(s,l),o}},hp={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 n=m(e.name),a=c("div",{class:"rui-checkbox-group",role:"group","data-name":n}),i=T(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((u,d)=>{const p=m(u.args?.[0]),f=m(u.args?.[1],`${n}-${d}`),b=m(u.args?.[2]),h=N(u.args?.[3]),g=`${n}-${f}`,y=c("label",{class:"rui-checkbox-item",for:g}),v=f in o?!!o[f]:h,x=c("input",{type:"checkbox",id:g,name:f,checked:v?"":null}),w=c("div",{class:"rui-checkbox-item-text"});w.append(c("div",{class:"rui-checkbox-item-label"},[p])),b&&w.append(c("div",{class:"rui-checkbox-item-description"},[b])),y.append(x,w),a.append(y)});const s=t.argMeta?.[2]?.stateRef,l=u=>{const d={};return u.querySelectorAll('input[type="checkbox"]').forEach(p=>{d[p.name]=p.checked}),d};return s&&r.bindState(a,s,{event:"change",getValue:l}),ce(a,e.onChange,r,{event:"change",getValue:u=>l(u)}),a}},bp={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 n=m(e.id),a=c("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of T(e.items)){const o=m(i.args?.[0]),s=m(i.args?.[1],o),l=`${n}-${o}`,u=c("label",{class:"rui-radio",for:l}),d=m(e.value)===o,p=c("input",{type:"radio",id:l,name:n,value:o,checked:d?"":null});p.checked=d,at(p,t,2,r),ce(p,e.onChange,r,{event:"change",getValue:f=>f.value}),u.append(p,c("span",{class:"rui-radio-label"},[s])),a.append(u)}return a}},vp={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 n=c("div",{class:"rui-form-control"});n.append(c("label",{class:"rui-form-label"},[m(e.label)]));const a=r.renderNode(e.field);n.append(a);const i=m(e.hint);return i&&n.append(c("p",{class:"rui-form-hint"},[i])),n}},co={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 n=c("form",{class:"rui-search-bar",role:"search"});n.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const a=L("magnifying-glass",{className:"rui-search-bar-icon"})??c("span",{class:"rui-search-bar-icon","aria-hidden":"true"});n.append(a);const i=c("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"});at(i,t,2,r),ce(i,e.onChange,r,{event:"input",getValue:s=>s.value}),n.append(i);const o=m(e.shortcut);if(o&&n.append(c("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=c("button",{type:"submit",class:"rui-search-bar-submit"},[m(e.submitLabel,"Search")]);n.append(s)}return n}},yp={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 n=c("form",{class:"rui-form",id:m(e.id)});n.onsubmit=a=>{a.preventDefault(),r.invoke(e.onSubmit)};for(const a of T(e.fields))n.append(r.renderNode(a));if(e.buttons){const a=c("div",{class:"rui-form-actions"});a.append(r.renderNode(e.buttons)),n.append(a)}return n}},xp={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 n=m(e.id),a=I(e.min,0),i=I(e.max,100),o=I(e.step,1),s=I(e.value,a),l=c("div",{class:"rui-slider","data-disabled":N(e.disabled)?"true":"false"}),u=m(e.label),d=N(e.showValue);if(u||d){const b=c("div",{class:"rui-slider-head"});u&&b.append(c("label",{class:"rui-slider-label",for:n},[u])),d&&b.append(c("span",{class:"rui-slider-value"},[String(s)])),l.append(b)}const p=c("input",{type:"range",class:"rui-slider-input",id:n,name:n,min:String(a),max:String(i),step:String(o),value:String(s),disabled:N(e.disabled)?"":null});p.oninput=b=>{const h=b.currentTarget;if(!h)return;const y=h.closest(".rui-slider")?.querySelector(".rui-slider-value");y&&(y.textContent=h.value)};const f=t.argMeta?.[4]?.stateRef;return f&&r.bindState(p,f,{event:"input",getValue:b=>Number(b.value)}),ce(p,e.onChange,r,{event:"input",getValue:b=>Number(b.value)}),l.append(p),l}},wp={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)"},...xn],render:(t,e,r)=>{const n=m(e.id),a=I(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?I(e.min,0):Number.NEGATIVE_INFINITY,l=o?I(e.max,0):Number.POSITIVE_INFINITY,u=N(e.disabled),d=c("div",{class:"rui-number-input","data-disabled":u?"true":"false"}),p=c("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:u?"":null},["−"]),f=c("input",{type:"number",class:"rui-number-input-field",id:n,name:n,value:m(e.value),placeholder:m(e.placeholder),min:i?String(s):null,max:o?String(l):null,step:String(a),disabled:u?"":null}),b=c("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:u?"":null},["+"]),h=t.argMeta?.[1]?.stateRef,g=v=>{const x=v.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};h&&r.bindState(f,h,{event:"input",getValue:g}),ce(f,e.onChange,r,{event:"input",getValue:g});const y=(v,x)=>{const k=v.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const A=Number(k.value),S=Number.isFinite(A)?A:0,$=Ap(S+x,s,l);k.value=String($),k.dispatchEvent(new Event("input",{bubbles:!0}))};return p.onclick=v=>y(v.currentTarget??v.target,-a),b.onclick=v=>y(v.currentTarget??v.target,a),dr(f,e,r,g),d.append(p,f,b),ur(d,e,{idKey:"id"})}},kp={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 n=m(e.id),a=c("div",{class:"rui-date-picker"}),i=m(e.label);i&&a.append(c("label",{class:"rui-date-picker-label",for:n},[i]));const o=c("input",{type:"date",class:"rui-date-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,placeholder:m(e.placeholder),disabled:N(e.disabled)?"":null});return at(o,t,1,r),ce(o,e.onChange,r,{event:"change",getValue:s=>s.value}),a.append(o),a}},Sp={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 n=m(e.id),a=N(e.disabled),i=c("div",{class:"rui-file-upload","data-disabled":a?"true":"false"}),o=c("label",{class:"rui-file-upload-dropzone",for:n}),s=L(m(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const l=c("div",{class:"rui-file-upload-text"});l.append(c("div",{class:"rui-file-upload-label"},[m(e.label,"Choose a file")]));const u=m(e.hint);u&&l.append(c("div",{class:"rui-file-upload-hint"},[u])),o.append(l);const d=c("input",{type:"file",id:n,name:n,class:"rui-file-upload-input",accept:m(e.accept)||null,multiple:N(e.multiple)?"":null,disabled:a?"":null});o.append(d),i.append(o);const p=(b,h)=>h.includes("image")||b.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(b.name),f=(b,h)=>{const g=b.querySelector(".rui-file-upload-preview");g&&g.remove();const y=h?Array.from(h):[];if(y.length===0)return;const v=m(e.accept),x=c("div",{class:"rui-file-upload-preview"});y.forEach(w=>{const k=c("div",{class:"rui-file-upload-preview-item"});if(p(w,v)){const S=URL.createObjectURL(w),$=c("img",{src:S,alt:w.name,class:"rui-file-upload-thumbnail"});$.onload=()=>URL.revokeObjectURL(S),k.append($)}k.append(c("span",{class:"rui-file-upload-filename"},[w.name]));const A=sp(w.size);A&&k.append(c("span",{class:"rui-file-upload-filesize"},[A])),x.append(k)}),b.append(x)};if(d.onchange=b=>{const h=b.currentTarget;r.invoke(e.onSelect,h.files);const g=h.closest(".rui-file-upload");g&&f(g,h.files)},!a){const b=h=>{h.preventDefault(),h.stopPropagation()};o.addEventListener("dragenter",h=>{b(h),o.classList.add("is-dragover")}),o.addEventListener("dragover",h=>{b(h),o.classList.add("is-dragover")}),o.addEventListener("dragleave",h=>{b(h),o.classList.remove("is-dragover")}),o.addEventListener("drop",h=>{b(h),o.classList.remove("is-dragover");const g=h.dataTransfer;if(!g||g.files.length===0)return;try{d.files=g.files}catch{}r.invoke(e.onSelect,g.files);const y=o.closest(".rui-file-upload");y&&f(y,g.files)})}return i}},uo={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 n=m(e.id),a=so(e.items),i=m(e.value),o=a.find(S=>S.value===i)?.label??i,s=m(e.placeholder,"Select…"),l=m(e.emptyLabel,"No matches"),u=N(e.disabled),d=N(e.open),p=r.useInstanceState("open",d),f=r.useInstanceState("filter",""),b=p.get(),h=c("div",{class:"rui-combobox","data-open":b?"true":"false","data-disabled":u?"true":"false"}),g=c("button",{type:"button",class:"rui-combobox-trigger",id:n,"aria-haspopup":"listbox","aria-expanded":b?"true":"false",disabled:u?"":null});g.append(c("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const y=L("chevron-down",{className:"rui-combobox-chevron"});y&&g.append(y),h.append(g);const v=c("div",{class:"rui-combobox-panel",role:"listbox"}),x=c("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:f.get()});v.append(x);const w=c("div",{class:"rui-combobox-list"});v.append(w);const k=(S,$)=>{S.replaceChildren();const C=$.trim().toLowerCase(),M=C===""?a:a.filter(E=>E.label.toLowerCase().includes(C)||E.value.toLowerCase().includes(C));if(M.length===0){S.append(c("div",{class:"rui-combobox-empty"},[l]));return}for(const E of M){const R=c("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":E.value,"aria-selected":E.value===i?"true":"false"},[E.label]);R.onclick=_=>{_.stopPropagation(),A(_.currentTarget,E.value)},S.append(R)}},A=(S,$)=>{const C=t.argMeta?.[2]?.stateRef;C&&r.setState(C,$),r.invoke(e.onChange,$),p.set(!1),f.set("");const M=S.closest(".rui-combobox");M?.setAttribute("data-open","false"),M?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),Ue(M)};return k(w,f.get()),x.oninput=S=>{const $=S.currentTarget;f.set($.value);const C=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");C&&k(C,$.value)},x.onkeydown=S=>{const $=S;if($.key!=="Enter")return;$.preventDefault();const E=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),R=E?.getAttribute("data-value");R!=null&&E&&A(E,R)},g.onclick=S=>{if(u)return;S.stopPropagation();const $=!p.get();p.set($);const C=S.currentTarget.closest(".rui-combobox");if(C?.setAttribute("data-open",$?"true":"false"),C?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!C){if(!$){Ue(C);return}setTimeout(()=>x.focus(),0),xt({liveRoot:C,onDismiss:()=>{p.set(!1),f.set(""),C.setAttribute("data-open","false"),C.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(v),h}},$p={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 n=m(e.id),a=so(e.items),i=m(e.placeholder,"Select…"),o=m(e.emptyLabel,"No matches"),s=N(e.disabled),l=Math.max(0,Math.floor(Number(e.max??0))),u=Array.isArray(e.value)?e.value.map(M=>m(M)).filter(Boolean):[],d=new Set(u),p=t.argMeta?.[2]?.stateRef,f=N(e.open),b=r.useInstanceState("open",f),h=r.useInstanceState("filter",""),g=b.get(),y=c("div",{class:"rui-multiselect","data-open":g?"true":"false","data-disabled":s?"true":"false"}),v=c("button",{type:"button",class:"rui-multiselect-trigger",id:n,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:s?"":null}),x=c("span",{class:"rui-multiselect-chips"}),w=M=>{p&&r.setState(p,M),r.invoke(e.onChange,M)};if(u.length===0)x.append(c("span",{class:"rui-multiselect-placeholder"},[i]));else for(const M of u){const E=a.find(B=>B.value===M)?.label??M,R=c("span",{class:"rui-multiselect-chip","data-value":M});R.append(c("span",{class:"rui-multiselect-chip-label"},[E]));const _=c("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${E}`},["×"]);_.onclick=B=>{B.stopPropagation();const U=u.filter(O=>O!==M);w(U)},R.append(_),x.append(R)}v.append(x);const k=L("chevron-down",{className:"rui-multiselect-chevron"});k&&v.append(k),y.append(v);const A=c("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=c("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:h.get()});A.append(S);const $=c("div",{class:"rui-multiselect-list"});A.append($);const C=(M,E)=>{M.replaceChildren();const R=E.trim().toLowerCase(),_=R===""?a:a.filter(B=>B.label.toLowerCase().includes(R)||B.value.toLowerCase().includes(R));if(_.length===0){M.append(c("div",{class:"rui-multiselect-empty"},[o]));return}for(const B of _){const U=d.has(B.value),O=!U&&l>0&&u.length>=l,Q=c("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":B.value,"data-selected":U?"true":"false","aria-selected":U?"true":"false",disabled:O?"":null}),ye=c("span",{class:"rui-multiselect-option-check"}),Re=L(U?"check":"",{className:"rui-multiselect-option-check-icon"});Re&&ye.append(Re),Q.append(ye),Q.append(c("span",{class:"rui-multiselect-option-label"},[B.label])),Q.onclick=Vt=>{if(Vt.stopPropagation(),O)return;const ut=U?u.filter($a=>$a!==B.value):[...u,B.value];w(ut)},M.append(Q)}};return C($,h.get()),S.oninput=M=>{const E=M.currentTarget;h.set(E.value);const R=E.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");R&&C(R,E.value)},v.onclick=M=>{if(s)return;M.stopPropagation();const E=!b.get();b.set(E);const R=M.currentTarget.closest(".rui-multiselect");if(R?.setAttribute("data-open",E?"true":"false"),R?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",E?"true":"false"),!!R){if(!E){Ue(R);return}setTimeout(()=>S.focus(),0),xt({liveRoot:R,onDismiss:()=>{b.set(!1),h.set(""),R.setAttribute("data-open","false"),R.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},y.append(A),y}},Cp={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 n=m(e.id),a=`${n}-from`,i=`${n}-to`,o=m(e.min),s=m(e.max),l=N(e.disabled),u=c("div",{class:"rui-date-range-picker","data-disabled":l?"true":"false"}),d=m(e.label);d&&u.append(c("label",{class:"rui-date-range-picker-label",for:a},[d]));const p=c("div",{class:"rui-date-range-picker-row"}),f=c("input",{type:"date",class:"rui-date-range-picker-input",id:a,name:a,value:m(e.from),min:o||null,max:s||null,disabled:l?"":null,"data-role":"from"});p.append(f),p.append(c("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const b=c("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:m(e.to),min:o||null,max:s||null,disabled:l?"":null,"data-role":"to"});p.append(b),u.append(p);const h=t.argMeta?.[1]?.stateRef,g=t.argMeta?.[2]?.stateRef;if(h&&r.bindState(f,h),g&&r.bindState(b,g),e.onChange!=null){const y=v=>{const x=v.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",v=>r.invoke(e.onChange,y(v.currentTarget))),b.addEventListener("change",v=>r.invoke(e.onChange,y(v.currentTarget)))}return u}};function Ap(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Tp(t,e,r){const n=t.argMeta?[...t.argMeta]:[];for(;n.length<5;)n.push({});n[4]?.stateRef&&(n[2]=n[4]);const a=uo.render({...t,argMeta:n},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return a.classList.add("rui-select-searchable"),a}function at(t,e,r,n){const a=e.argMeta?.[r]?.stateRef;if(a){if(t instanceof HTMLInputElement&&t.type==="checkbox"){n.bindState(t,a,{event:"change",getValue:i=>i.checked});return}n.bindState(t,a)}}function Mp(t,e){if(!e)return;const r=Array.isArray(e)?e.map(n=>String(n)):typeof e=="object"?Object.entries(e).map(([n,a])=>a?`${n}:${a}`:n):[];for(const n of r)n==="required"?t.required=!0:n.startsWith("minLength:")?t.minLength=Number(n.slice(10))||0:n.startsWith("maxLength:")?t.maxLength=Number(n.slice(10))||0:n==="email"&&(t.type="email")}const Ge=["default","primary","success","warning","danger","info"],it=(t,e)=>{const r=T(t);if(r.length===0)return null;const n=c("div",{class:"rui-pattern-actions"});for(const a of r)n.append(e.renderNode(a));return n},Np=[{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 Ip(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const n of Np)if(n.match.test(r))return n.label;return""}const Pp={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:Ge,description:"Accent tone"}],render:(t,e,r)=>{const n=m(e.layout,"default"),a=m(e.title),i=m(e.subtitle),s=m(e.eyebrow)||Ip(a,i),l=m(e.tone,"primary");if(n==="cover"){const h=Qc(m(e.imageSrc)),g=X(m(e.height),"280px"),y=c("section",{class:"rui-cover","data-tone":l,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${h}");min-height:${g};`}),v=c("div",{class:"rui-cover-body"});s&&v.append(c("span",{class:"rui-cover-eyebrow"},[s])),v.append(c("h1",{class:"rui-cover-title"},[a])),i&&v.append(c("p",{class:"rui-cover-subtitle"},[i]));const x=m(e.caption);x&&v.append(c("p",{class:"rui-cover-caption"},[x]));const w=it(e.actions,r);if(w)w.classList.add("rui-cover-actions"),v.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const A=c("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)A.append(r.renderNode(S));v.append(A)}}return y.append(v),y}const u=re(e.imageSrc),d=c("section",{class:"rui-hero","data-tone":l,"data-has-image":u?"true":"false"}),p=c("div",{class:"rui-hero-body"});s&&p.append(c("span",{class:"rui-hero-eyebrow"},[s])),p.append(c("h1",{class:"rui-hero-title"},[a])),i&&p.append(c("p",{class:"rui-hero-subtitle"},[i]));const f=T(e.highlights);if(f.length>0){const h=c("div",{class:"rui-hero-highlights"});for(const g of f){const y=m(g);y&&h.append(c("span",{class:"rui-hero-highlight"},[y]))}p.append(h)}const b=[e.primary,e.secondary].filter(Boolean);if(b.length>0){const h=c("div",{class:"rui-hero-ctas"});for(const g of b)h.append(r.renderNode(g));p.append(h)}if(d.append(p),u){const h=c("div",{class:"rui-hero-media"});h.append(c("img",{src:u,alt:"",loading:"lazy"})),d.append(h)}return d}},Ep={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 n=c("header",{class:"rui-page-header"}),a=m(e.title);let i=e.breadcrumbs;if(i==null?a&&(i=["Home",a]):(i===!1||i==="false")&&(i=null),i){const p=c("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((f,b)=>{b>0&&p.append(c("span",{class:"rui-page-header-crumb-sep"},["/"])),p.append(c("span",{class:"rui-page-header-crumb"},[m(f)]))}):p.append(r.renderNode(i)),n.append(p)}const o=c("div",{class:"rui-page-header-title-row"}),s=c("div",{class:"rui-page-header-title-block"}),l=c("div",{class:"rui-page-header-title-line"});l.append(c("h1",{class:"rui-page-header-title"},[a])),e.status&&l.append(r.renderNode(e.status)),s.append(l);const u=m(e.subtitle);u&&s.append(c("p",{class:"rui-page-header-subtitle"},[u])),o.append(s);const d=it(e.actions,r);return d&&(d.classList.add("rui-page-header-actions"),o.append(d)),n.append(o),n}},zp={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 n=c("div",{class:"rui-empty-state"}),a=re(e.illustration);if(a)n.append(c("img",{class:"rui-empty-state-illustration",src:a,alt:"",loading:"lazy"}));else{const s=m(e.title),l=m(e.description),u=m(e.icon)||oo(`${s} ${l}`)||"inbox",d=L(u,{className:"rui-empty-state-icon"});d&&n.append(d)}n.append(c("h3",{class:"rui-empty-state-title"},[m(e.title)]));const i=m(e.description);i&&n.append(c("p",{class:"rui-empty-state-description"},[i]));const o=T(e.actions);if(o.length>0){const s=c("div",{class:"rui-empty-state-actions"});for(const l of o)s.append(r.renderNode(l));n.append(s)}else if(e.action){const s=c("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),n.append(s)}return n}},Rp={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:Ge}],render:(t,e)=>{const r=c("li",{class:"rui-timeline-item","data-tone":m(e.tone,"default")}),n=c("span",{class:"rui-timeline-marker"}),a=L(e.icon);a&&n.append(a),r.append(n);const i=c("div",{class:"rui-timeline-body"}),o=c("div",{class:"rui-timeline-head"});o.append(c("span",{class:"rui-timeline-title"},[m(e.title)]));const s=m(e.time);s&&o.append(c("span",{class:"rui-timeline-time"},[s])),i.append(o);const l=m(e.description);return l&&i.append(c("div",{class:"rui-timeline-description"},[l])),r.append(i),r}},Lp={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 n=c("ol",{class:"rui-timeline"});for(const a of T(e.items))n.append(r.renderNode(a));return n}},Dp={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:Ge}],render:(t,e)=>{const r=c("div",{class:"rui-feature-item","data-tone":m(e.tone,"primary")}),n=m(e.icon,"sparkles"),a=L(n,{className:"rui-feature-icon"});a&&r.append(a),r.append(c("h3",{class:"rui-feature-title"},[m(e.title)]));const i=m(e.description);return i&&r.append(c("p",{class:"rui-feature-description"},[i])),r}},jp={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 n=Math.max(1,Math.min(4,Number(e.columns??"auto"))),a=c("div",{class:"rui-feature-grid","data-columns":n>0?String(n):null});for(const i of T(e.items))a.append(r.renderNode(i));return a}},Bp={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=c("figure",{class:"rui-testimonial"}),n=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(n>0){const l=c("div",{class:"rui-testimonial-rating"});for(let u=0;u<5;u+=1){const d=u<n,p=L(d?"star":"regular:star",{className:"rui-testimonial-rating-star"});p&&l.append(p)}r.append(l)}r.append(c("blockquote",{class:"rui-testimonial-quote"},[m(e.quote)]));const a=c("figcaption",{class:"rui-testimonial-author"}),i=re(e.avatarSrc);i&&a.append(c("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=c("div",{class:"rui-testimonial-meta"});o.append(c("div",{class:"rui-testimonial-name"},[m(e.author)]));const s=m(e.role);return s&&o.append(c("div",{class:"rui-testimonial-role"},[s])),a.append(o),r.append(a),r}},Op={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 n=c("div",{class:"rui-profile-card"}),a=c("div",{class:"rui-profile-card-header"});a.append(Nt(m(e.avatarSrc),m(e.name),"lg"));const i=c("div",{class:"rui-profile-card-meta"});i.append(c("h3",{class:"rui-profile-card-name"},[m(e.name)]));const o=m(e.role);o&&i.append(c("p",{class:"rui-profile-card-role"},[o])),a.append(i),n.append(a);const s=m(e.bio);s&&n.append(c("p",{class:"rui-profile-card-bio"},[s]));const l=T(e.tags);if(l.length>0){const d=c("div",{class:"rui-profile-card-tags"});for(const p of l){const f=m(p);f&&d.append(c("span",{class:"rui-tag","data-size":"sm"},[c("span",{class:"rui-tag-label"},[f])]))}n.append(d)}const u=it(e.actions,r);return u&&(u.classList.add("rui-profile-card-actions"),n.append(u)),n}},Fp={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 n=c("article",{class:"rui-comment"});n.append(Nt(m(e.avatarSrc),m(e.author),"md"));const a=c("div",{class:"rui-comment-body"}),i=c("header",{class:"rui-comment-header"});i.append(c("span",{class:"rui-comment-author"},[m(e.author)]));const o=m(e.time);o&&i.append(c("span",{class:"rui-comment-time"},[o])),a.append(i),a.append(c("div",{class:"rui-comment-content"},[m(e.body)]));const s=it(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),a.append(s)),n.append(a),n}},_p={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:Ge}],render:(t,e,r)=>{const n=m(e.tone,"primary"),a=c("aside",{class:"rui-banner","data-tone":n}),i=m(e.icon)||Ud(n)||"",o=L(i,{className:"rui-banner-icon"});o&&a.append(o);const s=c("div",{class:"rui-banner-body"});s.append(c("strong",{class:"rui-banner-title"},[m(e.title)]));const l=m(e.message);if(l&&s.append(c("span",{class:"rui-banner-message"},[l])),a.append(s),e.action){const u=c("div",{class:"rui-banner-action"});u.append(r.renderNode(e.action)),a.append(u)}return a}},Up={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:Ge},{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 n=c("div",{class:"rui-kanban-card","data-tone":m(e.tone,"default")});typeof e.onClick=="function"&&(n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.onclick=()=>r.invoke(e.onClick),n.onkeydown=u=>{const d=u;(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r.invoke(e.onClick))});const a=c("div",{class:"rui-kanban-card-title"}),i=L(e.icon,{className:"rui-kanban-card-icon"});i&&a.append(i),a.append(document.createTextNode(m(e.title))),n.append(a);const o=m(e.description);o&&n.append(c("p",{class:"rui-kanban-card-description"},[o]));const s=T(e.tags);if(s.length>0){const u=c("div",{class:"rui-kanban-card-tags"});for(const d of s){const p=m(d);p&&u.append(c("span",{class:"rui-tag","data-size":"sm"},[c("span",{class:"rui-tag-label"},[p])]))}n.append(u)}const l=m(e.assignee);if(l){const u=c("footer",{class:"rui-kanban-card-footer"});u.append(Nt("",l,"sm")),u.append(c("span",{class:"rui-kanban-card-assignee"},[l])),n.append(u)}return n}},Hp={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:Ge,description:"Header accent tone"}],render:(t,e,r)=>{const n=T(e.items),a=c("section",{class:"rui-kanban-column","data-tone":m(e.tone,"default")}),i=c("header",{class:"rui-kanban-column-header"});i.append(c("span",{class:"rui-kanban-column-title"},[m(e.title)])),i.append(c("span",{class:"rui-kanban-column-count"},[String(n.length)])),a.append(i);const o=c("div",{class:"rui-kanban-column-body"});for(const s of n)o.append(r.renderNode(s));return n.length===0&&o.append(c("div",{class:"rui-kanban-column-empty"},["No items"])),a.append(o),a}},qp={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 n=c("div",{class:"rui-kanban-board"});for(const a of T(e.columns))n.append(r.renderNode(a));return n}},Vp={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 n=c("header",{class:"rui-section-header"}),a=c("div",{class:"rui-section-header-left"}),i=m(e.eyebrow);i&&a.append(c("span",{class:"rui-section-header-eyebrow"},[i]));const o=c("div",{class:"rui-section-header-title-line"});o.append(c("h3",{class:"rui-section-header-title"},[m(e.title)])),e.status&&o.append(r.renderNode(e.status)),a.append(o);const s=m(e.subtitle);s&&a.append(c("p",{class:"rui-section-header-subtitle"},[s])),n.append(a);const l=it(e.actions,r);return l&&(l.classList.add("rui-section-header-actions"),n.append(l)),n}},Wp={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 n=T(e.center),a=c("div",{class:"rui-toolbar","data-has-center":n.length>0?"true":"false"}),i=c("div",{class:"rui-toolbar-side rui-toolbar-left"});N(e.searchable)&&i.append(co.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:m(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of T(e.left))i.append(r.renderNode(s));if(a.append(i),n.length>0){const s=c("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const l of n)s.append(r.renderNode(l));a.append(s)}const o=c("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of T(e.right))o.append(r.renderNode(s));return a.append(o),a}},Gp={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 n=m(e.to),a=e.active!==void 0&&e.active!==null,i=n?r.router.getPath():"",o=n?n==="/"?i==="/":i===n?!0:i.startsWith(n+"/"):!1,s=a?N(e.active):o,l=c("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":n||null}),u=L(e.icon,{className:"rui-sidebar-item-icon"});u&&l.append(u),l.append(c("span",{class:"rui-sidebar-item-label"},[m(e.label)]));const d=m(e.badge);return d&&l.append(c("span",{class:"rui-sidebar-item-badge"},[d])),(n||e.onClick!=null)&&(l.onclick=p=>{if(n){const f=p;if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey)return;r.router.navigate(n)}e.onClick!=null&&r.invoke(e.onClick)}),l}},Kp={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 n=c("div",{class:"rui-sidebar-section"}),a=m(e.label);a&&n.append(c("div",{class:"rui-sidebar-section-label"},[a]));for(const i of T(e.items))n.append(r.renderNode(i));return n}},Yp={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 n=N(e.collapsed),a=c("aside",{class:"rui-sidebar"});n&&(a.dataset.collapsed="true");const i=m(e.brand),o=m(e.tagline);if(i||o){const u=c("div",{class:"rui-sidebar-header"});i&&u.append(c("div",{class:"rui-sidebar-brand"},[i])),o&&u.append(c("div",{class:"rui-sidebar-tagline"},[o])),a.append(u)}const s=c("nav",{class:"rui-sidebar-body"});for(const u of T(e.items))s.append(r.renderNode(u));a.append(s);const l=T(e.footer);if(l.length>0){const u=c("div",{class:"rui-sidebar-footer"});for(const d of l)u.append(r.renderNode(d));a.append(u)}return a}},Xp={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 n=N(e.collapsible),a=N(e.sidebarOpen),i=c("div",{class:"rui-app-shell"});n&&(i.dataset.collapsible="true"),a&&(i.dataset.sidebarOpen="true");const o=c("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),n){const d=c("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});d.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(d)}const s=c("div",{class:"rui-app-shell-main"}),l=T(e.topbar);if(l.length>0||n){const d=c("div",{class:"rui-app-shell-topbar"});if(n){const p=c("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});p.append(L("bars",{size:"md"})??document.createTextNode("≡")),p.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),d.append(p)}for(const p of l)d.append(r.renderNode(p));s.append(d)}const u=c("div",{class:"rui-app-shell-content"});for(const d of T(e.content))u.append(r.renderNode(d));return s.append(u),i.append(s),i}},Zp={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 n=X(m(e.primaryWidth),"320px"),a=c("div",{class:"rui-split-view",style:`--rui-split-primary:${n}`}),i=c("div",{class:"rui-split-view-primary"});for(const s of T(e.primary))i.append(r.renderNode(s));const o=c("div",{class:"rui-split-view-detail"});for(const s of T(e.detail))o.append(r.renderNode(s));return a.append(i,o),a}},Qp={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 n=c("div",{class:"rui-description-item"}),a=c("dt",{class:"rui-description-label"}),i=L(e.icon,{className:"rui-description-icon"});i&&a.append(i),a.append(document.createTextNode(m(e.label)));const o=c("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))),n.append(a,o),n}},Jp={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 n=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),a=c("dl",{class:"rui-description-list","data-columns":String(n)});for(const i of T(e.items))a.append(r.renderNode(i));return a}},em={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=c("span",{class:"rui-status-dot","data-tone":m(e.tone,"success"),"data-pulse":N(e.pulse)?"true":"false"});return r.append(c("span",{class:"rui-status-dot-marker"})),r.append(c("span",{class:"rui-status-dot-label"},[m(e.label)])),r}},tm={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 n=N(e.featured),a=c("article",{class:"rui-pricing-card","data-featured":n?"true":"false"}),i=m(e.badge);i&&a.append(c("div",{class:"rui-pricing-card-badge"},[i])),a.append(c("h3",{class:"rui-pricing-card-plan"},[m(e.plan)]));const o=m(e.description);o&&a.append(c("p",{class:"rui-pricing-card-description"},[o]));const s=c("div",{class:"rui-pricing-card-price-row"});s.append(c("span",{class:"rui-pricing-card-price"},[m(e.price)]));const l=m(e.period);l&&s.append(c("span",{class:"rui-pricing-card-period"},[l])),a.append(s);const u=T(e.features);if(u.length>0){const d=c("ul",{class:"rui-pricing-card-features"});for(const p of u){const f=m(p);if(!f)continue;const b=L("circle-check",{className:"rui-pricing-card-check"})??c("span",{class:"rui-pricing-card-check"});d.append(c("li",{class:"rui-pricing-card-feature"},[b,document.createTextNode(f)]))}a.append(d)}if(e.action){const d=c("div",{class:"rui-pricing-card-action"});d.append(r.renderNode(e.action)),a.append(d)}return a}},rm={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 n=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),a=c("div",{class:"rui-pricing-table","data-columns":n>0?String(n):null});for(const i of T(e.tiers))a.append(r.renderNode(i));return a}},nm={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 n=m(e.orientation,"vertical"),a=c("article",{class:"rui-media-card","data-orientation":n}),i=am(m(e.ratio,n==="horizontal"?"4:3":"16:9")),o=c("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=re(e.imageSrc);if(s)o.append(c("img",{src:s,alt:m(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const b=L("image",{className:"rui-media-card-placeholder"})??c("span",{class:"rui-media-card-placeholder"});o.append(b)}if(e.badge){const b=c("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?b.append(document.createTextNode(m(e.badge))):b.append(r.renderNode(e.badge)),o.append(b)}a.append(o);const l=c("div",{class:"rui-media-card-body"});l.append(c("h3",{class:"rui-media-card-title"},[m(e.title)]));const u=m(e.description);u&&l.append(c("p",{class:"rui-media-card-description"},[u]));const d=T(e.tags);if(d.length>0){const b=c("div",{class:"rui-media-card-tags"});for(const h of d){const g=m(h);g&&b.append(c("span",{class:"rui-tag","data-size":"sm"},[c("span",{class:"rui-tag-label"},[g])]))}l.append(b)}const p=m(e.meta);p&&l.append(c("p",{class:"rui-media-card-meta"},[p]));const f=it(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),l.append(f)),a.append(l),a}};function am(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function wn(t,e="primary"){const a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"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),l=s-o||1,u=80/(t.length-1),p=t.map((g,y)=>{const v=y*u,x=2+(s-g)/l*20;return[v,x]}).map(([g,y],v)=>`${v===0?"M":"L"}${g.toFixed(1)},${y.toFixed(1)}`).join(" "),f=`${p} L80,24 L0,24 Z`,b=document.createElementNS(a,"path");b.setAttribute("d",f),b.setAttribute("class","rui-sparkline-area"),i.appendChild(b);const h=document.createElementNS(a,"path");return h.setAttribute("d",p),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),i.appendChild(h),i}const im={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 n=T(e.items),a=n.some(l=>l&&typeof l=="object"&&l.__kind==="Component");if(m(e.layout,a?"grid":"strip")==="grid"){const l=e.columns?Math.max(1,Math.min(6,Math.floor(I(e.columns)))):0,u=Wi.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:n,columns:l>0?l:"auto",gap:"m"},r);return u.classList.add("rui-metric-grid"),u}const o=m(e.align,"start"),s=c("div",{class:"rui-stats","data-align":o});for(const l of n){const u=l??{},d=m(u.tone,"default"),p=c("div",{class:"rui-stats-item","data-tone":d});p.append(c("div",{class:"rui-stats-label"},[m(u.label)]));const f=c("div",{class:"rui-stats-value-row"});f.append(c("div",{class:"rui-stats-value"},[m(u.value)]));const b=T(u.spark).map(g=>Number(g)).filter(g=>Number.isFinite(g));b.length>1&&f.append(wn(b,d)),p.append(f);const h=m(u.hint);h&&p.append(c("div",{class:"rui-stats-hint"},[h])),s.append(p)}return s}},om={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:Ge},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const n=typeof e.onClick=="function",i=c(n?"button":"div",{type:n?"button":null,class:"rui-tile","data-tone":m(e.tone,"default")}),o=L(e.icon,{className:"rui-tile-icon"});o&&i.append(o);const s=c("div",{class:"rui-tile-body"});s.append(c("div",{class:"rui-tile-label"},[m(e.label)]));const l=m(e.value);l&&s.append(c("div",{class:"rui-tile-value"},[l]));const u=m(e.description);return u&&s.append(c("div",{class:"rui-tile-description"},[u])),i.append(s),n&&(i.onclick=()=>r.invoke(e.onClick)),i}},po={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:Ge},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const n=N(e.unread),a=c("article",{class:"rui-notification","data-tone":m(e.tone,"default"),"data-unread":n?"true":"false"}),i=m(e.avatarSrc),o=c("div",{class:"rui-notification-visual"});if(i)o.append(Nt(i,m(e.title),"md"));else{const b=L(m(e.icon,"bell"),{className:"rui-notification-icon"});b&&o.append(b)}a.append(o);const s=c("div",{class:"rui-notification-body"}),l=c("header",{class:"rui-notification-head"}),u=c("span",{class:"rui-notification-title-wrap"});n&&u.append(c("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),u.append(c("span",{class:"rui-notification-title"},[m(e.title)])),l.append(u);const d=m(e.time);d&&l.append(c("span",{class:"rui-notification-time"},[d])),s.append(l);const p=m(e.message);p&&s.append(c("p",{class:"rui-notification-message"},[p]));const f=it(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),a.append(s),a}},sm={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 n=typeof e.onClick=="function",a=n?"button":"div",i=m(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=c(a,{type:n?"button":null,class:"rui-person-chip","data-size":i}),l=c("span",{class:"rui-person-chip-avatar"});l.append(Nt(m(e.avatarSrc),m(e.name),o));const u=m(e.status);u&&l.append(c("span",{class:"rui-person-chip-status","data-status":u})),s.append(l);const d=c("div",{class:"rui-person-chip-meta"});d.append(c("span",{class:"rui-person-chip-name"},[m(e.name)]));const p=m(e.role);return p&&d.append(c("span",{class:"rui-person-chip-role"},[p])),s.append(d),n&&(s.onclick=()=>r.invoke(e.onClick)),s}},mo=["left","center","right"],lm={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:mo,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=c("div",{class:"rui-col"});return r.append(c("strong",{},[m(e.header)])),r}},cm={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 n=T(e.columns),a=m(e.density,"comfortable"),i=N(e.striped),o=N(e.sticky),s=c("div",{class:"rui-table-wrapper","data-density":a,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),l=c("table",{class:"rui-table"}),u=m(e.caption);u&&l.append(c("caption",{class:"rui-table-caption"},[u]));const d=n.map(w=>{const k=m(w.args?.[3],"");return mo.includes(k)?k:""}),p=c("thead"),f=c("tr");for(let w=0;w<n.length;w+=1){const k=n[w],A=c("th",{"data-align":d[w]||null},[m(k.args?.[0])]);f.append(A)}p.append(f),l.append(p);const b=c("tbody"),h=n.map(w=>T(w.args?.[1])),g=n.map(w=>m(w.args?.[2],"text")),y=n.map(w=>w.args?.[6]),v=n.map(w=>w.args?.[7]),x=Math.max(0,...h.map(w=>w.length));for(let w=0;w<x;w+=1){const k=c("tr");h.forEach((A,S)=>{const $=g[S]??"text",C=d[S],M=c("td",{"data-format":$,"data-align":C||null});Zr(M,{format:$,render:y[S],onClick:v[S]},A[w],w,r,bm),k.append(M)}),b.append(k)}if(x===0){const w=c("tr"),k=m(e.emptyLabel,"No data");w.append(c("td",{colspan:String(n.length||1),class:"rui-table-empty"},[k])),b.append(w)}return l.append(b),s.append(l),s}},um={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=c("li",{class:"rui-list-item"}),n=L(e.icon,{className:"rui-list-icon"});n&&r.append(n);const a=c("div",{class:"rui-list-text"});a.append(c("div",{class:"rui-list-title"},[m(e.title)]));const i=m(e.description);return i&&a.append(c("div",{class:"rui-list-description"},[i])),r.append(a),r}},dm={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=N(e.ordered)?"ol":"ul",a=c(n,{class:"rui-list"});for(const i of T(e.items))a.append(r.renderNode(i));return a}},pm={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"),n=c("div",{class:"rui-stat-card","data-tone":r}),a=c("div",{class:"rui-stat-label-row"}),i=m(e.label),o=m(e.icon)||oo(i)||"",s=L(o,{className:"rui-stat-icon"});s&&a.append(s),a.append(c("div",{class:"rui-stat-label"},[i])),n.append(a),n.append(c("div",{class:"rui-stat-value"},[m(e.value)]));const l=m(e.delta),u=m(e.trend);(l||u)&&n.append(c("div",{class:"rui-stat-trend","data-trend":u||"flat"},[l||hm(u)]));const d=T(e.spark).map(p=>I(p));if(d.length>1){const p=c("div",{class:"rui-stat-spark"});p.append(wn(d,r==="default"?"primary":r)),n.append(p)}return n}},mm={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"),n=T(e.values).map(i=>I(i)),a=c("span",{class:"rui-sparkline-wrap"});return a.append(wn(n,r)),a}},fm={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 n=T(e.children),a=n.length>0,i=N(e.expanded),o=N(e.active),s=typeof e.onClick=="function",l=c(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":a?i?"true":"false":null});if(a){const h=L("chevron-right",{className:"rui-tree-node-chevron"});h&&l.append(h)}else l.append(c("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const u=L(e.icon,{className:"rui-tree-node-icon"});u&&l.append(u),l.append(c("span",{class:"rui-tree-node-label"},[m(e.label)]));const d=m(e.badge);if(d&&l.append(c("span",{class:"rui-tree-node-badge"},[d])),s&&(l.onclick=()=>r.invoke(e.onClick)),!a)return l;const p=c("details",{class:"rui-tree-node"});i&&p.setAttribute("open","");const f=c("summary",{class:"rui-tree-node-summary"});f.append(l),s&&(f.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),p.append(f);const b=c("div",{class:"rui-tree-node-children",role:"group"});for(const h of n)b.append(r.renderNode(h));return p.append(b),p}},gm={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 n=c("div",{class:"rui-tree",role:"tree"});for(const a of T(e.items))n.append(r.renderNode(a));return n}};function hm(t){return t==="up"?"▲":t==="down"?"▼":"—"}function bm(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 kn=["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)"],wt=t=>kn[t%kn.length]??kn[0],vm={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)=>c("span",{class:"rui-series","data-name":m(e.name)})},fo=t=>t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>I(o));return{name:a,values:i}}),ym={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=T(e.labels).map(v=>m(v)),n=fo(T(e.series)),a=c("div",{class:"rui-chart rui-bar-chart"});m(e.title)&&a.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const i=Math.max(1,...n.flatMap(v=>v.values)),o=640,s=240,l=ho(r,o-40-12),u={left:40,right:12,top:12,bottom:l.bottomPadding},d=o-u.left-u.right,p=s-u.top-u.bottom,f=Sn(o,s);vo(f,u,d,p,i);const b=r.length,h=d/Math.max(b,1),g=n.length,y=h*.7/Math.max(g,1);return n.forEach((v,x)=>{v.values.forEach((w,k)=>{const A=w/i*p,S=u.left+k*h+h*.15+x*y,$=u.top+p-A,C=Ce("rect",{x:String(S),y:String($),width:String(Math.max(y-2,1)),height:String(A),fill:wt(x),rx:"2"});C.append(Ce("title",{},[`${v.name}: ${w}`])),f.append(C)})}),bo(f,r,u,d,p,l,v=>u.left+(v+.5)*h),a.append(f),n.length>0&&a.append($n(n)),a}},xm={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=T(e.labels).map($=>m($)),n=fo(T(e.series));const a=T(e.data);if(a.length>0&&(r.length===0||n.length===0)){const $=[],C=new Map;for(const M of a){const E=M;if(!(!E||typeof E!="object")){$.push(m(E.x??E.label??""));for(const[R,_]of Object.entries(E)){if(R==="x"||R==="label")continue;const B=I(_);Number.isNaN(B)||(C.has(R)||C.set(R,[]),C.get(R).push(B))}}}r.length===0&&(r=$),n.length===0&&(n=[...C.entries()].map(([M,E])=>({name:M,values:E})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...n.map($=>$.values.length),1),l=n.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let C=0;n.forEach((M,E)=>{C+=M.values[$]??0,l[E][$]=C})}const u=c("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});m(e.title)&&u.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const d=i&&o?l.flat():n.flatMap($=>$.values),p=Math.max(1,...d),f=i&&o?0:Math.min(0,...d),b=640,h=240,g=ho(r,b-40-12),y={left:40,right:12,top:12,bottom:g.bottomPadding},v=b-y.left-y.right,x=h-y.top-y.bottom,w=Sn(b,h);vo(w,y,v,x,p,f);const k=Math.max(r.length-1,1),A=v/k,S=$=>y.left+$*(v/Math.max(s-1,1));return n.forEach(($,C)=>{const M=i&&o?l[C]:$.values,E=i&&o&&C>0?l[C-1]:null,R=M.map((B,U)=>{const O=S(U),Q=y.top+x-(B-f)/(p-f||1)*x;return[O,Q]});if(i&&R.length>0){let B=R.map(([U,O],Q)=>`${Q===0?"M":"L"}${U.toFixed(1)},${O.toFixed(1)}`).join(" ");if(E){const U=E.map((O,Q)=>{const ye=S(Q),Re=y.top+x-(O-f)/(p-f||1)*x;return[ye,Re]});B+=" "+U.slice().reverse().map(([O,Q])=>`L${O.toFixed(1)},${Q.toFixed(1)}`).join(" ")+" Z"}else{const U=R[0],O=R[R.length-1];B+=` L${O[0].toFixed(1)},${(y.top+x).toFixed(1)} L${U[0].toFixed(1)},${(y.top+x).toFixed(1)} Z`}w.append(Ce("path",{d:B,fill:wt(C),"fill-opacity":"0.2",stroke:"none"}))}const _=R.map(([B,U],O)=>`${O===0?"M":"L"}${B.toFixed(1)},${U.toFixed(1)}`).join(" ");w.append(Ce("path",{d:_,fill:"none",stroke:wt(C),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&R.forEach(([B,U])=>{w.append(Ce("circle",{cx:String(B),cy:String(U),r:"3",fill:wt(C)}))})}),bo(w,r,y,v,x,g,$=>y.left+$*A),u.append(w),n.length>0&&u.append($n(n)),u}},wm={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=T(e.labels).map(g=>m(g)),n=T(e.values).map(g=>I(g)),a=e.showValues==null?!0:N(e.showValues),i=m(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=c("div",{class:"rui-chart rui-pie-chart"});m(e.title)&&s.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const l=n.reduce((g,y)=>g+(y>0?y:0),0)||1,u=Sn(240,240),d=120,p=120,f=90,b=.05;let h=-Math.PI/2;return n.forEach((g,y)=>{const v=g>0?g:0,x=v/l,w=x*Math.PI*2,k=h+w,A=w>Math.PI?1:0,S=d+f*Math.cos(h),$=p+f*Math.sin(h),C=d+f*Math.cos(k),M=p+f*Math.sin(k),E=`M${d},${p} L${S},${$} A${f},${f} 0 ${A} 1 ${C},${M} Z`,R=Ce("path",{d:E,fill:wt(y),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(R.append(Ce("title",{},[`${r[y]??""}: ${g} (${(x*100).toFixed(1)}%)`])),u.append(R),a&&v>0&&x>=b){const _=h+w/2,B=f*.62,U=d+B*Math.cos(_),O=p+B*Math.sin(_),Q=km(g,x,o),ye=Ce("text",{x:String(U),y:String(O),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"},[Q]);u.append(ye)}h=k}),s.append(u),s.append($n(r.map((g,y)=>({name:g,values:[n[y]??0]})))),s}};function km(t,e,r){const n=`${Math.round(e*100)}%`,a=Sm(t);return r==="percent"?n:r==="both"?`${a} (${n})`:a}function Sm(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 $m=7,go=12;function ho(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),n=t.reduce((o,s)=>Math.max(o,s.length),0);if(n*$m+4<=r)return{step:1,rotated:!1,maxChars:n,bottomPadding:32};const a=r<go?Math.max(1,Math.ceil(go/r)):1,i=Math.min(n,14);return{step:a,rotated:!0,maxChars:i,bottomPadding:60}}function Cm(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function bo(t,e,r,n,a,i,o){const s=r.top+a+(i.rotated?14:18);e.forEach((l,u)=>{if(u%i.step!==0)return;const d=o(u),p=Cm(l,i.maxChars),f={x:String(d),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${d}, ${s})`);const b=Ce("text",f,[p]);p!==l&&b.append(Ce("title",{},[l])),t.append(b)})}function Sn(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 n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[a,i]of Object.entries(e))n.setAttribute(a,i);if(r)for(const a of r)n.append(typeof a=="string"?document.createTextNode(a):a);return n}function vo(t,e,r,n,a,i=0){for(let s=0;s<=4;s+=1){const l=s/4,u=e.top+n-l*n;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-6),y:String(u+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(a-i)*l)*10)/10)]))}}function $n(t){const e=c("div",{class:"rui-chart-legend"});return t.forEach((r,n)=>{const a=c("span",{class:"rui-chart-legend-item"});a.append(c("span",{class:"rui-chart-legend-swatch",style:`background:${wt(n)}`})),a.append(c("span",{},[r.name])),e.append(a)}),e}const Am={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 n=c("section",{class:"rui-section-block"});n.append(c("h3",{class:"rui-section-block-title"},[m(e.title)]));const a=m(e.description);a&&n.append(c("p",{class:"rui-section-block-description"},[a]));for(const i of T(e.children))n.append(r.renderNode(i));return n}},Tm={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=N(e.ordered)?"ol":"ul",n=c(r,{class:"rui-list-block"});for(const a of T(e.items))n.append(c("li",{},[m(a)]));return n}},Mm={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 n=c("div",{class:"rui-follow-up"}),a=m(e.title,"You can also ask");a&&n.append(c("div",{class:"rui-follow-up-title"},[a]));const i=c("div",{class:"rui-follow-up-list"});for(const o of T(e.items))i.append(Nm(o,r));return n.append(i),n}},Nm=(t,e)=>{const{label:r,message:n}=Im(t),a=c("button",{class:"rui-follow-up-button",type:"button"},[r]);return a.onclick=()=>{e.sendToAssistant(n)},a},Im=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 n=m(r.label),a=m(r.message,n);return{label:n,message:a}}const e=m(t);return{label:e,message:e}},Pm={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 n=m(e.label),a=m(e.message,n),i=c("button",{class:"rui-follow-up-button",type:"button"},[n]);return i.onclick=()=>{r.sendToAssistant(a)},i}},Em={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 n=c("a",{class:"rui-action-link",href:"#",role:"button"},[m(e.label)]);return n.onclick=a=>{a.preventDefault(),r.invoke(e.onClick)},n}},yo=["xs","sm","md","lg","xl"],zm=["initials","dicebear","gradient"];function Rm(t){let e=0;for(let a=0;a<t.length;a+=1)e=e*31+t.charCodeAt(a)>>>0;const r=e%360,n=(r+40)%360;return`background:linear-gradient(135deg, hsl(${r} 65% 55%), hsl(${n} 65% 45%));color:#fff;`}const xo={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:yo},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:zm,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"),n=c("span",{class:"rui-avatar","data-size":r,role:"img"}),a=m(e.name),i=m(e.fallback,"dicebear"),o=re(e.src),s=!o&&i==="dicebear"&&a?re(Hd(a)):"",l=o||s;if(l){const d=c("img",{src:l,alt:a,loading:"lazy"});d.onerror=p=>{const f=p;(f.currentTarget??f.target).replaceWith(c("span",{class:"rui-avatar-fallback"},[yt(a)]))},n.append(d)}else i==="gradient"&&a?n.append(c("span",{class:"rui-avatar-fallback rui-avatar-gradient",style:Rm(a)},[yt(a)])):n.append(c("span",{class:"rui-avatar-fallback"},[yt(a)]));const u=m(e.status);return u&&n.append(c("span",{class:"rui-avatar-status","data-status":u})),n}},Lm={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:yo}],render:(t,e,r)=>{const n=T(e.items),a=Math.max(1,Math.floor(Number(e.max??4))),i=m(e.size,"md"),o=n.slice(0,a),s=n.length-o.length,l=c("div",{class:"rui-avatar-group","data-size":i});for(const u of o){if(u&&typeof u=="object"&&u.__kind==="Component"){l.append(r.renderNode(u));continue}const d=u,p=typeof d=="string"?d:m((d??{}).name),f=typeof d=="string"?"":m((d??{}).src);l.append(xo.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:p,src:f,size:i},r))}return s>0&&l.append(c("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[c("span",{class:"rui-avatar-fallback"},[`+${s}`])])),l}},Dm={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,I(e.max,100)),n=N(e.indeterminate),a=Math.max(0,Math.min(r,I(e.value,0))),i=Math.round(a/r*100),o=Math.max(0,Math.floor(I(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,I(e.buffered,0))):null,l=c("div",{class:"rui-progress","data-tone":m(e.tone,"primary")}),u=m(e.label),d=N(e.showValue);if(u||d){const f=c("div",{class:"rui-progress-head"});if(f.append(c("span",{class:"rui-progress-label"},[u])),d&&!n){const b=o>0?`${Math.min(o,Math.round(a/r*o))} / ${o}`:`${i}%`;f.append(c("span",{class:"rui-progress-value"},[b]))}l.append(f)}if(o>0&&!n){const f=c("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(a/r*o)))}),b=Math.min(o,Math.round(a/r*o));for(let h=0;h<o;h+=1)f.append(c("span",{class:"rui-progress-segment","data-filled":h<b?"true":"false"}));return l.append(f),l}const p=c("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":n?null:String(a),"data-indeterminate":n?"true":"false"});if(s!==null){const f=Math.round(s/r*100);p.append(c("div",{class:"rui-progress-buffer",style:`width:${f}%`,"aria-hidden":"true"}))}return p.append(c("div",{class:"rui-progress-bar",style:n?"":`width:${i}%`})),l.append(p),l}},jm={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 n=m(e.id),a=c("label",{class:"rui-switch",for:n,"data-disabled":N(e.disabled)?"true":"false"}),i=N(e.value),o=c("input",{type:"checkbox",id:n,name:n,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:N(e.disabled)?"":null});o.checked=i;const s=c("span",{class:"rui-switch-track"},[c("span",{class:"rui-switch-thumb"})]),l=t.argMeta?.[2]?.stateRef;l&&r.bindState(o,l,{event:"change",getValue:p=>p.checked}),e.onChange!=null&&o.addEventListener("change",p=>{r.invoke(e.onChange,p.currentTarget.checked)});const u=m(e.label),d=m(e.description);if(a.append(o,s),u||d){const p=c("span",{class:"rui-switch-meta"});u&&p.append(c("span",{class:"rui-switch-label"},[u])),d&&p.append(c("span",{class:"rui-switch-description"},[d])),a.append(p)}return a}},Bm={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 n=m(e.value),a=m(e.variant,"outline"),i=m(e.size,"md"),o=c("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":a,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const l of T(e.items)){const{value:u,label:d,icon:p}=Om(l),f=u===n,b=c("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":f?"true":"false","data-variant":a,"data-size":i,"data-state":f?"on":"off","data-value":u}),h=L(p,{className:"rui-toggle-icon"});h&&b.append(h),b.append(c("span",{class:"rui-toggle-label"},[d])),b.onclick=()=>{s&&r.setState(s,u),r.invoke(e.onChange,u)},o.append(b)}return o}};function Om(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 Fm={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 n=m(e.side,"top"),a=c("span",{class:"rui-tooltip","data-side":n,tabindex:"0"});a.append(c("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=c("span",{class:"rui-tooltip-content",role:"tooltip"},[m(e.label)]);return i.append(c("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),a.append(i),a.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===a||a.contains(document.activeElement))&&document.activeElement?.blur?.()})}),a}},_m={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 n=c("span",{class:"rui-hover-card","data-side":m(e.side,"bottom"),"data-open":N(e.open)?"true":null,tabindex:"0"});n.append(c("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const a=c("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of T(e.content))a.append(r.renderNode(i));return n.append(a),n}},Cn={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"}},Um={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 n=Math.max(1,Math.floor(I(e.max,5))),a=m(e.size,"md"),i=N(e.halfStep),o=t.argMeta?.[0]?.stateRef,s=(N(e.interactive)||e.onChange!=null)&&!N(e.readonly),u=s&&!o?r.useInstanceState("rating-value",I(e.value,0)):null,d=I(u?u.get():e.value,0),p=Math.max(0,Math.min(n,d)),f=qm(m(e.icon)),b=c("div",{class:"rui-rating","data-size":a,"data-interactive":s?"true":"false","data-half-step":s&&i?"true":"false",role:"img","aria-label":`${p} of ${n}`}),h=c("span",{class:"rui-rating-stars"});for(let v=1;v<=n;v+=1){const x=Math.max(0,Math.min(1,p-(v-1))),w=x>=1?f.full:x>0?f.half:f.empty,k=Xt(w).join(" "),A=c(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 ${v}`:null,"aria-hidden":s?null:"true"});if(s){const S=v,$=v-.5;A.onclick=C=>{const M=C,E=M.currentTarget??M.target;let R=S;if(i){const _=E.getBoundingClientRect();_.width>0&&M.clientX-_.left<_.width/2&&(R=$)}o&&r.setState(o,R),u&&u.set(R),Hm(E.closest(".rui-rating"),R,n,f),r.invoke(e.onChange,R)}}h.append(A)}b.append(h);const g=m(e.label);g&&b.append(c("span",{class:"rui-rating-label"},[g]));const y=e.count!=null?I(e.count,0):null;return y!==null&&y>0&&b.append(c("span",{class:"rui-rating-count"},[`(${y.toLocaleString()})`])),b}};function Hm(t,e,r,n){if(!t)return;t.querySelectorAll(".rui-rating-star").forEach((i,o)=>{const s=Math.max(0,Math.min(1,e-o)),l=s>=1?n.full:s>0?n.half:n.empty;i.setAttribute("data-fill",s>=1?"full":s>0?"half":"empty"),i.className=`rui-rating-star ${Xt(l).join(" ")}`.trim()}),t.setAttribute("aria-label",`${Math.max(0,Math.min(r,e))} of ${r}`)}function qm(t){const e=t.trim().toLowerCase();return e?Cn[e]?Cn[e]:{full:e,half:e,empty:`regular:${e}`}:Cn.star}const Vm={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,I(e.max,100)),n=N(e.indeterminate),a=Math.max(0,Math.min(r,I(e.value,0))),i=Math.round(a/r*100),o=m(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,l=o==="lg"?10:o==="sm"?6:8,u=(s-l)/2,d=2*Math.PI*u,p=n?d*.65:d*(1-i/100),f=c("div",{class:"rui-progress-ring","data-tone":m(e.tone,"primary"),"data-size":o,"data-indeterminate":n?"true":"false"}),b=c("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",g=document.createElementNS(h,"svg");g.setAttribute("width",String(s)),g.setAttribute("height",String(s)),g.setAttribute("viewBox",`0 0 ${s} ${s}`),g.setAttribute("class","rui-progress-ring-svg");const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-track"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(u)),y.setAttribute("stroke-width",String(l)),y.setAttribute("fill","none"),g.appendChild(y);const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-bar"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(u)),v.setAttribute("stroke-width",String(l)),v.setAttribute("fill","none"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-dasharray",String(d)),v.setAttribute("stroke-dashoffset",String(p)),g.appendChild(v),b.append(g);const x=m(e.label,n?"…":`${i}%`),w=c("span",{class:"rui-progress-ring-value"}),k=L(x,{className:"rui-progress-ring-icon"});k&&Xt(x).length>0?w.append(k):w.append(document.createTextNode(x)),b.append(w),f.append(b);const A=m(e.caption);return A&&f.append(c("span",{class:"rui-progress-ring-caption"},[A])),f}},Wm={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"),n=c("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&n.append(wo(m(e.avatarSrc),m(e.author)));const a=c("div",{class:"rui-chat-bubble-bubble"}),i=c("header",{class:"rui-chat-bubble-head"});i.append(c("span",{class:"rui-chat-bubble-author"},[m(e.author)]));const o=m(e.time);o&&i.append(c("span",{class:"rui-chat-bubble-time"},[o])),a.append(i),a.append(c("p",{class:"rui-chat-bubble-body"},[m(e.body)]));const s=m(e.status);return s&&a.append(c("span",{class:"rui-chat-bubble-status","data-status":s},[s])),n.append(a),r==="me"&&n.append(wo(m(e.avatarSrc),m(e.author))),n}};function wo(t,e){const r=c("span",{class:"rui-chat-bubble-avatar"}),n=re(t);return n?r.append(c("img",{src:n,alt:e,loading:"lazy"})):r.append(c("span",{class:"rui-chat-bubble-fallback"},[yt(e)])),r}const Gm={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"),n=c("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&&n.append(c("span",{class:"rui-kbd-sep"},["+"])),n.append(c("kbd",{class:"rui-kbd"},[s])))}),n}},Km={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 n=N(e.open),a=r.useInstanceState("open",n),i=a.get(),o=X(e.width,""),s=c("div",{class:"rui-popover","data-open":i?"true":"false","data-side":m(e.side,"bottom"),"data-align":m(e.align,"start")}),l=c("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});l.append(r.renderNode(e.trigger)),s.append(l);const u=c("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),d=c("div",{class:"rui-popover-header"}),p=m(e.title);d.append(p?c("div",{class:"rui-popover-title"},[p]):c("span",{class:"rui-popover-title-spacer"}));const f=c("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);f.onclick=b=>{b.stopPropagation(),mr(f,!1,a)},d.append(f),u.append(d);for(const b of T(e.content))u.append(r.renderNode(b));return s.append(u),l.onclick=b=>{b.stopPropagation();const h=b.currentTarget??b.target,g=!a.get(),y=mr(h,g,a);g&&y&&ko(y,a)},l.onkeydown=b=>{const h=b,g=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const y=!a.get(),v=mr(g,y,a);y&&v&&ko(v,a)}else h.key==="Escape"&&a.get()&&(h.preventDefault(),mr(g,!1,a))},s}},mr=(t,e,r)=>{r.set(e);const n=t.closest(".rui-popover");if(!n)return null;n.setAttribute("data-open",e?"true":"false");const a=n.querySelector(".rui-popover-trigger");return a?.setAttribute("aria-expanded",e?"true":"false"),a?.setAttribute("data-state",e?"open":"closed"),e||Ue(n),n},ko=(t,e)=>{xt({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")}})},Ym=["default","primary","success","warning","danger","info"],So=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],Xm={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:Ym,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:So,description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const n=m(e.tone,"default"),a=m(e.position),i=c("div",{class:a?"rui-toast rui-toast-standalone":"rui-toast",role:n==="danger"?"alert":"status","aria-live":n==="danger"?"assertive":"polite","data-tone":n,"data-position":a||null}),o=m(e.icon)||Qm(n),s=L(o,{className:"rui-toast-icon"});s&&i.append(s);const l=c("div",{class:"rui-toast-body"});l.append(c("div",{class:"rui-toast-title"},[m(e.title)]));const u=m(e.message);if(u&&l.append(c("div",{class:"rui-toast-message"},[u])),e.action){const x=c("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),l.append(x)}i.append(l);const d=r.useInstanceState("dismissed",!1),p=r.useInstanceState("timer",null),f=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},b=()=>{const x=p.get();x!==null&&(clearTimeout(x),p.set(null))},h=r.useInstanceState("removal-timer",null),g=x=>{if(d.get())return;d.set(!0),b();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)},y=c("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);y.onclick=x=>{x.stopPropagation(),g(x.currentTarget??x.target)},i.append(y);const v=I(e.duration,0);if(v>0&&p.get()===null&&!d.get()){const x=setTimeout(()=>{p.set(null),!d.get()&&i.isConnected&&g()},v);p.set(x),r.registerDisposer(()=>{const w=p.get();w!==null&&(clearTimeout(w),p.set(null))},"auto-dismiss-timer")}return d.get()?c("div",{class:"rui-toast-placeholder",hidden:""}):i}},Zm={name:"Toasts",description:"Stacked container for transient `Toast` notifications, pinned to a viewport corner. Render the reactive `$toast.items` list into it: `Toasts($toast.items.map(t => Toast({ title: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))`. Use a standalone `Toast` with `position` for a single one-off notice.",props:[{name:"children",type:"Node[]",description:"Toast components to stack"},{name:"position",type:"string",optional:!0,enum:So,description:'Viewport corner the stack pins to (default "top-right")'}],render:(t,e,r)=>{const n=c("div",{class:"rui-toasts","data-position":m(e.position,"top-right"),"aria-live":"off"});for(const a of T(e.children))n.append(r.renderNode(a));return n}};function Qm(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 $o={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=c("li",{class:"rui-breadcrumb-item"}),n=m(e.label),a=m(e.href),i=a?Fe(a):"",o=[],s=L(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(c("span",{class:"rui-breadcrumb-label"},[n])),i)r.append(c("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const l=c("span",{class:"rui-breadcrumb-current"});for(const u of o)u&&l.append(typeof u=="string"?document.createTextNode(u):u);r.append(l)}return r}},Jm={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 n=T(e.items),a=m(e.separator,"/"),i=c("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=c("ol",{class:"rui-breadcrumb-list"});return n.forEach((s,l)=>{if(l>0&&o.append(c("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[a])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const u=m(s),d=l===n.length-1;o.append($o.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:u,href:d?"":"#"},r))}),i.append(o),i}},ef=[10,20,50,100],tf={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 n=Math.max(1,Math.floor(I(e.totalPages,1))),a=Math.max(1,Math.min(n,Math.floor(I(e.page,1)))),i=Math.max(0,Math.floor(I(e.siblings,1))),o=N(e.compact),s=t.argMeta?.[0]?.stateRef,l=c("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),u=g=>{if(!s)return;const y=Math.max(1,Math.min(n,g));y!==a&&r.setState(s,y)},d=e.total!=null?Math.max(0,Math.floor(I(e.total,0))):null,p=e.perPage!=null?Math.max(1,Math.floor(I(e.perPage,0))):null;if(d!==null&&p&&p>0){const g=d===0?0:(a-1)*p+1,y=Math.min(d,a*p);l.append(c("span",{class:"rui-pagination-summary"},[d===0?"No results":`Showing ${g.toLocaleString()}–${y.toLocaleString()} of ${d.toLocaleString()}`]))}else d!==null&&l.append(c("span",{class:"rui-pagination-summary"},[`${d.toLocaleString()} result${d===1?"":"s"}`]));const f=c("div",{class:"rui-pagination-buttons"}),b=(g,y,v={})=>{if(v.ellipsis)return c("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[g]);const x=c("button",{type:"button",class:"rui-pagination-button","data-active":v.active?"true":"false","aria-current":v.active?"page":null,"aria-label":v.ariaLabel??null,disabled:v.disabled?"":null},[g]);return!v.disabled&&!v.active&&(x.onclick=()=>u(y)),x};if(f.append(b("‹",a-1,{disabled:a<=1,ariaLabel:"Previous page"})),o)f.append(c("span",{class:"rui-pagination-current"},[`${a} / ${n}`]));else{const g=rf(a,n,i);for(const y of g)y==="…"?f.append(b("…",0,{ellipsis:!0})):f.append(b(String(y),y,{active:y===a}))}f.append(b("›",a+1,{disabled:a>=n,ariaLabel:"Next page"})),l.append(f);const h=t.argMeta?.[4]?.stateRef;if(p&&(h||T(e.perPageOptions).length>0)){const g=T(e.perPageOptions).length>0?T(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(ef),y=c("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),v=c("select",{class:"rui-pagination-per-page-select"});for(const x of g){const w=c("option",{value:String(x),selected:x===p?"":null},[String(x)]);v.append(w)}h&&r.bindState(v,h,{event:"change",getValue:x=>Number(x.value)}),y.append(v),y.append(document.createTextNode(" per page")),l.append(y)}return l}};function rf(t,e,r){const n=[],a=(l,u)=>{for(let d=l;d<=u;d+=1)n.push(d)},i=r*2+5;if(e<=i)return a(1,e),n;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return n.push(1),o>2&&n.push("…"),a(o,s),s<e-1&&n.push("…"),n.push(e),n}const nf={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 n=m(e.label),a=e.icon,i=N(e.active),o=m(e.to),s=Fe(e.href,""),l=N(e.external),u=o||s?"a":"button",d=c(u,{class:"rui-navbar-item",type:u==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:l&&s?"_blank":null,rel:l&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),p=L(a,{className:"rui-navbar-item-icon"});return p&&d.append(p),d.append(c("span",{class:"rui-navbar-item-label"},[n])),o&&!s?d.onclick=f=>{if(f.defaultPrevented)return;const b=f;b.button!==0||b.metaKey||b.ctrlKey||b.shiftKey||b.altKey||(f.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(d.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),d}},af={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 n=c("nav",{class:"rui-navbar","data-sticky":N(e.sticky)?"true":"false","data-variant":m(e.variant,"default"),"aria-label":"Primary"}),a=e.brand;if(a!=null&&a!==""){const s=c("div",{class:"rui-navbar-brand"});typeof a=="string"?s.append(document.createTextNode(a)):s.append(r.renderNode(a)),n.append(s)}const i=T(e.items);if(i.length>0){const s=c("div",{class:"rui-navbar-items"});for(const l of i)s.append(r.renderNode(l));n.append(s)}const o=T(e.actions);if(o.length>0){const s=c("div",{class:"rui-navbar-actions"});for(const l of o)s.append(r.renderNode(l));n.append(s)}return n}},of=["bottom","top","left","right"],sf=["start","center","end"],lf=["default","danger"],fr=(t,e,r)=>{r.set(e);const n=t.closest(".rui-dropdown-menu");return n?(n.setAttribute("data-open",e?"true":"false"),n.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||Ue(n),n):null},Co=(t,e)=>{xt({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},An=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},cf={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:of,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:sf,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 n=N(e.open),a=r.useInstanceState("open",n),i=a.get(),o=c("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":m(e.side,"bottom"),"data-align":m(e.align,"start")}),s=c("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 d=u.currentTarget??u.target,p=!a.get(),f=fr(d,p,a);p&&f&&Co(f,a)},s.onkeydown=u=>{const d=u,p=d.currentTarget??d.target;if(d.key==="Enter"||d.key===" "){d.preventDefault();const f=!a.get(),b=fr(p,f,a);f&&b&&Co(b,a);return}d.key==="Escape"&&a.get()&&(d.preventDefault(),fr(p,!1,a))},o.append(s);const l=c("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":m(e.label)||null});for(const u of T(e.items)){if(An(u,"MenuItem")){const d=u.args??[],p=m(d[0]),f=d[1],b=d[2],h=m(d[3]),g=m(d[4],"default"),y=N(d[5]),v=c("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":g,disabled:y?"":null}),x=L(b,{className:"rui-menu-item-icon"});x&&v.append(x),v.append(c("span",{class:"rui-menu-item-label"},[p])),h&&v.append(c("span",{class:"rui-menu-item-shortcut"},[h])),y||(v.onclick=w=>{const k=w.currentTarget??w.target;fr(k,!1,a),r.invoke(f)}),l.append(v);continue}if(An(u,"MenuSeparator")){l.append(c("div",{class:"rui-menu-separator",role:"separator"}));continue}if(An(u,"MenuLabel")){const d=m((u.args??[])[0]);l.append(c("div",{class:"rui-menu-label"},[d]));continue}l.append(r.renderNode(u))}return o.append(l),o}},uf={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:lf,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=N(e.disabled),a=c("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":m(e.variant,"default"),disabled:n?"":null}),i=L(e.icon,{className:"rui-menu-item-icon"});i&&a.append(i),a.append(c("span",{class:"rui-menu-item-label"},[m(e.label)]));const o=m(e.shortcut);return o&&a.append(c("span",{class:"rui-menu-item-shortcut"},[o])),n||(a.onclick=()=>{r.invoke(e.onClick)}),a}},df={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>c("div",{class:"rui-menu-separator",role:"separator"})},pf={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)=>c("div",{class:"rui-menu-label"},[m(e.label)])},mf=["left","center","right"];function ff(t){return T(t).map((e,r)=>{const n=e.args??[],a=m(n[0]);return{header:a,values:T(n[1]),format:m(n[2],"text"),align:mf.includes(m(n[3]))?m(n[3]):"",sortable:N(n[4]),filterable:N(n[5]),render:n[6],onClick:n[7],key:a||`col-${r}`}})}function Ao(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return I(t,0)-I(e,0);if(r==="date"){const n=new Date(m(t)).getTime(),a=new Date(m(e)).getTime();if(Number.isFinite(n)&&Number.isFinite(a))return n-a}return m(t).localeCompare(m(e))}function It(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)}}function To(t){return/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function gf(t,e){const r=t.map(a=>To(a.header)).join(","),n=e.map(a=>t.map(i=>To(It(i.values[a],i.format))).join(","));return[r,...n].join(`\r
|
|
99
|
-
`)}function hf(t,e){try{if(typeof Blob>"u"||typeof URL>"u"||typeof document>"u")return;const r=URL.createObjectURL(new Blob([t],{type:"text/csv;charset=utf-8"})),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}catch{}}const bf={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"},{name:"exportable",type:"boolean",optional:!0,description:"Show an Export CSV button that downloads the filtered rows"},{name:"exportFilename",type:"string",optional:!0,description:"CSV download filename (default `data.csv`)"}],render:(t,e,r)=>{const n=ff(e.columns),a=Math.max(0,...n.map(F=>F.values.length)),i=T(e.rowIds),o=F=>m(i[F]??F),s=e.sort&&typeof e.sort=="object"?e.sort:null,l=m(s?.key),u=m(s?.direction,"asc")==="desc"?"desc":"asc",d=T(e.selectedIds).map(F=>m(F)),p=new Set(d),f=N(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,b=e.stickyHeader===void 0?!0:N(e.stickyHeader),h=N(e.stickyFirstColumn),g=m(e.density,"comfortable"),y=N(e.striped),v=r.useInstanceState("filters",{}),x=v.get(),w=[];for(let F=0;F<a;F+=1){let Z=!0;for(const J of n){if(!J.filterable)continue;const ee=(x[J.key]??"").trim().toLowerCase();if(!ee)continue;const le=J.values[F];if(!It(le,J.format).toLowerCase().includes(ee)){Z=!1;break}}Z&&w.push(F)}if(l){const F=n.find(Z=>Z.key===l);F&&F.sortable&&w.sort((Z,J)=>{const ee=Ao(F.values[Z],F.values[J],F.format);return u==="desc"?-ee:ee})}const k=w.length,A=Math.max(1,Math.floor(I(e.perPage,20))),S=Math.max(1,Math.ceil(k/A)),$=Math.max(1,Math.floor(I(e.page,1))),C=Math.min($,S),M=w.slice((C-1)*A,C*A),E=c("div",{class:"rui-data-grid","data-density":g,"data-striped":y?"true":"false","data-sticky-header":b?"true":"false","data-sticky-first":h?"true":"false"}),R=t.argMeta?.[3]?.stateRef,_=t.argMeta?.[4]?.stateRef,B=t.argMeta?.[6]?.stateRef,U=T(e.toolbar);if(d.length>0&&U.length>0){const F=c("div",{class:"rui-data-grid-bulk"});F.append(c("span",{class:"rui-data-grid-bulk-count"},[`${d.length} selected`]));const Z=c("div",{class:"rui-data-grid-bulk-tools"});for(const J of U)Z.append(r.renderNode(J));F.append(Z),E.append(F)}if(N(e.exportable)){const F=c("div",{class:"rui-data-grid-toolbar"}),Z=c("button",{type:"button",class:"rui-data-grid-export"}),J=L("download",{className:"rui-data-grid-export-icon"});J&&Z.append(J),Z.append(c("span",{},["Export CSV"])),Z.onclick=()=>{const ee=gf(n,w);hf(ee,m(e.exportFilename,"data.csv")||"data.csv")},F.append(Z),E.append(F)}const O=c("div",{class:"rui-data-grid-scroll"}),Q=c("table",{class:"rui-data-grid-table"}),ye=m(e.caption);ye&&Q.append(c("caption",{class:"rui-data-grid-caption"},[ye]));const Re=c("thead"),Vt=c("tr");if(f){const F=c("th",{class:"rui-data-grid-cell-select",scope:"col"}),Z=M.length>0&&M.every(ee=>p.has(o(ee))),J=c("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:Z?"":null});_&&(J.onclick=ee=>{const le=ee.currentTarget,ae=new Set(d);for(const te of M){const ne=o(te);le.checked?ae.add(ne):ae.delete(ne)}r.setState(_,Array.from(ae))}),F.append(J),Vt.append(F)}if(n.forEach((F,Z)=>{const J=c("th",{scope:"col","data-align":F.align||null,"data-sortable":F.sortable?"true":null,"data-active":F.sortable&&F.key===l?"true":null,"data-first":Z===0?"true":null});if(F.sortable&&R){const ee=c("button",{type:"button",class:"rui-data-grid-sort"});ee.append(c("span",{},[F.header]));const le=F.key===l?u==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",ae=L(le,{className:"rui-data-grid-sort-icon"});ae&&ee.append(ae),ee.onclick=()=>{const te=F.key===l&&u==="asc"?"desc":"asc";r.setState(R,{key:F.key,direction:te})},J.append(ee)}else J.append(document.createTextNode(F.header));Vt.append(J)}),Re.append(Vt),n.some(F=>F.filterable)){const F=c("tr",{class:"rui-data-grid-filter-row"});f&&F.append(c("td",{class:"rui-data-grid-cell-select"})),n.forEach(Z=>{const J=c("td");if(Z.filterable){const ee=c("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${Z.header}`,value:x[Z.key]??""});ee.oninput=le=>{const ae=le.currentTarget,te={...v.get(),[Z.key]:ae.value};v.set(te);const ne=ae.closest("table")?.querySelector("tbody");ow(ne)},J.append(ee)}F.append(J)}),Re.append(F)}Q.append(Re);const ut=c("tbody");Q.append(ut);const $a=F=>{if(ut.replaceChildren(),F.length===0){const Z=c("tr"),J=(f?1:0)+Math.max(n.length,1);Z.append(c("td",{colspan:String(J),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),ut.append(Z);return}for(const Z of F){const J=o(Z),ee=p.has(J),le=c("tr",{"data-selected":ee?"true":null});if(f){const ae=c("td",{class:"rui-data-grid-cell-select"}),te=c("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:ee?"":null});_&&(te.onclick=ne=>{ne.stopPropagation();const Ne=ne.currentTarget,Ie=new Set(d);Ne.checked?Ie.add(J):Ie.delete(J),r.setState(_,Array.from(Ie))}),ae.append(te),le.append(ae)}n.forEach((ae,te)=>{const ne=c("td",{"data-format":ae.format,"data-align":ae.align||null,"data-first":te===0?"true":null});Zr(ne,ae,ae.values[Z],Z,r,It),le.append(ne)}),typeof e.onRowClick=="function"&&(le.setAttribute("data-clickable","true"),le.onclick=ae=>{ae.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,Z)}),ut.append(le)}},ow=F=>{const Z=F??ut,J=v.get(),ee=[];for(let te=0;te<a;te+=1){let ne=!0;for(const Ne of n){if(!Ne.filterable)continue;const Ie=(J[Ne.key]??"").trim().toLowerCase();if(!Ie)continue;const Wt=Ne.values[te];if(!It(Wt,Ne.format).toLowerCase().includes(Ie)){ne=!1;break}}ne&&ee.push(te)}if(l){const te=n.find(ne=>ne.key===l);te&&te.sortable&&ee.sort((ne,Ne)=>{const Ie=Ao(te.values[ne],te.values[Ne],te.format);return u==="desc"?-Ie:Ie})}const le=ee.slice((C-1)*A,C*A);(te=>{te.replaceChildren();for(const ne of le){const Ne=o(ne),Ie=p.has(Ne),Wt=c("tr",{"data-selected":Ie?"true":null});if(f){const dt=c("td",{class:"rui-data-grid-cell-select"}),Ca=c("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:Ie?"":null});dt.append(Ca),Wt.append(dt)}n.forEach((dt,Ca)=>{const Fl=c("td",{"data-format":dt.format,"data-align":dt.align||null,"data-first":Ca===0?"true":null});Zr(Fl,dt,dt.values[ne],ne,r,It),Wt.append(Fl)}),te.append(Wt)}if(le.length===0){const ne=c("tr"),Ne=(f?1:0)+Math.max(n.length,1);ne.append(c("td",{colspan:String(Ne),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),te.append(ne)}})(Z)};if($a(M),O.append(Q),E.append(O),k>A){const F=c("div",{class:"rui-data-grid-footer"}),Z=k===0?0:(C-1)*A+1,J=Math.min(k,C*A);F.append(c("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${Z}–${J} of ${k}`]));const ee=c("div",{class:"rui-data-grid-footer-buttons"}),le=c("button",{type:"button",class:"rui-data-grid-page-button",disabled:C<=1?"":null},["‹ Prev"]),ae=c("button",{type:"button",class:"rui-data-grid-page-button",disabled:C>=S?"":null},["Next ›"]);B&&(le.onclick=()=>{C<=1||r.setState(B,C-1)},ae.onclick=()=>{C>=S||r.setState(B,C+1)}),ee.append(le),ee.append(c("span",{class:"rui-data-grid-page-current"},[`${C} / ${S}`])),ee.append(ae),F.append(ee),E.append(F)}return E}};function vf(t){const e=[];for(const r of T(t)){if(!r||typeof r!="object")continue;const n=r,a=m(n.date);a&&e.push({date:a,title:m(n.title),tone:m(n.tone,"primary"),time:m(n.time)})}return e}function Mo(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-a),r}function No(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${n}`}const yf={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 n=m(e.view,"month"),a=vf(e.events),i=m(e.value),o=m(e.month,i),s=new Date;let l=new Date(NaN);if(o){const A=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(A)l=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())||(l=S)}}Number.isNaN(l.getTime())&&(l=s);const u=(I(e.firstDay,1)%7+7)%7,d=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",p=new Map;for(const A of a){const S=A.date.slice(0,10),$=p.get(S)??[];$.push(A),p.set(S,$)}const f=t.argMeta?.[0]?.stateRef,b=c("div",{class:"rui-calendar","data-view":n}),h=c("div",{class:"rui-calendar-header"}),g=l.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(c("div",{class:"rui-calendar-title"},[g])),b.append(h);const y=c("div",{class:"rui-calendar-weekrow"}),v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let A=0;A<7;A+=1){const S=v[(u+A)%7]??"";y.append(c("div",{class:"rui-calendar-weekday"},[S]))}b.append(y);const x=[];if(n==="week"){const A=d?new Date(d):l,S=Mo(A,u);for(let $=0;$<7;$+=1){const C=new Date(S);C.setDate(S.getDate()+$),x.push({date:C,inMonth:C.getMonth()===l.getMonth()})}}else{const A=new Date(l.getFullYear(),l.getMonth(),1),S=new Date(l.getFullYear(),l.getMonth()+1,0),$=Mo(A,u),C=Math.ceil((S.getDate()+(A.getDay()-u+7)%7)/7)*7;for(let M=0;M<C;M+=1){const E=new Date($);E.setDate($.getDate()+M),x.push({date:E,inMonth:E.getMonth()===l.getMonth()})}}const w=c("div",{class:"rui-calendar-grid","data-view":n}),k=No(s);for(const A of x){const S=No(A.date),$=S===k,C=S===d,M=p.get(S)??[],E=c("button",{type:"button",class:"rui-calendar-day","data-in-month":A.inMonth?"true":"false","data-today":$?"true":"false","data-selected":C?"true":"false","aria-label":A.date.toDateString()});if(E.append(c("span",{class:"rui-calendar-daynumber"},[String(A.date.getDate())])),M.length>0){const R=c("div",{class:"rui-calendar-day-events"}),_=M.slice(0,3);for(const B of _){const U=c("span",{class:"rui-calendar-event","data-tone":B.tone??"primary",title:B.time?`${B.time} — ${B.title}`:B.title},[B.title]);R.append(U)}M.length>3&&R.append(c("span",{class:"rui-calendar-event-more"},[`+${M.length-3} more`])),E.append(R)}E.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(E)}return b.append(w),b}};function xf(t){const e=[];for(const r of T(t)){if(!r||typeof r!="object")continue;const n=r;e.push({title:m(n.title),description:m(n.description),actor:m(n.actor),avatarSrc:m(n.avatarSrc),time:m(n.time),icon:m(n.icon),tone:m(n.tone,"default"),meta:m(n.meta)})}return e}function wf(t,e,r){const n=c("ol",{class:t,"data-variant":r});for(const a of e){const i=c("li",{class:`${t}-item`,"data-tone":a.tone}),o=c("span",{class:`${t}-marker`}),s=L(a.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const l=c("div",{class:`${t}-body`}),u=c("div",{class:`${t}-head`});a.actor&&u.append(c("span",{class:`${t}-actor`},[a.actor])),u.append(c("span",{class:`${t}-title`},[a.title])),a.time&&u.append(c("span",{class:`${t}-time`},[a.time])),l.append(u),a.description&&l.append(c("p",{class:`${t}-description`},[a.description])),a.meta&&l.append(c("span",{class:`${t}-meta`},[a.meta])),i.append(l),n.append(i)}return n}const kf={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 wf(r==="audit"?"rui-audit-trail":"rui-activity-log",xf(e.items),r)}},Sf={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 n=T(e.columns).map(f=>m(f)),a=T(e.rows).map(f=>{const b=f??{};return{label:m(b.label),values:T(b.values),hint:m(b.hint),group:m(b.group)}}),i=Math.floor(I(e.highlightColumn,-1)),o=c("div",{class:"rui-comparison-table"}),s=c("table"),l=c("thead"),u=c("tr");u.append(c("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),n.forEach((f,b)=>{u.append(c("th",{scope:"col","data-highlight":b===i?"true":null},[f]))}),l.append(u),s.append(l);const d=c("tbody");let p="";for(const f of a){if(f.group&&f.group!==p){p=f.group;const g=c("tr",{class:"rui-comparison-table-group"});g.append(c("td",{colspan:String(n.length+1)},[f.group])),d.append(g)}const b=c("tr"),h=c("td",{class:"rui-comparison-table-feature"});h.append(c("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&h.append(c("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),b.append(h);for(let g=0;g<n.length;g+=1){const y=f.values[g],v=c("td",{"data-highlight":g===i?"true":null});if(y===!0){const x=L("circle-check",{className:"rui-comparison-yes"});x?v.append(x):v.textContent="✓"}else y===!1||y===null||y===void 0?v.append(c("span",{class:"rui-comparison-no"},["—"])):y&&typeof y=="object"&&y.__kind==="Component"?v.append(r.renderNode(y)):v.textContent=m(y);b.append(v)}d.append(b)}return s.append(d),o.append(s),o}},$f={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 n=c("div",{class:"rui-infinite-list"}),a=c("div",{class:"rui-infinite-list-body"});for(const s of T(e.items))a.append(r.renderNode(s));n.append(a);const i=e.hasMore===void 0?!0:N(e.hasMore),o=N(e.loading);if(i){const s=c("div",{class:"rui-infinite-list-sentinel"});if(o){const l=L("spinner",{className:"rui-infinite-list-spin"});l&&s.append(l),s.append(c("span",{},[m(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const l=c("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);l.onclick=()=>r.invoke(e.onLoadMore),s.append(l)}if(n.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const l=e.onLoadMore,u=new IntersectionObserver(d=>{for(const p of d)if(p.isIntersecting){r.invoke(l);break}});u.observe(s),r.registerDisposer(()=>u.disconnect(),"infinite-observer")}}return n}},Cf=/^(https?:|blob:|data:(audio|video)\/)/i;function gr(t){const e=m(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":Cf.test(e)?e:"":""}const Af={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=c("figure",{class:"rui-video-player"}),n=Tn(m(e.ratio,"16:9")),a=c("div",{class:"rui-video-player-frame",style:`aspect-ratio:${n};`}),i=e.controls===void 0?!0:N(e.controls),o=c("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:N(e.autoplay)?"":null,loop:N(e.loop)?"":null,muted:N(e.muted)?"":null,poster:re(e.poster)||null,playsinline:"",preload:"metadata"}),s=T(e.sources);if(s.length>0)for(const u of s){if(!u||typeof u!="object")continue;const d=u,p=gr(d.src);p&&o.append(c("source",{src:p,type:m(d.type)||null}))}else{const u=gr(e.src);u&&o.setAttribute("src",u)}a.append(o),r.append(a);const l=m(e.caption);return l&&r.append(c("figcaption",{class:"rui-video-player-caption"},[l])),r}},Tf={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=c("div",{class:"rui-audio-player"}),n=c("div",{class:"rui-audio-player-meta"}),a=L(m(e.icon,"music"),{className:"rui-audio-player-icon"});a&&n.append(a);const i=c("div",{class:"rui-audio-player-text"}),o=m(e.title);o&&i.append(c("div",{class:"rui-audio-player-title"},[o]));const s=m(e.artist);s&&i.append(c("div",{class:"rui-audio-player-artist"},[s])),n.append(i),r.append(n);const l=e.controls===void 0?!0:N(e.controls),u=c("audio",{class:"rui-audio-player-audio",controls:l?"":null,autoplay:N(e.autoplay)?"":null,loop:N(e.loop)?"":null,preload:"metadata"}),d=T(e.sources);if(d.length>0)for(const p of d){if(!p||typeof p!="object")continue;const f=p,b=gr(f.src);b&&u.append(c("source",{src:b,type:m(f.type)||null}))}else{const p=gr(e.src);p&&u.setAttribute("src",p)}return r.append(u),r}};function Mf(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=re(t);return r?c("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,n=re(r.src);if(n){const a=c("figure",{class:"rui-carousel-figure"});a.append(c("img",{src:n,alt:m(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=m(r.caption??r.title);return i&&a.append(c("figcaption",{class:"rui-carousel-caption"},[i])),a}}return e.renderNode(t)}const Nf={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 n=T(e.items),a=n.length,i=Math.max(0,Math.min(Math.max(a-1,0),Math.floor(I(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=a&&(s=0,o.set(s));const l=e.showDots===void 0?!0:N(e.showDots),u=e.showArrows===void 0?!0:N(e.showArrows),d=Tn(m(e.ratio,"16:9")),p=c("div",{class:"rui-carousel"}),f=c("div",{class:"rui-carousel-frame",style:`aspect-ratio:${d};`}),b=c("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});n.forEach(g=>{const y=c("div",{class:"rui-carousel-slide"}),v=Mf(g,r);v&&y.append(v),b.append(y)}),f.append(b);const h=(g,y)=>{const v=(y%a+a)%a;o.set(v);const x=g.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${v*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,A)=>{k.setAttribute("data-active",A===v?"true":"false")})};if(u&&a>1){const g=c("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),y=L("chevron-left");y&&g.append(y);const v=c("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=L("chevron-right");x&&v.append(x),g.onclick=w=>h(w.currentTarget,o.get()-1),v.onclick=w=>h(w.currentTarget,o.get()+1),f.append(g,v)}if(p.append(f),l&&a>1){const g=c("div",{class:"rui-carousel-dots"});n.forEach((y,v)=>{const x=c("button",{type:"button",class:"rui-carousel-dot","data-active":v===s?"true":"false","aria-label":`Go to slide ${v+1}`});x.onclick=w=>h(w.currentTarget,v),g.append(x)}),p.append(g)}return p}},If={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 n=T(e.items),a=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Tn(m(e.ratio,"1:1")),o=c("div",{class:"rui-gallery","data-columns":a>0?String(a):null});return n.forEach((s,l)=>{const{src:u,alt:d,caption:p}=Io(s),f=re(u),b=typeof e.onSelect=="function",h=c(b?"button":"figure",{type:b?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(l)});if(f)h.append(c("img",{src:f,alt:d,loading:"lazy"}));else{const g=L("image",{className:"rui-gallery-placeholder"});g&&h.append(g)}p&&h.append(c("span",{class:"rui-gallery-caption"},[p])),b&&(h.onclick=()=>r.invoke(e.onSelect,l,s)),o.append(h)}),o}};function Io(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 Pf={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 n=T(e.items).map($=>Io($)).filter($=>re($.src)!==""),a=n.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),l=r.useInstanceState("index",0),u=o?N(e.open):s.get(),d=i?Math.floor(I(e.index,0)):l.get(),p=a===0?0:(d%a+a)%a,f=$=>{o?r.setState(o,$):s.set($)},b=$=>{i?r.setState(i,$):l.set($)},h=()=>f(!1),g=$=>{a!==0&&b(((p+$)%a+a)%a)},y=c("div",{class:"rui-lightbox-root"});if(!o&&a>0){const $=n[p],C=c("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const M=re($.src);M&&C.append(c("img",{src:M,alt:$.alt,loading:"lazy"}))}C.onclick=M=>{M.stopPropagation(),f(!0)},y.append(C)}const v=c("div",{class:"rui-lightbox-overlay","data-open":u?"true":"false"});if(y.append(v),!u||a===0)return y;const x=n[p];if(!x)return y;const w=re(x.src);v.onclick=$=>{$.target===v&&h()};const k=c("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),A=c("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(A.onclick=h,k.append(A),a>1){const $=c("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),C=L("chevron-left");C&&$.append(C),$.onclick=()=>g(-1);const M=c("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),E=L("chevron-right");E&&M.append(E),M.onclick=()=>g(1),k.append($,M)}const S=c("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(c("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(c("div",{class:"rui-lightbox-caption"},[x.caption])),a>1&&k.append(c("div",{class:"rui-lightbox-counter"},[`${p+1} / ${a}`])),v.append(k),y}};function Ef(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=I(e.lat??e.latitude,NaN),n=I(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(n))return{lat:r,lng:n}}if(Array.isArray(t)&&t.length>=2){const e=I(t[0],NaN),r=I(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 zf={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=c("figure",{class:"rui-map"}),n=X(e.height,"320px"),a=c("div",{class:"rui-map-frame",style:`height:${n};`}),i=I(e.lat,NaN),o=I(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){a.append(c("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(a);const g=m(e.caption);return g&&r.append(c("figcaption",{class:"rui-map-caption"},[g])),r}const l=Math.max(1,Math.min(18,Math.floor(I(e.zoom,13)))),u=1/Math.pow(2,l-8),p=`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=c("iframe",{class:"rui-map-iframe",src:p,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});a.append(f),r.append(a);const b=T(e.markers).map(g=>{const y=Ef(g),v=g&&typeof g=="object"?m(g.label):"";return y?{...y,label:v}:null}).filter(g=>g!==null);if(b.length>0){const g=c("ul",{class:"rui-map-markers"});for(const y of b){const v=c("li",{class:"rui-map-marker"}),x=L("location-dot",{className:"rui-map-marker-icon"});x&&v.append(x),v.append(c("span",{class:"rui-map-marker-label"},[y.label||`${y.lat.toFixed(4)}, ${y.lng.toFixed(4)}`])),g.append(v)}r.append(g)}const h=m(e.caption);return h&&r.append(c("figcaption",{class:"rui-map-caption"},[h])),r}};function Tn(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const Rf=[{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"}],Lf={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 n=m(e.id),a=m(e.placeholder,"Start writing…"),i=N(e.disabled),o=c("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=c("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const b of Rf){const h=c("button",{type:"button",class:"rui-rich-text-tool","data-command":b.command,"data-block":b.block??null,"aria-label":b.label,title:b.label,disabled:i?"":null}),g=L(b.icon);g&&h.append(g),h.onmousedown=y=>y.preventDefault(),h.onclick=y=>{const x=y.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(b.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else b.command==="formatBlock"&&b.block?document.execCommand("formatBlock",!1,b.block):document.execCommand(b.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(h)}o.append(s);const l=m(e.value)||"",u=b=>b.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,d=c("div",{class:"rui-rich-text-content",id:n,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":a,"data-placeholder":a,"data-empty":u(l)?"true":"false",style:`min-height:${m(e.minHeight,"160px")};`,html:l}),p=b=>{b.setAttribute("data-empty",u(b.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(d,f,{event:"input",getValue:b=>{const h=b;return p(h),h.innerHTML}}):d.oninput=b=>{const h=b.currentTarget??b.target;p(h)},d.onblur=b=>{const h=b.currentTarget??b.target;p(h)},ce(d,e.onChange,r,{event:"input",getValue:b=>b.innerHTML}),o.append(d),o}},Df={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 n=m(e.id),a=m(e.value),i=m(e.language,"text"),o=e.showGutter===void 0?!0:N(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(I(e.tabSize,2)))),l=N(e.readonly),u=m(e.minHeight,"200px"),d=c("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),p=c("div",{class:"rui-code-editor-head"});p.append(c("span",{class:"rui-code-editor-language"},[i])),d.append(p);const f=c("div",{class:"rui-code-editor-body",style:`min-height:${u};`}),b=c("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((v=>{b.replaceChildren();const x=v.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)b.append(c("span",{class:"rui-code-editor-line"},[String(k)]))})(a),f.append(b));const g=c("textarea",{class:"rui-code-editor-textarea",id:n,name:n,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:m(e.placeholder),readonly:l?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});g.value=a,g.oninput=v=>{const x=v.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(c("span",{class:"rui-code-editor-line"},[String($)]))},g.onkeydown=v=>{const x=v;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 y=t.argMeta?.[1]?.stateRef;return y&&!l&&r.bindState(g,y,{event:"input",getValue:v=>v.value}),l||ce(g,e.onChange,r,{event:"input",getValue:v=>v.value}),f.append(g),d.append(f),d}};function jf(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const n=e.args;return{label:m(n[0]),action:n[1],icon:m(n[2]),shortcut:m(n[3]),variant:m(n[4],"default"),disabled:N(n[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:N(r.disabled),separator:!1}}return null}const Bf={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 n=c("div",{class:"rui-context-menu"}),a=c("div",{class:"rui-context-menu-target"});a.append(r.renderNode(e.target)),n.append(a);const i=c("div",{class:"rui-context-menu-pop",role:"menu","aria-label":m(e.label)||null,"data-open":"false"}),o=T(e.items).map(jf).filter(u=>u!==null);for(const u of o){if(u.separator){i.append(c("div",{class:"rui-menu-separator",role:"separator"}));continue}const d=c("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":u.variant,disabled:u.disabled?"":null}),p=L(u.icon,{className:"rui-menu-item-icon"});p&&d.append(p),d.append(c("span",{class:"rui-menu-item-label"},[u.label])),u.shortcut&&d.append(c("span",{class:"rui-menu-item-shortcut"},[u.shortcut])),u.disabled||(d.onclick=()=>{r.invoke(u.action),i.setAttribute("data-open","false")}),i.append(d)}n.append(i);const s=()=>i.setAttribute("data-open","false"),l=(u,d)=>{const p=a.isConnected?a.closest(".rui-context-menu"):null,f=p?.querySelector(".rui-context-menu-pop")??i,b=p?.getBoundingClientRect(),h=b?u-b.left:u,g=b?d-b.top:d;f.style.left=`${h}px`,f.style.top=`${g}px`,f.setAttribute("data-open","true");const y=v=>{v.target&&f.contains(v.target)||(f.setAttribute("data-open","false"),document.removeEventListener("click",y,!0),document.removeEventListener("contextmenu",y,!0))};setTimeout(()=>{document.addEventListener("click",y,!0),document.addEventListener("contextmenu",y,!0)},0)};return a.oncontextmenu=u=>{u.preventDefault(),l(u.clientX,u.clientY)},a.onkeydown=u=>{const d=u;if(d.key==="ContextMenu"||d.shiftKey&&d.key==="F10"){d.preventDefault();const f=d.currentTarget.getBoundingClientRect();l(f.left,f.top+f.height)}d.key==="Escape"&&s()},n}},Of=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function Pt(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(n=>n+n).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const Ff={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 n=m(e.id),a=Pt(m(e.value))||m(e.value,"#000000"),i=N(e.disabled),o=c("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=m(e.label);s&&o.append(c("label",{class:"rui-color-picker-label",for:n},[s]));const l=c("div",{class:"rui-color-picker-row"}),u=c("input",{type:"color",class:"rui-color-picker-color",id:n,name:n,value:Pt(a)||"#000000",disabled:i?"":null}),d=c("input",{type:"text",class:"rui-color-picker-hex",value:a,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),p=c("div",{class:"rui-color-picker-swatches"}),f=T(e.swatches).map(g=>m(g)).filter(Boolean),b=f.length>0?f:Of;for(const g of b){const y=Pt(g)||g,v=c("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${y}`,"aria-label":y,title:y,"data-active":y.toLowerCase()===a.toLowerCase()?"true":"false"});v.onclick=()=>{u.value=Pt(y)||u.value,d.value=y,u.dispatchEvent(new Event("input",{bubbles:!0}))},p.append(v)}const h=t.argMeta?.[1]?.stateRef;return h&&!i&&(r.bindState(u,h,{event:"input",getValue:g=>g.value}),u.addEventListener("input",()=>{d.value=u.value}),d.oninput=()=>{const g=Pt(d.value);g&&(u.value=g,u.dispatchEvent(new Event("input",{bubbles:!0})))}),i||ce(u,e.onChange,r,{event:"input",getValue:g=>g.value}),l.append(u,d),o.append(l,p),o}},Mn=["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)"],ot=t=>Mn[t%Mn.length]??Mn[0];function _f(t){return t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>I(o));return{name:a,values:i}})}function hr(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 me(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[a,i]of Object.entries(e))n.setAttribute(a,i);if(r)for(const a of r)n.append(typeof a=="string"?document.createTextNode(a):a);return n}function Po(t){const e=c("div",{class:"rui-chart-legend"});return t.forEach((r,n)=>{const a=c("span",{class:"rui-chart-legend-item"});a.append(c("span",{class:"rui-chart-legend-swatch",style:`background:${ot(n)}`})),a.append(c("span",{},[r.name])),e.append(a)}),e}const Uf={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=I(e.min,0),n=Math.max(r+1,I(e.max,100)),a=Math.max(r,Math.min(n,I(e.value,r))),i=(a-r)/(n-r),o=m(e.tone,"primary"),s=m(e.size,"md"),l=s==="lg"?220:s==="sm"?140:180,u=l/2,d=s==="lg"?18:s==="sm"?10:14,p=u-d,f=c("div",{class:"rui-gauge","data-tone":o,"data-size":s}),b=hr(l,u+d+4),h=u,g=u,y=h-p,v=g,x=h+p,w=g;if(b.append(me("path",{d:`M${y},${v} A${p},${p} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(d),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,C=h-p*Math.cos($),M=g-p*Math.sin($);b.append(me("path",{d:`M${y},${v} A${p},${p} 0 0 1 ${C.toFixed(2)},${M.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${ot(0)})`,"stroke-width":String(d),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(b);const k=Hf(a,r,n),A=m(e.label)||k;f.append(c("div",{class:"rui-gauge-value"},[A]));const S=m(e.caption);return S&&f.append(c("div",{class:"rui-gauge-caption"},[S])),f}};function Hf(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 qf={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=T(e.xLabels).map(d=>m(d)),n=T(e.yLabels).map(d=>m(d)),a=T(e.values).map(d=>T(d).map(p=>I(p,0))),i=m(e.tone,"primary"),o=Math.max(1,...a.flat()),s=c("div",{class:"rui-heatmap","data-tone":i});m(e.title)&&s.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const l=c("div",{class:"rui-heatmap-table"}),u=c("div",{class:"rui-heatmap-row rui-heatmap-row-header"});u.append(c("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const d of r)u.append(c("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[d]));return l.append(u),a.forEach((d,p)=>{const f=c("div",{class:"rui-heatmap-row"});f.append(c("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[n[p]??String(p+1)])),d.forEach((b,h)=>{const g=o>0?b/o:0,y=c("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${ot(0)}) ${Math.round(g*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${n[p]??p+1}: ${b}`});y.append(c("span",{},[String(b)])),f.append(y)}),l.append(f)}),s.append(l),s}},Vf={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=T(e.axes).map(b=>m(b)),n=_f(T(e.series)),a=Math.max(r.length,3),i=c("div",{class:"rui-chart rui-radar-chart"});m(e.title)&&i.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const o=Math.max(1,I(e.max,n.flatMap(b=>b.values).reduce((b,h)=>Math.max(b,h),1))),s=280,l=s/2,u=s/2,d=s/2-24,p=hr(s,s),f=4;for(let b=1;b<=f;b+=1){const h=d/f*b,g=[];for(let y=0;y<a;y+=1){const v=Math.PI*2*y/a-Math.PI/2;g.push(`${(l+h*Math.cos(v)).toFixed(1)},${(u+h*Math.sin(v)).toFixed(1)}`)}p.append(me("polygon",{points:g.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let b=0;b<a;b+=1){const h=Math.PI*2*b/a-Math.PI/2,g=l+d*Math.cos(h),y=u+d*Math.sin(h);p.append(me("line",{x1:String(l),y1:String(u),x2:g.toFixed(1),y2:y.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const v=l+(d+16)*Math.cos(h),x=u+(d+16)*Math.sin(h);p.append(me("text",{x:v.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[b]??""]))}return n.forEach((b,h)=>{const g=[];for(let y=0;y<a;y+=1){const v=b.values[y]??0,x=Math.max(0,Math.min(1,v/o)),w=Math.PI*2*y/a-Math.PI/2,k=l+d*x*Math.cos(w),A=u+d*x*Math.sin(w);g.push(`${k.toFixed(1)},${A.toFixed(1)}`)}p.append(me("polygon",{points:g.join(" "),fill:ot(h),"fill-opacity":"0.2",stroke:ot(h),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(p),n.length>0&&i.append(Po(n)),i}};function Wf(t){return t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>{if(Array.isArray(o))return{x:I(o[0],0),y:I(o[1],0),label:m(o[2])};if(o&&typeof o=="object"){const s=o;return{x:I(s.x,0),y:I(s.y,0),label:m(s.label)}}return{x:0,y:0,label:""}});return{name:a,points:i}})}const Gf={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=Wf(T(e.series)),n=c("div",{class:"rui-chart rui-scatter-chart"});m(e.title)&&n.append(c("div",{class:"rui-chart-title"},[m(e.title)]));const a=640,i=280,o={left:50,right:16,top:16,bottom:40},s=a-o.left-o.right,l=i-o.top-o.bottom,u=r.flatMap(k=>k.points);if(u.length===0)return n.append(c("div",{class:"rui-chart-empty"},["No points"])),n;const d=u.map(k=>k.x),p=u.map(k=>k.y),f=Math.min(...d),b=Math.max(...d),h=Math.min(...p),g=Math.max(...p),y=b-f||1,v=g-h||1,x=hr(a,i);if(zo(x,o,s,l,g,h),x.append(me("line",{x1:String(o.left),y1:String(o.top+l),x2:String(o.left+s),y2:String(o.top+l),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,A)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/y*s,C=o.top+l-(S.y-h)/v*l,M=me("circle",{cx:$.toFixed(1),cy:C.toFixed(1),r:"7",fill:ot(A),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});M.append(me("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(M)})}),m(e.xLabel)&&x.append(me("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 A=o.top+l/2;x.append(me("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"},[m(e.yLabel)]))}n.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(A=>A.y)}));return w.length>0&&n.append(Po(w)),n}},Kf={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 b=f??{};return{label:m(b.label),count:I(b.count,0)}});else{const f=T(e.values).map(b=>I(b,NaN)).filter(b=>Number.isFinite(b));if(f.length>0){const b=Math.max(2,Math.min(50,Math.floor(I(e.binCount,10)))),h=Math.min(...f),v=(Math.max(...f)-h||1)/b,x=new Array(b).fill(0);for(const w of f){let k=Math.floor((w-h)/v);k>=b&&(k=b-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const A=h+k*v,S=A+v;return{label:`${Eo(A)}–${Eo(S)}`,count:w}})}}const n=c("div",{class:"rui-chart rui-histogram"});if(m(e.title)&&n.append(c("div",{class:"rui-chart-title"},[m(e.title)])),r.length===0)return n.append(c("div",{class:"rui-chart-empty"},["No data"])),n;const a=640,i=240,o={left:40,right:12,top:16,bottom:50},s=a-o.left-o.right,l=i-o.top-o.bottom,u=Math.max(1,...r.map(f=>f.count)),d=s/r.length,p=hr(a,i);return zo(p,o,s,l,u),r.forEach((f,b)=>{const h=o.left+b*d+d*.1,g=d*.8,y=f.count/u*l,v=o.top+l-y,x=me("rect",{x:h.toFixed(1),y:v.toFixed(1),width:g.toFixed(1),height:y.toFixed(1),fill:ot(0),rx:"2"});x.append(me("title",{},[`${f.label}: ${f.count}`])),p.append(x),p.append(me("text",{x:(h+g/2).toFixed(1),y:String(o.top+l+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),n.append(p),n}};function Eo(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function zo(t,e,r,n,a,i=0){for(let s=0;s<=4;s+=1){const l=s/4,u=e.top+n-l*n;t.append(me("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(me("text",{x:String(e.left-8),y:String(u+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(a-i)*l)*10)/10)]))}}const Yf=["numeric","alphanumeric"];function Xf(t,e,r,n,a,i,o){const s=c("div",{class:"rui-pin-input","data-disabled":a?"true":"false"}),l=[];for(let p=0;p<e;p+=1){const f=c("input",{class:"rui-pin-input-slot",id:p===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${p+1}`,value:n.charAt(p)||"",disabled:a?"":null});l.push(f),s.append(f)}const u=p=>{const f=p.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):l},d=p=>u(p).map(f=>f.value).join("").slice(0,e);return l.forEach((p,f)=>{p.oninput=b=>{const h=b.currentTarget,g=u(h);let y=h.value;if(r==="numeric"?y=y.replace(/\D/g,""):y=y.replace(/[^A-Za-z0-9]/g,""),y.length>1){const v=y.split("");v.slice(0,e-f).forEach((w,k)=>{const A=g[f+k];A&&(A.value=w)});const x=Math.min(f+v.length,e-1);g[x]?.focus()}else h.value=y,y&&f<e-1&&g[f+1]?.focus();o?.(d(h))},p.onkeydown=b=>{const h=b,g=h.currentTarget,y=u(g);if(h.key==="Backspace"&&!g.value&&f>0){h.preventDefault(),y[f-1]?.focus();const v=y[f-1];v&&(v.value=""),o?.(d(g))}else h.key==="ArrowLeft"&&f>0?(h.preventDefault(),y[f-1]?.focus()):h.key==="ArrowRight"&&f<e-1&&(h.preventDefault(),y[f+1]?.focus())}}),s}const Zf={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:Yf},{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 n=m(e.id),a=Math.max(1,Math.min(12,Math.floor(I(e.length,4)))),i=m(e.type,"numeric"),o=m(e.value),s=N(e.disabled),l=N(e.mask),u=t.argMeta?.[2]?.stateRef;return Xf(n,a,i,o,s,l,d=>{u&&r.setState(u,d),r.invoke(e.onChange,d)})}};function Qf(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 Jf={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 n=m(e.id),a=r.useInstanceState("visible",!1),i=a.get(),o=N(e.disabled),s=c("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),l=m(e.label);l&&s.append(c("label",{class:"rui-password-input-label",for:n},[l]));const u=c("div",{class:"rui-password-input-row"}),d=c("input",{type:i?"text":"password",class:"rui-password-input-field",id:n,name:n,autocomplete:"current-password",placeholder:m(e.placeholder),value:m(e.value),disabled:o?"":null}),p=c("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=L(i?"eye-slash":"eye");f&&p.append(f),p.onclick=h=>{h.preventDefault();const g=!a.get();a.set(g);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=g?"text":"password")};const b=t.argMeta?.[1]?.stateRef;if(b&&r.bindState(d,b,{event:"input",getValue:h=>h.value}),ce(d,e.onChange,r,{event:"input",getValue:h=>h.value}),u.append(d),u.append(p),s.append(u),N(e.strengthMeter)){const h=Qf(m(e.value)),g=c("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let v=0;v<4;v+=1)g.append(c("span",{class:"rui-password-input-strength-bar","data-filled":v<h.score?"true":"false"}));const y=c("div",{class:"rui-password-input-strength-row"});y.append(g),h.label&&y.append(c("span",{class:"rui-password-input-strength-label"},[h.label])),s.append(y)}return s}},eg={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 n=m(e.id),a=T(e.value).map(f=>m(f)).filter(Boolean),i=Math.max(0,Math.floor(I(e.max,0))),o=N(e.disabled),s=t.argMeta?.[1]?.stateRef,l=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},u=m(e.label),d=c("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const f of a){const b=c("span",{class:"rui-tag-input-chip"});b.append(c("span",{},[f]));const h=c("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);h.onclick=()=>l(a.filter(g=>g!==f)),b.append(h),d.append(b)}const p=c("input",{type:"text",class:"rui-tag-input-field",id:n,name:n,placeholder:m(e.placeholder,a.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(p.onkeydown=f=>{const b=f,h=b.currentTarget;if(b.key==="Enter"||b.key===","){b.preventDefault();const g=h.value.trim();if(!g||i>0&&a.length>=i)return;if(a.includes(g)){h.value="";return}l([...a,g]),h.value=""}else b.key==="Backspace"&&h.value===""&&a.length>0&&(b.preventDefault(),l(a.slice(0,-1)))},d.append(p),u){const f=c("div",{class:"rui-tag-input-wrapper"});return f.append(c("label",{class:"rui-tag-input-label",for:n},[u])),f.append(d),f}return d}};function tg(t){return T(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,n=m(r.label??r.name??r.value??r.id);return{value:m(r.handle??r.value??r.id??r.name??r.label),label:n}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const rg={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 n=m(e.id),a=tg(e.people),i=N(e.disabled),o=c("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=c("textarea",{class:"rui-mention-input-field",id:n,name:n,rows:String(Math.max(2,Math.floor(I(e.rows,3)))),placeholder:m(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=m(e.value);const l=c("div",{class:"rui-mention-input-suggestions","data-open":"false"}),u=r.useInstanceState("activeIndex",0),d=r.useInstanceState("matches",[]),p=r.useInstanceState("query",null),f=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,b=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 C=k.slice(A),M=`@${w.value} `,E=S.slice(0,$)+M+C;x.value=E;const R=$+M.length;x.selectionStart=x.selectionEnd=R,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},g=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),d.set([]);return}const k=w.toLowerCase(),S=a.filter(C=>C.label.toLowerCase().includes(k)||C.value.toLowerCase().includes(k)).slice(0,6);if(d.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((C,M)=>{const E=c("button",{type:"button",class:"rui-mention-input-option","data-value":C.value,"data-active":M===$?"true":"false"});E.append(c("span",{class:"rui-mention-input-option-label"},[C.label])),C.value&&C.value!==C.label&&E.append(c("span",{class:"rui-mention-input-option-handle"},[`@${C.value}`])),E.onmousedown=R=>R.preventDefault(),E.onclick=R=>{const _=R.currentTarget,B=b(_),U=f(_);B&&h(B,C),p.set(null),U&&g(U,null)},x.append(E)})},y=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;p.set($),g(w,$)},v=t.argMeta?.[2]?.stateRef;return v?r.bindState(s,v,{event:"input",getValue:x=>{const w=x;return y(w),w.value}}):s.oninput=x=>{y(x.currentTarget)},ce(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=d.get();if(A.length!==0)if(x.key==="ArrowDown"){x.preventDefault();const S=(u.get()+1)%A.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((C,M)=>C.setAttribute("data-active",M===S?"true":"false"))}else if(x.key==="ArrowUp"){x.preventDefault();const S=(u.get()-1+A.length)%A.length;u.set(S),k.querySelectorAll(".rui-mention-input-option").forEach((C,M)=>C.setAttribute("data-active",M===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=A[u.get()];S&&(h(w,S),p.set(null),g(k,null))}else x.key==="Escape"&&(p.set(null),g(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);p.set(null),k&&g(k,null)},120)},o.append(s),o.append(l),g(l,p.get()),o}},ng={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 n=m(e.id),a=c("div",{class:"rui-time-picker"}),i=m(e.label);i&&a.append(c("label",{class:"rui-time-picker-label",for:n},[i]));const o=c("input",{type:"time",class:"rui-time-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(I(e.step,60)):null,disabled:N(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ce(o,e.onChange,r,{event:"change",getValue:l=>l.value}),a.append(o),a}},ag={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 n=m(e.id),a=c("div",{class:"rui-datetime-picker"}),i=m(e.label);i&&a.append(c("label",{class:"rui-datetime-picker-label",for:n},[i]));const o=c("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(I(e.step,60)):null,disabled:N(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),ce(o,e.onChange,r,{event:"change",getValue:l=>l.value}),a.append(o),a}};function Ro(t,e){if(!e)return t;let r="",n=0;const a=String(t??"");for(const i of e){if(n>=a.length)break;if(i==="9"){for(;n<a.length&&!/\d/.test(a[n]??"");)n+=1;if(n>=a.length)break;r+=a[n],n+=1}else if(i==="A"){for(;n<a.length&&!/[a-zA-Z]/.test(a[n]??"");)n+=1;if(n>=a.length)break;r+=a[n],n+=1}else i==="*"?(r+=a[n],n+=1):(r+=i,a[n]===i&&(n+=1))}return r}const ig={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 n=m(e.id),a=m(e.mask),i=N(e.disabled),o=Ro(m(e.value),a),s=m(e.label),l=c("input",{type:"text",class:"rui-masked-input",id:n,name:n,value:o,placeholder:m(e.placeholder,a),disabled:i?"":null,autocomplete:"off"});l.value=o;const u=t.argMeta?.[2]?.stateRef,d=p=>{const f=p.value,b=Ro(f,a);if(b===f)return b;const h=p.selectionStart??b.length;p.value=b;const g=Math.min(b.length,h);try{p.setSelectionRange(g,g)}catch{}return b};if(u?r.bindState(l,u,{event:"input",getValue:p=>d(p)}):l.oninput=p=>{d(p.currentTarget??p.target)},ce(l,e.onChange,r,{event:"input",getValue:p=>p.value}),s){const p=c("div",{class:"rui-masked-input-wrapper"});return p.append(c("label",{class:"rui-masked-input-label",for:n},[s])),p.append(l),p}return l}},og={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 n=c("section",{class:"rui-form-section"}),a=c("header",{class:"rui-form-section-header"});a.append(c("h3",{class:"rui-form-section-label"},[m(e.label)]));const i=m(e.helper);i&&a.append(c("p",{class:"rui-form-section-helper"},[i])),n.append(a);const o=c("div",{class:"rui-form-section-body"});for(const s of T(e.children))o.append(r.renderNode(s));return n.append(o),n}},sg={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 n=c("fieldset",{class:"rui-fieldset",disabled:N(e.disabled)?"":null});n.append(c("legend",{class:"rui-fieldset-legend"},[m(e.legend)]));const a=m(e.helper);a&&n.append(c("p",{class:"rui-fieldset-helper"},[a]));for(const i of T(e.children))n.append(r.renderNode(i));return n}},lg={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=T(e.errors).map(l=>{if(!l)return null;if(typeof l=="string")return{label:"",message:l,field:""};if(typeof l=="object"){const u=l;return{label:m(u.label),message:m(u.message??u.error),field:m(u.field)}}return null}).filter(l=>l!==null&&l.message!=="");if(r.length===0)return c("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const n=m(e.tone,"danger"),a=c("aside",{class:"rui-validation-summary","data-tone":n,role:"alert"}),i=c("div",{class:"rui-validation-summary-title"}),o=L(n==="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:"))),a.append(i);const s=c("ul",{class:"rui-validation-summary-list"});for(const l of r){const u=c("li",{class:"rui-validation-summary-item"});l.label&&u.append(c("strong",{},[`${l.label}: `])),u.append(document.createTextNode(l.message)),s.append(u)}return a.append(s),a}};function cg(t){return T(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 ug={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 n=cg(e.steps),a=n.length,i=Math.max(0,Math.min(a-1,Math.floor(I(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=m(e.stepsLayout,"column").toLowerCase(),l=s==="row"||s==="horizontal"?"row":"column",u=c("div",{class:"rui-multi-step-form","data-layout":l}),d=c("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":l});n.forEach((x,w)=>{const k=c("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(c("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(c("div",{class:"rui-steps-details"},[x.details])),d.append(k)}),u.append(d);const p=c("div",{class:"rui-multi-step-form-body"}),f=n[i];f&&f.content&&p.append(r.renderNode(f.content)),u.append(p);const b=c("div",{class:"rui-multi-step-form-footer"}),h=c("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[m(e.prevLabel,"Back")]);o&&i>0&&(h.onclick=()=>r.setState(o,i-1));const g=i>=a-1,y=g?m(e.submitLabel,"Submit"):m(e.nextLabel,"Continue"),v=c("button",{type:"button",class:"rui-button","data-variant":"primary"},[y]);return v.onclick=()=>{g?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},b.append(h),b.append(c("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${a}`])),b.append(v),u.append(b),u}};function dg(t){return T(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:N(r.unread),avatarSrc:m(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const pg={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 n=dg(e.items),a=n.filter(l=>l.unread),i=n.filter(l=>!l.unread),o=c("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&a.length>0){const l=c("div",{class:"rui-inbox-panel-toolbar"}),u=c("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);u.onclick=()=>r.invoke(e.onMarkAllRead),l.append(u),o.append(l)}if(n.length===0)return o.append(c("div",{class:"rui-inbox-panel-empty"},[m(e.emptyLabel,"You're all caught up.")])),o;const s=(l,u)=>{if(u.length===0)return;const d=c("section",{class:"rui-inbox-panel-group"}),p=c("header",{class:"rui-inbox-panel-group-head"});p.append(c("span",{class:"rui-inbox-panel-group-label"},[l])),p.append(c("span",{class:"rui-inbox-panel-group-count"},[String(u.length)])),d.append(p);for(const f of u){const b=po.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"&&(b.setAttribute("data-clickable","true"),b.onclick=()=>r.invoke(f.onClick)),d.append(b)}o.append(d)};return s(`Unread (${a.length})`,a),s("Earlier",i),o}};function mg(t){return T(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:m(r.title),description:m(r.description),done:N(r.done),onClick:r.onClick??r.action,cta:m(r.cta,"Start")}}).filter(e=>e!==null)}const fg={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 n=mg(e.items),a=n.filter(p=>p.done).length,i=Math.max(1,n.length),o=Math.round(a/i*100),s=c("div",{class:"rui-onboarding-checklist"}),l=c("header",{class:"rui-onboarding-checklist-header"});l.append(c("h3",{class:"rui-onboarding-checklist-title"},[m(e.title,"Getting started")]));const u=m(e.subtitle);u&&l.append(c("p",{class:"rui-onboarding-checklist-subtitle"},[u])),l.append(c("div",{class:"rui-onboarding-checklist-progress"},[c("div",{class:"rui-onboarding-checklist-bar"},[c("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),c("span",{class:"rui-onboarding-checklist-meta"},[`${a}/${n.length} complete`])])),s.append(l);const d=c("ol",{class:"rui-onboarding-checklist-list"});for(const p of n){const f=c("li",{class:"rui-onboarding-checklist-item","data-done":p.done?"true":"false"}),b=c("span",{class:"rui-onboarding-checklist-marker"}),h=L(p.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&b.append(h),f.append(b);const g=c("div",{class:"rui-onboarding-checklist-body"});if(g.append(c("div",{class:"rui-onboarding-checklist-item-title"},[p.title])),p.description&&g.append(c("p",{class:"rui-onboarding-checklist-item-description"},[p.description])),f.append(g),!p.done&&typeof p.onClick=="function"){const y=c("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[p.cta]);y.onclick=()=>r.invoke(p.onClick),f.append(y)}d.append(f)}return s.append(d),s}};function Lo(t){const e=c("div",{class:`rui-${t.klass}`});if(t.iconName){const n=L(t.iconName,{className:t.iconClass});n&&e.append(n)}t.title&&e.append(c("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(c("p",{class:`rui-${t.klass}-description`},[t.description]));const r=T(t.actions);if(r.length>0){const n=c("div",{class:`rui-${t.klass}-actions`});for(const a of r)n.append(t.helpers.renderNode(a));e.append(n)}return e}const gg={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=c("div",{class:"rui-loading-state"}),n=c("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});n.append(c("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(n),r.append(c("h3",{class:"rui-loading-state-title"},[m(e.title,"Loading…")]));const a=m(e.description);return a&&r.append(c("p",{class:"rui-loading-state-description"},[a])),r}},hg={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)=>Lo({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})},bg={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)=>Lo({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})},vg={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 n=T(e.steps).map(y=>{if(!y||typeof y!="object")return{title:m(y),description:"",target:""};const v=y;return{title:m(v.title),description:m(v.description),target:m(v.target)}}),a=e.open===void 0?!0:N(e.open),i=n.length,o=Math.max(0,Math.min(i-1,Math.floor(I(e.current,0)))),s=t.argMeta?.[1]?.stateRef,l=c("div",{class:"rui-tour","data-open":a?"true":"false"});if(!a||i===0)return l;const u=n[o];if(!u)return l;const d=c("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});d.append(c("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),d.append(c("h3",{class:"rui-tour-title"},[u.title])),u.description&&d.append(c("p",{class:"rui-tour-description"},[u.description])),u.target&&d.append(c("div",{class:"rui-tour-target"},[`Target: ${u.target}`]));const p=c("div",{class:"rui-tour-footer"}),f=c("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);f.onclick=()=>r.invoke(e.onComplete);const b=c("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(b.onclick=()=>r.setState(s,o-1));const h=o>=i-1,g=c("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return g.onclick=()=>{h?r.invoke(e.onComplete):s&&r.setState(s,o+1)},p.append(f,b,g),d.append(p),l.append(d),l}},yg={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 n=e.open===void 0?!0:N(e.open),a=c("div",{class:"rui-spotlight","data-open":n?"true":"false"});if(!n)return a;const i=c("div",{class:"rui-spotlight-card"});i.append(c("h3",{class:"rui-spotlight-title"},[m(e.title)]));const o=m(e.description);o&&i.append(c("p",{class:"rui-spotlight-description"},[o]));const s=T(e.actions);if(s.length>0){const u=c("div",{class:"rui-spotlight-actions"});for(const d of s)u.append(r.renderNode(d));i.append(u)}const l=t.argMeta?.[1]?.stateRef;return l&&(a.onclick=u=>{u.target===a&&r.setState(l,!1)}),a.append(i),a}},xg={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. Sets `data-stuck="true"` on itself once pinned, so a CSS hook (a shadow/border) can flag the pinned state.',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 n=m(e.side,"top"),a=X(e.offset,"0"),i=Math.max(0,Math.floor(I(e.zIndex,10))),o=`position:sticky;${n}:${a};z-index:${i};`,s=c("div",{class:"rui-sticky",style:o});for(const l of T(e.children))s.append(r.renderNode(l));if(typeof IntersectionObserver<"u"){const l=/^(\d+(?:\.\d+)?)px$/.exec(a)?.[1]??"0",u=n==="bottom"?`0px 0px -${Number(l)+1}px 0px`:`-${Number(l)+1}px 0px 0px 0px`;setTimeout(()=>{const d=new IntersectionObserver(([p])=>{p&&s.setAttribute("data-stuck",p.intersectionRatio<1?"true":"false")},{threshold:[1],rootMargin:u});d.observe(s),r.registerDisposer(()=>d.disconnect(),"rui-sticky-io")},0)}return s}},wg={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 n=X(e.initialPrimaryWidth,"40%"),a=X(e.minPrimaryWidth,"240px"),i=c("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${n};--rui-resizable-min:${a};`}),o=c("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const u of T(e.primary))o.append(r.renderNode(u));const s=c("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),l=c("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const u of T(e.secondary))l.append(r.renderNode(u));return i.append(o,s,l),s.onpointerdown=u=>{const d=u,p=d.currentTarget;p.setPointerCapture(d.pointerId);const f=p.closest(".rui-resizable-panels");if(!f)return;const b=f.getBoundingClientRect(),h=y=>{const v=(y.clientX-b.left)/b.width*100,x=Math.max(15,Math.min(85,v));f.style.setProperty("--rui-resizable-primary",`${x}%`)},g=y=>{p.releasePointerCapture(y.pointerId),p.removeEventListener("pointermove",h),p.removeEventListener("pointerup",g)};p.addEventListener("pointermove",h),p.addEventListener("pointerup",g)},i}},kg={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:ue}],render:(t,e,r)=>{const n=Math.max(1,Math.min(6,Math.floor(I(e.columns,3)))),a=ge(e.gap,"md"),i=c("div",{class:"rui-masonry-grid","data-columns":String(n),"data-gap":a});for(const o of T(e.items))i.append(r.renderNode(o));return i}},Sg={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 n=N(e.open),a=m(e.side,"right"),i=c("div",{class:"rui-sheet-overlay","data-open":n?"true":"false","data-side":a}),o=c("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":a}),s=c("header",{class:"rui-sheet-header"});s.append(c("h3",{class:"rui-sheet-title"},[m(e.title)]));const l=c("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),u=t.argMeta?.[1]?.stateRef,d=()=>{u&&r.setState(u,!1),r.invoke(e.onClose)};l.onclick=d,i.onclick=b=>{b.target===i&&d()},s.append(l),o.append(s);const p=c("div",{class:"rui-sheet-body"});for(const b of T(e.children))p.append(r.renderNode(b));o.append(p);const f=T(e.footer);if(f.length>0){const b=c("footer",{class:"rui-sheet-footer"});for(const h of f)b.append(r.renderNode(h));o.append(b)}return i.append(o),i}},$g={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 n=c("header",{class:"rui-topbar","data-sticky":N(e.sticky)?"true":"false"}),a=c("div",{class:"rui-topbar-side rui-topbar-left"}),i=m(e.title);if(i){const l=c("div",{class:"rui-topbar-title-block"});l.append(c("h2",{class:"rui-topbar-title"},[i]));const u=m(e.subtitle);u&&l.append(c("p",{class:"rui-topbar-subtitle"},[u])),a.append(l)}for(const l of T(e.left))a.append(r.renderNode(l));n.append(a);const o=T(e.center);if(o.length>0){const l=c("div",{class:"rui-topbar-side rui-topbar-center"});for(const u of o)l.append(r.renderNode(u));n.append(l)}const s=c("div",{class:"rui-topbar-side rui-topbar-right"});for(const l of T(e.right))s.append(r.renderNode(l));return n.append(s),n}},Cg={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` (and `aria-current="page"` for assistive tech) 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."},{name:"prefetch",type:"callable",optional:!0,description:"Called once on first hover/focus (warm a `$query` cache for the target route)."}],render:(t,e,r)=>{const n=m(e.label,""),a=m(e.to,"/"),i=m(e.variant,"default"),o=N(e.exact,!1),s=r.router,l=s.getPath(),u=l?o?l===a:a==="/"?l==="/":l===a?!0:l.startsWith(a+"/"):!1,d=c("a",{class:"rui-nav-link","data-variant":i,"data-active":u?"true":"false","aria-current":u?"page":null,href:"#"+(a.startsWith("/")?a:"/"+a)}),p=L(e.icon,{className:"rui-nav-link-icon"});if(p&&d.append(p),d.append(c("span",{class:"rui-nav-link-label"},[n])),typeof e.prefetch=="function"){let f=!1;const b=()=>{f||(f=!0,r.invoke(e.prefetch,a))};d.addEventListener("pointerenter",b,{once:!0}),d.addEventListener("focus",b,{once:!0})}return d.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(a)))},d}},Ag=["primary","secondary","ghost","danger"],Tg=["xs","sm","md","lg","xl"];function Mg(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 Ng(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.value??n.label);return{value:a,label:m(n.label,a)}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function br(t){return T(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Ig(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.value??n.label);return{value:a,label:m(n.label,a),group:m(n.group)||void 0,shortcut:m(n.shortcut)||void 0,action:n.action}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function Do(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.name??n.label);return{name:a,label:m(n.label,a),type:m(n.type,"text")||"text"}}const r=m(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Pg(t){return br(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?I(e.progress,0):void 0}))}function st(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Eg(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 to(t=cr){const e=()=>({inBacktick:!1,inBlockComment:!1}),r=p=>({...p}),n=new Set(t.atoms),a=new Set(t.keywords),i=/^[A-Z][A-Za-z0-9_]*/,o=/^[a-z_][A-Za-z0-9_]*/,s=/^-?\d+(?:\.\d+)?/,l=new Set([...t.operators.join(""),..."=<>!&|"]),c=(p,f)=>{for(;!p.eol();){const b=p.next();if(!b)return;if(b==="\\"){p.next();continue}if(b===f)return}};return{startState:e,copyState:r,token:(p,f)=>{if(f.inBacktick){for(;!p.eol();){const h=p.next();if(h==="\\"){p.next();continue}if(h==="`")return f.inBacktick=!1,"string"}return"string"}if(f.inBlockComment){for(;!p.eol();){if(p.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";p.next()}return"comment"}if(p.eatWhile(/[ \t]/))return null;if(p.match(t.comments.line,!0))return p.skipToEnd(),"comment";if(p.match(t.comments.blockStart,!0)){for(f.inBlockComment=!0;!p.eol();){if(p.match(t.comments.blockEnd,!0))return f.inBlockComment=!1,"comment";p.next()}return"comment"}const b=p.peek();if(b==null)return null;if(t.strings.singleLineQuotes.includes(b)){const h=b;return p.next(),c(p,h),"string"}if(b===t.strings.multiLineQuote){for(p.next();!p.eol();){const h=p.next();if(h==="\\"){p.next();continue}if(h==="`")return"string"}return f.inBacktick=!0,"string"}if(b>="0"&&b<="9"&&p.match(s,!0)||b==="-"&&p.match(/^-\d+(?:\.\d+)?/,!1)&&p.match(s,!0))return"number";if(b===t.sigils.state)return p.next(),p.peek()===t.sigils.state&&p.next(),p.eatWhile(t.identifier.part),"state";if(t.identifier.start.test(b)){if(p.match(i,!0))return"component";const g=p.match(o,!0);if(g){const y=g[0];return n.has(y)?"atom":a.has(y)?"keyword":p.peek()==="."?"loopvar":"identifier"}}for(const h of t.operatorsLong)if(p.match(h,!0))return"operator";return b==="."?(p.next(),p.peek()&&t.identifier.start.test(p.peek())?(p.eatWhile(t.identifier.part),"property"):"punctuation"):"()[]{},:?".includes(b)?(p.next(),"punctuation"):l.has(b)?(p.next(),"operator"):(p.next(),null)},languageData:{commentTokens:{line:t.comments.line,block:{open:t.comments.blockStart,close:t.comments.blockEnd}},closeBrackets:{brackets:["(","[","{",'"',"'","`"]},indentOnInput:/^\s*[)\]}]$/}}}const ro={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},ur=[{name:"state",sigil:"$state",category:"hook",signature:"$state(initial)",summary:"Hook: per-instance state → [value, setValue] (like React's useState)."},{name:"memo",sigil:"$memo",category:"hook",signature:"$memo(() => value, [deps])",summary:"Hook: value recomputed only when a dependency changes (like useMemo)."},{name:"ref",sigil:"$ref",category:"hook",signature:"$ref(initial)",summary:"Hook: stable { current } box; writing .current does not re-render (like useRef)."},{name:"reducer",sigil:"$reducer",category:"hook",signature:"$reducer((state, action) => next, initial)",summary:"Hook: [state, dispatch] (like useReducer)."},{name:"id",sigil:"$id",category:"hook",signature:"$id(prefix?)",summary:"Hook: stable unique id per component instance (like useId)."},{name:"effect",sigil:"$effect",category:"effect",signature:"$effect(() => { … }, [deps])",summary:'Declarative side effect; deps mix $state, "mount"/"unmount", "every(N)", "debounce(N)".'},{name:"optimistic",sigil:"$optimistic",category:"effect",signature:"$optimistic(() => { … })",summary:"Run optimistic writes; auto-rolls back state if the callback throws or rejects."},{name:"store",sigil:"$store",category:"effect",signature:"$store({ ...state, ...methods })",summary:'Global store: shared state + actions (like Zustand/Pinia). persist: "key" mirrors data to localStorage (persistIn: "session" for sessionStorage); history: true|depth adds undo()/redo()/clearHistory() + reactive canUndo/canRedo.'},{name:"form",sigil:"$form",category:"effect",signature:"$form({ values, rules, onSubmit })",summary:"Reactive form engine: values/errors/touched/dirty/valid/submitting/validating + field()/validate()/touch()/setField()/submit() (alias handleSubmit())/reset(). Async rules ($util.rules.asyncCustom) are awaited before submit; submitting stays true until an async onSubmit settles."},{name:"http",sigil:"$http",category:"data",signature:"$http({ url, method, … })",summary:"Reactive HTTP resource bag — { data, loading, error, refetch }."},{name:"query",sigil:"$query",category:"data",signature:"$query({ url, key, ttl })",summary:"Cached + deduplicated HTTP read. Polling via refetchInterval/refetchOnFocus/refetchOnReconnect; pagination via infinite: { param, limit, mode } (→ .loadMore()/.hasMore/.loadingMore); GraphQL via gql + variables."},{name:"mutation",sigil:"$mutation",category:"data",signature:"$mutation({ url, method })",summary:"Deferred write; fires on .mutate(overrides?). optimistic: (vars) => {…} applies instantly (auto-rollback on failure); invalidates: [keys] refetches matching cached queries; gql for GraphQL."},{name:"socket",sigil:"$socket",category:"data",signature:"$socket({ url, reconnect? })",summary:'Reactive WebSocket — { status: "connecting"|"open"|"closed", connected, last, messages, attempts, send, close }. reconnect: true|n retries with exponential backoff; sends queue while connecting and flush on open; close() stops for good.'},{name:"sse",sigil:"$sse",category:"data",signature:"$sse({ url, event })",summary:'Reactive Server-Sent Events stream — { status, connected, last, messages, close }. EventSource reconnects natively (status reads "connecting" while it does).'},{name:"script",sigil:"$script",category:"data",signature:"$script({ src, global? })",summary:"Load an external UMD/ESM script or stylesheet once → reactive { ready, loading, error, value }. `global` reads window[global] into `value` (e.g. window.Stripe). De-duplicated per src across the app; gate a third-party widget on `.ready`."},{name:"head",sigil:"$head",category:"app",signature:"$head({ title, meta, og, twitter, link, jsonLd })",summary:"Reactive document head: title, meta description, canonical/alternate links, Open Graph + Twitter cards, JSON-LD, <html> attrs. Per-route calls compose; renderToString emits the resolved <head> so SSR pages are crawlable."},{name:"app",sigil:"$app",category:"app",signature:"$app(root)",summary:"Register the root of the rendered UI tree — every program needs one."},{name:"router",sigil:"$router",category:"routing",signature:"$router({ '/': Home(), default: NotFound() })",summary:"Outlet-first router: maps path patterns to component trees."},{name:"theme",sigil:"$theme",category:"theme",signature:"$theme({ colors, radius, font, … })",summary:"In-script theme override merged on top of the active base theme. Structured groups: colors/radius/font/spacing/shadows/gradients/zIndex/motion/fonts (web-font import)/icons (custom inline SVG), plus name/direction metadata."},{name:"emit",sigil:"$emit",category:"event",signature:"$emit('name', detail)",summary:"Dispatch a CustomEvent from the host element."},{name:"util",sigil:"$util",category:"namespace",signature:"$util",summary:"Runtime helper + reactive-environment namespace: data helpers ($util.format/.sum/.range/.groupBy…), formatting ($util.slugify/.truncate/.initials/.currency/.percent/.bytes/.relativeTime), misc ($util.copy — async, resolves true on real success —/.sleep/.uuid/.debounceFn/.throttleFn — leading+trailing), styling ($util.style.cx/.gradient/.alpha/.clamp/.token/.toStyle), validators ($util.rules.required/.email/.url/.min/.max/.minLength/.maxLength/.pattern/.oneOf/.matches/.custom/.asyncCustom + .validate/.validateAll), computed ($util.derived(fn)), hooks ($util.onError/.onNavigate/.onRequest/.onResponse/.invalidate), reactive env ($util.scroll/.viewport/.breakpoint/.media/.mouse/.url incl. .url.setQuery/.removeQuery), device ($util.vibrate/.share/.readClipboard/.geolocate/.isOnline/.deviceType/.nativeShell/.isNativeApp), and platform ($util.worker/.registerServiceWorker/.webManifest).",namespace:!0},{name:"storage",sigil:"$storage",category:"namespace",signature:"$storage",summary:"Persistent storage namespace ($storage.local, $storage.session, …).",namespace:!0},{name:"console",sigil:"$console",category:"namespace",signature:"$console",summary:"Console namespace ($console.log, $console.warn, …).",namespace:!0},{name:"toast",sigil:"$toast",category:"namespace",signature:"$toast",summary:"Imperative toasts: $toast.show/.success/.error/.dismiss; reactive .items.",namespace:!0},{name:"dom",sigil:"$dom",category:"namespace",signature:"$dom",summary:"Managed DOM-observer namespace: $dom.onResize(node, cb) / .onIntersect(node, cb, opts?) / .onMutation(node, cb, opts?) (auto-disposed on replan) and .measure(node) → { rect, scroll, viewport }. Pair with Mount/OnMount node refs.",namespace:!0},{name:"i18n",sigil:"$i18n",category:"data",signature:"$i18n({ translations, … })",summary:"Translation bundle → { t, setCurrentLanguage, getCurrentLanguage }."}],no=new Set(ur.map(t=>t.name)),ao=Object.freeze(Object.fromEntries(ur.map(t=>[t.name,t])));function nd(t){return ao[t]}function ad(t){return no.has(t)}const N=(t,e,r)=>({name:t,kind:"method",signature:e,summary:r}),q=(t,e)=>({name:t,kind:"property",signature:t,summary:e}),id=[N("count","count(items)","Number of items in an array."),N("sum","sum(items)","Sum of the numeric values."),N("avg","avg(items)","Arithmetic mean of the values."),N("min","min(items)","Smallest numeric value."),N("max","max(items)","Largest numeric value."),N("first","first(items)","First element, or null when empty."),N("last","last(items)","Last element, or null when empty."),N("filter","filter(items, field?, op?, value?)","Keep items where field matches. Operators: == != > < >= <= contains startsWith endsWith."),N("find","find(items, field?, op?, value?)","First item matching the comparator, or null."),N("sort","sort(items, field?, direction?)",'Sort by field, "asc" (default) or "desc".'),N("groupBy","groupBy(items, field?)","Group items into an object keyed by the field value."),N("slice","slice(items, start?, end?)","Subarray between start and end indices."),N("unique","unique(items, field?)","De-duplicate an array (optionally by a field)."),N("reverse","reverse(items)","Reversed copy of the array."),N("range","range(start, end, step?)","Array of numbers from start to end (inclusive)."),N("repeat","repeat(value, n)","Array with the value repeated n times."),N("pick","pick(obj, keys)","Object containing only the listed keys."),N("omit","omit(obj, keys)","Object without the listed keys."),N("chunk","chunk(items, size)","Split an array into chunks of the given size."),N("flatten","flatten(items, depth?)","Flatten nested arrays to the given depth (default 1)."),N("zip","zip(...arrays)","Combine arrays element-wise into tuples."),N("partition","partition(items, field?, op?, value?)","Split into [pass, fail] by a comparator."),N("keyBy","keyBy(items, field?)","Index an array into an object keyed by a field."),N("cloneDeep","cloneDeep(value)","Deep-clone a value (arrays / objects / dates)."),N("merge","merge(target, ...sources)","Deep-merge source objects onto a clone of the target."),N("format","format(value, mode?, options?)",'Locale number format: "number" | "currency" | "percent" | "compact".'),N("formatDate","formatDate(value, format?)",'Format a date — a token pattern (MMM D, YYYY-MM-DD) or "relative"/"date"/"time"/"datetime"/"iso".'),N("plural","plural(count, singular, plural?)","Count + correctly pluralised noun: `3 items` / `1 item`."),N("capitalize","capitalize(text)","Capitalise the first letter."),N("lowercase","lowercase(text)","Lowercase the whole string."),N("uppercase","uppercase(text)","Uppercase the whole string."),N("titlecase","titlecase(text)","Title-case each word."),N("case","case(text, kind?)",'Recase: "camel" | "pascal" | "snake" | "kebab".'),N("now","now()","Current time as epoch milliseconds."),N("today","today()","Start of today as an ISO string."),N("addDays","addDays(date, days)","Date shifted by n days (ISO)."),N("addHours","addHours(date, hours)","Date shifted by n hours (ISO)."),N("diffDays","diffDays(start, end)","Whole days between two dates."),N("startOfWeek","startOfWeek(date)","Start of the week containing the date (ISO)."),N("endOfMonth","endOfMonth(date)","End of the month containing the date (ISO)."),N("join","join(items, sep?)","Join an array into a string with a separator."),N("split","split(text, sep?)","Split a string into an array on a separator."),N("trim","trim(text)","Trim surrounding whitespace."),N("replace","replace(text, search, replacement?)","Replace every occurrence of a substring."),N("substring","substring(text, start, end?)","Substring between two indices."),N("startsWith","startsWith(text, prefix)","True when the text starts with the prefix."),N("endsWith","endsWith(text, suffix)","True when the text ends with the suffix."),N("contains","contains(text, needle)","True when the text contains the needle."),N("match","match(text, pattern)","Test the text against a regular-expression pattern."),N("round","round(value, decimals?)","Round to n decimal places."),N("floor","floor(value)","Round down to an integer."),N("ceil","ceil(value)","Round up to an integer."),N("abs","abs(value)","Absolute value."),N("clamp","clamp(value, min, max)","Constrain a number to a [min, max] range."),N("pow","pow(base, exp)","Exponentiation (base^exp)."),N("sqrt","sqrt(value)","Square root."),N("random","random()","Pseudo-random number in [0, 1)."),N("log","log(value)","Natural logarithm."),N("slugify","slugify(text)",'URL-safe slug: "Hello World" → "hello-world".'),N("truncate","truncate(text, length?, ellipsis?)","Cut text to n chars with an ellipsis."),N("initials","initials(name, max?)","Up-to-`max` initials from a full name."),N("currency","currency(value, code?, locale?)","Locale currency string."),N("percent","percent(value, decimals?)",'Locale percent string (0.42 → "42%").'),N("bytes","bytes(value)",'Human-readable byte size (1536 → "1.5 KB").'),N("relativeTime","relativeTime(value)",'"3 minutes ago" / "in 2 days" via Intl.'),N("copy","copy(text)","Copy to the clipboard — async; resolves true only when the write succeeds (`await $util.copy(x)`)."),N("sleep","sleep(ms?)","Awaitable pause: `await $util.sleep(ms)` (capped at 60s)."),N("uuid","uuid()","Random UUID v4 string."),N("debounceFn","debounceFn(fn, wait?)","Wrap a function so it fires `wait` ms after the LAST call."),N("throttleFn","throttleFn(fn, wait?)","Wrap a function to fire at most once per `wait` ms (leading + one trailing)."),N("derived","derived(fn)","Computed reactive value — recomputes from the atoms the lambda reads."),N("onError","onError(fn)","Program-level error sink — fires with { error, source } when an action throws."),N("onNavigate","onNavigate(fn)","Navigation guard: return false to block, a path string to redirect, anything else to allow."),N("onRequest","onRequest(fn)","HTTP request interceptor — a partial return merges over every outgoing request."),N("onResponse","onResponse(fn)","HTTP response interceptor — replace the response or `await retry()`."),N("invalidate","invalidate(keys)","Refetch every cached $query whose key contains one of the substrings."),q("scroll",'Reactive scroll: .x / .y / .progress (0–1) / .direction ("up"|"down").'),q("viewport","Reactive viewport: .width / .height."),q("breakpoint",'Reactive breakpoint: .active ("base"|"sm"|"md"|"lg"|"xl") + boolean .sm/.md/.lg/.xl.'),q("media","Reactive media flags: .prefersDark / .prefersReducedMotion / .online / .pointer / .portrait."),q("mouse","Reactive pointer position: .x / .y."),q("url","Reactive URL snapshot: .path / .params / .query / .hash + .navigate(to)."),N("url.setQuery","url.setQuery(key, value)",'Write a query param in place (null/"" drops it) — shareable filter/tab state.'),N("url.removeQuery","url.removeQuery(key)","Drop a query param from the URL."),{name:"style",kind:"namespace",signature:"style",summary:"Safe styling helpers: .cx / .gradient / .alpha / .clamp / .token / .toStyle."},N("style.cx","style.cx(...args)","clsx-style class composer — strings, arrays, { name: cond } objects."),N("style.gradient","style.gradient(stops, angle?)","Safe linear-gradient() from color stops + angle."),N("style.alpha","style.alpha(color, amount)","color-mix transparency: token or color at 0–1 alpha."),N("style.clamp","style.clamp(min, preferred, max)","Responsive clamp(min, preferred, max) size."),N("style.token","style.token(path)",'Resolve a theme token path to its CSS var: "colors.primary" → var(--rui-color-primary).'),N("style.toStyle","style.toStyle(obj)","Serialise a CSS-declarations object to a sanitised style string."),{name:"rules",kind:"namespace",signature:"rules",summary:"Composable validators — compose per field; run with .validate / .validateAll or hand to $form."},N("rules.required","rules.required(message?)","Non-empty value."),N("rules.email","rules.email(message?)","Valid email address."),N("rules.url","rules.url(message?)","Valid http(s) URL."),N("rules.min","rules.min(n, message?)","Number ≥ n."),N("rules.max","rules.max(n, message?)","Number ≤ n."),N("rules.minLength","rules.minLength(n, message?)","String length ≥ n."),N("rules.maxLength","rules.maxLength(n, message?)","String length ≤ n."),N("rules.pattern","rules.pattern(re, message?)","Match a regular expression."),N("rules.oneOf","rules.oneOf(options, message?)","Value is in the allowed list."),N("rules.matches","rules.matches(other, message?)","Equals another value (password confirmation)."),N("rules.custom","rules.custom(fn, message?)","Custom sync rule — return true/null (valid), false, or an error string."),N("rules.asyncCustom","rules.asyncCustom(fn, message?)","Async rule (Promise) — server-side checks; $form awaits it before submitting."),N("rules.validate","rules.validate(value, validators)","Run validators — first error message or null (a Promise when an async rule is hit)."),N("rules.validateAll","rules.validateAll(values, schema)","Validate an object against { field: [validators] } → { field: message }."),N("vibrate","vibrate(pattern?)","Haptic pulse (ms or pattern array) on supporting devices."),N("share","share(data)","Native share sheet (Web Share API) — resolves true on share."),N("readClipboard","readClipboard()","Read clipboard text (async, permission-gated)."),N("geolocate","geolocate(options?)","Resolve { lat, lng, accuracy } via the Geolocation API."),N("isOnline","isOnline()","Current navigator.onLine flag."),N("deviceType","deviceType()",'"mobile" | "tablet" | "desktop" heuristic.'),N("worker","worker(fn, ...args)","Run a closure-free function in a Web Worker; resolves its return value."),N("registerServiceWorker","registerServiceWorker(url, scope?)","Register a service worker for PWA/offline."),N("webManifest","webManifest(config)","Build a sanitised web-app manifest (name, icons, themeColor…)."),N("nativeShell","nativeShell()",'Detect the wrapper: capacitor/cordova/tauri/electron/react-native or "web".'),N("isNativeApp","isNativeApp()","True when running inside a native shell.")],xn=(t,e)=>[N(`${t}set`,`${t}set(key, value, options?)`,`${e} write.`),N(`${t}get`,`${t}get(key)`,`${e} read. Returns null when missing.`),N(`${t}remove`,`${t}remove(key, options?)`,`Delete a key from ${e.toLowerCase()}.`),N(`${t}clear`,`${t}clear()`,`Wipe every ${e.toLowerCase()} entry.`)],od=[...xn("","localStorage (default namespace)"),{name:"local",kind:"namespace",signature:"local",summary:"localStorage backend — set/get/remove/clear."},...xn("local.","localStorage"),{name:"session",kind:"namespace",signature:"session",summary:"sessionStorage backend (per-tab) — set/get/remove/clear."},...xn("session.","Per-tab sessionStorage"),{name:"cookies",kind:"namespace",signature:"cookies",summary:"Document cookies — set/get/remove/clear (options: expires, maxAge, path, domain, secure, sameSite)."},N("cookies.set","cookies.set(key, value, options?)","Set a cookie. Options: expires, maxAge, path, domain, secure, sameSite."),N("cookies.get","cookies.get(key)","Read a cookie value."),N("cookies.remove","cookies.remove(key, options?)","Delete a cookie. Path/domain must match the original set call."),N("cookies.clear","cookies.clear()","Clear every cookie on this document.")],sd=[N("log","log(...args)","Log a message at the default level."),N("error","error(...args)","Log an error."),N("warn","warn(...args)","Log a warning."),N("info","info(...args)","Log an informational message."),N("debug","debug(...args)","Log a verbose debug message.")],ld=[N("show","show(message, options?)","Show a toast; returns its id. Options: { title?, tone?, duration? }."),N("success","success(message, options?)",'`show` with tone "success".'),N("error","error(message, options?)",'`show` with tone "danger".'),N("info","info(message, options?)",'`show` with tone "info".'),N("warning","warning(message, options?)",'`show` with tone "warning".'),N("dismiss","dismiss(id)","Remove a single toast by id."),N("clear","clear()","Remove every toast."),q("items","Reactive list of live toasts (newest last). Treat as read-only.")],cd=[N("onResize","onResize(node, callback)","Observe element size with a ResizeObserver; callback gets { width, height, entry }. Returns a disposer; auto-disposed on replan."),N("onIntersect","onIntersect(node, callback, options?)","Observe viewport intersection with an IntersectionObserver; callback gets the entry. Options: { root?, rootMargin?, threshold? }."),N("onMutation","onMutation(node, callback, options?)","Observe DOM mutations with a MutationObserver. Options: { childList?, attributes?, subtree?, characterData? }."),N("measure","measure(node)","One-shot read → { rect, scroll, viewport } (getBoundingClientRect + scroll offsets + window size).")],io=[{name:"util",sigil:"$util",summary:"Runtime helper + reactive-environment namespace.",members:id},{name:"storage",sigil:"$storage",summary:"Browser storage namespace (local / session / cookies).",members:od},{name:"console",sigil:"$console",summary:"Console namespace forwarding to the browser console.",members:sd},{name:"toast",sigil:"$toast",summary:"Imperative toast namespace.",members:ld},{name:"dom",sigil:"$dom",summary:"Managed DOM-observer namespace (resize / intersection / mutation / measure).",members:cd}],dr=Object.freeze(Object.fromEntries(io.map(t=>[t.name,t]))),oo=[q("data","Parsed response body — `null` until the request resolves."),q("error","`null` on success; `{ status, body }` on a non-2xx; the thrown error on network failure."),q("status","HTTP status code of the last response, e.g. `200`."),q("loading","`true` while a request is in flight."),q("headers","Response headers as a plain object."),q("lastUpdated","Epoch-ms of the last successful response."),N("refetch","refetch()","Re-issue the original request."),N("cancel","cancel()","Abort the in-flight request."),q("onDone","Settable callback fired each time the request settles (success or error).")],ud=[...oo,N("loadMore","loadMore()","Fetch the next page (infinite mode)."),q("hasMore","`true` while more pages are available (infinite mode)."),q("loadingMore","`true` while a `loadMore()` page is in flight."),q("pages","Raw page bodies loaded so far (infinite mode); `.data` is the flattened items.")],dd=[N("mutate","mutate(overrides?)","Fire the request; overrides shallow-merge over the config. `optimistic` applies instantly and rolls back on failure."),q("data","Response body of the last successful mutation."),q("error","`null` on success; error details on failure."),q("loading","`true` while the mutation request is in flight."),q("status","HTTP status code of the last response."),q("onDone","Settable callback fired when the mutation settles.")],pd=[q("status",'Connection lifecycle: "connecting" | "open" | "closed".'),q("connected",'`true` while status is "open".'),q("last","Most recent message (JSON auto-parsed), or null."),q("messages","Buffered messages, newest last (capped to bufferSize)."),q("attempts","Reconnect attempts in the current streak (resets on success)."),q("error","Last socket error event, if any."),N("send","send(data)","Send a message (objects JSON-stringified). Queues while connecting; flushes on open."),N("close","close()","Close for good — disables auto-reconnect.")],md=[q("status",'"connecting" | "open" | "closed" (EventSource retries natively).'),q("connected","`true` while the stream is open."),q("last","Most recent event payload (JSON auto-parsed)."),q("messages","Buffered events, newest last (capped to bufferSize)."),q("error","Last stream error, if any."),N("close","close()","Close the stream.")],fd=[q("values","Reactive field values — two-way bind with an input's `value`."),q("errors","Per-field error messages (set after validate/touch/submit)."),q("touched","Per-field booleans — true once the user has interacted."),q("dirty","`true` once any value differs from the clean snapshot."),q("valid","`true` when the last validation pass found no errors."),q("submitting","`true` from submit() until an async onSubmit settles."),q("validating","`true` while async rules ($util.rules.asyncCustom) are in flight."),N("field","field(name)","Controlled prop bag: { value, error, name, onChange, onBlur } — spread onto an input."),N("touch","touch(name)","Mark a field touched + validate it (wire to `onBlur`)."),N("setField","setField(name, value)","Set one field value (clears its error)."),N("setValues","setValues(values)","Merge several field values at once."),N("validate","validate()","Validate every field → boolean (a Promise when async rules exist)."),N("validateField","validateField(name)","Validate one field → message | null (Promise for async rules)."),N("submit","submit()","Touch all → validate → onSubmit(values) when valid. Alias: handleSubmit()."),N("handleSubmit","handleSubmit()","Alias of submit()."),N("reset","reset()","Restore initial values; clears errors/touched/dirty.")],gd=[q("ready","`true` once the external script / stylesheet has loaded successfully."),q("loading","`true` while the resource is still downloading."),q("error","The load error, or `null` on success."),q("value","The resolved value — `window[global]` for a script with a `global` (e.g. window.Stripe), else `true`. `null` until ready.")],hd=[N("undo","undo()","Undo the last change (`history: true|depth` stores)."),N("redo","redo()","Redo the last undone change."),q("canUndo","Reactive — `true` when an undo step is available."),q("canRedo","Reactive — `true` when a redo step is available."),N("clearHistory","clearHistory()","Drop the undo/redo stacks.")],wn=[{factory:"http",summary:"Reactive HTTP resource bag.",members:oo},{factory:"query",summary:"Cached query bag (HTTP + pagination).",members:ud},{factory:"mutation",summary:"Deferred mutation bag (fires on .mutate()).",members:dd},{factory:"socket",summary:"Reactive WebSocket bag.",members:pd},{factory:"sse",summary:"Reactive Server-Sent Events bag.",members:md},{factory:"script",summary:"External script / stylesheet load bag.",members:gd},{factory:"form",summary:"Managed form engine bag.",members:fd},{factory:"store",summary:"Global store handle (built-in history methods).",members:hd}],bd=Object.freeze(Object.fromEntries(wn.map(t=>[t.factory,t]))),kn=new Set(wn.map(t=>t.factory)),vd=[q("path","Current URL path, e.g. `/users/42`."),q("params","Captured path segments from the matched route pattern (`route.params.id`)."),q("query","Parsed query-string parameters as an object."),q("pattern","The matched route pattern, or `null`."),N("navigate","navigate(to)","Imperatively navigate to a path.")],yd=[N("t","t(key, vars?)","Translate a key for the current language; interpolates {name} placeholders + ICU plural/select."),N("setCurrentLanguage","setCurrentLanguage(lang)","Switch the active language."),N("getCurrentLanguage","getCurrentLanguage()","Return the active language code.")];function xd(t){return dr[t]}function wd(t){return t in dr}function kd(t){return bd[t]}function Sd(t,e=[]){const r=dr[t];if(!r)return[];if(e.length===0)return r.members.slice();const n=`${e.join(".")}.`,a=[];for(const i of r.members)i.name.startsWith(n)&&a.push({...i,name:i.name.slice(n.length)});return a}function $d(t,e){const r=dr[t];if(r)return r.members.find(n=>n.name===e)}const B=(t,e,r)=>({name:t,type:e,summary:r}),so=[B("url","string","Absolute request URL."),B("method",'enum: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS"',"HTTP method. Defaults to GET."),B("query","object","Object serialised into the URL querystring (`?k=v`)."),B("headers","object","Request headers as a plain object."),B("body","object","Request body. Objects are JSON-encoded automatically."),B("credentials",'enum: "omit" | "same-origin" | "include"',"Fetch credentials mode."),B("mode",'enum: "cors" | "no-cors" | "same-origin"',"Fetch request mode."),B("cache",'enum: "default" | "no-store" | "reload" | "no-cache" | "force-cache"',"Fetch cache mode."),B("gql","string","GraphQL query — POSTs { query, variables }; `.data` is the unwrapped GraphQL data."),B("variables","object","GraphQL variables paired with `gql`.")],Cd=[...so,B("key","string","Cache key — identical keys share one in-flight request + cached bag."),B("ttl","number","Milliseconds before cached data is considered stale and auto-refetched."),B("refetchInterval","number","Poll interval in ms (live dashboards)."),B("refetchOnFocus","boolean","Refetch when the tab regains focus."),B("refetchOnReconnect","boolean","Refetch when the network reconnects."),B("infinite","object","Pagination config: { param?, start?, limit?, mode?, select? } → .loadMore()/.hasMore.")],Ad=[B("url","string","Absolute request URL."),B("method",'enum: "POST" | "PUT" | "PATCH" | "DELETE"',"HTTP method. Defaults to POST."),B("body","object","Default body; shallow-merged with `.mutate(overrides)`."),B("headers","object","Request headers as a plain object."),B("query","object","Object serialised into the URL querystring."),B("optimistic","(vars) => void","Runs synchronously before the request; auto-rolled-back on failure."),B("invalidates","string[]","Refetch every cached $query whose key contains a listed substring on success."),B("gql","string","GraphQL mutation document."),B("variables","object","GraphQL variables paired with `gql`.")],Td=[B("url","string","WebSocket URL (ws:// or wss://)."),B("protocols","string | string[]","Optional sub-protocol(s)."),B("bufferSize","number","Max buffered messages kept in `.messages`."),B("onMessage","(msg) => void","Callback fired for each received message."),B("reconnect","boolean | number","Retry dropped connections (true, or a max-attempt count) with backoff.")],Md=[B("url","string","EventSource URL."),B("event","string","Named event to listen for (defaults to message)."),B("withCredentials","boolean","Send credentials with the EventSource request."),B("bufferSize","number","Max buffered events kept in `.messages`.")],Nd=[B("src","string","URL of the script (or stylesheet) to load. De-duplicated per src."),B("global","string",'Name of the window global the script defines — read into `.value` once ready (e.g. "Stripe").'),B("type","string",'Script type attribute (e.g. "module" for ESM).'),B("as",'enum: "script" | "style"',"Force the resource kind. Inferred from a `.css` src otherwise."),B("attributes","object","Extra attributes to set on the injected <script>/<link> (e.g. crossorigin, integrity).")],Id=[B("title","string","Document title (sets document.title + <title>)."),B("titleTemplate","string",'Wrap `title` with a template, e.g. "%s — Acme".'),B("meta","object",'Named meta tags: { description, "theme-color", keywords, … } → <meta name content>.'),B("og","object",'Open Graph tags: { title, image, type, … } → <meta property="og:KEY">.'),B("twitter","object",'Twitter card tags: { card, site, … } → <meta name="twitter:KEY">.'),B("link","object[]",'Array of <link> descriptors, e.g. [{ rel: "canonical", href }].'),B("jsonLd","object | object[]",'JSON-LD structured data → <script type="application/ld+json">. @context defaults to schema.org.'),B("base","string | object","<base href> for the document."),B("htmlAttrs","object",'Attributes for the <html> element, e.g. { lang: "en", dir: "ltr" }.')],Pd=[B("values","object","Initial field values — the clean snapshot."),B("rules","object","Per-field validator arrays: { field: [$util.rules.required(), …] }."),B("onSubmit","(values) => void","Called with the values once validation passes.")],Rd=[B("persist","string","Mirror the store's data to localStorage under this key (hydrates on first render)."),B("persistIn",'enum: "local" | "session"',"Storage backend for `persist` (defaults to local)."),B("history","boolean | number","Enable undo()/redo()/clearHistory() + reactive canUndo/canRedo (number = depth).")],Ed=[B("name","string",'Selects a built-in base theme ("dark", "neon", …).'),B("direction",'enum: "ltr" | "rtl"',"Reading direction (metadata)."),B("colors","object","CSS color tokens: bg, surface, border, text, primary, accent, success, warning, danger, info, …."),B("radius","object","Border-radius tokens: xs, sm, md, lg, pill, button, input."),B("font","object","Font tokens: family, familyHeading, familyMono, sizeBase, weightBody, …."),B("spacing","object","Spacing scale tokens."),B("shadows","object","Box-shadow tokens."),B("gradients","object","Gradient color-stop arrays — referenced as gradient.<name>."),B("zIndex","object","Layer tokens (modal, toast, …) → sx.zIndex / --rui-z-*."),B("motion","object","Motion tokens: { fast, base, slow, ease } → --rui-motion-*."),B("fonts","object",'Web-font import: { import: ["Inter:400,700"] }.'),B("icons","object","Custom inline-SVG icons by name, usable anywhere an icon name is.")],Ld=[B("defaultLanguage","string","Fallback language when a key is missing for the current language."),B("currentLanguage","string","Active language — drive from a reactive atom for live switching."),B("translations","object",'{ key: { lang: "text {name}" } }. Supports ICU plural/select.')],zd=Object.freeze({http:so,query:Cd,mutation:Ad,socket:Td,sse:Md,script:Nd,head:Id,form:Pd,store:Rd,theme:Ed,i18n:Ld});function jd(t){return zd[t]}const Lt=12,Dd={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Od={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Bd(t){return Dd[t]??"stretch"}function Fd(t){return Od[t]??"flex-start"}function lo(t,e){return e?t==="row"?"row-reverse":t==="column"?"column-reverse":t.endsWith("-reverse")?t:`${t}-reverse`:t}function ot(t,e,r){for(const n of yt){const a=e.values[n];a&&t.push(`${r}-${n}:${Ii(a)||`var(--rui-spacing-${a}, ${a})`}`)}}function _d(t,e,r,n){for(const a of yt){const i=e.values[a];i&&t.push(`${r}-${a}:${n(String(i))}`)}}function co(t,e,r,n){const a=Te(t);if(a.kind==="single"){const i=a.value?String(a.value):n.defaultToken;r[n.attrName]=i;return}r[n.attrName]="responsive",r[n.responsiveFlag]="true",_d(e,a,n.cssVarPrefix,n.mapper)}function Ud(t,e){return!!(t&&typeof t=="object"&&t.__kind==="Component"&&t.name===e)}function Hd(t){const e=Te(t.direction);return e.kind==="single"?e.value?String(e.value):"column":e.values.base?String(e.values.base):"column"}const qd={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 n={class:"rui-stack-item"},a=[];e.grow!==void 0&&e.grow!==null&&(n["data-grow"]=String(P(e.grow,0))),e.shrink!==void 0&&e.shrink!==null&&(n["data-shrink"]=String(P(e.shrink,1)));const i=m(e.basis);i==="auto"||i==="0"?n["data-basis"]=i:i&&a.push(`flex-basis:${Z(i,i)}`);const o=m(e.alignSelf);if(o&&(n["data-align-self"]=o),e.order!==void 0&&e.order!==null){const d=P(e.order,0);n["data-order"]=String(d),a.push(`order:${d}`)}const s=m(e.minWidth);s&&a.push(`min-width:${Z(s,s)}`);const l=m(e.maxWidth);l&&a.push(`max-width:${Z(l,l)}`),a.length>0&&(n.style=a.join(";"));const c=u("div",n);return c.append(r.renderNode(e.child)),c}};function Sn(t,e,r,n,a){const i=Te(t),o=Te(n.gap),s=Te(n.padding),l=I(n.reverse),c={class:"rui-stack","data-wrap":I(n.wrap)?"true":null,"data-reverse":l?"true":null,"data-uniform":e?"true":"false","data-inline":I(n.inline)?"true":null},d=[];if(i.kind==="single"){const b=i.value?String(i.value):"column";c["data-direction"]=lo(b,l)}else{c["data-direction"]="responsive",c["data-responsive-dir"]="true";for(const b of yt){const h=i.values[b];h&&d.push(`--rui-stack-dir-${b}:${lo(String(h),l)}`)}}o.kind==="single"?c["data-gap"]=o.value?ve(o.value,String(o.value)):"md":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",ot(d,o,"--rui-stack-gap")),co(n.align,d,c,{attrName:"data-align",responsiveFlag:"data-responsive-align",cssVarPrefix:"--rui-stack-align",defaultToken:r,mapper:Bd}),co(n.justify,d,c,{attrName:"data-justify",responsiveFlag:"data-responsive-justify",cssVarPrefix:"--rui-stack-justify",defaultToken:"start",mapper:Fd});const p=m(n.alignContent);if(p&&(c["data-align-content"]=p),s.kind==="single"){const b=s.value?ve(s.value,String(s.value)):null;b&&(c["data-padding"]=b)}else c["data-padding"]="responsive",c["data-responsive-padding"]="true",ot(d,s,"--rui-stack-padding");d.length>0&&(c.style=d.join(";"));const f=u("div",c);for(const b of T(n.children))f.append(a.renderNode(b));return f}const Vd={name:"gap",type:"string | object",optional:!0,enum:me,description:"Spacing between children. May be a responsive map."},$n={name:"justify",type:"string | object",optional:!0,enum:["start","center","end","between","around","evenly"],description:"Main-axis distribution. May be a responsive map."},Cn={name:"wrap",type:"boolean",optional:!0,description:"Wrap children onto multiple lines when they overflow"},An={name:"reverse",type:"boolean",optional:!0,description:"Reverse the visual order of children"},Tn={name:"padding",type:"string | object",optional:!0,enum:me,description:"Inner padding token. May be a responsive map."},Mn={name:"inline",type:"boolean",optional:!0,description:"Use inline-flex (shrink-to-fit) instead of a full-width block"},uo={name:"alignContent",type:"string",optional:!0,enum:["start","center","end","between","around","stretch"],description:"Alignment of wrapped lines (only when `wrap` is on)"},Wd={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:me,description:"Horizontal spacing between children (default `md`). 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."},{...$n},{name:"grow",type:"boolean",optional:!0,description:"Children share the row width equally (replaces the old `uniform`)"},{...Cn},{...An},{...Tn},{...Mn},{...uo}],render:(t,e,r)=>Sn("row",I(e.grow),"center",e,r)},Gd={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:me,description:"Vertical spacing between children (default `md`). 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."},{...$n},{...Cn},{...An},{...Tn},{...Mn}],render:(t,e,r)=>Sn("column",!1,"stretch",e,r)},Kd={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"}`.'},{...Vd},{name:"align",type:"string | object",optional:!0,enum:["start","center","end","stretch"],description:"Cross-axis alignment (default stretch). May be a responsive map."},{...$n},{...uo},{...Cn},{...An},{name:"uniform",type:"boolean",optional:!0,description:"Row children share space equally (default true for row stacks; use `Row` for natural widths)"},{...Mn},{...Tn}],render:(t,e,r)=>{const a=Hd(e)==="row",i=e.uniform===void 0?a:I(e.uniform,a);return Sn(e.direction,i,"stretch",e,r)}},Yd={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:me,description:"Spacing between stacked children (default `md`)"},{name:"padding",type:"string",optional:!0,enum:me,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 n={class:"rui-center","data-axis":m(e.axis,"both"),"data-gap":ve(e.gap,"md"),"data-inline":I(e.inline)?"true":null},a=ve(e.padding,m(e.padding));a&&(n["data-padding"]=a);const i=[],o=m(e.minHeight);o&&i.push(`min-height:${Z(o,o)}`),i.length>0&&(n.style=i.join(";"));const s=u("div",n);for(const l of T(e.children))s.append(r.renderNode(l));return s}},Xd={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 n=u("div",{class:"rui-card","data-variant":m(e.variant,"default")});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Jd={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=u("header",{class:"rui-card-header"});r.append(u("h3",{class:"rui-card-title"},[m(e.title)]));const n=m(e.subtitle);return n&&r.append(u("p",{class:"rui-card-subtitle"},[n])),r}},Qd={name:"CardFooter",description:"Card footer for actions.",props:[{name:"children",type:"Node[]"}],render:(t,e,r)=>{const n=u("footer",{class:"rui-card-footer"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Zd={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"),n=I(e.decorative,!0),a=m(e.label);return a&&r==="horizontal"?u("div",{class:"rui-separator rui-separator-with-label","data-orientation":r,role:n?"presentation":"separator","aria-orientation":n?null:r},[u("span",{class:"rui-separator-line"}),u("span",{class:"rui-separator-label"},[a]),u("span",{class:"rui-separator-line"})]):u("div",{class:"rui-separator","data-orientation":r,role:n?"presentation":"separator","aria-orientation":n?null:r})}},po=(t,e,r=!1)=>{const n=u("li",{class:"rui-steps-item","data-active":r?"true":"false"});return n.append(u("div",{class:"rui-steps-title"},[t])),e&&n.append(u("div",{class:"rui-steps-details"},[e])),n},ep={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 n=u("ol",{class:"rui-steps"});for(const a of T(e.items)){if(a&&typeof a=="object"&&a.__kind==="Component"){n.append(r.renderNode(a));continue}if(a&&typeof a=="object"){const i=a;n.append(po(m(i.title),m(i.details),I(i.active)));continue}n.append(po(m(a),""))}return n}},tp={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 n=u("div",{class:"rui-tab-content",role:"tabpanel","data-value":m(e.value),"data-active":"false"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},rp={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 n=T(e.items),a=m(e.orientation,"horizontal"),i=u("div",{class:"rui-tabs","data-orientation":a}),o=u("div",{class:"rui-tab-list",role:"tablist","aria-orientation":a}),s=u("div",{class:"rui-tab-panels"});let l=m(e.defaultValue);if(!l&&n.length>0){const f=n[0];l=m(f?.args?.[0],"tab-0")}const c=r.useInstanceState("activeTab",l);m(e.defaultValue)&&m(e.defaultValue)!==l&&c.set(m(e.defaultValue)),new Set(n.map((f,b)=>m(f.args?.[0],`tab-${b}`))).has(c.get())||c.set(l);const p=(f,b)=>{const h=c.get();c.set(f);const g=b.closest(".rui-tabs");g&&(g.querySelectorAll(".rui-tab-trigger").forEach(y=>{const v=y.getAttribute("data-value")===f;y.setAttribute("aria-selected",v?"true":"false"),y.tabIndex=v?0:-1}),g.querySelectorAll(".rui-tab-content").forEach(y=>{y.setAttribute("data-active",y.getAttribute("data-value")===f?"true":"false")})),h!==f&&r.invoke(e.onChange,f)};return n.forEach((f,b)=>{const h=f,g=m(h.args?.[0],`tab-${b}`),y=m(h.args?.[1],`Tab ${b+1}`),v=m(h.args?.[3]),x=m(h.args?.[4]),w=g===c.get(),k=u("button",{class:"rui-tab-trigger",role:"tab",type:"button","data-value":g,"aria-selected":w?"true":"false",tabindex:w?"0":"-1"}),A=x?np(x):null;A&&k.append(A),k.append(u("span",{class:"rui-tab-trigger-label"},[y])),v&&k.append(u("span",{class:"rui-tab-trigger-badge"},[v])),k.onclick=$=>{const C=$.currentTarget??$.target;p(g,C)},k.onkeydown=$=>{const C=$,M=a!=="vertical",L=M?C.key==="ArrowRight":C.key==="ArrowDown",z=M?C.key==="ArrowLeft":C.key==="ArrowUp";if(!L&&!z&&C.key!=="Home"&&C.key!=="End")return;C.preventDefault();const H=C.currentTarget??C.target,F=H.closest(".rui-tab-list");if(!F)return;const V=Array.from(F.querySelectorAll(".rui-tab-trigger"));if(V.length===0)return;const _=V.indexOf(H);let te=_;C.key==="Home"?te=0:C.key==="End"?te=V.length-1:L?te=(_+1)%V.length:z&&(te=(_-1+V.length)%V.length);const ke=V[te];if(!ke)return;ke.focus();const De=ke.getAttribute("data-value")??"";De&&p(De,ke)},o.append(k);const S=r.renderNode(f);S.setAttribute("data-value",g),S.setAttribute("data-active",w?"true":"false"),s.append(S)}),i.append(o,s),i}};function np(t){return j(t,{className:"rui-tab-trigger-icon"})}const ap={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 n=e.showArrow!==void 0&&e.showArrow!==null,a=u("details",{class:"rui-accordion-item","data-show-arrow":n?I(e.showArrow)?"true":"false":null});I(e.open)&&a.setAttribute("open","");const i=u("summary",{class:"rui-accordion-trigger"});i.append(u("span",{class:"rui-accordion-title"},[m(e.title)])),i.append(u("span",{class:"rui-accordion-chevron","aria-hidden":"true"})),a.append(i);const o=u("div",{class:"rui-accordion-body"});for(const s of T(e.children))o.append(r.renderNode(s));return a.append(o),a}},ip={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 n=u("div",{class:"rui-accordion","data-show-arrow":I(e.showArrow)?"true":"false"});for(const a of T(e.items))n.append(r.renderNode(a));return n}},pr=t=>Math.max(1,Math.min(Lt,Math.round(t)));function Nn(t){if(t==null||t==="")return 12;const e=String(t).trim();if(e.includes("/")){const[r,n]=e.split("/"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return pr(Math.round(Lt*a/i))}return e==="auto"||e==="fit"||e==="auto-fit"||e==="full"||e==="100%"?12:pr(P(t,12))}function op(t){const e=m(t.minChildWidth)||m(t.minItemWidth);return Z(e||"220px","220px")}const sp={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 n=Nn(e.span??12),a=Te(e.spanAt),i=e.offset===void 0||e.offset===null?0:Math.max(0,Math.min(Lt-1,Math.round(P(e.offset,0)))),o={class:"rui-grid-item","data-span":String(n)},s=[`--rui-grid-item-span:${n}`];if(i>0&&(o["data-offset"]=String(i),s.push(`--rui-grid-item-offset:${i}`)),a.kind==="responsive"){o["data-responsive-span"]="true";for(const c of yt){const d=a.values[c];if(d!==void 0){const p=Nn(d);s.push(`--rui-grid-item-span-${c}:${p}`)}}}else if(a.kind==="single"&&a.value!=null){const c=Nn(a.value);s.push(`--rui-grid-item-span:${c}`),o["data-span"]=String(c)}o.style=s.join(";");const l=u("div",o);return l.append(r.renderNode(e.child)),l}},lp={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:me,description:"Inner padding. May be a responsive map."},{name:"margin",type:"string | object",optional:!0,enum:me,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 n=Te(e.padding),a=Te(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:${Z(s,s)}`),n.kind==="single"){const c=n.value?ve(n.value,String(n.value)):null;c&&(i["data-padding"]=c)}else i["data-padding"]="responsive",i["data-responsive-padding"]="true",ot(o,n,"--rui-box-padding");if(a.kind==="single"){const c=a.value?ve(a.value,String(a.value)):null;c&&(i["data-margin"]=c)}else i["data-margin"]="responsive",i["data-responsive-margin"]="true",ot(o,a,"--rui-box-margin");o.length>0&&(i.style=o.join(";"));const l=u("div",i);for(const c of T(e.children))l.append(r.renderNode(c));return l}},cp={name:"Fragment",description:"Groups several siblings into one value WITHOUT adding a layout box — the wrapper is `display: contents`, so the children participate in the parent's flex/grid layout directly. Use to return multiple nodes from a component, or to conditionally group siblings, without a stray `div` that would break a Grid/Stack's spacing.",props:[{name:"children",type:"Node[]",description:"Sibling nodes to group"}],render:(t,e,r)=>{const n=u("div",{class:"rui-fragment",style:"display:contents;"});for(const a of T(e.children))n.append(r.renderNode(a));return n}},mo={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:me,description:"Gap on both axes (default `md`). May be a responsive map."},{name:"rowGap",type:"string | object",optional:!0,enum:me,description:"Row gap override. May be a responsive map."},{name:"columnGap",type:"string | object",optional:!0,enum:me,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 n=T(e.children),a=n.some(y=>Ud(y,"GridItem")),i=Te(e.columns),o=Te(e.gap),s=Te(e.rowGap),l=Te(e.columnGap),c={class:"rui-grid"},d=[];let p=!1,f=!1;if(i.kind==="single"){const y=i.value===null?0:P(i.value,0),v=y>0?pr(y):0;if(v===Lt?p=!0:v>0&&(f=!0),v>0){c["data-columns"]=String(v);const x=m(e.minChildWidth)||m(e.minItemWidth);x&&(c["data-min-child-width"]="true",d.push(`--rui-grid-min-child:${Z(x,"220px")}`))}else d.push(`--rui-grid-min-item:${op(e)}`)}else{c["data-responsive-cols"]="true";for(const y of yt){const v=i.values[y];if(v===void 0)continue;const x=pr(P(v,0));x===Lt?p=!0:x>0&&(f=!0),d.push(`--rui-grid-cols-${y}:${x}`)}}a&&!f&&(p=!0),p&&(c["data-grid-mode"]="12"),o.kind==="single"?c["data-gap"]=o.value?ve(o.value,String(o.value)):"md":(c["data-gap"]="responsive",c["data-responsive-gap"]="true",ot(d,o,"--rui-grid-gap")),s.kind==="single"&&s.value?c["data-row-gap"]=ve(s.value,String(s.value)):s.kind==="responsive"&&(c["data-row-gap"]="responsive",c["data-responsive-row-gap"]="true",ot(d,s,"--rui-grid-row-gap")),l.kind==="single"&&l.value?c["data-column-gap"]=ve(l.value,String(l.value)):l.kind==="responsive"&&(c["data-column-gap"]="responsive",c["data-responsive-column-gap"]="true",ot(d,l,"--rui-grid-column-gap"));const b=m(e.alignItems);b&&(c["data-align-items"]=b);const h=m(e.justifyItems);h&&(c["data-justify-items"]=h),I(e.dense)&&(c["data-dense"]="true"),d.length>0&&(c.style=d.join(";"));const g=u("div",c);for(const y of n)g.append(r.renderNode(y));return g}},up={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 n=dp(m(e.ratio,"16:9")),a=u("div",{class:"rui-aspect-ratio",style:`aspect-ratio:${n};`});for(const i of T(e.children))a.append(r.renderNode(i));return a}};function dp(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i!==0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const pp={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 n=u("div",{class:"rui-scroll-area","data-direction":m(e.direction,"vertical"),style:`max-height:${Z(e.maxHeight,"320px")};`});for(const a of T(e.children))n.append(r.renderNode(a));return n}},mp=["sm","md","lg","xl","full"],fo='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let fp=0;function go(t){return t.getRootNode().activeElement??null}const gp={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). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",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:mp,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 n=m(e.size,"md"),a=e.closable===void 0?!0:I(e.closable),i=u("div",{class:"rui-modal-overlay","data-open":I(e.open)?"true":"false"}),o=r.useInstanceState("rui-modal-title-id","");o.get()||o.set(`rui-modal-title-${fp+=1}`);const s=o.get(),l=u("div",{class:"rui-modal",role:"dialog","aria-modal":"true","aria-labelledby":s,tabindex:"-1","data-size":n}),c=u("header",{class:"rui-modal-header"});c.append(u("h3",{class:"rui-modal-title",id:s},[m(e.title)]));const d=t.argMeta?.[1]?.stateRef,p=()=>{d&&r.setState(d,!1),r.invoke(e.onClose)};if(a){const v=u("button",{type:"button",class:"rui-modal-close","aria-label":"Close dialog"},["×"]);v.onclick=x=>{x.stopPropagation(),p()},c.append(v)}l.append(c);const f=u("div",{class:"rui-modal-body"});for(const v of T(e.children))f.append(r.renderNode(v));l.append(f);const b=T(e.footer);if(b.length>0){const v=u("footer",{class:"rui-modal-footer"});for(const x of b)v.append(r.renderNode(x));l.append(v)}i.append(l),I(e.closeOnBackdrop)&&(i.onclick=v=>{v.target===i&&p()});const h=I(e.open);l.addEventListener("keydown",v=>{if(v.key==="Escape"&&a){v.stopPropagation(),p();return}if(v.key!=="Tab")return;const x=[...l.querySelectorAll(fo)];if(x.length===0){v.preventDefault(),l.focus();return}const w=x[0],k=x[x.length-1],A=go(l);v.shiftKey&&A===w?(v.preventDefault(),k.focus()):!v.shiftKey&&A===k&&(v.preventDefault(),w.focus())});const g=r.useInstanceState("rui-modal-focus",{open:!1,prev:null}),y=g.get();if(h&&!y.open){const v=go(l);g.set({open:!0,prev:v});const x=()=>{([...l.querySelectorAll(fo)][0]??l).focus()};typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}else if(!h&&y.open){const v=y.prev;if(g.set({open:!1,prev:null}),v&&typeof v.focus=="function"){const x=()=>v.focus();typeof queueMicrotask=="function"?queueMicrotask(x):Promise.resolve().then(x)}}return i}},ho={js:new Set(["const","let","var","function","return","if","else","for","while","do","switch","case","break","continue","new","class","extends","super","this","import","export","from","default","try","catch","finally","throw","typeof","instanceof","in","of","await","async","yield","delete","void","null","undefined","true","false","interface","type","enum","public","private","protected","readonly","static","as","implements","namespace"]),py:new Set(["def","return","if","elif","else","for","while","import","from","as","class","try","except","finally","raise","with","lambda","yield","pass","break","continue","and","or","not","in","is","None","True","False","global","nonlocal","async","await","self"]),css:new Set([]),json:new Set(["true","false","null"])};function bo(t){const e=t.toLowerCase();return["js","jsx","ts","tsx","javascript","typescript","mjs","cjs","aktion"].includes(e)?"js":["py","python"].includes(e)?"py":["css","scss","less"].includes(e)?"css":["json","jsonc"].includes(e)?"json":["html","xml","svg","vue"].includes(e)?"html":"generic"}const vo=/[A-Za-z_$][\w$]*/y,yo=/0[xX][0-9a-fA-F]+|\d*\.?\d+(?:[eE][+-]?\d+)?/y,xo=/\s+/y;function hp(t,e,r){const n=bo(e);if(n==="html")return bp(t);const a=[],i=ho[n==="generic"?"js":n]??ho.js;let o=0;const s=t.length,l=(c,d)=>{c&&a.push({text:c,cls:d})};for(;o<s;){if(r.inBlockComment){const h=t.indexOf("*/",o);if(h===-1){l(t.slice(o),"comment"),o=s;break}l(t.slice(o,h+2),"comment"),o=h+2,r.inBlockComment=!1;continue}const c=t[o],d=t.slice(o,o+2);if(n==="py"&&c==="#"||(n==="js"||n==="css"||n==="generic")&&d==="//"){l(t.slice(o),"comment");break}if((n==="js"||n==="css"||n==="generic")&&d==="/*"){const h=t.indexOf("*/",o+2);if(h===-1){l(t.slice(o),"comment"),r.inBlockComment=!0,o=s;break}l(t.slice(o,h+2),"comment"),o=h+2;continue}if(c==='"'||c==="'"||c==="`"){let h=o+1;for(;h<s;){if(t[h]==="\\"){h+=2;continue}if(t[h]===c){h+=1;break}h+=1}l(t.slice(o,h),"string"),o=h;continue}xo.lastIndex=o;const p=xo.exec(t);if(p&&p.index===o){l(p[0],null),o+=p[0].length;continue}yo.lastIndex=o;const f=yo.exec(t);if(f&&f.index===o&&f[0]){l(f[0],"number"),o+=f[0].length;continue}vo.lastIndex=o;const b=vo.exec(t);if(b&&b.index===o){const h=b[0],g=t[o+h.length];i.has(h)?l(h,"keyword"):g==="("?l(h,"fn"):l(h,null),o+=h.length;continue}l(c,"punct"),o+=1}return a}function bp(t){const e=[],r=/(<\/?[\w-]+)|(\/?>)|([\w-]+)(?==)|("[^"]*"|'[^']*')|(<!--.*?-->)/g;let n=0,a;for(;(a=r.exec(t))!==null;)a.index>n&&e.push({text:t.slice(n,a.index),cls:null}),a[1]?e.push({text:a[1],cls:"tag"}):a[2]?e.push({text:a[2],cls:"tag"}):a[3]?e.push({text:a[3],cls:"attr"}):a[4]?e.push({text:a[4],cls:"string"}):a[5]&&e.push({text:a[5],cls:"comment"}),n=r.lastIndex;return n<t.length&&e.push({text:t.slice(n),cls:null}),e}function vp(t){return bo(t)!=="generic"||t.length>0}function wo(t,e,r,n){const a=hp(e,r,n);for(const i of a)i.cls?t.append(u("span",{class:`rui-hl-${i.cls}`},[i.text])):t.append(document.createTextNode(i.text))}const yp=["solid","regular","brands"],mr=["xs","sm","md","lg","xl"],xp=["default","neutral","primary","success","warning","danger","info"];function In(t,e="md"){const r=m(t).trim().toLowerCase();return r?r==="small"?"sm":r==="normal"?"md":r==="large"?"lg":mr.includes(r)?r:e:e}const wp={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:yp},{name:"size",type:"string",optional:!0,enum:gu},{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),n=m(e.variant,""),a=m(e.size,"md"),i=m(e.color,""),o=n?`${n}:${r}`:r,s=j(o,{size:a,color:i});return s||u("span",{class:"rui-icon","data-icon-size":a},[r])}},kp=["small","small-heavy","body","body-heavy","large","large-heavy","heading","title"];function Sp(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const ko=[{name:"value",type:"string"},{name:"variant",type:"string",optional:!0,enum:kp},{name:"tone",type:"string",optional:!0,enum:["default","muted","primary","success","warning","danger"],description:"Visual accent"},{name:"align",type:"string",optional:!0,enum:["left","center","right"],description:"Horizontal text alignment — the text becomes its own block-level line"},{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;").'}],So=(t,e)=>{const r=m(e.variant,"body"),n=m(e.tone,"default"),a=m(e.align),i=Sp(e.style);return u("span",{class:"rui-text","data-variant":r,"data-color":n,"data-align":a||null,style:i||null},[m(e.value)])},$p={name:"Text",description:'Renders plain text with a typographic variant. `align` (left|center|right) sets the horizontal alignment (the text renders as its own block). Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',props:ko,render:So},Cp={name:"TextContent",description:"Deprecated alias for `Text`. Prefer `Text(...)` — both render identically.",props:ko,render:So},Ap={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` (and it reserves space to avoid layout shift). `fit` controls how the image fills that box. `placeholder: "blur"` fades the image in once loaded; `sizes`/`srcset` enable responsive loading; `loading: "eager"` opts out of lazy-loading. When `src` is missing/unsafe or fails to load it shows the `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/errored"},{name:"placeholder",type:"string",optional:!0,enum:["blur","none"],description:"`blur` fades the image in on load"},{name:"loading",type:"string",optional:!0,enum:["lazy","eager"],description:"Native loading strategy (default lazy)"},{name:"sizes",type:"string",optional:!0,description:"Responsive `sizes` attribute"},{name:"srcset",type:"string",optional:!0,aliases:["srcSet"],description:"Responsive `srcset` candidates"}],render:(t,e)=>{const r=u("figure",{class:"rui-image","data-fit":m(e.fit,"cover"),style:e.ratio?`aspect-ratio:${Tp(m(e.ratio))};`:null}),n=ie(e.src),a=()=>{const o=u("div",{class:"rui-image-placeholder",role:"presentation","aria-hidden":"true"}),s=m(e.fallback);if(s){const l=j(s,{className:"rui-image-fallback-icon"});l?o.append(l):o.append(u("span",{class:"rui-image-fallback-text"},[s]))}return o};if(n){const o=m(e.placeholder)==="blur",s=u("img",{src:n,alt:m(e.alt),loading:m(e.loading,"lazy")==="eager"?"eager":"lazy",decoding:"async",sizes:m(e.sizes)||null,srcset:m(e.srcset)||null,"data-blur":o?"true":null});o&&(s.complete?s.setAttribute("data-loaded","true"):s.addEventListener("load",()=>s.setAttribute("data-loaded","true"),{once:!0})),s.addEventListener("error",()=>{s.replaceWith(a())},{once:!0}),r.append(s)}else r.append(a());const i=m(e.caption);return i&&r.append(u("figcaption",{class:"rui-image-caption"},[i])),r}};function Tp(t){if(!t)return"auto";if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"auto"}const $o=["neutral","primary","success","warning","danger","info"],Mp={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:$o,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:mr}],render:(t,e)=>{const r=m(e.tone,"neutral"),n=In(e.size,"md"),a=u("span",{class:"rui-badge","data-variant":r,"data-size":n}),i=j(e.icon,{className:"rui-badge-icon"});i&&a.append(i);const o=m(e.label);return o&&a.append(u("span",{class:"rui-badge-label"},[o])),a}},Np={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:$o,aliases:["variant"]},{name:"size",type:"string",optional:!0,enum:mr}],render:(t,e)=>{const r=m(e.tone,"neutral"),n=In(e.size,"md"),a=u("div",{class:"rui-badge-list"});for(const i of T(e.labels)){const o=m(i);if(!o)continue;const s=u("span",{class:"rui-badge","data-variant":r,"data-size":n});s.append(u("span",{class:"rui-badge-label"},[o])),a.append(s)}return a}},Ip={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"),n=I(e.compact),a=u("div",{class:"rui-callout","data-variant":r,"data-compact":n?"true":"false"}),i=m(e.icon)||Rp(r),o=j(i,{className:"rui-callout-icon"});o&&a.append(o);const s=u("div",{class:"rui-callout-body"});s.append(u("div",{class:"rui-callout-title"},[m(e.title)]));const l=m(e.description);return l&&s.append(u("div",{class:"rui-callout-description"},[l])),a.append(s),a}},fr={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. `header=false` renders a chromeless variant — no language label or copy button, no border or rounding — that fills its container (100%×100%), for embedding in your own frame (CodeWindow uses it). `width`/`height` set an explicit size; overflowing code scrolls either way.',props:[{name:"language",type:"string",optional:!0,description:"Display label + syntax highlighting (e.g. aktion, 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,description:'Highlight ranges, e.g. "3-5,8"'},{name:"highlight",type:"boolean",optional:!0,description:"Syntax-highlight tokens when a language is set (default true)"},{name:"copy",type:"boolean",optional:!0,description:"Show the copy-to-clipboard button (default true)"},{name:"header",type:"boolean",optional:!0,description:"Show the header bar (default true); false = chromeless, fills its container"},{name:"width",type:"string",optional:!0,description:"Explicit width (CSS length)"},{name:"height",type:"string",optional:!0,description:"Explicit height (CSS length); overflowing code scrolls"}],render:(t,e)=>{const r=m(e.language),n=m(e.codeString),a=I(e.showLineNumbers),i=Pp(m(e.highlightLines)),o=e.copy===void 0?!0:I(e.copy),s=e.header===void 0?!0:I(e.header),l=Z(e.width,""),c=Z(e.height,""),d=[l?`width:${l}`:"",c?`height:${c}`:""].filter(Boolean).join(";"),p=u("div",{class:"rui-code-block","data-headerless":s?null:"true",style:d||null});if(s&&(r||o)){const h=u("div",{class:"rui-code-block-head"});if(r&&h.append(u("span",{class:"rui-code-block-language"},[r])),o){const g=u("button",{type:"button",class:"rui-code-block-copy","aria-label":"Copy code",title:"Copy"}),y=j("copy",{className:"rui-code-block-copy-icon"});y&&g.append(y),g.append(u("span",{class:"rui-code-block-copy-label"},["Copy"])),g.onclick=v=>{const x=v.currentTarget??v.target,k=x.closest(".rui-code-block")?.querySelector("code")?.textContent??n,S=(typeof navigator<"u"?navigator:null)?.clipboard;S?.writeText&&S.writeText(k).catch(()=>{});const $=x.querySelector(".rui-code-block-copy-label");if($){const C=$.textContent??"Copy";$.textContent="Copied",setTimeout(()=>{$.textContent=C},1500)}},h.append(g)}p.append(h)}const f=u("pre",{class:"rui-code-block-pre","data-line-numbers":a?"true":"false"}),b=(e.highlight===void 0?!0:I(e.highlight))&&!!r&&vp(r);if(a||i.size>0){const h=n.split(/\r?\n/),g=u("code",{}),y={inBlockComment:!1};h.forEach((v,x)=>{const w=x+1,k=u("span",{class:"rui-code-block-line","data-line":String(w),"data-highlight":i.has(w)?"true":null});a&&k.append(u("span",{class:"rui-code-block-gutter"},[String(w)]));const A=u("span",{class:"rui-code-block-code"});b?wo(A,v,r,y):A.append(document.createTextNode(v)),k.append(A),g.append(k)}),f.append(g)}else if(b){const h=u("code",{}),g={inBlockComment:!1},y=n.split(/\r?\n/);y.forEach((v,x)=>{wo(h,v,r,g),x<y.length-1&&h.append(document.createTextNode(`
|
|
97
|
+
`))}),f.append(h)}else f.append(u("code",{},[n]));return p.append(f),p}};function Pp(t){const e=new Set;if(!t)return e;for(const r of t.split(",")){const n=r.trim();if(n)if(n.includes("-")){const a=n.split("-").map(s=>Number(s.trim())),i=a[0]??NaN,o=a[1]??NaN;if(Number.isFinite(i)&&Number.isFinite(o)&&i<=o)for(let s=i;s<=o;s+=1)e.add(s)}else{const a=Number(n);Number.isFinite(a)&&e.add(a)}}return e}function Rp(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 Ep={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),n=m(e.shape);if(n)return Lp(n,e);if(r&&r!=="paragraph")return zp(r,e);const a=Number(e.lines),i=Math.max(1,Math.min(50,Number.isFinite(a)?Math.floor(a):3)),o=Number(e.height),s=Number.isFinite(o)&&o>0?Math.min(200,Math.floor(o)):12,l=u("div",{class:"rui-skeleton","data-variant":"paragraph"});for(let c=0;c<i;c+=1)l.append(u("div",{class:"rui-skeleton-line",style:`height:${s}px`}));return l}};function Lp(t,e){const r=Z(m(e.width),"100%"),n=m(e.height),a=n?Z(n,"16px"):t==="circle"?r:"16px";return u("div",{class:"rui-skeleton","data-variant":"shape","data-shape":t==="circle"?"circle":"rect",style:`width:${r};height:${a};`})}function zp(t,e){const r=u("div",{class:"rui-skeleton","data-variant":t});switch(t){case"avatar":{const n=Z(m(e.width),"40px");return r.append(u("div",{class:"rui-skeleton-shape","data-shape":"circle",style:`width:${n};height:${n};`})),r}case"image":{const n=Z(m(e.width),"100%"),a=Z(m(e.height),"160px");return r.append(u("div",{class:"rui-skeleton-shape","data-shape":"rect",style:`width:${n};height:${a};`})),r}case"card":return r.append(u("div",{class:"rui-skeleton-shape","data-shape":"rect",style:"width:100%;height:120px;"})),r.append(u("div",{class:"rui-skeleton-line",style:"height:14px;width:70%;"})),r.append(u("div",{class:"rui-skeleton-line",style:"height:12px;width:90%;"})),r.append(u("div",{class:"rui-skeleton-line",style:"height:12px;width:60%;"})),r;case"table-row":{const n=Math.max(1,Math.min(8,Math.floor(Number(e.lines??4)))),a=u("div",{class:"rui-skeleton-row"});for(let i=0;i<n;i+=1)a.append(u("div",{class:"rui-skeleton-line",style:"height:12px;flex:1;"}));return r.append(a),r}default:return r}}const jp={name:"Markdown",description:"Render markdown-flavoured text. Supports **bold**, *italic*, `code`, headings (`#`/`##`/`###`), blockquotes (`>`), bullet (`-`/`*`) and numbered (`1.`) lists, fenced code blocks (```), images (``), inline links, and auto-linked bare URLs. Multi-line paragraphs collapse into `<p>` blocks.",props:[{name:"content",type:"string"}],render:(t,e)=>{const r=m(e.content),n=_p(r);return u("div",{class:"rui-markdown",html:n})}},Dp={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:me,description:"Horizontal padding (default md)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-container","data-size":m(e.size,"lg"),"data-padding":ve(e.padding,"md"),style:e.maxWidth?`max-width:${Z(e.maxWidth,"auto")};`:null});for(const a of T(e.children))n.append(r.renderNode(a));return n}},Op={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:me,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=ve(e.size,m(e.size)),n=e.flex===void 0?!r:I(e.flex);return u("span",{class:"rui-spacer","data-size":r||null,"data-flex":n?"true":"false","aria-hidden":"true"})}},Bp={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:mr,description:"Default `md`"},{name:"label",type:"string",optional:!0,description:"Caption rendered beside the spinner (also announced)"},{name:"tone",type:"string",optional:!0,enum:xp,description:"Visual accent (default `primary`)"}],render:(t,e)=>{const r=In(e.size,"md"),n=m(e.tone,"primary"),a=m(e.label),i=u("span",{class:"rui-spinner","data-size":r,"data-tone":n,role:"status","aria-live":"polite","aria-label":a||"Loading"});return i.append(u("span",{class:"rui-spinner-ring","aria-hidden":"true"})),a&&i.append(u("span",{class:"rui-spinner-label"},[a])),i}},Fp={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=u("figure",{class:"rui-quote","data-tone":m(e.tone,"default")});r.append(u("blockquote",{class:"rui-quote-text"},[m(e.text)]));const n=m(e.cite);return n&&r.append(u("figcaption",{class:"rui-quote-cite"},[n])),r}};function _p(t){const e=b=>b.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),r=t.split(/\r?\n/),n=[];let a=null,i=!1,o=!1,s="",l=[];const c=()=>{a&&(n.push(a==="ul"?"</ul>":"</ol>"),a=null)},d=()=>{i&&(n.push("</blockquote>"),i=!1)},p=()=>{const b=s?` data-language="${e(s)}"`:"";n.push(`<pre class="rui-markdown-code"${b}><code>${e(l.join(`
|
|
98
|
+
`))}</code></pre>`),l=[],s="",o=!1};for(const b of r){const h=/^```\s*(.*)$/.exec(b.trim());if(o){if(h){p();continue}l.push(b);continue}if(h){c(),d(),o=!0,s=h[1]??"";continue}const g=/^\s*(#{1,3})\s+(.+)$/.exec(b);if(g){c(),d();const w=g[1].length;n.push(`<h${w} class="rui-markdown-h${w}">${f(e(g[2]))}</h${w}>`);continue}const y=/^\s*>\s?(.*)$/.exec(b);if(y){c(),i||(n.push('<blockquote class="rui-markdown-quote">'),i=!0),n.push(`<p>${f(e(y[1]??""))}</p>`);continue}else i&&b.trim()!==""&&d();const v=/^\s*[-*]\s+(.*)$/.exec(b);if(v){d(),a!=="ul"&&(c(),n.push("<ul>"),a="ul"),n.push(`<li>${f(e(v[1]??""))}</li>`);continue}const x=/^\s*\d+\.\s+(.*)$/.exec(b);if(x){d(),a!=="ol"&&(c(),n.push("<ol>"),a="ol"),n.push(`<li>${f(e(x[1]??""))}</li>`);continue}if(b.trim()===""){c(),d();continue}c(),d(),n.push(`<p>${f(e(b))}</p>`)}return o&&p(),c(),d(),n.join("");function f(b){let h=b.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(g,y,v)=>{const x=ie(v);return x?`<img class="rui-markdown-image" src="${gr(x)}" alt="${y}" loading="lazy">`:`<span class="rui-markdown-image-fallback">${y}</span>`}).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(g,y,v)=>`<a class="rui-link" href="${Co(v)}" target="_blank" rel="noopener noreferrer">${y}</a>`);return h=h.replace(/(?<![="'>])\bhttps?:\/\/[a-zA-Z0-9._~:/?#@!$&'()*+,;=%\-]+/g,g=>`<a class="rui-link" href="${Co(g)}" target="_blank" rel="noopener noreferrer">${g}</a>`),h}}function Co(t){const e=t.trim();if(!e||e.startsWith("//"))return"#";if(e.startsWith("#")||e.startsWith("/")||e.startsWith("?"))return gr(e);const r=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);if(!r)return gr(e);const n=r[1].toLowerCase();return new Set(["http","https","mailto","tel"]).has(n)?gr(e):"#"}function gr(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function zt(t,e,r){const n=u("span",{class:"rui-avatar","data-size":r,role:"img"}),a=ie(t);if(a){const i=u("img",{src:a,alt:e,loading:"lazy"});i.onerror=o=>{const s=o;(s.currentTarget??s.target).replaceWith(u("span",{class:"rui-avatar-fallback"},[St(e)]))},n.append(i)}else n.append(u("span",{class:"rui-avatar-fallback"},[St(e)]));return n}function St(t){const e=t.trim();return e?e.split(/\s+/).slice(0,2).map(n=>n.charAt(0).toUpperCase()).join("")||e.charAt(0).toUpperCase():"?"}const hr=new WeakMap;function $t(t){const{liveRoot:e,onDismiss:r}=t,n=hr.get(e);n&&n.dispose();const a=e.getRootNode();let i=!1;const o=p=>{const f=p.target;f&&e.contains(f)||(d.dispose(),r())},s=p=>{p.key==="Escape"&&(d.dispose(),r())},l=e.ownerDocument;let c=null;if(l&&typeof MutationObserver<"u"){c=new MutationObserver(()=>{e.isConnected||d.dispose()});const p=e.getRootNode();(p instanceof Element||p instanceof Document||p instanceof ShadowRoot)&&c.observe(p,{childList:!0,subtree:!0})}const d={dispose:()=>{i||(i=!0,a.removeEventListener("click",o,!0),a.removeEventListener("keydown",s,!0),c?.disconnect(),hr.delete(e))}};return setTimeout(()=>{i||(a.addEventListener("click",o,!0),a.addEventListener("keydown",s,!0))},0),hr.set(e,d),d}function We(t){if(!t)return;const e=hr.get(t);e&&e.dispose()}const Ao="a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])";function Pn(t,e){return r=>{const n=r.currentTarget??r.target;if(!n)return;if(r.key==="Escape"){r.stopPropagation(),e(n);return}if(r.key!=="Tab")return;const a=n.querySelector(t);if(!a)return;const i=Array.from(a.querySelectorAll(Ao));if(i.length===0){r.preventDefault();return}const s=n.getRootNode().activeElement,l=i[0],c=i[i.length-1];r.shiftKey&&(s===l||!a.contains(s))?(r.preventDefault(),c.focus()):!r.shiftKey&&s===c&&(r.preventDefault(),l.focus())}}function Rn(t,e,r){typeof MutationObserver>"u"||setTimeout(()=>{if(!t.isConnected)return;let n=null;const a=s=>{const l=t.getRootNode();if(s){n=l.activeElement??null;const c=t.querySelector(e);c&&!c.contains(l.activeElement)&&(c.querySelector(Ao)??c).focus?.()}else n?.focus?.(),n=null};let i=t.getAttribute("data-open")==="true";i&&a(!0);const o=new MutationObserver(()=>{const s=t.getAttribute("data-open")==="true";s!==i&&(i=s,a(s))});o.observe(t,{attributes:!0,attributeFilter:["data-open"]}),r.registerDisposer(()=>o.disconnect(),"rui-dialog-focus")},0)}const Up=[{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 To(t){if(!t)return null;for(const e of Up)if(e.match.test(t))return e.icon;return null}const Hp={default:"circle-info",info:"circle-info",primary:"bolt",success:"circle-check",warning:"triangle-exclamation",danger:"circle-exclamation",error:"circle-exclamation",neutral:"circle-info"};function qp(t){return t?Hp[t.toLowerCase()]??null:null}function Vp(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 br(t,e,r={}){const n=m(e.label),a=m(e.hint),i=m(e.error),o=I(e.required);if(!n&&!a&&!i&&!o)return t;const s=m(e[r.idKey??"id"])||m(t.getAttribute("id"));o&&t.setAttribute("required",""),i&&t.setAttribute("aria-invalid","true");const l=u("div",{class:"rui-field","data-invalid":i?"true":null});if(n){const c=u("label",{class:"rui-field-label",for:s||null},[n]);o&&c.append(u("span",{class:"rui-field-required","aria-hidden":"true"},["*"])),l.append(c)}if(l.append(t),i){const c=s?`${s}-error`:null,d=u("div",{class:"rui-field-error",id:c,role:"alert"},[i]);c&&t.setAttribute("aria-describedby",c),l.append(d)}else if(a){const c=s?`${s}-hint`:null,d=u("div",{class:"rui-field-hint",id:c},[a]);c&&t.setAttribute("aria-describedby",c),l.append(d)}return l}const En=[{name:"label",type:"string",optional:!0,description:"Field label rendered above the control"},{name:"hint",type:"string",optional:!0,description:"Helper text rendered below the control"},{name:"error",type:"string",optional:!0,description:"Validation error rendered below the control (marks it invalid)"},{name:"required",type:"boolean",optional:!0,description:"Mark the field required (adds a `*` and the `required` attribute)"},{name:"onBlur",type:"callable",optional:!0,aliases:["onblur"],description:"Called with the current value when focus leaves the control (validate-on-blur, `form.touch`)"},{name:"onFocus",type:"callable",optional:!0,aliases:["onfocus"],description:"Called when the control gains focus"}];function vr(t,e,r,n=a=>a.value){e.onBlur!=null&&(t.onblur=a=>{const i=a.currentTarget??a.target;r.invoke(e.onBlur,n(i))}),e.onFocus!=null&&(t.onfocus=a=>{const i=a.currentTarget??a.target;r.invoke(e.onFocus,n(i))})}function Mo(t){return T(t).map(r=>{if(r&&typeof r=="object"){const a=r;if(a.__kind==="Component"&&Array.isArray(a.args)){const i=m(a.args[0]);return{value:i,label:m(a.args[1],i)}}if(a.value!==void 0||a.label!==void 0){const i=m(a.value);return{value:i,label:m(a.label,i)}}}const n=m(r);return{value:n,label:n}}).filter(r=>r.value!==""||r.label!=="")}function st(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=u("span",{class:"rui-wrapper-fragment"});for(const n of e)n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}function yr(t,e){return u("span",{class:`rui-wrapper ${t}`,style:"display: contents;",...e??{}})}function Wp(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}const Gp=/^[A-Za-z_][A-Za-z0-9_\-:/]*$/;function Kp(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&&Gp.test(r))}const Yp={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 n=yr("rui-on-click",{role:"button",tabindex:"0"});n.append(st(r,e.child));const a=I(e.disabled),i=I(e.stopPropagation),o=s=>{a||(i&&s.stopPropagation(),r.invoke(e.onClick,s))};return n.addEventListener("click",o),n.addEventListener("keydown",s=>{const l=s;(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o(l))}),n}},Xp=[{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"}],Jp={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 n=yr("rui-on-mouse");I(e.draggable)&&n.setAttribute("draggable","true"),n.append(st(r,e.child));const a=e.passiveScroll===void 0?!0:I(e.passiveScroll);for(const{prop:i,event:o}of Xp){const s=e[i];if(s==null)continue;const c=o==="scroll"||o==="wheel"?{passive:a}:{};n.addEventListener(o,d=>{r.invoke(s,d)},c)}return n}},Qp=[{prop:"onKeyDown",event:"keydown"},{prop:"onKeyUp",event:"keyup"},{prop:"onKeyPress",event:"keypress"}],Zp={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 n=e.focusable===void 0?!0:I(e.focusable),a=yr("rui-on-keyboard",n?{tabindex:"0"}:{});a.append(st(r,e.child));for(const{prop:i,event:o}of Qp){const s=e[i];s!=null&&a.addEventListener(o,l=>{r.invoke(s,l)})}return a}},em={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 n=yr("rui-on-focus");return n.append(st(r,e.child)),e.onFocus!=null&&n.addEventListener("focusin",a=>r.invoke(e.onFocus,a)),e.onBlur!=null&&n.addEventListener("focusout",a=>r.invoke(e.onBlur,a)),n}},tm={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 n=u("span",{class:"rui-wrapper rui-on-intersect",style:"display: inline-block;"});n.append(st(r,e.child));const a=typeof IntersectionObserver<"u"?IntersectionObserver:void 0;if(!a)return n;const i=Math.max(0,Math.min(1,P(e.threshold,.05))),o=m(e.rootMargin),s=I(e.once);let l=null;const c=new a(d=>{for(const p of d){const f=p.isIntersecting;if(f!==l&&(f&&e.onEnter!=null&&r.invoke(e.onEnter,p),!f&&l===!0&&e.onLeave!=null&&r.invoke(e.onLeave,p),l=f),e.onChange!=null&&r.invoke(e.onChange,{visible:f,ratio:p.intersectionRatio}),s&&f){c.disconnect();return}}},{threshold:i,...o?{rootMargin:o}:{}});return c.observe(n),r.registerDisposer(()=>c.disconnect(),"rui-onintersect-io"),n}},rm={name:"OnMount",description:"Run imperative code against the wrapped component's rendered DOM node. `onMount(node)` fires once, on a microtask after the child is attached to the DOM — the Aktion way to get a DOM ref (measure an element, focus it, or hand it to an imperative library such as a chart / map / editor). `onUnmount(node)` fires when the component leaves the tree. Pair with `$ref(...)` to stash the node across renders.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onMount",type:"callable",optional:!0,description:"`(node) => void` — fired once after the wrapped element is attached."},{name:"onUnmount",type:"callable",optional:!0,description:"`(node) => void` — fired when the wrapped element leaves the tree."}],render:(t,e,r)=>{const n=u("span",{class:"rui-wrapper rui-on-mount",style:"display: contents;"});n.append(st(r,e.child));const a=r.useInstanceState("rui-on-mount",!1);if(!a.get()){a.set(!0);const i=()=>{const o=n.firstElementChild??n;e.onMount!=null&&r.invoke(e.onMount,o),e.onUnmount!=null&&r.registerDisposer(()=>{const s=()=>r.invoke(e.onUnmount,o);typeof queueMicrotask=="function"?queueMicrotask(s):Promise.resolve().then(s)},"rui-on-mount-unmount")};typeof queueMicrotask=="function"?queueMicrotask(i):Promise.resolve().then(i)}return n}};function nm(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 No={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 n=m(e.to),a=I(e.external),i=n||m(e.href),o=n?i.startsWith("/")||i.startsWith("#")?i:qe(i,"#"):qe(e.href,"#"),s=m(e.variant,"default"),l=u("a",{class:"rui-link","data-variant":s,href:o,target:a?"_blank":null,rel:a?"noopener noreferrer":null});for(const c of nm(r,e.label))l.append(c);return n&&!a&&l.addEventListener("click",c=>{c.defaultPrevented||c.button===0&&(c.metaKey||c.ctrlKey||c.shiftKey||c.altKey||(c.preventDefault(),r.router.navigate(n)))}),l}},am={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 n=st(r,e.child),a=n instanceof HTMLElement?n:(()=>{const s=u("span",{class:"rui-css"});return s.append(n),s})(),i=Kp(e.class);for(const s of i)a.classList.add(s);const o=Wp(e.style);if(o){const s=a.getAttribute("style");a.setAttribute("style",s?`${s};${o}`:o)}return a}};function pe(t,e,r,n){if(e==null)return;const a=n.event??"change";t.addEventListener(a,()=>{r.invoke(e,n.getValue(t))})}const im=["primary","secondary","outline","ghost","link","danger","default"],om=["xs","sm","md","lg","xl"],sm=["text","email","password","number","tel","url","date"];function lm(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"}function cm(t){if(!Number.isFinite(t)||t<=0)return"";const e=["B","KB","MB","GB"];let r=t,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r>=10||n===0?Math.round(r):r.toFixed(1)} ${e[n]}`}const um={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:im,description:"Visual style — `primary` solid brand button (`default` is its alias), `secondary` surface + border, `outline` transparent with primary border, `ghost` bare, `link` text-only (underlines on hover), `danger` destructive"},{name:"type",type:"string",optional:!0,enum:["button","submit"],description:"HTML button type"},{name:"size",type:"string",optional:!0,enum:om,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 n=I(e.loading),a=I(e.iconOnly),i=m(e.iconPosition,"leading"),o=m(e.label),s=u("button",{class:"rui-button",type:m(e.type,"button"),"data-variant":m(e.variant,"primary"),"data-size":lm(e.size),"data-icon-position":i,"data-icon-only":a?"true":null,"data-full-width":I(e.fullWidth)?"true":null,"data-loading":n?"true":null,"aria-label":a?o:null,disabled:I(e.disabled)||n?"":null}),l=u("span",{class:"rui-button-label"},[o]),c=j(e.icon,{className:"rui-button-icon"}),p=(n?j("spinner",{className:"rui-button-spinner"}):null)??c;return a?p&&s.append(p):i==="trailing"?(s.append(l),p&&s.append(p)):(p&&s.append(p),s.append(l)),s.onclick=()=>{n||r.invoke(e.onClick)},s}},dm={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 n=u("div",{class:"rui-buttons","data-direction":m(e.direction,"row")});for(const a of T(e.items))n.append(r.renderNode(a));return n}},pm={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. Pass `label`/`hint`/`error`/`required` to render a labelled field shell with validation messaging.",props:[{name:"id",type:"string",description:"Input identifier"},{name:"placeholder",type:"string",optional:!0},{name:"type",type:"string",optional:!0,enum:sm},{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"},...En],render:(t,e,r)=>{const n=u("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 lt(n,t,4,r),pe(n,e.onChange,r,{event:"input",getValue:a=>a.value}),vr(n,e,r),Im(n,e.validations),br(n,e)}},mm={name:"TextArea",description:"Multi-line text input. `onChange(value)` fires on every keystroke with the current text. Pass `label`/`hint`/`error`/`required` for a labelled field shell.",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"},...En],render:(t,e,r)=>{const n=u("textarea",{class:"rui-textarea",id:m(e.id),name:m(e.id),placeholder:m(e.placeholder),rows:String(Number(e.rows??4)||4)});return n.value=m(e.value),lt(n,t,3,r),pe(n,e.onChange,r,{event:"input",getValue:a=>a.value}),vr(n,e,r,a=>a.value),br(n,e)}},fm={name:"SelectItem",description:"Single option for a Select component.",props:[{name:"value",type:"string"},{name:"label",type:"string"}],render:(t,e)=>u("option",{value:m(e.value)},[m(e.label)])},gm={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"},{name:"hint",type:"string",optional:!0,description:"Helper text rendered below the control"},{name:"error",type:"string",optional:!0,description:"Validation error rendered below the control (marks it invalid)"},{name:"required",type:"boolean",optional:!0,description:"Mark the field required"}],render:(t,e,r)=>{if(I(e.searchable))return Nm(t,e,r);const n=u("select",{class:"rui-select",id:m(e.id),name:m(e.id)}),a=m(e.placeholder);a&&n.append(u("option",{value:"",disabled:"",selected:""},[a]));for(const i of T(e.items))n.append(r.renderNode(i));return n.value=m(e.value),lt(n,t,4,r),pe(n,e.onChange,r,{event:"change",getValue:i=>i.value}),vr(n,e,r,i=>i.value),br(n,e)}},hm={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 n=u("label",{class:"rui-checkbox"}),a=I(e.value),i=u("input",{type:"checkbox",id:m(e.id),name:m(e.id),checked:a?"":null});return i.checked=a,lt(i,t,2,r),pe(i,e.onChange,r,{event:"change",getValue:o=>o.checked}),n.append(i,u("span",{class:"rui-checkbox-label"},[m(e.label)])),n}},bm={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),n=m(e.label),a=m(e.description),i=I(e.defaultChecked),o=u("label",{class:"rui-checkbox-item","data-name":r}),s=u("input",{type:"checkbox",name:r,checked:i?"":null});s.checked=i;const l=u("div",{class:"rui-checkbox-item-text"});return l.append(u("div",{class:"rui-checkbox-item-label"},[n])),a&&l.append(u("div",{class:"rui-checkbox-item-description"},[a])),o.append(s,l),o}},vm={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 n=m(e.name),a=u("div",{class:"rui-checkbox-group",role:"group","data-name":n}),i=T(e.items),o=e.value&&typeof e.value=="object"?e.value:{};i.forEach((c,d)=>{const p=m(c.args?.[0]),f=m(c.args?.[1],`${n}-${d}`),b=m(c.args?.[2]),h=I(c.args?.[3]),g=`${n}-${f}`,y=u("label",{class:"rui-checkbox-item",for:g}),v=f in o?!!o[f]:h,x=u("input",{type:"checkbox",id:g,name:f,checked:v?"":null}),w=u("div",{class:"rui-checkbox-item-text"});w.append(u("div",{class:"rui-checkbox-item-label"},[p])),b&&w.append(u("div",{class:"rui-checkbox-item-description"},[b])),y.append(x,w),a.append(y)});const s=t.argMeta?.[2]?.stateRef,l=c=>{const d={};return c.querySelectorAll('input[type="checkbox"]').forEach(p=>{d[p.name]=p.checked}),d};return s&&r.bindState(a,s,{event:"change",getValue:l}),pe(a,e.onChange,r,{event:"change",getValue:c=>l(c)}),a}},ym={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 n=m(e.id),a=u("div",{class:"rui-radio-group",role:"radiogroup"});for(const i of T(e.items)){const o=m(i.args?.[0]),s=m(i.args?.[1],o),l=`${n}-${o}`,c=u("label",{class:"rui-radio",for:l}),d=m(e.value)===o,p=u("input",{type:"radio",id:l,name:n,value:o,checked:d?"":null});p.checked=d,lt(p,t,2,r),pe(p,e.onChange,r,{event:"change",getValue:f=>f.value}),c.append(p,u("span",{class:"rui-radio-label"},[s])),a.append(c)}return a}},xm={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 n=u("div",{class:"rui-form-control"});n.append(u("label",{class:"rui-form-label"},[m(e.label)]));const a=r.renderNode(e.field);n.append(a);const i=m(e.hint);return i&&n.append(u("p",{class:"rui-form-hint"},[i])),n}},Io={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 n=u("form",{class:"rui-search-bar",role:"search"});n.onsubmit=s=>{s.preventDefault(),r.invoke(e.onSubmit)};const a=j("magnifying-glass",{className:"rui-search-bar-icon"})??u("span",{class:"rui-search-bar-icon","aria-hidden":"true"});n.append(a);const i=u("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"});lt(i,t,2,r),pe(i,e.onChange,r,{event:"input",getValue:s=>s.value}),n.append(i);const o=m(e.shortcut);if(o&&n.append(u("span",{class:"rui-search-bar-shortcut"},[o])),e.onSubmit!=null){const s=u("button",{type:"submit",class:"rui-search-bar-submit"},[m(e.submitLabel,"Search")]);n.append(s)}return n}},wm={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 n=u("form",{class:"rui-form",id:m(e.id)});n.onsubmit=a=>{a.preventDefault(),r.invoke(e.onSubmit)};for(const a of T(e.fields))n.append(r.renderNode(a));if(e.buttons){const a=u("div",{class:"rui-form-actions"});a.append(r.renderNode(e.buttons)),n.append(a)}return n}},km={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 n=m(e.id),a=P(e.min,0),i=P(e.max,100),o=P(e.step,1),s=P(e.value,a),l=u("div",{class:"rui-slider","data-disabled":I(e.disabled)?"true":"false"}),c=m(e.label),d=I(e.showValue);if(c||d){const b=u("div",{class:"rui-slider-head"});c&&b.append(u("label",{class:"rui-slider-label",for:n},[c])),d&&b.append(u("span",{class:"rui-slider-value"},[String(s)])),l.append(b)}const p=u("input",{type:"range",class:"rui-slider-input",id:n,name:n,min:String(a),max:String(i),step:String(o),value:String(s),disabled:I(e.disabled)?"":null});p.oninput=b=>{const h=b.currentTarget;if(!h)return;const y=h.closest(".rui-slider")?.querySelector(".rui-slider-value");y&&(y.textContent=h.value)};const f=t.argMeta?.[4]?.stateRef;return f&&r.bindState(p,f,{event:"input",getValue:b=>Number(b.value)}),pe(p,e.onChange,r,{event:"input",getValue:b=>Number(b.value)}),l.append(p),l}},Sm={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)"},...En],render:(t,e,r)=>{const n=m(e.id),a=P(e.step,1),i=e.min!==void 0&&e.min!==null,o=e.max!==void 0&&e.max!==null,s=i?P(e.min,0):Number.NEGATIVE_INFINITY,l=o?P(e.max,0):Number.POSITIVE_INFINITY,c=I(e.disabled),d=u("div",{class:"rui-number-input","data-disabled":c?"true":"false"}),p=u("button",{type:"button",class:"rui-number-input-button","data-direction":"down","aria-label":"Decrement",disabled:c?"":null},["−"]),f=u("input",{type:"number",class:"rui-number-input-field",id:n,name:n,value:m(e.value),placeholder:m(e.placeholder),min:i?String(s):null,max:o?String(l):null,step:String(a),disabled:c?"":null}),b=u("button",{type:"button",class:"rui-number-input-button","data-direction":"up","aria-label":"Increment",disabled:c?"":null},["+"]),h=t.argMeta?.[1]?.stateRef,g=v=>{const x=v.value;if(x==="")return null;const w=Number(x);return Number.isFinite(w)?w:null};h&&r.bindState(f,h,{event:"input",getValue:g}),pe(f,e.onChange,r,{event:"input",getValue:g});const y=(v,x)=>{const k=v.closest(".rui-number-input")?.querySelector(".rui-number-input-field");if(!k)return;const A=Number(k.value),S=Number.isFinite(A)?A:0,$=Mm(S+x,s,l);k.value=String($),k.dispatchEvent(new Event("input",{bubbles:!0}))};return p.onclick=v=>y(v.currentTarget??v.target,-a),b.onclick=v=>y(v.currentTarget??v.target,a),vr(f,e,r,g),d.append(p,f,b),br(d,e,{idKey:"id"})}},$m={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 n=m(e.id),a=u("div",{class:"rui-date-picker"}),i=m(e.label);i&&a.append(u("label",{class:"rui-date-picker-label",for:n},[i]));const o=u("input",{type:"date",class:"rui-date-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,placeholder:m(e.placeholder),disabled:I(e.disabled)?"":null});return lt(o,t,1,r),pe(o,e.onChange,r,{event:"change",getValue:s=>s.value}),a.append(o),a}},Cm={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 n=m(e.id),a=I(e.disabled),i=u("div",{class:"rui-file-upload","data-disabled":a?"true":"false"}),o=u("label",{class:"rui-file-upload-dropzone",for:n}),s=j(m(e.icon,"cloud-arrow-up"),{className:"rui-file-upload-icon"});s&&o.append(s);const l=u("div",{class:"rui-file-upload-text"});l.append(u("div",{class:"rui-file-upload-label"},[m(e.label,"Choose a file")]));const c=m(e.hint);c&&l.append(u("div",{class:"rui-file-upload-hint"},[c])),o.append(l);const d=u("input",{type:"file",id:n,name:n,class:"rui-file-upload-input",accept:m(e.accept)||null,multiple:I(e.multiple)?"":null,disabled:a?"":null});o.append(d),i.append(o);const p=(b,h)=>h.includes("image")||b.type.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(b.name),f=(b,h)=>{const g=b.querySelector(".rui-file-upload-preview");g&&g.remove();const y=h?Array.from(h):[];if(y.length===0)return;const v=m(e.accept),x=u("div",{class:"rui-file-upload-preview"});y.forEach(w=>{const k=u("div",{class:"rui-file-upload-preview-item"});if(p(w,v)){const S=URL.createObjectURL(w),$=u("img",{src:S,alt:w.name,class:"rui-file-upload-thumbnail"});$.onload=()=>URL.revokeObjectURL(S),k.append($)}k.append(u("span",{class:"rui-file-upload-filename"},[w.name]));const A=cm(w.size);A&&k.append(u("span",{class:"rui-file-upload-filesize"},[A])),x.append(k)}),b.append(x)};if(d.onchange=b=>{const h=b.currentTarget;r.invoke(e.onSelect,h.files);const g=h.closest(".rui-file-upload");g&&f(g,h.files)},!a){const b=h=>{h.preventDefault(),h.stopPropagation()};o.addEventListener("dragenter",h=>{b(h),o.classList.add("is-dragover")}),o.addEventListener("dragover",h=>{b(h),o.classList.add("is-dragover")}),o.addEventListener("dragleave",h=>{b(h),o.classList.remove("is-dragover")}),o.addEventListener("drop",h=>{b(h),o.classList.remove("is-dragover");const g=h.dataTransfer;if(!g||g.files.length===0)return;try{d.files=g.files}catch{}r.invoke(e.onSelect,g.files);const y=o.closest(".rui-file-upload");y&&f(y,g.files)})}return i}},Po={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 n=m(e.id),a=Mo(e.items),i=m(e.value),o=a.find(S=>S.value===i)?.label??i,s=m(e.placeholder,"Select…"),l=m(e.emptyLabel,"No matches"),c=I(e.disabled),d=I(e.open),p=r.useInstanceState("open",d),f=r.useInstanceState("filter",""),b=p.get(),h=u("div",{class:"rui-combobox","data-open":b?"true":"false","data-disabled":c?"true":"false"}),g=u("button",{type:"button",class:"rui-combobox-trigger",id:n,"aria-haspopup":"listbox","aria-expanded":b?"true":"false",disabled:c?"":null});g.append(u("span",{class:"rui-combobox-value","data-placeholder":o?"false":"true"},[o||s]));const y=j("chevron-down",{className:"rui-combobox-chevron"});y&&g.append(y),h.append(g);const v=u("div",{class:"rui-combobox-panel",role:"listbox"}),x=u("input",{type:"text",class:"rui-combobox-filter",placeholder:"Filter…",autocomplete:"off",value:f.get()});v.append(x);const w=u("div",{class:"rui-combobox-list"});v.append(w);const k=(S,$)=>{S.replaceChildren();const C=$.trim().toLowerCase(),M=C===""?a:a.filter(L=>L.label.toLowerCase().includes(C)||L.value.toLowerCase().includes(C));if(M.length===0){S.append(u("div",{class:"rui-combobox-empty"},[l]));return}for(const L of M){const z=u("button",{type:"button",class:"rui-combobox-option",role:"option","data-value":L.value,"aria-selected":L.value===i?"true":"false"},[L.label]);z.onclick=H=>{H.stopPropagation(),A(H.currentTarget,L.value)},S.append(z)}},A=(S,$)=>{const C=t.argMeta?.[2]?.stateRef;C&&r.setState(C,$),r.invoke(e.onChange,$),p.set(!1),f.set("");const M=S.closest(".rui-combobox");M?.setAttribute("data-open","false"),M?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false"),We(M)};return k(w,f.get()),x.oninput=S=>{const $=S.currentTarget;f.set($.value);const C=$.closest(".rui-combobox-panel")?.querySelector(".rui-combobox-list");C&&k(C,$.value)},x.onkeydown=S=>{const $=S;if($.key!=="Enter")return;$.preventDefault();const L=$.currentTarget.closest(".rui-combobox")?.querySelector(".rui-combobox-option[data-value]"),z=L?.getAttribute("data-value");z!=null&&L&&A(L,z)},g.onclick=S=>{if(c)return;S.stopPropagation();const $=!p.get();p.set($);const C=S.currentTarget.closest(".rui-combobox");if(C?.setAttribute("data-open",$?"true":"false"),C?.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded",$?"true":"false"),!!C){if(!$){We(C);return}setTimeout(()=>x.focus(),0),$t({liveRoot:C,onDismiss:()=>{p.set(!1),f.set(""),C.setAttribute("data-open","false"),C.querySelector(".rui-combobox-trigger")?.setAttribute("aria-expanded","false")}})}},h.append(v),h}},Am={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 n=m(e.id),a=Mo(e.items),i=m(e.placeholder,"Select…"),o=m(e.emptyLabel,"No matches"),s=I(e.disabled),l=Math.max(0,Math.floor(Number(e.max??0))),c=Array.isArray(e.value)?e.value.map(M=>m(M)).filter(Boolean):[],d=new Set(c),p=t.argMeta?.[2]?.stateRef,f=I(e.open),b=r.useInstanceState("open",f),h=r.useInstanceState("filter",""),g=b.get(),y=u("div",{class:"rui-multiselect","data-open":g?"true":"false","data-disabled":s?"true":"false"}),v=u("button",{type:"button",class:"rui-multiselect-trigger",id:n,"aria-haspopup":"listbox","aria-expanded":g?"true":"false",disabled:s?"":null}),x=u("span",{class:"rui-multiselect-chips"}),w=M=>{p&&r.setState(p,M),r.invoke(e.onChange,M)};if(c.length===0)x.append(u("span",{class:"rui-multiselect-placeholder"},[i]));else for(const M of c){const L=a.find(F=>F.value===M)?.label??M,z=u("span",{class:"rui-multiselect-chip","data-value":M});z.append(u("span",{class:"rui-multiselect-chip-label"},[L]));const H=u("button",{type:"button",class:"rui-multiselect-chip-remove","aria-label":`Remove ${L}`},["×"]);H.onclick=F=>{F.stopPropagation();const V=c.filter(_=>_!==M);w(V)},z.append(H),x.append(z)}v.append(x);const k=j("chevron-down",{className:"rui-multiselect-chevron"});k&&v.append(k),y.append(v);const A=u("div",{class:"rui-multiselect-panel",role:"listbox","aria-multiselectable":"true"}),S=u("input",{type:"text",class:"rui-multiselect-filter",placeholder:"Filter…",autocomplete:"off",value:h.get()});A.append(S);const $=u("div",{class:"rui-multiselect-list"});A.append($);const C=(M,L)=>{M.replaceChildren();const z=L.trim().toLowerCase(),H=z===""?a:a.filter(F=>F.label.toLowerCase().includes(z)||F.value.toLowerCase().includes(z));if(H.length===0){M.append(u("div",{class:"rui-multiselect-empty"},[o]));return}for(const F of H){const V=d.has(F.value),_=!V&&l>0&&c.length>=l,te=u("button",{type:"button",class:"rui-multiselect-option",role:"option","data-value":F.value,"data-selected":V?"true":"false","aria-selected":V?"true":"false",disabled:_?"":null}),ke=u("span",{class:"rui-multiselect-option-check"}),De=j(V?"check":"",{className:"rui-multiselect-option-check-icon"});De&&ke.append(De),te.append(ke),te.append(u("span",{class:"rui-multiselect-option-label"},[F.label])),te.onclick=Jt=>{if(Jt.stopPropagation(),_)return;const ft=V?c.filter(_a=>_a!==F.value):[...c,F.value];w(ft)},M.append(te)}};return C($,h.get()),S.oninput=M=>{const L=M.currentTarget;h.set(L.value);const z=L.closest(".rui-multiselect-panel")?.querySelector(".rui-multiselect-list");z&&C(z,L.value)},v.onclick=M=>{if(s)return;M.stopPropagation();const L=!b.get();b.set(L);const z=M.currentTarget.closest(".rui-multiselect");if(z?.setAttribute("data-open",L?"true":"false"),z?.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded",L?"true":"false"),!!z){if(!L){We(z);return}setTimeout(()=>S.focus(),0),$t({liveRoot:z,onDismiss:()=>{b.set(!1),h.set(""),z.setAttribute("data-open","false"),z.querySelector(".rui-multiselect-trigger")?.setAttribute("aria-expanded","false")}})}},y.append(A),y}},Tm={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 n=m(e.id),a=`${n}-from`,i=`${n}-to`,o=m(e.min),s=m(e.max),l=I(e.disabled),c=u("div",{class:"rui-date-range-picker","data-disabled":l?"true":"false"}),d=m(e.label);d&&c.append(u("label",{class:"rui-date-range-picker-label",for:a},[d]));const p=u("div",{class:"rui-date-range-picker-row"}),f=u("input",{type:"date",class:"rui-date-range-picker-input",id:a,name:a,value:m(e.from),min:o||null,max:s||null,disabled:l?"":null,"data-role":"from"});p.append(f),p.append(u("span",{class:"rui-date-range-picker-separator","aria-hidden":"true"},["–"]));const b=u("input",{type:"date",class:"rui-date-range-picker-input",id:i,name:i,value:m(e.to),min:o||null,max:s||null,disabled:l?"":null,"data-role":"to"});p.append(b),c.append(p);const h=t.argMeta?.[1]?.stateRef,g=t.argMeta?.[2]?.stateRef;if(h&&r.bindState(f,h),g&&r.bindState(b,g),e.onChange!=null){const y=v=>{const x=v.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",v=>r.invoke(e.onChange,y(v.currentTarget))),b.addEventListener("change",v=>r.invoke(e.onChange,y(v.currentTarget)))}return c}};function Mm(t,e,r){return Number.isNaN(t)?e===Number.NEGATIVE_INFINITY?0:e:Math.min(Math.max(t,e),r)}function Nm(t,e,r){const n=t.argMeta?[...t.argMeta]:[];for(;n.length<5;)n.push({});n[4]?.stateRef&&(n[2]=n[4]);const a=Po.render({...t,argMeta:n},{id:e.id,items:e.items,value:e.value,placeholder:e.placeholder,emptyLabel:"No matches",disabled:!1},r);return a.classList.add("rui-select-searchable"),a}function lt(t,e,r,n){const a=e.argMeta?.[r]?.stateRef;if(a){if(t instanceof HTMLInputElement&&t.type==="checkbox"){n.bindState(t,a,{event:"change",getValue:i=>i.checked});return}n.bindState(t,a)}}function Im(t,e){if(!e)return;const r=Array.isArray(e)?e.map(n=>String(n)):typeof e=="object"?Object.entries(e).map(([n,a])=>a?`${n}:${a}`:n):[];for(const n of r)n==="required"?t.required=!0:n.startsWith("minLength:")?t.minLength=Number(n.slice(10))||0:n.startsWith("maxLength:")?t.maxLength=Number(n.slice(10))||0:n==="email"&&(t.type="email")}const Je=["default","primary","success","warning","danger","info"],ct=(t,e)=>{const r=T(t);if(r.length===0)return null;const n=u("div",{class:"rui-pattern-actions"});for(const a of r)n.append(e.renderNode(a));return n},Pm=[{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 Rm(t,e){const r=`${t} ${e}`.trim();if(!r)return"";for(const n of Pm)if(n.match.test(r))return n.label;return""}const Em={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:Je,description:"Accent tone"}],render:(t,e,r)=>{const n=m(e.layout,"default"),a=m(e.title),i=m(e.subtitle),s=m(e.eyebrow)||Rm(a,i),l=m(e.tone,"primary");if(n==="cover"){const h=ku(m(e.imageSrc)),g=Z(m(e.height),"280px"),y=u("section",{class:"rui-cover","data-tone":l,style:`background-image:linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.62) 100%), url("${h}");min-height:${g};`}),v=u("div",{class:"rui-cover-body"});s&&v.append(u("span",{class:"rui-cover-eyebrow"},[s])),v.append(u("h1",{class:"rui-cover-title"},[a])),i&&v.append(u("p",{class:"rui-cover-subtitle"},[i]));const x=m(e.caption);x&&v.append(u("p",{class:"rui-cover-caption"},[x]));const w=ct(e.actions,r);if(w)w.classList.add("rui-cover-actions"),v.append(w);else{const k=[e.primary,e.secondary].filter(Boolean);if(k.length>0){const A=u("div",{class:"rui-cover-actions rui-pattern-actions"});for(const S of k)A.append(r.renderNode(S));v.append(A)}}return y.append(v),y}const c=ie(e.imageSrc),d=u("section",{class:"rui-hero","data-tone":l,"data-has-image":c?"true":"false"}),p=u("div",{class:"rui-hero-body"});s&&p.append(u("span",{class:"rui-hero-eyebrow"},[s])),p.append(u("h1",{class:"rui-hero-title"},[a])),i&&p.append(u("p",{class:"rui-hero-subtitle"},[i]));const f=T(e.highlights);if(f.length>0){const h=u("div",{class:"rui-hero-highlights"});for(const g of f){const y=m(g);y&&h.append(u("span",{class:"rui-hero-highlight"},[y]))}p.append(h)}const b=[e.primary,e.secondary].filter(Boolean);if(b.length>0){const h=u("div",{class:"rui-hero-ctas"});for(const g of b)h.append(r.renderNode(g));p.append(h)}if(d.append(p),c){const h=u("div",{class:"rui-hero-media"});h.append(u("img",{src:c,alt:"",loading:"lazy"})),d.append(h)}return d}},Lm={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 n=u("header",{class:"rui-page-header"}),a=m(e.title);let i=e.breadcrumbs;if(i==null?a&&(i=["Home",a]):(i===!1||i==="false")&&(i=null),i){const p=u("div",{class:"rui-page-header-breadcrumbs"});Array.isArray(i)?i.forEach((f,b)=>{b>0&&p.append(u("span",{class:"rui-page-header-crumb-sep"},["/"])),p.append(u("span",{class:"rui-page-header-crumb"},[m(f)]))}):p.append(r.renderNode(i)),n.append(p)}const o=u("div",{class:"rui-page-header-title-row"}),s=u("div",{class:"rui-page-header-title-block"}),l=u("div",{class:"rui-page-header-title-line"});l.append(u("h1",{class:"rui-page-header-title"},[a])),e.status&&l.append(r.renderNode(e.status)),s.append(l);const c=m(e.subtitle);c&&s.append(u("p",{class:"rui-page-header-subtitle"},[c])),o.append(s);const d=ct(e.actions,r);return d&&(d.classList.add("rui-page-header-actions"),o.append(d)),n.append(o),n}},zm={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 n=u("div",{class:"rui-empty-state"}),a=ie(e.illustration);if(a)n.append(u("img",{class:"rui-empty-state-illustration",src:a,alt:"",loading:"lazy"}));else{const s=m(e.title),l=m(e.description),c=m(e.icon)||To(`${s} ${l}`)||"inbox",d=j(c,{className:"rui-empty-state-icon"});d&&n.append(d)}n.append(u("h3",{class:"rui-empty-state-title"},[m(e.title)]));const i=m(e.description);i&&n.append(u("p",{class:"rui-empty-state-description"},[i]));const o=T(e.actions);if(o.length>0){const s=u("div",{class:"rui-empty-state-actions"});for(const l of o)s.append(r.renderNode(l));n.append(s)}else if(e.action){const s=u("div",{class:"rui-empty-state-action"});s.append(r.renderNode(e.action)),n.append(s)}return n}},jm={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:Je}],render:(t,e)=>{const r=u("li",{class:"rui-timeline-item","data-tone":m(e.tone,"default")}),n=u("span",{class:"rui-timeline-marker"}),a=j(e.icon);a&&n.append(a),r.append(n);const i=u("div",{class:"rui-timeline-body"}),o=u("div",{class:"rui-timeline-head"});o.append(u("span",{class:"rui-timeline-title"},[m(e.title)]));const s=m(e.time);s&&o.append(u("span",{class:"rui-timeline-time"},[s])),i.append(o);const l=m(e.description);return l&&i.append(u("div",{class:"rui-timeline-description"},[l])),r.append(i),r}},Dm={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 n=u("ol",{class:"rui-timeline"});for(const a of T(e.items))n.append(r.renderNode(a));return n}},Om={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:Je}],render:(t,e)=>{const r=u("div",{class:"rui-feature-item","data-tone":m(e.tone,"primary")}),n=m(e.icon,"sparkles"),a=j(n,{className:"rui-feature-icon"});a&&r.append(a),r.append(u("h3",{class:"rui-feature-title"},[m(e.title)]));const i=m(e.description);return i&&r.append(u("p",{class:"rui-feature-description"},[i])),r}},Bm={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 n=Math.max(1,Math.min(4,Number(e.columns??"auto"))),a=u("div",{class:"rui-feature-grid","data-columns":n>0?String(n):null});for(const i of T(e.items))a.append(r.renderNode(i));return a}},Fm={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=u("figure",{class:"rui-testimonial"}),n=Math.max(0,Math.min(5,Math.round(Number(e.rating??0))));if(n>0){const l=u("div",{class:"rui-testimonial-rating"});for(let c=0;c<5;c+=1){const d=c<n,p=j(d?"star":"regular:star",{className:"rui-testimonial-rating-star"});p&&l.append(p)}r.append(l)}r.append(u("blockquote",{class:"rui-testimonial-quote"},[m(e.quote)]));const a=u("figcaption",{class:"rui-testimonial-author"}),i=ie(e.avatarSrc);i&&a.append(u("img",{class:"rui-testimonial-avatar",src:i,alt:""}));const o=u("div",{class:"rui-testimonial-meta"});o.append(u("div",{class:"rui-testimonial-name"},[m(e.author)]));const s=m(e.role);return s&&o.append(u("div",{class:"rui-testimonial-role"},[s])),a.append(o),r.append(a),r}},_m={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 n=u("div",{class:"rui-profile-card"}),a=u("div",{class:"rui-profile-card-header"});a.append(zt(m(e.avatarSrc),m(e.name),"lg"));const i=u("div",{class:"rui-profile-card-meta"});i.append(u("h3",{class:"rui-profile-card-name"},[m(e.name)]));const o=m(e.role);o&&i.append(u("p",{class:"rui-profile-card-role"},[o])),a.append(i),n.append(a);const s=m(e.bio);s&&n.append(u("p",{class:"rui-profile-card-bio"},[s]));const l=T(e.tags);if(l.length>0){const d=u("div",{class:"rui-profile-card-tags"});for(const p of l){const f=m(p);f&&d.append(u("span",{class:"rui-tag","data-size":"sm"},[u("span",{class:"rui-tag-label"},[f])]))}n.append(d)}const c=ct(e.actions,r);return c&&(c.classList.add("rui-profile-card-actions"),n.append(c)),n}},Um={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 n=u("article",{class:"rui-comment"});n.append(zt(m(e.avatarSrc),m(e.author),"md"));const a=u("div",{class:"rui-comment-body"}),i=u("header",{class:"rui-comment-header"});i.append(u("span",{class:"rui-comment-author"},[m(e.author)]));const o=m(e.time);o&&i.append(u("span",{class:"rui-comment-time"},[o])),a.append(i),a.append(u("div",{class:"rui-comment-content"},[m(e.body)]));const s=ct(e.actions,r);return s&&(s.classList.add("rui-comment-actions"),a.append(s)),n.append(a),n}},Hm={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:Je}],render:(t,e,r)=>{const n=m(e.tone,"primary"),a=u("aside",{class:"rui-banner","data-tone":n}),i=m(e.icon)||qp(n)||"",o=j(i,{className:"rui-banner-icon"});o&&a.append(o);const s=u("div",{class:"rui-banner-body"});s.append(u("strong",{class:"rui-banner-title"},[m(e.title)]));const l=m(e.message);if(l&&s.append(u("span",{class:"rui-banner-message"},[l])),a.append(s),e.action){const c=u("div",{class:"rui-banner-action"});c.append(r.renderNode(e.action)),a.append(c)}return a}},qm={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:Je},{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 n=u("div",{class:"rui-kanban-card","data-tone":m(e.tone,"default")});typeof e.onClick=="function"&&(n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.onclick=()=>r.invoke(e.onClick),n.onkeydown=c=>{const d=c;(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r.invoke(e.onClick))});const a=u("div",{class:"rui-kanban-card-title"}),i=j(e.icon,{className:"rui-kanban-card-icon"});i&&a.append(i),a.append(document.createTextNode(m(e.title))),n.append(a);const o=m(e.description);o&&n.append(u("p",{class:"rui-kanban-card-description"},[o]));const s=T(e.tags);if(s.length>0){const c=u("div",{class:"rui-kanban-card-tags"});for(const d of s){const p=m(d);p&&c.append(u("span",{class:"rui-tag","data-size":"sm"},[u("span",{class:"rui-tag-label"},[p])]))}n.append(c)}const l=m(e.assignee);if(l){const c=u("footer",{class:"rui-kanban-card-footer"});c.append(zt("",l,"sm")),c.append(u("span",{class:"rui-kanban-card-assignee"},[l])),n.append(c)}return n}},Vm={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:Je,description:"Header accent tone"}],render:(t,e,r)=>{const n=T(e.items),a=u("section",{class:"rui-kanban-column","data-tone":m(e.tone,"default")}),i=u("header",{class:"rui-kanban-column-header"});i.append(u("span",{class:"rui-kanban-column-title"},[m(e.title)])),i.append(u("span",{class:"rui-kanban-column-count"},[String(n.length)])),a.append(i);const o=u("div",{class:"rui-kanban-column-body"});for(const s of n)o.append(r.renderNode(s));return n.length===0&&o.append(u("div",{class:"rui-kanban-column-empty"},["No items"])),a.append(o),a}},Wm={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 n=u("div",{class:"rui-kanban-board"});for(const a of T(e.columns))n.append(r.renderNode(a));return n}},Gm={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 n=u("header",{class:"rui-section-header"}),a=u("div",{class:"rui-section-header-left"}),i=m(e.eyebrow);i&&a.append(u("span",{class:"rui-section-header-eyebrow"},[i]));const o=u("div",{class:"rui-section-header-title-line"});o.append(u("h3",{class:"rui-section-header-title"},[m(e.title)])),e.status&&o.append(r.renderNode(e.status)),a.append(o);const s=m(e.subtitle);s&&a.append(u("p",{class:"rui-section-header-subtitle"},[s])),n.append(a);const l=ct(e.actions,r);return l&&(l.classList.add("rui-section-header-actions"),n.append(l)),n}},Km={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 n=T(e.center),a=u("div",{class:"rui-toolbar","data-has-center":n.length>0?"true":"false"}),i=u("div",{class:"rui-toolbar-side rui-toolbar-left"});I(e.searchable)&&i.append(Io.render({__kind:"Component",name:"SearchBar",args:[],argMeta:[]},{id:"toolbar-search",placeholder:m(e.searchPlaceholder,"Search…"),value:e.searchValue},r));for(const s of T(e.left))i.append(r.renderNode(s));if(a.append(i),n.length>0){const s=u("div",{class:"rui-toolbar-side rui-toolbar-center"});for(const l of n)s.append(r.renderNode(l));a.append(s)}const o=u("div",{class:"rui-toolbar-side rui-toolbar-right"});for(const s of T(e.right))o.append(r.renderNode(s));return a.append(o),a}},Ym={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 n=m(e.to),a=e.active!==void 0&&e.active!==null,i=n?r.router.getPath():"",o=n?n==="/"?i==="/":i===n?!0:i.startsWith(n+"/"):!1,s=a?I(e.active):o,l=u("button",{type:"button",class:"rui-sidebar-item","data-active":s?"true":"false","data-to":n||null}),c=j(e.icon,{className:"rui-sidebar-item-icon"});c&&l.append(c),l.append(u("span",{class:"rui-sidebar-item-label"},[m(e.label)]));const d=m(e.badge);return d&&l.append(u("span",{class:"rui-sidebar-item-badge"},[d])),(n||e.onClick!=null)&&(l.onclick=p=>{if(n){const f=p;if(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey)return;r.router.navigate(n)}e.onClick!=null&&r.invoke(e.onClick)}),l}},Xm={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 n=u("div",{class:"rui-sidebar-section"}),a=m(e.label);a&&n.append(u("div",{class:"rui-sidebar-section-label"},[a]));for(const i of T(e.items))n.append(r.renderNode(i));return n}},Jm={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 n=I(e.collapsed),a=u("aside",{class:"rui-sidebar"});n&&(a.dataset.collapsed="true");const i=m(e.brand),o=m(e.tagline);if(i||o){const c=u("div",{class:"rui-sidebar-header"});i&&c.append(u("div",{class:"rui-sidebar-brand"},[i])),o&&c.append(u("div",{class:"rui-sidebar-tagline"},[o])),a.append(c)}const s=u("nav",{class:"rui-sidebar-body"});for(const c of T(e.items))s.append(r.renderNode(c));a.append(s);const l=T(e.footer);if(l.length>0){const c=u("div",{class:"rui-sidebar-footer"});for(const d of l)c.append(r.renderNode(d));a.append(c)}return a}},Qm={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 n=I(e.collapsible),a=I(e.sidebarOpen),i=u("div",{class:"rui-app-shell"});n&&(i.dataset.collapsible="true"),a&&(i.dataset.sidebarOpen="true");const o=u("div",{class:"rui-app-shell-sidebar"});if(o.append(r.renderNode(e.sidebar)),i.append(o),n){const d=u("div",{class:"rui-app-shell-scrim","aria-hidden":"true"});d.addEventListener("click",()=>{delete i.dataset.sidebarOpen}),i.append(d)}const s=u("div",{class:"rui-app-shell-main"}),l=T(e.topbar);if(l.length>0||n){const d=u("div",{class:"rui-app-shell-topbar"});if(n){const p=u("button",{class:"rui-app-shell-toggle",type:"button","aria-label":"Toggle navigation"});p.append(j("bars",{size:"md"})??document.createTextNode("≡")),p.addEventListener("click",()=>{i.dataset.sidebarOpen?delete i.dataset.sidebarOpen:i.dataset.sidebarOpen="true"}),d.append(p)}for(const p of l)d.append(r.renderNode(p));s.append(d)}const c=u("div",{class:"rui-app-shell-content"});for(const d of T(e.content))c.append(r.renderNode(d));return s.append(c),i.append(s),i}},Zm={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 n=Z(m(e.primaryWidth),"320px"),a=u("div",{class:"rui-split-view",style:`--rui-split-primary:${n}`}),i=u("div",{class:"rui-split-view-primary"});for(const s of T(e.primary))i.append(r.renderNode(s));const o=u("div",{class:"rui-split-view-detail"});for(const s of T(e.detail))o.append(r.renderNode(s));return a.append(i,o),a}},ef={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 n=u("div",{class:"rui-description-item"}),a=u("dt",{class:"rui-description-label"}),i=j(e.icon,{className:"rui-description-icon"});i&&a.append(i),a.append(document.createTextNode(m(e.label)));const o=u("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))),n.append(a,o),n}},tf={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 n=Math.max(1,Math.min(2,Math.floor(Number(e.columns??2)))),a=u("dl",{class:"rui-description-list","data-columns":String(n)});for(const i of T(e.items))a.append(r.renderNode(i));return a}},rf={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=u("span",{class:"rui-status-dot","data-tone":m(e.tone,"success"),"data-pulse":I(e.pulse)?"true":"false"});return r.append(u("span",{class:"rui-status-dot-marker"})),r.append(u("span",{class:"rui-status-dot-label"},[m(e.label)])),r}},nf={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 n=I(e.featured),a=u("article",{class:"rui-pricing-card","data-featured":n?"true":"false"}),i=m(e.badge);i&&a.append(u("div",{class:"rui-pricing-card-badge"},[i])),a.append(u("h3",{class:"rui-pricing-card-plan"},[m(e.plan)]));const o=m(e.description);o&&a.append(u("p",{class:"rui-pricing-card-description"},[o]));const s=u("div",{class:"rui-pricing-card-price-row"});s.append(u("span",{class:"rui-pricing-card-price"},[m(e.price)]));const l=m(e.period);l&&s.append(u("span",{class:"rui-pricing-card-period"},[l])),a.append(s);const c=T(e.features);if(c.length>0){const d=u("ul",{class:"rui-pricing-card-features"});for(const p of c){const f=m(p);if(!f)continue;const b=j("circle-check",{className:"rui-pricing-card-check"})??u("span",{class:"rui-pricing-card-check"});d.append(u("li",{class:"rui-pricing-card-feature"},[b,document.createTextNode(f)]))}a.append(d)}if(e.action){const d=u("div",{class:"rui-pricing-card-action"});d.append(r.renderNode(e.action)),a.append(d)}return a}},af={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 n=Math.max(1,Math.min(4,Math.floor(Number(e.columns??"auto")))),a=u("div",{class:"rui-pricing-table","data-columns":n>0?String(n):null});for(const i of T(e.tiers))a.append(r.renderNode(i));return a}},of={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 n=m(e.orientation,"vertical"),a=u("article",{class:"rui-media-card","data-orientation":n}),i=sf(m(e.ratio,n==="horizontal"?"4:3":"16:9")),o=u("div",{class:"rui-media-card-media",style:`aspect-ratio:${i};`}),s=ie(e.imageSrc);if(s)o.append(u("img",{src:s,alt:m(e.title),loading:"lazy"}));else{o.classList.add("rui-media-card-media-empty");const b=j("image",{className:"rui-media-card-placeholder"})??u("span",{class:"rui-media-card-placeholder"});o.append(b)}if(e.badge){const b=u("span",{class:"rui-media-card-badge"});typeof e.badge=="string"?b.append(document.createTextNode(m(e.badge))):b.append(r.renderNode(e.badge)),o.append(b)}a.append(o);const l=u("div",{class:"rui-media-card-body"});l.append(u("h3",{class:"rui-media-card-title"},[m(e.title)]));const c=m(e.description);c&&l.append(u("p",{class:"rui-media-card-description"},[c]));const d=T(e.tags);if(d.length>0){const b=u("div",{class:"rui-media-card-tags"});for(const h of d){const g=m(h);g&&b.append(u("span",{class:"rui-tag","data-size":"sm"},[u("span",{class:"rui-tag-label"},[g])]))}l.append(b)}const p=m(e.meta);p&&l.append(u("p",{class:"rui-media-card-meta"},[p]));const f=ct(e.actions,r);return f&&(f.classList.add("rui-media-card-actions"),l.append(f)),a.append(l),a}};function sf(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}function Ln(t,e="primary"){const a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"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),l=s-o||1,c=80/(t.length-1),p=t.map((g,y)=>{const v=y*c,x=2+(s-g)/l*20;return[v,x]}).map(([g,y],v)=>`${v===0?"M":"L"}${g.toFixed(1)},${y.toFixed(1)}`).join(" "),f=`${p} L80,24 L0,24 Z`,b=document.createElementNS(a,"path");b.setAttribute("d",f),b.setAttribute("class","rui-sparkline-area"),i.appendChild(b);const h=document.createElementNS(a,"path");return h.setAttribute("d",p),h.setAttribute("class","rui-sparkline-line"),h.setAttribute("fill","none"),i.appendChild(h),i}const lf={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 n=T(e.items),a=n.some(l=>l&&typeof l=="object"&&l.__kind==="Component");if(m(e.layout,a?"grid":"strip")==="grid"){const l=e.columns?Math.max(1,Math.min(6,Math.floor(P(e.columns)))):0,c=mo.render({__kind:"Component",name:"Grid",args:[],argMeta:[]},{children:n,columns:l>0?l:"auto",gap:"m"},r);return c.classList.add("rui-metric-grid"),c}const o=m(e.align,"start"),s=u("div",{class:"rui-stats","data-align":o});for(const l of n){const c=l??{},d=m(c.tone,"default"),p=u("div",{class:"rui-stats-item","data-tone":d});p.append(u("div",{class:"rui-stats-label"},[m(c.label)]));const f=u("div",{class:"rui-stats-value-row"});f.append(u("div",{class:"rui-stats-value"},[m(c.value)]));const b=T(c.spark).map(g=>Number(g)).filter(g=>Number.isFinite(g));b.length>1&&f.append(Ln(b,d)),p.append(f);const h=m(c.hint);h&&p.append(u("div",{class:"rui-stats-hint"},[h])),s.append(p)}return s}},cf={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:Je},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const n=typeof e.onClick=="function",i=u(n?"button":"div",{type:n?"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=u("div",{class:"rui-tile-body"});s.append(u("div",{class:"rui-tile-label"},[m(e.label)]));const l=m(e.value);l&&s.append(u("div",{class:"rui-tile-value"},[l]));const c=m(e.description);return c&&s.append(u("div",{class:"rui-tile-description"},[c])),i.append(s),n&&(i.onclick=()=>r.invoke(e.onClick)),i}},Ro={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:Je},{name:"unread",type:"boolean",optional:!0,description:"Highlights the card with an accent"},{name:"actions",type:"Node[]",optional:!0}],render:(t,e,r)=>{const n=I(e.unread),a=u("article",{class:"rui-notification","data-tone":m(e.tone,"default"),"data-unread":n?"true":"false"}),i=m(e.avatarSrc),o=u("div",{class:"rui-notification-visual"});if(i)o.append(zt(i,m(e.title),"md"));else{const b=j(m(e.icon,"bell"),{className:"rui-notification-icon"});b&&o.append(b)}a.append(o);const s=u("div",{class:"rui-notification-body"}),l=u("header",{class:"rui-notification-head"}),c=u("span",{class:"rui-notification-title-wrap"});n&&c.append(u("span",{class:"rui-notification-unread-dot","aria-label":"Unread"})),c.append(u("span",{class:"rui-notification-title"},[m(e.title)])),l.append(c);const d=m(e.time);d&&l.append(u("span",{class:"rui-notification-time"},[d])),s.append(l);const p=m(e.message);p&&s.append(u("p",{class:"rui-notification-message"},[p]));const f=ct(e.actions,r);return f&&(f.classList.add("rui-notification-actions"),s.append(f)),a.append(s),a}},uf={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 n=typeof e.onClick=="function",a=n?"button":"div",i=m(e.size,"md"),o=i==="lg"?"lg":i==="sm"?"sm":"md",s=u(a,{type:n?"button":null,class:"rui-person-chip","data-size":i}),l=u("span",{class:"rui-person-chip-avatar"});l.append(zt(m(e.avatarSrc),m(e.name),o));const c=m(e.status);c&&l.append(u("span",{class:"rui-person-chip-status","data-status":c})),s.append(l);const d=u("div",{class:"rui-person-chip-meta"});d.append(u("span",{class:"rui-person-chip-name"},[m(e.name)]));const p=m(e.role);return p&&d.append(u("span",{class:"rui-person-chip-role"},[p])),s.append(d),n&&(s.onclick=()=>r.invoke(e.onClick)),s}},Eo=["left","center","right"],df={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:Eo,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=u("div",{class:"rui-col"});return r.append(u("strong",{},[m(e.header)])),r}},pf={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 n=T(e.columns),a=m(e.density,"comfortable"),i=I(e.striped),o=I(e.sticky),s=u("div",{class:"rui-table-wrapper","data-density":a,"data-striped":i?"true":"false","data-sticky":o?"true":"false"}),l=u("table",{class:"rui-table"}),c=m(e.caption);c&&l.append(u("caption",{class:"rui-table-caption"},[c]));const d=n.map(w=>{const k=m(w.args?.[3],"");return Eo.includes(k)?k:""}),p=u("thead"),f=u("tr");for(let w=0;w<n.length;w+=1){const k=n[w],A=u("th",{"data-align":d[w]||null},[m(k.args?.[0])]);f.append(A)}p.append(f),l.append(p);const b=u("tbody"),h=n.map(w=>T(w.args?.[1])),g=n.map(w=>m(w.args?.[2],"text")),y=n.map(w=>w.args?.[6]),v=n.map(w=>w.args?.[7]),x=Math.max(0,...h.map(w=>w.length));for(let w=0;w<x;w+=1){const k=u("tr");h.forEach((A,S)=>{const $=g[S]??"text",C=d[S],M=u("td",{"data-format":$,"data-align":C||null});ln(M,{format:$,render:y[S],onClick:v[S]},A[w],w,r,xf),k.append(M)}),b.append(k)}if(x===0){const w=u("tr"),k=m(e.emptyLabel,"No data");w.append(u("td",{colspan:String(n.length||1),class:"rui-table-empty"},[k])),b.append(w)}return l.append(b),s.append(l),s}},mf={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=u("li",{class:"rui-list-item"}),n=j(e.icon,{className:"rui-list-icon"});n&&r.append(n);const a=u("div",{class:"rui-list-text"});a.append(u("div",{class:"rui-list-title"},[m(e.title)]));const i=m(e.description);return i&&a.append(u("div",{class:"rui-list-description"},[i])),r.append(a),r}},ff={name:"List",description:"Vertical list of ListItems.",props:[{name:"items",type:"ListItem[]"},{name:"ordered",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=I(e.ordered)?"ol":"ul",a=u(n,{class:"rui-list"});for(const i of T(e.items))a.append(r.renderNode(i));return a}},gf={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"),n=u("div",{class:"rui-stat-card","data-tone":r}),a=u("div",{class:"rui-stat-label-row"}),i=m(e.label),o=m(e.icon)||To(i)||"",s=j(o,{className:"rui-stat-icon"});s&&a.append(s),a.append(u("div",{class:"rui-stat-label"},[i])),n.append(a),n.append(u("div",{class:"rui-stat-value"},[m(e.value)]));const l=m(e.delta),c=m(e.trend);(l||c)&&n.append(u("div",{class:"rui-stat-trend","data-trend":c||"flat"},[l||yf(c)]));const d=T(e.spark).map(p=>P(p));if(d.length>1){const p=u("div",{class:"rui-stat-spark"});p.append(Ln(d,r==="default"?"primary":r)),n.append(p)}return n}},hf={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"),n=T(e.values).map(i=>P(i)),a=u("span",{class:"rui-sparkline-wrap"});return a.append(Ln(n,r)),a}},bf={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 n=T(e.children),a=n.length>0,i=I(e.expanded),o=I(e.active),s=typeof e.onClick=="function",l=u(s?"button":"div",{type:s?"button":null,class:"rui-tree-node-row",role:"treeitem","data-active":o?"true":"false","aria-expanded":a?i?"true":"false":null});if(a){const h=j("chevron-right",{className:"rui-tree-node-chevron"});h&&l.append(h)}else l.append(u("span",{class:"rui-tree-node-chevron-spacer","aria-hidden":"true"}));const c=j(e.icon,{className:"rui-tree-node-icon"});c&&l.append(c),l.append(u("span",{class:"rui-tree-node-label"},[m(e.label)]));const d=m(e.badge);if(d&&l.append(u("span",{class:"rui-tree-node-badge"},[d])),s&&(l.onclick=()=>r.invoke(e.onClick)),!a)return l;const p=u("details",{class:"rui-tree-node"});i&&p.setAttribute("open","");const f=u("summary",{class:"rui-tree-node-summary"});f.append(l),s&&(f.onclick=h=>{h.target?.closest(".rui-tree-node-chevron")||h.preventDefault()}),p.append(f);const b=u("div",{class:"rui-tree-node-children",role:"group"});for(const h of n)b.append(r.renderNode(h));return p.append(b),p}},vf={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 n=u("div",{class:"rui-tree",role:"tree"});for(const a of T(e.items))n.append(r.renderNode(a));return n}};function yf(t){return t==="up"?"▲":t==="down"?"▼":"—"}function xf(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 zn=["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)"],Ct=t=>zn[t%zn.length]??zn[0],wf={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)=>u("span",{class:"rui-series","data-name":m(e.name)})},Lo=t=>t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>P(o));return{name:a,values:i}}),kf={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=T(e.labels).map(v=>m(v)),n=Lo(T(e.series)),a=u("div",{class:"rui-chart rui-bar-chart"});m(e.title)&&a.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const i=Math.max(1,...n.flatMap(v=>v.values)),o=640,s=240,l=jo(r,o-40-12),c={left:40,right:12,top:12,bottom:l.bottomPadding},d=o-c.left-c.right,p=s-c.top-c.bottom,f=jn(o,s);Oo(f,c,d,p,i);const b=r.length,h=d/Math.max(b,1),g=n.length,y=h*.7/Math.max(g,1);return n.forEach((v,x)=>{v.values.forEach((w,k)=>{const A=w/i*p,S=c.left+k*h+h*.15+x*y,$=c.top+p-A,C=Me("rect",{x:String(S),y:String($),width:String(Math.max(y-2,1)),height:String(A),fill:Ct(x),rx:"2"});C.append(Me("title",{},[`${v.name}: ${w}`])),f.append(C)})}),Do(f,r,c,d,p,l,v=>c.left+(v+.5)*h),a.append(f),n.length>0&&a.append(Dn(n)),a}},Sf={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=T(e.labels).map($=>m($)),n=Lo(T(e.series));const a=T(e.data);if(a.length>0&&(r.length===0||n.length===0)){const $=[],C=new Map;for(const M of a){const L=M;if(!(!L||typeof L!="object")){$.push(m(L.x??L.label??""));for(const[z,H]of Object.entries(L)){if(z==="x"||z==="label")continue;const F=P(H);Number.isNaN(F)||(C.has(z)||C.set(z,[]),C.get(z).push(F))}}}r.length===0&&(r=$),n.length===0&&(n=[...C.entries()].map(([M,L])=>({name:M,values:L})))}const i=e.filled===!0,o=e.stacked===!0,s=Math.max(r.length,...n.map($=>$.values.length),1),l=n.map(()=>Array(s).fill(0));if(i&&o)for(let $=0;$<s;$+=1){let C=0;n.forEach((M,L)=>{C+=M.values[$]??0,l[L][$]=C})}const c=u("div",{class:"rui-chart rui-line-chart","data-filled":i?"true":"false"});m(e.title)&&c.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const d=i&&o?l.flat():n.flatMap($=>$.values),p=Math.max(1,...d),f=i&&o?0:Math.min(0,...d),b=640,h=240,g=jo(r,b-40-12),y={left:40,right:12,top:12,bottom:g.bottomPadding},v=b-y.left-y.right,x=h-y.top-y.bottom,w=jn(b,h);Oo(w,y,v,x,p,f);const k=Math.max(r.length-1,1),A=v/k,S=$=>y.left+$*(v/Math.max(s-1,1));return n.forEach(($,C)=>{const M=i&&o?l[C]:$.values,L=i&&o&&C>0?l[C-1]:null,z=M.map((F,V)=>{const _=S(V),te=y.top+x-(F-f)/(p-f||1)*x;return[_,te]});if(i&&z.length>0){let F=z.map(([V,_],te)=>`${te===0?"M":"L"}${V.toFixed(1)},${_.toFixed(1)}`).join(" ");if(L){const V=L.map((_,te)=>{const ke=S(te),De=y.top+x-(_-f)/(p-f||1)*x;return[ke,De]});F+=" "+V.slice().reverse().map(([_,te])=>`L${_.toFixed(1)},${te.toFixed(1)}`).join(" ")+" Z"}else{const V=z[0],_=z[z.length-1];F+=` L${_[0].toFixed(1)},${(y.top+x).toFixed(1)} L${V[0].toFixed(1)},${(y.top+x).toFixed(1)} Z`}w.append(Me("path",{d:F,fill:Ct(C),"fill-opacity":"0.2",stroke:"none"}))}const H=z.map(([F,V],_)=>`${_===0?"M":"L"}${F.toFixed(1)},${V.toFixed(1)}`).join(" ");w.append(Me("path",{d:H,fill:"none",stroke:Ct(C),"stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"})),$.values.length<=30&&z.forEach(([F,V])=>{w.append(Me("circle",{cx:String(F),cy:String(V),r:"3",fill:Ct(C)}))})}),Do(w,r,y,v,x,g,$=>y.left+$*A),c.append(w),n.length>0&&c.append(Dn(n)),c}},$f={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=T(e.labels).map(g=>m(g)),n=T(e.values).map(g=>P(g)),a=e.showValues==null?!0:I(e.showValues),i=m(e.valueFormat,"value").toLowerCase(),o=i==="percent"?"percent":i==="both"?"both":"value",s=u("div",{class:"rui-chart rui-pie-chart"});m(e.title)&&s.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const l=n.reduce((g,y)=>g+(y>0?y:0),0)||1,c=jn(240,240),d=120,p=120,f=90,b=.05;let h=-Math.PI/2;return n.forEach((g,y)=>{const v=g>0?g:0,x=v/l,w=x*Math.PI*2,k=h+w,A=w>Math.PI?1:0,S=d+f*Math.cos(h),$=p+f*Math.sin(h),C=d+f*Math.cos(k),M=p+f*Math.sin(k),L=`M${d},${p} L${S},${$} A${f},${f} 0 ${A} 1 ${C},${M} Z`,z=Me("path",{d:L,fill:Ct(y),stroke:"var(--rui-color-bg, #fff)","stroke-width":"2"});if(z.append(Me("title",{},[`${r[y]??""}: ${g} (${(x*100).toFixed(1)}%)`])),c.append(z),a&&v>0&&x>=b){const H=h+w/2,F=f*.62,V=d+F*Math.cos(H),_=p+F*Math.sin(H),te=Cf(g,x,o),ke=Me("text",{x:String(V),y:String(_),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"},[te]);c.append(ke)}h=k}),s.append(c),s.append(Dn(r.map((g,y)=>({name:g,values:[n[y]??0]})))),s}};function Cf(t,e,r){const n=`${Math.round(e*100)}%`,a=Af(t);return r==="percent"?n:r==="both"?`${a} (${n})`:a}function Af(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 Tf=7,zo=12;function jo(t,e){if(t.length===0)return{step:1,rotated:!1,maxChars:32,bottomPadding:32};const r=e/Math.max(t.length,1),n=t.reduce((o,s)=>Math.max(o,s.length),0);if(n*Tf+4<=r)return{step:1,rotated:!1,maxChars:n,bottomPadding:32};const a=r<zo?Math.max(1,Math.ceil(zo/r)):1,i=Math.min(n,14);return{step:a,rotated:!0,maxChars:i,bottomPadding:60}}function Mf(t,e){return t.length<=e?t:t.slice(0,Math.max(e-1,1))+"…"}function Do(t,e,r,n,a,i,o){const s=r.top+a+(i.rotated?14:18);e.forEach((l,c)=>{if(c%i.step!==0)return;const d=o(c),p=Mf(l,i.maxChars),f={x:String(d),y:String(s),class:"rui-chart-label","text-anchor":i.rotated?"end":"middle"};i.rotated&&(f.transform=`rotate(-45, ${d}, ${s})`);const b=Me("text",f,[p]);p!==l&&b.append(Me("title",{},[l])),t.append(b)})}function jn(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 Me(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[a,i]of Object.entries(e))n.setAttribute(a,i);if(r)for(const a of r)n.append(typeof a=="string"?document.createTextNode(a):a);return n}function Oo(t,e,r,n,a,i=0){for(let s=0;s<=4;s+=1){const l=s/4,c=e.top+n-l*n;t.append(Me("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(Me("text",{x:String(e.left-6),y:String(c+3),"text-anchor":"end",class:"rui-chart-tick"},[String(Math.round((i+(a-i)*l)*10)/10)]))}}function Dn(t){const e=u("div",{class:"rui-chart-legend"});return t.forEach((r,n)=>{const a=u("span",{class:"rui-chart-legend-item"});a.append(u("span",{class:"rui-chart-legend-swatch",style:`background:${Ct(n)}`})),a.append(u("span",{},[r.name])),e.append(a)}),e}const Nf={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 n=u("section",{class:"rui-section-block"});n.append(u("h3",{class:"rui-section-block-title"},[m(e.title)]));const a=m(e.description);a&&n.append(u("p",{class:"rui-section-block-description"},[a]));for(const i of T(e.children))n.append(r.renderNode(i));return n}},If={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=I(e.ordered)?"ol":"ul",n=u(r,{class:"rui-list-block"});for(const a of T(e.items))n.append(u("li",{},[m(a)]));return n}},Pf={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 n=u("div",{class:"rui-follow-up"}),a=m(e.title,"You can also ask");a&&n.append(u("div",{class:"rui-follow-up-title"},[a]));const i=u("div",{class:"rui-follow-up-list"});for(const o of T(e.items))i.append(Rf(o,r));return n.append(i),n}},Rf=(t,e)=>{const{label:r,message:n}=Ef(t),a=u("button",{class:"rui-follow-up-button",type:"button"},[r]);return a.onclick=()=>{e.sendToAssistant(n)},a},Ef=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 n=m(r.label),a=m(r.message,n);return{label:n,message:a}}const e=m(t);return{label:e,message:e}},Lf={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 n=m(e.label),a=m(e.message,n),i=u("button",{class:"rui-follow-up-button",type:"button"},[n]);return i.onclick=()=>{r.sendToAssistant(a)},i}},zf={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 n=u("a",{class:"rui-action-link",href:"#",role:"button"},[m(e.label)]);return n.onclick=a=>{a.preventDefault(),r.invoke(e.onClick)},n}},Bo=["xs","sm","md","lg","xl"],jf=["initials","dicebear","gradient"];function Df(t){let e=0;for(let a=0;a<t.length;a+=1)e=e*31+t.charCodeAt(a)>>>0;const r=e%360,n=(r+40)%360;return`background:linear-gradient(135deg, hsl(${r} 65% 55%), hsl(${n} 65% 45%));color:#fff;`}const Fo={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:Bo},{name:"status",type:"string",optional:!0,enum:["online","offline","busy","away"]},{name:"fallback",type:"string",optional:!0,enum:jf,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"),n=u("span",{class:"rui-avatar","data-size":r,role:"img"}),a=m(e.name),i=m(e.fallback,"dicebear"),o=ie(e.src),s=!o&&i==="dicebear"&&a?ie(Vp(a)):"",l=o||s;if(l){const d=u("img",{src:l,alt:a,loading:"lazy"});d.onerror=p=>{const f=p;(f.currentTarget??f.target).replaceWith(u("span",{class:"rui-avatar-fallback"},[St(a)]))},n.append(d)}else i==="gradient"&&a?n.append(u("span",{class:"rui-avatar-fallback rui-avatar-gradient",style:Df(a)},[St(a)])):n.append(u("span",{class:"rui-avatar-fallback"},[St(a)]));const c=m(e.status);return c&&n.append(u("span",{class:"rui-avatar-status","data-status":c})),n}},Of={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:Bo}],render:(t,e,r)=>{const n=T(e.items),a=Math.max(1,Math.floor(Number(e.max??4))),i=m(e.size,"md"),o=n.slice(0,a),s=n.length-o.length,l=u("div",{class:"rui-avatar-group","data-size":i});for(const c of o){if(c&&typeof c=="object"&&c.__kind==="Component"){l.append(r.renderNode(c));continue}const d=c,p=typeof d=="string"?d:m((d??{}).name),f=typeof d=="string"?"":m((d??{}).src);l.append(Fo.render({__kind:"Component",name:"Avatar",args:[],argMeta:[]},{name:p,src:f,size:i},r))}return s>0&&l.append(u("span",{class:"rui-avatar rui-avatar-overflow","data-size":i},[u("span",{class:"rui-avatar-fallback"},[`+${s}`])])),l}},Bf={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,P(e.max,100)),n=I(e.indeterminate),a=Math.max(0,Math.min(r,P(e.value,0))),i=Math.round(a/r*100),o=Math.max(0,Math.floor(P(e.segments,0))),s=e.buffered!=null?Math.max(0,Math.min(r,P(e.buffered,0))):null,l=u("div",{class:"rui-progress","data-tone":m(e.tone,"primary")}),c=m(e.label),d=I(e.showValue);if(c||d){const f=u("div",{class:"rui-progress-head"});if(f.append(u("span",{class:"rui-progress-label"},[c])),d&&!n){const b=o>0?`${Math.min(o,Math.round(a/r*o))} / ${o}`:`${i}%`;f.append(u("span",{class:"rui-progress-value"},[b]))}l.append(f)}if(o>0&&!n){const f=u("div",{class:"rui-progress-segments",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o),"aria-valuenow":String(Math.min(o,Math.round(a/r*o)))}),b=Math.min(o,Math.round(a/r*o));for(let h=0;h<o;h+=1)f.append(u("span",{class:"rui-progress-segment","data-filled":h<b?"true":"false"}));return l.append(f),l}const p=u("div",{class:"rui-progress-track",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(r),"aria-valuenow":n?null:String(a),"data-indeterminate":n?"true":"false"});if(s!==null){const f=Math.round(s/r*100);p.append(u("div",{class:"rui-progress-buffer",style:`width:${f}%`,"aria-hidden":"true"}))}return p.append(u("div",{class:"rui-progress-bar",style:n?"":`width:${i}%`})),l.append(p),l}},Ff={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 n=m(e.id),a=u("label",{class:"rui-switch",for:n,"data-disabled":I(e.disabled)?"true":"false"}),i=I(e.value),o=u("input",{type:"checkbox",id:n,name:n,class:"rui-switch-input",role:"switch",checked:i?"":null,disabled:I(e.disabled)?"":null});o.checked=i;const s=u("span",{class:"rui-switch-track"},[u("span",{class:"rui-switch-thumb"})]),l=t.argMeta?.[2]?.stateRef;l&&r.bindState(o,l,{event:"change",getValue:p=>p.checked}),e.onChange!=null&&o.addEventListener("change",p=>{r.invoke(e.onChange,p.currentTarget.checked)});const c=m(e.label),d=m(e.description);if(a.append(o,s),c||d){const p=u("span",{class:"rui-switch-meta"});c&&p.append(u("span",{class:"rui-switch-label"},[c])),d&&p.append(u("span",{class:"rui-switch-description"},[d])),a.append(p)}return a}},_f={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 n=m(e.value),a=m(e.variant,"outline"),i=m(e.size,"md"),o=u("div",{class:"rui-toggle-group",role:"radiogroup","data-variant":a,"data-size":i}),s=t.argMeta?.[2]?.stateRef;for(const l of T(e.items)){const{value:c,label:d,icon:p}=Uf(l),f=c===n,b=u("button",{type:"button",class:"rui-toggle",role:"radio","aria-checked":f?"true":"false","data-variant":a,"data-size":i,"data-state":f?"on":"off","data-value":c}),h=j(p,{className:"rui-toggle-icon"});h&&b.append(h),b.append(u("span",{class:"rui-toggle-label"},[d])),b.onclick=()=>{s&&r.setState(s,c),r.invoke(e.onChange,c)},o.append(b)}return o}};function Uf(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 Hf={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 n=m(e.side,"top"),a=u("span",{class:"rui-tooltip","data-side":n,tabindex:"0"});a.append(u("span",{class:"rui-tooltip-trigger"},[r.renderNode(e.trigger)]));const i=u("span",{class:"rui-tooltip-content",role:"tooltip"},[m(e.label)]);return i.append(u("span",{class:"rui-tooltip-arrow","aria-hidden":"true"})),a.append(i),a.addEventListener("mousedown",()=>{requestAnimationFrame(()=>{(document.activeElement===a||a.contains(document.activeElement))&&document.activeElement?.blur?.()})}),a}},qf={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 n=u("span",{class:"rui-hover-card","data-side":m(e.side,"bottom"),"data-open":I(e.open)?"true":null,tabindex:"0"});n.append(u("span",{class:"rui-hover-card-trigger"},[r.renderNode(e.trigger)]));const a=u("span",{class:"rui-hover-card-content",role:"dialog"});for(const i of T(e.content))a.append(r.renderNode(i));return n.append(a),n}},On={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"}},Vf={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 n=Math.max(1,Math.floor(P(e.max,5))),a=m(e.size,"md"),i=I(e.halfStep),o=t.argMeta?.[0]?.stateRef,s=(I(e.interactive)||e.onChange!=null)&&!I(e.readonly),c=s&&!o?r.useInstanceState("rating-value",P(e.value,0)):null,d=P(c?c.get():e.value,0),p=Math.max(0,Math.min(n,d)),f=Gf(m(e.icon)),b=u("div",{class:"rui-rating","data-size":a,"data-interactive":s?"true":"false","data-half-step":s&&i?"true":"false",role:"img","aria-label":`${p} of ${n}`}),h=u("span",{class:"rui-rating-stars"});for(let v=1;v<=n;v+=1){const x=Math.max(0,Math.min(1,p-(v-1))),w=x>=1?f.full:x>0?f.half:f.empty,k=rr(w).join(" "),A=u(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 ${v}`:null,"aria-hidden":s?null:"true"});if(s){const S=v,$=v-.5;A.onclick=C=>{const M=C,L=M.currentTarget??M.target;let z=S;if(i){const H=L.getBoundingClientRect();H.width>0&&M.clientX-H.left<H.width/2&&(z=$)}o&&r.setState(o,z),c&&c.set(z),Wf(L.closest(".rui-rating"),z,n,f),r.invoke(e.onChange,z)}}h.append(A)}b.append(h);const g=m(e.label);g&&b.append(u("span",{class:"rui-rating-label"},[g]));const y=e.count!=null?P(e.count,0):null;return y!==null&&y>0&&b.append(u("span",{class:"rui-rating-count"},[`(${y.toLocaleString()})`])),b}};function Wf(t,e,r,n){if(!t)return;t.querySelectorAll(".rui-rating-star").forEach((i,o)=>{const s=Math.max(0,Math.min(1,e-o)),l=s>=1?n.full:s>0?n.half:n.empty;i.setAttribute("data-fill",s>=1?"full":s>0?"half":"empty"),i.className=`rui-rating-star ${rr(l).join(" ")}`.trim()}),t.setAttribute("aria-label",`${Math.max(0,Math.min(r,e))} of ${r}`)}function Gf(t){const e=t.trim().toLowerCase();return e?On[e]?On[e]:{full:e,half:e,empty:`regular:${e}`}:On.star}const Kf={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,P(e.max,100)),n=I(e.indeterminate),a=Math.max(0,Math.min(r,P(e.value,0))),i=Math.round(a/r*100),o=m(e.size,"md"),s=o==="lg"?120:o==="sm"?72:96,l=o==="lg"?10:o==="sm"?6:8,c=(s-l)/2,d=2*Math.PI*c,p=n?d*.65:d*(1-i/100),f=u("div",{class:"rui-progress-ring","data-tone":m(e.tone,"primary"),"data-size":o,"data-indeterminate":n?"true":"false"}),b=u("div",{class:"rui-progress-ring-wrap"}),h="http://www.w3.org/2000/svg",g=document.createElementNS(h,"svg");g.setAttribute("width",String(s)),g.setAttribute("height",String(s)),g.setAttribute("viewBox",`0 0 ${s} ${s}`),g.setAttribute("class","rui-progress-ring-svg");const y=document.createElementNS(h,"circle");y.setAttribute("class","rui-progress-ring-track"),y.setAttribute("cx",String(s/2)),y.setAttribute("cy",String(s/2)),y.setAttribute("r",String(c)),y.setAttribute("stroke-width",String(l)),y.setAttribute("fill","none"),g.appendChild(y);const v=document.createElementNS(h,"circle");v.setAttribute("class","rui-progress-ring-bar"),v.setAttribute("cx",String(s/2)),v.setAttribute("cy",String(s/2)),v.setAttribute("r",String(c)),v.setAttribute("stroke-width",String(l)),v.setAttribute("fill","none"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-dasharray",String(d)),v.setAttribute("stroke-dashoffset",String(p)),g.appendChild(v),b.append(g);const x=m(e.label,n?"…":`${i}%`),w=u("span",{class:"rui-progress-ring-value"}),k=j(x,{className:"rui-progress-ring-icon"});k&&rr(x).length>0?w.append(k):w.append(document.createTextNode(x)),b.append(w),f.append(b);const A=m(e.caption);return A&&f.append(u("span",{class:"rui-progress-ring-caption"},[A])),f}},Yf={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"),n=u("div",{class:"rui-chat-bubble","data-from":r});r!=="me"&&n.append(_o(m(e.avatarSrc),m(e.author)));const a=u("div",{class:"rui-chat-bubble-bubble"}),i=u("header",{class:"rui-chat-bubble-head"});i.append(u("span",{class:"rui-chat-bubble-author"},[m(e.author)]));const o=m(e.time);o&&i.append(u("span",{class:"rui-chat-bubble-time"},[o])),a.append(i),a.append(u("p",{class:"rui-chat-bubble-body"},[m(e.body)]));const s=m(e.status);return s&&a.append(u("span",{class:"rui-chat-bubble-status","data-status":s},[s])),n.append(a),r==="me"&&n.append(_o(m(e.avatarSrc),m(e.author))),n}};function _o(t,e){const r=u("span",{class:"rui-chat-bubble-avatar"}),n=ie(t);return n?r.append(u("img",{src:n,alt:e,loading:"lazy"})):r.append(u("span",{class:"rui-chat-bubble-fallback"},[St(e)])),r}const Xf={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"),n=u("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&&n.append(u("span",{class:"rui-kbd-sep"},["+"])),n.append(u("kbd",{class:"rui-kbd"},[s])))}),n}},Jf={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 n=I(e.open),a=r.useInstanceState("open",n),i=a.get(),o=Z(e.width,""),s=u("div",{class:"rui-popover","data-open":i?"true":"false","data-side":m(e.side,"bottom"),"data-align":m(e.align,"start")}),l=u("span",{class:"rui-popover-trigger","data-state":i?"open":"closed","aria-haspopup":"dialog","aria-expanded":i?"true":"false"});l.append(r.renderNode(e.trigger)),s.append(l);const c=u("div",{class:"rui-popover-content",role:"dialog",style:o?`width: ${o};`:null}),d=u("div",{class:"rui-popover-header"}),p=m(e.title);d.append(p?u("div",{class:"rui-popover-title"},[p]):u("span",{class:"rui-popover-title-spacer"}));const f=u("button",{type:"button",class:"rui-popover-close","aria-label":"Close popover"},["×"]);f.onclick=b=>{b.stopPropagation(),xr(f,!1,a)},d.append(f),c.append(d);for(const b of T(e.content))c.append(r.renderNode(b));return s.append(c),l.onclick=b=>{b.stopPropagation();const h=b.currentTarget??b.target,g=!a.get(),y=xr(h,g,a);g&&y&&Uo(y,a)},l.onkeydown=b=>{const h=b,g=h.currentTarget??h.target;if(h.key==="Enter"||h.key===" "){h.preventDefault();const y=!a.get(),v=xr(g,y,a);y&&v&&Uo(v,a)}else h.key==="Escape"&&a.get()&&(h.preventDefault(),xr(g,!1,a))},s}},xr=(t,e,r)=>{r.set(e);const n=t.closest(".rui-popover");if(!n)return null;n.setAttribute("data-open",e?"true":"false");const a=n.querySelector(".rui-popover-trigger");return a?.setAttribute("aria-expanded",e?"true":"false"),a?.setAttribute("data-state",e?"open":"closed"),e||We(n),n},Uo=(t,e)=>{$t({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")}})},Qf=["default","primary","success","warning","danger","info"],Ho=["top-right","top-left","top-center","bottom-right","bottom-left","bottom-center"],Zf={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:Qf,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:Ho,description:"Pin a standalone Toast to a viewport corner without wrapping it in `Stack(...)`"}],render:(t,e,r)=>{const n=m(e.tone,"default"),a=m(e.position),i=u("div",{class:a?"rui-toast rui-toast-standalone":"rui-toast",role:n==="danger"?"alert":"status","aria-live":n==="danger"?"assertive":"polite","data-tone":n,"data-position":a||null}),o=m(e.icon)||tg(n),s=j(o,{className:"rui-toast-icon"});s&&i.append(s);const l=u("div",{class:"rui-toast-body"});l.append(u("div",{class:"rui-toast-title"},[m(e.title)]));const c=m(e.message);if(c&&l.append(u("div",{class:"rui-toast-message"},[c])),e.action){const x=u("div",{class:"rui-toast-action"});x.append(r.renderNode(e.action)),l.append(x)}i.append(l);const d=r.useInstanceState("dismissed",!1),p=r.useInstanceState("timer",null),f=x=>{if(x){const w=x.closest(".rui-toast");if(w)return w}return i.isConnected?i:null},b=()=>{const x=p.get();x!==null&&(clearTimeout(x),p.set(null))},h=r.useInstanceState("removal-timer",null),g=x=>{if(d.get())return;d.set(!0),b();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)},y=u("button",{type:"button",class:"rui-toast-close","aria-label":"Dismiss notification"},["×"]);y.onclick=x=>{x.stopPropagation(),g(x.currentTarget??x.target)},i.append(y);const v=P(e.duration,0);if(v>0&&p.get()===null&&!d.get()){const x=setTimeout(()=>{p.set(null),!d.get()&&i.isConnected&&g()},v);p.set(x),r.registerDisposer(()=>{const w=p.get();w!==null&&(clearTimeout(w),p.set(null))},"auto-dismiss-timer")}return d.get()?u("div",{class:"rui-toast-placeholder",hidden:""}):i}},eg={name:"Toasts",description:"Stacked container for transient `Toast` notifications, pinned to a viewport corner. Render the reactive `$toast.items` list into it: `Toasts($toast.items.map(t => Toast({ title: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))`. Use a standalone `Toast` with `position` for a single one-off notice.",props:[{name:"children",type:"Node[]",description:"Toast components to stack"},{name:"position",type:"string",optional:!0,enum:Ho,description:'Viewport corner the stack pins to (default "top-right")'}],render:(t,e,r)=>{const n=u("div",{class:"rui-toasts","data-position":m(e.position,"top-right"),"aria-live":"off"});for(const a of T(e.children))n.append(r.renderNode(a));return n}};function tg(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 qo={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=u("li",{class:"rui-breadcrumb-item"}),n=m(e.label),a=m(e.href),i=a?qe(a):"",o=[],s=j(e.icon,{className:"rui-breadcrumb-icon"});if(s&&o.push(s),o.push(u("span",{class:"rui-breadcrumb-label"},[n])),i)r.append(u("a",{class:"rui-breadcrumb-link",href:i},o));else{r.setAttribute("aria-current","page");const l=u("span",{class:"rui-breadcrumb-current"});for(const c of o)c&&l.append(typeof c=="string"?document.createTextNode(c):c);r.append(l)}return r}},rg={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 n=T(e.items),a=m(e.separator,"/"),i=u("nav",{class:"rui-breadcrumb","aria-label":"Breadcrumb"}),o=u("ol",{class:"rui-breadcrumb-list"});return n.forEach((s,l)=>{if(l>0&&o.append(u("li",{class:"rui-breadcrumb-separator","aria-hidden":"true"},[a])),s&&typeof s=="object"&&s.__kind==="Component"){o.append(r.renderNode(s));return}const c=m(s),d=l===n.length-1;o.append(qo.render({__kind:"Component",name:"BreadcrumbItem",args:[],argMeta:[]},{label:c,href:d?"":"#"},r))}),i.append(o),i}},ng=[10,20,50,100],ag={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 n=Math.max(1,Math.floor(P(e.totalPages,1))),a=Math.max(1,Math.min(n,Math.floor(P(e.page,1)))),i=Math.max(0,Math.floor(P(e.siblings,1))),o=I(e.compact),s=t.argMeta?.[0]?.stateRef,l=u("nav",{class:"rui-pagination","aria-label":"Pagination","data-compact":o?"true":"false"}),c=g=>{if(!s)return;const y=Math.max(1,Math.min(n,g));y!==a&&r.setState(s,y)},d=e.total!=null?Math.max(0,Math.floor(P(e.total,0))):null,p=e.perPage!=null?Math.max(1,Math.floor(P(e.perPage,0))):null;if(d!==null&&p&&p>0){const g=d===0?0:(a-1)*p+1,y=Math.min(d,a*p);l.append(u("span",{class:"rui-pagination-summary"},[d===0?"No results":`Showing ${g.toLocaleString()}–${y.toLocaleString()} of ${d.toLocaleString()}`]))}else d!==null&&l.append(u("span",{class:"rui-pagination-summary"},[`${d.toLocaleString()} result${d===1?"":"s"}`]));const f=u("div",{class:"rui-pagination-buttons"}),b=(g,y,v={})=>{if(v.ellipsis)return u("span",{class:"rui-pagination-ellipsis","aria-hidden":"true"},[g]);const x=u("button",{type:"button",class:"rui-pagination-button","data-active":v.active?"true":"false","aria-current":v.active?"page":null,"aria-label":v.ariaLabel??null,disabled:v.disabled?"":null},[g]);return!v.disabled&&!v.active&&(x.onclick=()=>c(y)),x};if(f.append(b("‹",a-1,{disabled:a<=1,ariaLabel:"Previous page"})),o)f.append(u("span",{class:"rui-pagination-current"},[`${a} / ${n}`]));else{const g=ig(a,n,i);for(const y of g)y==="…"?f.append(b("…",0,{ellipsis:!0})):f.append(b(String(y),y,{active:y===a}))}f.append(b("›",a+1,{disabled:a>=n,ariaLabel:"Next page"})),l.append(f);const h=t.argMeta?.[4]?.stateRef;if(p&&(h||T(e.perPageOptions).length>0)){const g=T(e.perPageOptions).length>0?T(e.perPageOptions).map(x=>Math.max(1,Math.floor(Number(x)||0))).filter(x=>x>0):Array.from(ng),y=u("label",{class:"rui-pagination-per-page"},[document.createTextNode("Show ")]),v=u("select",{class:"rui-pagination-per-page-select"});for(const x of g){const w=u("option",{value:String(x),selected:x===p?"":null},[String(x)]);v.append(w)}h&&r.bindState(v,h,{event:"change",getValue:x=>Number(x.value)}),y.append(v),y.append(document.createTextNode(" per page")),l.append(y)}return l}};function ig(t,e,r){const n=[],a=(l,c)=>{for(let d=l;d<=c;d+=1)n.push(d)},i=r*2+5;if(e<=i)return a(1,e),n;const o=Math.max(2,t-r),s=Math.min(e-1,t+r);return n.push(1),o>2&&n.push("…"),a(o,s),s<e-1&&n.push("…"),n.push(e),n}const og={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 n=m(e.label),a=e.icon,i=I(e.active),o=m(e.to),s=qe(e.href,""),l=I(e.external),c=o||s?"a":"button",d=u(c,{class:"rui-navbar-item",type:c==="button"?"button":null,href:s||(o?`#${o.startsWith("/")?o:`/${o}`}`:null),target:l&&s?"_blank":null,rel:l&&s?"noopener noreferrer":null,"data-active":i?"true":"false"}),p=j(a,{className:"rui-navbar-item-icon"});return p&&d.append(p),d.append(u("span",{class:"rui-navbar-item-label"},[n])),o&&!s?d.onclick=f=>{if(f.defaultPrevented)return;const b=f;b.button!==0||b.metaKey||b.ctrlKey||b.shiftKey||b.altKey||(f.preventDefault(),r.router.navigate(o))}:typeof e.onClick=="function"&&(d.onclick=f=>{f.preventDefault(),r.invoke(e.onClick)}),d}},sg={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 n=u("nav",{class:"rui-navbar","data-sticky":I(e.sticky)?"true":"false","data-variant":m(e.variant,"default"),"aria-label":"Primary"}),a=e.brand;if(a!=null&&a!==""){const s=u("div",{class:"rui-navbar-brand"});typeof a=="string"?s.append(document.createTextNode(a)):s.append(r.renderNode(a)),n.append(s)}const i=T(e.items);if(i.length>0){const s=u("div",{class:"rui-navbar-items"});for(const l of i)s.append(r.renderNode(l));n.append(s)}const o=T(e.actions);if(o.length>0){const s=u("div",{class:"rui-navbar-actions"});for(const l of o)s.append(r.renderNode(l));n.append(s)}return n}},lg=["bottom","top","left","right"],cg=["start","center","end"],ug=["default","danger"],wr=(t,e,r)=>{r.set(e);const n=t.closest(".rui-dropdown-menu");return n?(n.setAttribute("data-open",e?"true":"false"),n.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded",e?"true":"false"),e||We(n),n):null},Vo=(t,e)=>{$t({liveRoot:t,onDismiss:()=>{e.set(!1),t.setAttribute("data-open","false"),t.querySelector(".rui-dropdown-menu-trigger")?.setAttribute("aria-expanded","false")}})},Bn=(t,e)=>{if(!t||typeof t!="object")return!1;const r=t;return r.__kind==="Component"&&r.name===e},dg={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:lg,description:'Where the menu opens relative to the trigger (default "bottom")'},{name:"align",type:"string",optional:!0,enum:cg,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 n=I(e.open),a=r.useInstanceState("open",n),i=a.get(),o=u("div",{class:"rui-dropdown-menu","data-open":i?"true":"false","data-side":m(e.side,"bottom"),"data-align":m(e.align,"start")}),s=u("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 d=c.currentTarget??c.target,p=!a.get(),f=wr(d,p,a);p&&f&&Vo(f,a)},s.onkeydown=c=>{const d=c,p=d.currentTarget??d.target;if(d.key==="Enter"||d.key===" "){d.preventDefault();const f=!a.get(),b=wr(p,f,a);f&&b&&Vo(b,a);return}d.key==="Escape"&&a.get()&&(d.preventDefault(),wr(p,!1,a))},o.append(s);const l=u("div",{class:"rui-dropdown-menu-content",role:"menu","aria-label":m(e.label)||null});for(const c of T(e.items)){if(Bn(c,"MenuItem")){const d=c.args??[],p=m(d[0]),f=d[1],b=d[2],h=m(d[3]),g=m(d[4],"default"),y=I(d[5]),v=u("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":g,disabled:y?"":null}),x=j(b,{className:"rui-menu-item-icon"});x&&v.append(x),v.append(u("span",{class:"rui-menu-item-label"},[p])),h&&v.append(u("span",{class:"rui-menu-item-shortcut"},[h])),y||(v.onclick=w=>{const k=w.currentTarget??w.target;wr(k,!1,a),r.invoke(f)}),l.append(v);continue}if(Bn(c,"MenuSeparator")){l.append(u("div",{class:"rui-menu-separator",role:"separator"}));continue}if(Bn(c,"MenuLabel")){const d=m((c.args??[])[0]);l.append(u("div",{class:"rui-menu-label"},[d]));continue}l.append(r.renderNode(c))}return o.append(l),o}},pg={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:ug,description:'Use "danger" for destructive actions'},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=I(e.disabled),a=u("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":m(e.variant,"default"),disabled:n?"":null}),i=j(e.icon,{className:"rui-menu-item-icon"});i&&a.append(i),a.append(u("span",{class:"rui-menu-item-label"},[m(e.label)]));const o=m(e.shortcut);return o&&a.append(u("span",{class:"rui-menu-item-shortcut"},[o])),n||(a.onclick=()=>{r.invoke(e.onClick)}),a}},mg={name:"MenuSeparator",description:"Thin horizontal rule used inside a DropdownMenu to group items.",props:[],render:()=>u("div",{class:"rui-menu-separator",role:"separator"})},fg={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)=>u("div",{class:"rui-menu-label"},[m(e.label)])},gg=["left","center","right"];function hg(t){return T(t).map((e,r)=>{const n=e.args??[],a=m(n[0]);return{header:a,values:T(n[1]),format:m(n[2],"text"),align:gg.includes(m(n[3]))?m(n[3]):"",sortable:I(n[4]),filterable:I(n[5]),render:n[6],onClick:n[7],key:a||`col-${r}`}})}function Wo(t,e,r){if(t==null)return e==null?0:1;if(e==null)return-1;if(r==="number"||r==="currency")return P(t,0)-P(e,0);if(r==="date"){const n=new Date(m(t)).getTime(),a=new Date(m(e)).getTime();if(Number.isFinite(n)&&Number.isFinite(a))return n-a}return m(t).localeCompare(m(e))}function jt(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)}}function Go(t){return/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function bg(t,e){const r=t.map(a=>Go(a.header)).join(","),n=e.map(a=>t.map(i=>Go(jt(i.values[a],i.format))).join(","));return[r,...n].join(`\r
|
|
99
|
+
`)}function vg(t,e){try{if(typeof Blob>"u"||typeof URL>"u"||typeof document>"u")return;const r=URL.createObjectURL(new Blob([t],{type:"text/csv;charset=utf-8"})),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}catch{}}const yg={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"},{name:"exportable",type:"boolean",optional:!0,description:"Show an Export CSV button that downloads the filtered rows"},{name:"exportFilename",type:"string",optional:!0,description:"CSV download filename (default `data.csv`)"}],render:(t,e,r)=>{const n=hg(e.columns),a=Math.max(0,...n.map(U=>U.values.length)),i=T(e.rowIds),o=U=>m(i[U]??U),s=e.sort&&typeof e.sort=="object"?e.sort:null,l=m(s?.key),c=m(s?.direction,"asc")==="desc"?"desc":"asc",d=T(e.selectedIds).map(U=>m(U)),p=new Set(d),f=I(e.selectable)||t.argMeta?.[4]?.stateRef!==void 0,b=e.stickyHeader===void 0?!0:I(e.stickyHeader),h=I(e.stickyFirstColumn),g=m(e.density,"comfortable"),y=I(e.striped),v=r.useInstanceState("filters",{}),x=v.get(),w=[];for(let U=0;U<a;U+=1){let ee=!0;for(const re of n){if(!re.filterable)continue;const ne=(x[re.key]??"").trim().toLowerCase();if(!ne)continue;const de=re.values[U];if(!jt(de,re.format).toLowerCase().includes(ne)){ee=!1;break}}ee&&w.push(U)}if(l){const U=n.find(ee=>ee.key===l);U&&U.sortable&&w.sort((ee,re)=>{const ne=Wo(U.values[ee],U.values[re],U.format);return c==="desc"?-ne:ne})}const k=w.length,A=Math.max(1,Math.floor(P(e.perPage,20))),S=Math.max(1,Math.ceil(k/A)),$=Math.max(1,Math.floor(P(e.page,1))),C=Math.min($,S),M=w.slice((C-1)*A,C*A),L=u("div",{class:"rui-data-grid","data-density":g,"data-striped":y?"true":"false","data-sticky-header":b?"true":"false","data-sticky-first":h?"true":"false"}),z=t.argMeta?.[3]?.stateRef,H=t.argMeta?.[4]?.stateRef,F=t.argMeta?.[6]?.stateRef,V=T(e.toolbar);if(d.length>0&&V.length>0){const U=u("div",{class:"rui-data-grid-bulk"});U.append(u("span",{class:"rui-data-grid-bulk-count"},[`${d.length} selected`]));const ee=u("div",{class:"rui-data-grid-bulk-tools"});for(const re of V)ee.append(r.renderNode(re));U.append(ee),L.append(U)}if(I(e.exportable)){const U=u("div",{class:"rui-data-grid-toolbar"}),ee=u("button",{type:"button",class:"rui-data-grid-export"}),re=j("download",{className:"rui-data-grid-export-icon"});re&&ee.append(re),ee.append(u("span",{},["Export CSV"])),ee.onclick=()=>{const ne=bg(n,w);vg(ne,m(e.exportFilename,"data.csv")||"data.csv")},U.append(ee),L.append(U)}const _=u("div",{class:"rui-data-grid-scroll"}),te=u("table",{class:"rui-data-grid-table"}),ke=m(e.caption);ke&&te.append(u("caption",{class:"rui-data-grid-caption"},[ke]));const De=u("thead"),Jt=u("tr");if(f){const U=u("th",{class:"rui-data-grid-cell-select",scope:"col"}),ee=M.length>0&&M.every(ne=>p.has(o(ne))),re=u("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select all rows on this page",checked:ee?"":null});H&&(re.onclick=ne=>{const de=ne.currentTarget,se=new Set(d);for(const ae of M){const oe=o(ae);de.checked?se.add(oe):se.delete(oe)}r.setState(H,Array.from(se))}),U.append(re),Jt.append(U)}if(n.forEach((U,ee)=>{const re=u("th",{scope:"col","data-align":U.align||null,"data-sortable":U.sortable?"true":null,"data-active":U.sortable&&U.key===l?"true":null,"data-first":ee===0?"true":null});if(U.sortable&&z){const ne=u("button",{type:"button",class:"rui-data-grid-sort"});ne.append(u("span",{},[U.header]));const de=U.key===l?c==="asc"?"arrow-up-short-wide":"arrow-down-wide-short":"sort",se=j(de,{className:"rui-data-grid-sort-icon"});se&&ne.append(se),ne.onclick=()=>{const ae=U.key===l&&c==="asc"?"desc":"asc";r.setState(z,{key:U.key,direction:ae})},re.append(ne)}else re.append(document.createTextNode(U.header));Jt.append(re)}),De.append(Jt),n.some(U=>U.filterable)){const U=u("tr",{class:"rui-data-grid-filter-row"});f&&U.append(u("td",{class:"rui-data-grid-cell-select"})),n.forEach(ee=>{const re=u("td");if(ee.filterable){const ne=u("input",{type:"search",class:"rui-data-grid-filter",placeholder:`Filter ${ee.header}`,value:x[ee.key]??""});ne.oninput=de=>{const se=de.currentTarget,ae={...v.get(),[ee.key]:se.value};v.set(ae);const oe=se.closest("table")?.querySelector("tbody");M0(oe)},re.append(ne)}U.append(re)}),De.append(U)}te.append(De);const ft=u("tbody");te.append(ft);const _a=U=>{if(ft.replaceChildren(),U.length===0){const ee=u("tr"),re=(f?1:0)+Math.max(n.length,1);ee.append(u("td",{colspan:String(re),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),ft.append(ee);return}for(const ee of U){const re=o(ee),ne=p.has(re),de=u("tr",{"data-selected":ne?"true":null});if(f){const se=u("td",{class:"rui-data-grid-cell-select"}),ae=u("input",{type:"checkbox",class:"rui-data-grid-checkbox","aria-label":"Select row",checked:ne?"":null});H&&(ae.onclick=oe=>{oe.stopPropagation();const Re=oe.currentTarget,Ee=new Set(d);Re.checked?Ee.add(re):Ee.delete(re),r.setState(H,Array.from(Ee))}),se.append(ae),de.append(se)}n.forEach((se,ae)=>{const oe=u("td",{"data-format":se.format,"data-align":se.align||null,"data-first":ae===0?"true":null});ln(oe,se,se.values[ee],ee,r,jt),de.append(oe)}),typeof e.onRowClick=="function"&&(de.setAttribute("data-clickable","true"),de.onclick=se=>{se.target?.closest("input,button,a,label,select,textarea")||r.invoke(e.onRowClick,ee)}),ft.append(de)}},M0=U=>{const ee=U??ft,re=v.get(),ne=[];for(let ae=0;ae<a;ae+=1){let oe=!0;for(const Re of n){if(!Re.filterable)continue;const Ee=(re[Re.key]??"").trim().toLowerCase();if(!Ee)continue;const Qt=Re.values[ae];if(!jt(Qt,Re.format).toLowerCase().includes(Ee)){oe=!1;break}}oe&&ne.push(ae)}if(l){const ae=n.find(oe=>oe.key===l);ae&&ae.sortable&&ne.sort((oe,Re)=>{const Ee=Wo(ae.values[oe],ae.values[Re],ae.format);return c==="desc"?-Ee:Ee})}const de=ne.slice((C-1)*A,C*A);(ae=>{ae.replaceChildren();for(const oe of de){const Re=o(oe),Ee=p.has(Re),Qt=u("tr",{"data-selected":Ee?"true":null});if(f){const gt=u("td",{class:"rui-data-grid-cell-select"}),Ua=u("input",{type:"checkbox",class:"rui-data-grid-checkbox",checked:Ee?"":null});gt.append(Ua),Qt.append(gt)}n.forEach((gt,Ua)=>{const uc=u("td",{"data-format":gt.format,"data-align":gt.align||null,"data-first":Ua===0?"true":null});ln(uc,gt,gt.values[oe],oe,r,jt),Qt.append(uc)}),ae.append(Qt)}if(de.length===0){const oe=u("tr"),Re=(f?1:0)+Math.max(n.length,1);oe.append(u("td",{colspan:String(Re),class:"rui-data-grid-empty"},[m(e.emptyLabel,"No results")])),ae.append(oe)}})(ee)};if(_a(M),_.append(te),L.append(_),k>A){const U=u("div",{class:"rui-data-grid-footer"}),ee=k===0?0:(C-1)*A+1,re=Math.min(k,C*A);U.append(u("span",{class:"rui-data-grid-footer-summary"},[k===0?"No results":`Showing ${ee}–${re} of ${k}`]));const ne=u("div",{class:"rui-data-grid-footer-buttons"}),de=u("button",{type:"button",class:"rui-data-grid-page-button",disabled:C<=1?"":null},["‹ Prev"]),se=u("button",{type:"button",class:"rui-data-grid-page-button",disabled:C>=S?"":null},["Next ›"]);F&&(de.onclick=()=>{C<=1||r.setState(F,C-1)},se.onclick=()=>{C>=S||r.setState(F,C+1)}),ne.append(de),ne.append(u("span",{class:"rui-data-grid-page-current"},[`${C} / ${S}`])),ne.append(se),U.append(ne),L.append(U)}return L}};function xg(t){const e=[];for(const r of T(t)){if(!r||typeof r!="object")continue;const n=r,a=m(n.date);a&&e.push({date:a,title:m(n.title),tone:m(n.tone,"primary"),time:m(n.time)})}return e}function Ko(t,e){const r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=(r.getDay()-e+7)%7;return r.setDate(r.getDate()-a),r}function Yo(t){const e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${n}`}const wg={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 n=m(e.view,"month"),a=xg(e.events),i=m(e.value),o=m(e.month,i),s=new Date;let l=new Date(NaN);if(o){const A=/^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(o);if(A)l=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())||(l=S)}}Number.isNaN(l.getTime())&&(l=s);const c=(P(e.firstDay,1)%7+7)%7,d=i&&/^\d{4}-\d{2}-\d{2}$/.test(i)?i:"",p=new Map;for(const A of a){const S=A.date.slice(0,10),$=p.get(S)??[];$.push(A),p.set(S,$)}const f=t.argMeta?.[0]?.stateRef,b=u("div",{class:"rui-calendar","data-view":n}),h=u("div",{class:"rui-calendar-header"}),g=l.toLocaleDateString(void 0,{month:"long",year:"numeric"});h.append(u("div",{class:"rui-calendar-title"},[g])),b.append(h);const y=u("div",{class:"rui-calendar-weekrow"}),v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(let A=0;A<7;A+=1){const S=v[(c+A)%7]??"";y.append(u("div",{class:"rui-calendar-weekday"},[S]))}b.append(y);const x=[];if(n==="week"){const A=d?new Date(d):l,S=Ko(A,c);for(let $=0;$<7;$+=1){const C=new Date(S);C.setDate(S.getDate()+$),x.push({date:C,inMonth:C.getMonth()===l.getMonth()})}}else{const A=new Date(l.getFullYear(),l.getMonth(),1),S=new Date(l.getFullYear(),l.getMonth()+1,0),$=Ko(A,c),C=Math.ceil((S.getDate()+(A.getDay()-c+7)%7)/7)*7;for(let M=0;M<C;M+=1){const L=new Date($);L.setDate($.getDate()+M),x.push({date:L,inMonth:L.getMonth()===l.getMonth()})}}const w=u("div",{class:"rui-calendar-grid","data-view":n}),k=Yo(s);for(const A of x){const S=Yo(A.date),$=S===k,C=S===d,M=p.get(S)??[],L=u("button",{type:"button",class:"rui-calendar-day","data-in-month":A.inMonth?"true":"false","data-today":$?"true":"false","data-selected":C?"true":"false","aria-label":A.date.toDateString()});if(L.append(u("span",{class:"rui-calendar-daynumber"},[String(A.date.getDate())])),M.length>0){const z=u("div",{class:"rui-calendar-day-events"}),H=M.slice(0,3);for(const F of H){const V=u("span",{class:"rui-calendar-event","data-tone":F.tone??"primary",title:F.time?`${F.time} — ${F.title}`:F.title},[F.title]);z.append(V)}M.length>3&&z.append(u("span",{class:"rui-calendar-event-more"},[`+${M.length-3} more`])),L.append(z)}L.onclick=()=>{f&&r.setState(f,S),r.invoke(e.onSelect,S)},w.append(L)}return b.append(w),b}};function kg(t){const e=[];for(const r of T(t)){if(!r||typeof r!="object")continue;const n=r;e.push({title:m(n.title),description:m(n.description),actor:m(n.actor),avatarSrc:m(n.avatarSrc),time:m(n.time),icon:m(n.icon),tone:m(n.tone,"default"),meta:m(n.meta)})}return e}function Sg(t,e,r){const n=u("ol",{class:t,"data-variant":r});for(const a of e){const i=u("li",{class:`${t}-item`,"data-tone":a.tone}),o=u("span",{class:`${t}-marker`}),s=j(a.icon,{className:`${t}-icon`});s&&o.append(s),i.append(o);const l=u("div",{class:`${t}-body`}),c=u("div",{class:`${t}-head`});a.actor&&c.append(u("span",{class:`${t}-actor`},[a.actor])),c.append(u("span",{class:`${t}-title`},[a.title])),a.time&&c.append(u("span",{class:`${t}-time`},[a.time])),l.append(c),a.description&&l.append(u("p",{class:`${t}-description`},[a.description])),a.meta&&l.append(u("span",{class:`${t}-meta`},[a.meta])),i.append(l),n.append(i)}return n}const $g={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 Sg(r==="audit"?"rui-audit-trail":"rui-activity-log",kg(e.items),r)}},Cg={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 n=T(e.columns).map(f=>m(f)),a=T(e.rows).map(f=>{const b=f??{};return{label:m(b.label),values:T(b.values),hint:m(b.hint),group:m(b.group)}}),i=Math.floor(P(e.highlightColumn,-1)),o=u("div",{class:"rui-comparison-table"}),s=u("table"),l=u("thead"),c=u("tr");c.append(u("th",{scope:"col",class:"rui-comparison-table-feature"},["Feature"])),n.forEach((f,b)=>{c.append(u("th",{scope:"col","data-highlight":b===i?"true":null},[f]))}),l.append(c),s.append(l);const d=u("tbody");let p="";for(const f of a){if(f.group&&f.group!==p){p=f.group;const g=u("tr",{class:"rui-comparison-table-group"});g.append(u("td",{colspan:String(n.length+1)},[f.group])),d.append(g)}const b=u("tr"),h=u("td",{class:"rui-comparison-table-feature"});h.append(u("div",{class:"rui-comparison-table-feature-label"},[f.label])),f.hint&&h.append(u("div",{class:"rui-comparison-table-feature-hint"},[f.hint])),b.append(h);for(let g=0;g<n.length;g+=1){const y=f.values[g],v=u("td",{"data-highlight":g===i?"true":null});if(y===!0){const x=j("circle-check",{className:"rui-comparison-yes"});x?v.append(x):v.textContent="✓"}else y===!1||y===null||y===void 0?v.append(u("span",{class:"rui-comparison-no"},["—"])):y&&typeof y=="object"&&y.__kind==="Component"?v.append(r.renderNode(y)):v.textContent=m(y);b.append(v)}d.append(b)}return s.append(d),o.append(s),o}},Ag={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 n=u("div",{class:"rui-infinite-list"}),a=u("div",{class:"rui-infinite-list-body"});for(const s of T(e.items))a.append(r.renderNode(s));n.append(a);const i=e.hasMore===void 0?!0:I(e.hasMore),o=I(e.loading);if(i){const s=u("div",{class:"rui-infinite-list-sentinel"});if(o){const l=j("spinner",{className:"rui-infinite-list-spin"});l&&s.append(l),s.append(u("span",{},[m(e.loaderLabel,"Loading…")]))}else if(typeof e.onLoadMore=="function"){const l=u("button",{type:"button",class:"rui-infinite-list-load-more"},["Load more"]);l.onclick=()=>r.invoke(e.onLoadMore),s.append(l)}if(n.append(s),!o&&typeof e.onLoadMore=="function"&&typeof IntersectionObserver<"u"){const l=e.onLoadMore,c=new IntersectionObserver(d=>{for(const p of d)if(p.isIntersecting){r.invoke(l);break}});c.observe(s),r.registerDisposer(()=>c.disconnect(),"infinite-observer")}}return n}},Tg=/^(https?:|blob:|data:(audio|video)\/)/i;function kr(t){const e=m(t).trim();return e?e.startsWith("/")||e.startsWith(".")?e:e.startsWith("//")?"":Tg.test(e)?e:"":""}const Mg={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=u("figure",{class:"rui-video-player"}),n=Fn(m(e.ratio,"16:9")),a=u("div",{class:"rui-video-player-frame",style:`aspect-ratio:${n};`}),i=e.controls===void 0?!0:I(e.controls),o=u("video",{class:"rui-video-player-video",controls:i?"":null,autoplay:I(e.autoplay)?"":null,loop:I(e.loop)?"":null,muted:I(e.muted)?"":null,poster:ie(e.poster)||null,playsinline:"",preload:"metadata"}),s=T(e.sources);if(s.length>0)for(const c of s){if(!c||typeof c!="object")continue;const d=c,p=kr(d.src);p&&o.append(u("source",{src:p,type:m(d.type)||null}))}else{const c=kr(e.src);c&&o.setAttribute("src",c)}a.append(o),r.append(a);const l=m(e.caption);return l&&r.append(u("figcaption",{class:"rui-video-player-caption"},[l])),r}},Ng={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=u("div",{class:"rui-audio-player"}),n=u("div",{class:"rui-audio-player-meta"}),a=j(m(e.icon,"music"),{className:"rui-audio-player-icon"});a&&n.append(a);const i=u("div",{class:"rui-audio-player-text"}),o=m(e.title);o&&i.append(u("div",{class:"rui-audio-player-title"},[o]));const s=m(e.artist);s&&i.append(u("div",{class:"rui-audio-player-artist"},[s])),n.append(i),r.append(n);const l=e.controls===void 0?!0:I(e.controls),c=u("audio",{class:"rui-audio-player-audio",controls:l?"":null,autoplay:I(e.autoplay)?"":null,loop:I(e.loop)?"":null,preload:"metadata"}),d=T(e.sources);if(d.length>0)for(const p of d){if(!p||typeof p!="object")continue;const f=p,b=kr(f.src);b&&c.append(u("source",{src:b,type:m(f.type)||null}))}else{const p=kr(e.src);p&&c.setAttribute("src",p)}return r.append(c),r}};function Ig(t,e){if(t==null)return null;if(typeof t=="object"&&t.__kind==="Component")return e.renderNode(t);if(typeof t=="string"){const r=ie(t);return r?u("img",{src:r,alt:"",loading:"lazy",class:"rui-carousel-image"}):null}if(typeof t=="object"){const r=t,n=ie(r.src);if(n){const a=u("figure",{class:"rui-carousel-figure"});a.append(u("img",{src:n,alt:m(r.alt??r.caption??r.title),loading:"lazy",class:"rui-carousel-image"}));const i=m(r.caption??r.title);return i&&a.append(u("figcaption",{class:"rui-carousel-caption"},[i])),a}}return e.renderNode(t)}const Pg={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 n=T(e.items),a=n.length,i=Math.max(0,Math.min(Math.max(a-1,0),Math.floor(P(e.activeIndex,0)))),o=r.useInstanceState("active",i);let s=o.get();s>=a&&(s=0,o.set(s));const l=e.showDots===void 0?!0:I(e.showDots),c=e.showArrows===void 0?!0:I(e.showArrows),d=Fn(m(e.ratio,"16:9")),p=u("div",{class:"rui-carousel"}),f=u("div",{class:"rui-carousel-frame",style:`aspect-ratio:${d};`}),b=u("div",{class:"rui-carousel-track",style:`transform:translateX(${s*-100}%);`});n.forEach(g=>{const y=u("div",{class:"rui-carousel-slide"}),v=Ig(g,r);v&&y.append(v),b.append(y)}),f.append(b);const h=(g,y)=>{const v=(y%a+a)%a;o.set(v);const x=g.closest(".rui-carousel"),w=x?.querySelector(".rui-carousel-track");w&&(w.style.transform=`translateX(${v*-100}%)`),x?.querySelectorAll(".rui-carousel-dot").forEach((k,A)=>{k.setAttribute("data-active",A===v?"true":"false")})};if(c&&a>1){const g=u("button",{type:"button",class:"rui-carousel-arrow","data-direction":"prev","aria-label":"Previous slide"}),y=j("chevron-left");y&&g.append(y);const v=u("button",{type:"button",class:"rui-carousel-arrow","data-direction":"next","aria-label":"Next slide"}),x=j("chevron-right");x&&v.append(x),g.onclick=w=>h(w.currentTarget,o.get()-1),v.onclick=w=>h(w.currentTarget,o.get()+1),f.append(g,v)}if(p.append(f),l&&a>1){const g=u("div",{class:"rui-carousel-dots"});n.forEach((y,v)=>{const x=u("button",{type:"button",class:"rui-carousel-dot","data-active":v===s?"true":"false","aria-label":`Go to slide ${v+1}`});x.onclick=w=>h(w.currentTarget,v),g.append(x)}),p.append(g)}return p}},Rg={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 n=T(e.items),a=Math.max(1,Math.min(6,Number(e.columns??"auto"))),i=Fn(m(e.ratio,"1:1")),o=u("div",{class:"rui-gallery","data-columns":a>0?String(a):null});return n.forEach((s,l)=>{const{src:c,alt:d,caption:p}=Xo(s),f=ie(c),b=typeof e.onSelect=="function",h=u(b?"button":"figure",{type:b?"button":null,class:"rui-gallery-tile",style:`aspect-ratio:${i};`,"data-index":String(l)});if(f)h.append(u("img",{src:f,alt:d,loading:"lazy"}));else{const g=j("image",{className:"rui-gallery-placeholder"});g&&h.append(g)}p&&h.append(u("span",{class:"rui-gallery-caption"},[p])),b&&(h.onclick=()=>r.invoke(e.onSelect,l,s)),o.append(h)}),o}};function Xo(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 Eg={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 n=T(e.items).map($=>Xo($)).filter($=>ie($.src)!==""),a=n.length,i=t.argMeta?.[2]?.stateRef,o=t.argMeta?.[1]?.stateRef,s=r.useInstanceState("open",!1),l=r.useInstanceState("index",0),c=o?I(e.open):s.get(),d=i?Math.floor(P(e.index,0)):l.get(),p=a===0?0:(d%a+a)%a,f=$=>{o?r.setState(o,$):s.set($)},b=$=>{i?r.setState(i,$):l.set($)},h=()=>f(!1),g=$=>{a!==0&&b(((p+$)%a+a)%a)},y=u("div",{class:"rui-lightbox-root"});if(!o&&a>0){const $=n[p],C=u("button",{type:"button",class:"rui-lightbox-thumb","aria-label":$?.alt||"Open image"});if($){const M=ie($.src);M&&C.append(u("img",{src:M,alt:$.alt,loading:"lazy"}))}C.onclick=M=>{M.stopPropagation(),f(!0)},y.append(C)}const v=u("div",{class:"rui-lightbox-overlay","data-open":c?"true":"false"});if(y.append(v),!c||a===0)return y;const x=n[p];if(!x)return y;const w=ie(x.src);v.onclick=$=>{$.target===v&&h()};const k=u("div",{class:"rui-lightbox",role:"dialog","aria-modal":"true"}),A=u("button",{type:"button",class:"rui-lightbox-close","aria-label":"Close lightbox"},["×"]);if(A.onclick=h,k.append(A),a>1){const $=u("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"prev","aria-label":"Previous image"}),C=j("chevron-left");C&&$.append(C),$.onclick=()=>g(-1);const M=u("button",{type:"button",class:"rui-lightbox-arrow","data-direction":"next","aria-label":"Next image"}),L=j("chevron-right");L&&M.append(L),M.onclick=()=>g(1),k.append($,M)}const S=u("div",{class:"rui-lightbox-image-wrap"});return w&&S.append(u("img",{src:w,alt:x.alt})),k.append(S),x.caption&&k.append(u("div",{class:"rui-lightbox-caption"},[x.caption])),a>1&&k.append(u("div",{class:"rui-lightbox-counter"},[`${p+1} / ${a}`])),v.append(k),y}};function Lg(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){const e=t,r=P(e.lat??e.latitude,NaN),n=P(e.lng??e.longitude,NaN);if(Number.isFinite(r)&&Number.isFinite(n))return{lat:r,lng:n}}if(Array.isArray(t)&&t.length>=2){const e=P(t[0],NaN),r=P(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 zg={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=u("figure",{class:"rui-map"}),n=Z(e.height,"320px"),a=u("div",{class:"rui-map-frame",style:`height:${n};`}),i=P(e.lat,NaN),o=P(e.lng,NaN),s=Number.isFinite(i)&&Number.isFinite(o)?{lat:i,lng:o}:null;if(!s){a.append(u("div",{class:"rui-map-empty"},["Pass lat & lng (numbers) to render the map."])),r.append(a);const g=m(e.caption);return g&&r.append(u("figcaption",{class:"rui-map-caption"},[g])),r}const l=Math.max(1,Math.min(18,Math.floor(P(e.zoom,13)))),c=1/Math.pow(2,l-8),p=`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=u("iframe",{class:"rui-map-iframe",src:p,loading:"lazy",title:"Map view",referrerpolicy:"no-referrer"});a.append(f),r.append(a);const b=T(e.markers).map(g=>{const y=Lg(g),v=g&&typeof g=="object"?m(g.label):"";return y?{...y,label:v}:null}).filter(g=>g!==null);if(b.length>0){const g=u("ul",{class:"rui-map-markers"});for(const y of b){const v=u("li",{class:"rui-map-marker"}),x=j("location-dot",{className:"rui-map-marker-icon"});x&&v.append(x),v.append(u("span",{class:"rui-map-marker-label"},[y.label||`${y.lat.toFixed(4)}, ${y.lng.toFixed(4)}`])),g.append(v)}r.append(g)}const h=m(e.caption);return h&&r.append(u("figcaption",{class:"rui-map-caption"},[h])),r}};function Fn(t){if(t.includes(":")){const[r,n]=t.split(":"),a=Number(r),i=Number(n);if(Number.isFinite(a)&&Number.isFinite(i)&&i>0)return`${a} / ${i}`}const e=Number(t);return Number.isFinite(e)&&e>0?`${e} / 1`:"16 / 9"}const jg=[{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"}],Dg={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 n=m(e.id),a=m(e.placeholder,"Start writing…"),i=I(e.disabled),o=u("div",{class:"rui-rich-text","data-disabled":i?"true":"false"}),s=u("div",{class:"rui-rich-text-toolbar",role:"toolbar"});for(const b of jg){const h=u("button",{type:"button",class:"rui-rich-text-tool","data-command":b.command,"data-block":b.block??null,"aria-label":b.label,title:b.label,disabled:i?"":null}),g=j(b.icon);g&&h.append(g),h.onmousedown=y=>y.preventDefault(),h.onclick=y=>{const x=y.currentTarget.closest(".rui-rich-text")?.querySelector(".rui-rich-text-content");if(x){x.focus();try{if(b.command==="createLink"){const w=window.prompt("URL");w&&document.execCommand("createLink",!1,w)}else b.command==="formatBlock"&&b.block?document.execCommand("formatBlock",!1,b.block):document.execCommand(b.command,!1)}catch{}x.dispatchEvent(new Event("input",{bubbles:!0}))}},s.append(h)}o.append(s);const l=m(e.value)||"",c=b=>b.replace(/<br\s*\/?>(?=\s*$)/gi,"").replace(/<[^>]+>/g,"").replace(/ /g," ").trim().length===0,d=u("div",{class:"rui-rich-text-content",id:n,contenteditable:i?"false":"true",role:"textbox","aria-multiline":"true","aria-placeholder":a,"data-placeholder":a,"data-empty":c(l)?"true":"false",style:`min-height:${m(e.minHeight,"160px")};`,html:l}),p=b=>{b.setAttribute("data-empty",c(b.innerHTML)?"true":"false")},f=t.argMeta?.[1]?.stateRef;return f&&!i?r.bindState(d,f,{event:"input",getValue:b=>{const h=b;return p(h),h.innerHTML}}):d.oninput=b=>{const h=b.currentTarget??b.target;p(h)},d.onblur=b=>{const h=b.currentTarget??b.target;p(h)},pe(d,e.onChange,r,{event:"input",getValue:b=>b.innerHTML}),o.append(d),o}},Og={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 n=m(e.id),a=m(e.value),i=m(e.language,"text"),o=e.showGutter===void 0?!0:I(e.showGutter),s=Math.max(1,Math.min(8,Math.floor(P(e.tabSize,2)))),l=I(e.readonly),c=m(e.minHeight,"200px"),d=u("div",{class:"rui-code-editor","data-language":i,"data-gutter":o?"true":"false"}),p=u("div",{class:"rui-code-editor-head"});p.append(u("span",{class:"rui-code-editor-language"},[i])),d.append(p);const f=u("div",{class:"rui-code-editor-body",style:`min-height:${c};`}),b=u("div",{class:"rui-code-editor-gutter","aria-hidden":"true"});o&&((v=>{b.replaceChildren();const x=v.split(/\r?\n/),w=Math.max(1,x.length);for(let k=1;k<=w;k+=1)b.append(u("span",{class:"rui-code-editor-line"},[String(k)]))})(a),f.append(b));const g=u("textarea",{class:"rui-code-editor-textarea",id:n,name:n,spellcheck:"false",autocorrect:"off",autocapitalize:"off",placeholder:m(e.placeholder),readonly:l?"":null,style:`tab-size:${s};-moz-tab-size:${s};`});g.value=a,g.oninput=v=>{const x=v.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(u("span",{class:"rui-code-editor-line"},[String($)]))},g.onkeydown=v=>{const x=v;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 y=t.argMeta?.[1]?.stateRef;return y&&!l&&r.bindState(g,y,{event:"input",getValue:v=>v.value}),l||pe(g,e.onChange,r,{event:"input",getValue:v=>v.value}),f.append(g),d.append(f),d}};function Bg(t){if(!t)return null;if(typeof t=="object"){const e=t;if(e.__kind==="Component"&&e.name==="MenuItem"&&Array.isArray(e.args)){const n=e.args;return{label:m(n[0]),action:n[1],icon:m(n[2]),shortcut:m(n[3]),variant:m(n[4],"default"),disabled:I(n[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:I(r.disabled),separator:!1}}return null}const Fg={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 n=u("div",{class:"rui-context-menu"}),a=u("div",{class:"rui-context-menu-target"});a.append(r.renderNode(e.target)),n.append(a);const i=u("div",{class:"rui-context-menu-pop",role:"menu","aria-label":m(e.label)||null,"data-open":"false"}),o=T(e.items).map(Bg).filter(c=>c!==null);for(const c of o){if(c.separator){i.append(u("div",{class:"rui-menu-separator",role:"separator"}));continue}const d=u("button",{type:"button",class:"rui-menu-item",role:"menuitem","data-variant":c.variant,disabled:c.disabled?"":null}),p=j(c.icon,{className:"rui-menu-item-icon"});p&&d.append(p),d.append(u("span",{class:"rui-menu-item-label"},[c.label])),c.shortcut&&d.append(u("span",{class:"rui-menu-item-shortcut"},[c.shortcut])),c.disabled||(d.onclick=()=>{r.invoke(c.action),i.setAttribute("data-open","false")}),i.append(d)}n.append(i);const s=()=>i.setAttribute("data-open","false"),l=(c,d)=>{const p=a.isConnected?a.closest(".rui-context-menu"):null,f=p?.querySelector(".rui-context-menu-pop")??i,b=p?.getBoundingClientRect(),h=b?c-b.left:c,g=b?d-b.top:d;f.style.left=`${h}px`,f.style.top=`${g}px`,f.setAttribute("data-open","true");const y=v=>{v.target&&f.contains(v.target)||(f.setAttribute("data-open","false"),document.removeEventListener("click",y,!0),document.removeEventListener("contextmenu",y,!0))};setTimeout(()=>{document.addEventListener("click",y,!0),document.addEventListener("contextmenu",y,!0)},0)};return a.oncontextmenu=c=>{c.preventDefault(),l(c.clientX,c.clientY)},a.onkeydown=c=>{const d=c;if(d.key==="ContextMenu"||d.shiftKey&&d.key==="F10"){d.preventDefault();const f=d.currentTarget.getBoundingClientRect();l(f.left,f.top+f.height)}d.key==="Escape"&&s()},n}},_g=["#0f172a","#334155","#64748b","#94a3b8","#ef4444","#f59e0b","#facc15","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6"];function Dt(t){const e=t.trim();if(!e)return"";let r=e.startsWith("#")?e.slice(1):e;return r.length===3&&(r=r.split("").map(n=>n+n).join("")),/^[0-9a-fA-F]{6,8}$/.test(r)?`#${r.toLowerCase().slice(0,6)}`:""}const Ug={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 n=m(e.id),a=Dt(m(e.value))||m(e.value,"#000000"),i=I(e.disabled),o=u("div",{class:"rui-color-picker","data-disabled":i?"true":"false"}),s=m(e.label);s&&o.append(u("label",{class:"rui-color-picker-label",for:n},[s]));const l=u("div",{class:"rui-color-picker-row"}),c=u("input",{type:"color",class:"rui-color-picker-color",id:n,name:n,value:Dt(a)||"#000000",disabled:i?"":null}),d=u("input",{type:"text",class:"rui-color-picker-hex",value:a,placeholder:"#000000",disabled:i?"":null,autocomplete:"off"}),p=u("div",{class:"rui-color-picker-swatches"}),f=T(e.swatches).map(g=>m(g)).filter(Boolean),b=f.length>0?f:_g;for(const g of b){const y=Dt(g)||g,v=u("button",{type:"button",class:"rui-color-picker-swatch",style:`background:${y}`,"aria-label":y,title:y,"data-active":y.toLowerCase()===a.toLowerCase()?"true":"false"});v.onclick=()=>{c.value=Dt(y)||c.value,d.value=y,c.dispatchEvent(new Event("input",{bubbles:!0}))},p.append(v)}const h=t.argMeta?.[1]?.stateRef;return h&&!i&&(r.bindState(c,h,{event:"input",getValue:g=>g.value}),c.addEventListener("input",()=>{d.value=c.value}),d.oninput=()=>{const g=Dt(d.value);g&&(c.value=g,c.dispatchEvent(new Event("input",{bubbles:!0})))}),i||pe(c,e.onChange,r,{event:"input",getValue:g=>g.value}),l.append(c,d),o.append(l,p),o}},_n=["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)"],ut=t=>_n[t%_n.length]??_n[0];function Hg(t){return t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>P(o));return{name:a,values:i}})}function Sr(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 he(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const[a,i]of Object.entries(e))n.setAttribute(a,i);if(r)for(const a of r)n.append(typeof a=="string"?document.createTextNode(a):a);return n}function Jo(t){const e=u("div",{class:"rui-chart-legend"});return t.forEach((r,n)=>{const a=u("span",{class:"rui-chart-legend-item"});a.append(u("span",{class:"rui-chart-legend-swatch",style:`background:${ut(n)}`})),a.append(u("span",{},[r.name])),e.append(a)}),e}const qg={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=P(e.min,0),n=Math.max(r+1,P(e.max,100)),a=Math.max(r,Math.min(n,P(e.value,r))),i=(a-r)/(n-r),o=m(e.tone,"primary"),s=m(e.size,"md"),l=s==="lg"?220:s==="sm"?140:180,c=l/2,d=s==="lg"?18:s==="sm"?10:14,p=c-d,f=u("div",{class:"rui-gauge","data-tone":o,"data-size":s}),b=Sr(l,c+d+4),h=c,g=c,y=h-p,v=g,x=h+p,w=g;if(b.append(he("path",{d:`M${y},${v} A${p},${p} 0 0 1 ${x},${w}`,fill:"none",stroke:"var(--rui-color-border, #e2e8f0)","stroke-width":String(d),"stroke-linecap":"round"})),i>0){const $=Math.PI*i,C=h-p*Math.cos($),M=g-p*Math.sin($);b.append(he("path",{d:`M${y},${v} A${p},${p} 0 0 1 ${C.toFixed(2)},${M.toFixed(2)}`,fill:"none",stroke:`var(--rui-color-${o}, ${ut(0)})`,"stroke-width":String(d),"stroke-linecap":"round",class:"rui-gauge-arc"}))}f.append(b);const k=Vg(a,r,n),A=m(e.label)||k;f.append(u("div",{class:"rui-gauge-value"},[A]));const S=m(e.caption);return S&&f.append(u("div",{class:"rui-gauge-caption"},[S])),f}};function Vg(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 Wg={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=T(e.xLabels).map(d=>m(d)),n=T(e.yLabels).map(d=>m(d)),a=T(e.values).map(d=>T(d).map(p=>P(p,0))),i=m(e.tone,"primary"),o=Math.max(1,...a.flat()),s=u("div",{class:"rui-heatmap","data-tone":i});m(e.title)&&s.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const l=u("div",{class:"rui-heatmap-table"}),c=u("div",{class:"rui-heatmap-row rui-heatmap-row-header"});c.append(u("div",{class:"rui-heatmap-cell rui-heatmap-corner"}));for(const d of r)c.append(u("div",{class:"rui-heatmap-cell rui-heatmap-xlabel"},[d]));return l.append(c),a.forEach((d,p)=>{const f=u("div",{class:"rui-heatmap-row"});f.append(u("div",{class:"rui-heatmap-cell rui-heatmap-ylabel"},[n[p]??String(p+1)])),d.forEach((b,h)=>{const g=o>0?b/o:0,y=u("div",{class:"rui-heatmap-cell rui-heatmap-value",style:`background:color-mix(in srgb, var(--rui-color-${i}, ${ut(0)}) ${Math.round(g*90+5)}%, transparent);`,title:`${r[h]??h+1} · ${n[p]??p+1}: ${b}`});y.append(u("span",{},[String(b)])),f.append(y)}),l.append(f)}),s.append(l),s}},Gg={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=T(e.axes).map(b=>m(b)),n=Hg(T(e.series)),a=Math.max(r.length,3),i=u("div",{class:"rui-chart rui-radar-chart"});m(e.title)&&i.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const o=Math.max(1,P(e.max,n.flatMap(b=>b.values).reduce((b,h)=>Math.max(b,h),1))),s=280,l=s/2,c=s/2,d=s/2-24,p=Sr(s,s),f=4;for(let b=1;b<=f;b+=1){const h=d/f*b,g=[];for(let y=0;y<a;y+=1){const v=Math.PI*2*y/a-Math.PI/2;g.push(`${(l+h*Math.cos(v)).toFixed(1)},${(c+h*Math.sin(v)).toFixed(1)}`)}p.append(he("polygon",{points:g.join(" "),fill:"none",stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}))}for(let b=0;b<a;b+=1){const h=Math.PI*2*b/a-Math.PI/2,g=l+d*Math.cos(h),y=c+d*Math.sin(h);p.append(he("line",{x1:String(l),y1:String(c),x2:g.toFixed(1),y2:y.toFixed(1),stroke:"var(--rui-color-border-subtle, rgba(0,0,0,0.08))","stroke-width":"1"}));const v=l+(d+16)*Math.cos(h),x=c+(d+16)*Math.sin(h);p.append(he("text",{x:v.toFixed(1),y:x.toFixed(1),"text-anchor":"middle","dominant-baseline":"middle",class:"rui-chart-label","font-size":"13","font-weight":"500"},[r[b]??""]))}return n.forEach((b,h)=>{const g=[];for(let y=0;y<a;y+=1){const v=b.values[y]??0,x=Math.max(0,Math.min(1,v/o)),w=Math.PI*2*y/a-Math.PI/2,k=l+d*x*Math.cos(w),A=c+d*x*Math.sin(w);g.push(`${k.toFixed(1)},${A.toFixed(1)}`)}p.append(he("polygon",{points:g.join(" "),fill:ut(h),"fill-opacity":"0.2",stroke:ut(h),"stroke-width":"2","stroke-linejoin":"round"}))}),i.append(p),n.length>0&&i.append(Jo(n)),i}};function Kg(t){return t.map((e,r)=>{const n=e,a=m(n.args?.[0],`Series ${r+1}`),i=T(n.args?.[1]).map(o=>{if(Array.isArray(o))return{x:P(o[0],0),y:P(o[1],0),label:m(o[2])};if(o&&typeof o=="object"){const s=o;return{x:P(s.x,0),y:P(s.y,0),label:m(s.label)}}return{x:0,y:0,label:""}});return{name:a,points:i}})}const Yg={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=Kg(T(e.series)),n=u("div",{class:"rui-chart rui-scatter-chart"});m(e.title)&&n.append(u("div",{class:"rui-chart-title"},[m(e.title)]));const a=640,i=280,o={left:50,right:16,top:16,bottom:40},s=a-o.left-o.right,l=i-o.top-o.bottom,c=r.flatMap(k=>k.points);if(c.length===0)return n.append(u("div",{class:"rui-chart-empty"},["No points"])),n;const d=c.map(k=>k.x),p=c.map(k=>k.y),f=Math.min(...d),b=Math.max(...d),h=Math.min(...p),g=Math.max(...p),y=b-f||1,v=g-h||1,x=Sr(a,i);if(Zo(x,o,s,l,g,h),x.append(he("line",{x1:String(o.left),y1:String(o.top+l),x2:String(o.left+s),y2:String(o.top+l),stroke:"var(--rui-color-border, #e2e8f0)"})),r.forEach((k,A)=>{k.points.forEach(S=>{const $=o.left+(S.x-f)/y*s,C=o.top+l-(S.y-h)/v*l,M=he("circle",{cx:$.toFixed(1),cy:C.toFixed(1),r:"7",fill:ut(A),"fill-opacity":"0.8",stroke:"#fff","stroke-width":"1.5"});M.append(he("title",{},[S.label||`${S.x}, ${S.y}`])),x.append(M)})}),m(e.xLabel)&&x.append(he("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 A=o.top+l/2;x.append(he("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"},[m(e.yLabel)]))}n.append(x);const w=r.map(k=>({name:k.name,values:k.points.map(A=>A.y)}));return w.length>0&&n.append(Jo(w)),n}},Xg={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 b=f??{};return{label:m(b.label),count:P(b.count,0)}});else{const f=T(e.values).map(b=>P(b,NaN)).filter(b=>Number.isFinite(b));if(f.length>0){const b=Math.max(2,Math.min(50,Math.floor(P(e.binCount,10)))),h=Math.min(...f),v=(Math.max(...f)-h||1)/b,x=new Array(b).fill(0);for(const w of f){let k=Math.floor((w-h)/v);k>=b&&(k=b-1),k<0&&(k=0),x[k]+=1}r=x.map((w,k)=>{const A=h+k*v,S=A+v;return{label:`${Qo(A)}–${Qo(S)}`,count:w}})}}const n=u("div",{class:"rui-chart rui-histogram"});if(m(e.title)&&n.append(u("div",{class:"rui-chart-title"},[m(e.title)])),r.length===0)return n.append(u("div",{class:"rui-chart-empty"},["No data"])),n;const a=640,i=240,o={left:40,right:12,top:16,bottom:50},s=a-o.left-o.right,l=i-o.top-o.bottom,c=Math.max(1,...r.map(f=>f.count)),d=s/r.length,p=Sr(a,i);return Zo(p,o,s,l,c),r.forEach((f,b)=>{const h=o.left+b*d+d*.1,g=d*.8,y=f.count/c*l,v=o.top+l-y,x=he("rect",{x:h.toFixed(1),y:v.toFixed(1),width:g.toFixed(1),height:y.toFixed(1),fill:ut(0),rx:"2"});x.append(he("title",{},[`${f.label}: ${f.count}`])),p.append(x),p.append(he("text",{x:(h+g/2).toFixed(1),y:String(o.top+l+22),"text-anchor":"middle",class:"rui-chart-label","font-size":"12"},[f.label]))}),n.append(p),n}};function Qo(t){return Number.isFinite(t)?Math.abs(t)>=1e3?Math.round(t).toLocaleString():Math.abs(t)>=10?t.toFixed(0):t.toFixed(1):"?"}function Zo(t,e,r,n,a,i=0){for(let s=0;s<=4;s+=1){const l=s/4,c=e.top+n-l*n;t.append(he("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(he("text",{x:String(e.left-8),y:String(c+5),"text-anchor":"end",class:"rui-chart-tick","font-size":"14"},[String(Math.round((i+(a-i)*l)*10)/10)]))}}const Jg=["numeric","alphanumeric"];function Qg(t,e,r,n,a,i,o){const s=u("div",{class:"rui-pin-input","data-disabled":a?"true":"false"}),l=[];for(let p=0;p<e;p+=1){const f=u("input",{class:"rui-pin-input-slot",id:p===0?t:null,maxlength:"1",autocomplete:"one-time-code",inputmode:r==="numeric"?"numeric":"text",type:i?"password":"text","aria-label":`Digit ${p+1}`,value:n.charAt(p)||"",disabled:a?"":null});l.push(f),s.append(f)}const c=p=>{const f=p.closest(".rui-pin-input");return f?Array.from(f.querySelectorAll(".rui-pin-input-slot")):l},d=p=>c(p).map(f=>f.value).join("").slice(0,e);return l.forEach((p,f)=>{p.oninput=b=>{const h=b.currentTarget,g=c(h);let y=h.value;if(r==="numeric"?y=y.replace(/\D/g,""):y=y.replace(/[^A-Za-z0-9]/g,""),y.length>1){const v=y.split("");v.slice(0,e-f).forEach((w,k)=>{const A=g[f+k];A&&(A.value=w)});const x=Math.min(f+v.length,e-1);g[x]?.focus()}else h.value=y,y&&f<e-1&&g[f+1]?.focus();o?.(d(h))},p.onkeydown=b=>{const h=b,g=h.currentTarget,y=c(g);if(h.key==="Backspace"&&!g.value&&f>0){h.preventDefault(),y[f-1]?.focus();const v=y[f-1];v&&(v.value=""),o?.(d(g))}else h.key==="ArrowLeft"&&f>0?(h.preventDefault(),y[f-1]?.focus()):h.key==="ArrowRight"&&f<e-1&&(h.preventDefault(),y[f+1]?.focus())}}),s}const Zg={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:Jg},{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 n=m(e.id),a=Math.max(1,Math.min(12,Math.floor(P(e.length,4)))),i=m(e.type,"numeric"),o=m(e.value),s=I(e.disabled),l=I(e.mask),c=t.argMeta?.[2]?.stateRef;return Qg(n,a,i,o,s,l,d=>{c&&r.setState(c,d),r.invoke(e.onChange,d)})}};function eh(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 th={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 n=m(e.id),a=r.useInstanceState("visible",!1),i=a.get(),o=I(e.disabled),s=u("div",{class:"rui-password-input","data-disabled":o?"true":"false"}),l=m(e.label);l&&s.append(u("label",{class:"rui-password-input-label",for:n},[l]));const c=u("div",{class:"rui-password-input-row"}),d=u("input",{type:i?"text":"password",class:"rui-password-input-field",id:n,name:n,autocomplete:"current-password",placeholder:m(e.placeholder),value:m(e.value),disabled:o?"":null}),p=u("button",{type:"button",class:"rui-password-input-toggle","aria-label":i?"Hide password":"Show password"}),f=j(i?"eye-slash":"eye");f&&p.append(f),p.onclick=h=>{h.preventDefault();const g=!a.get();a.set(g);const x=h.currentTarget.closest(".rui-password-input")?.querySelector(".rui-password-input-field");x&&(x.type=g?"text":"password")};const b=t.argMeta?.[1]?.stateRef;if(b&&r.bindState(d,b,{event:"input",getValue:h=>h.value}),pe(d,e.onChange,r,{event:"input",getValue:h=>h.value}),c.append(d),c.append(p),s.append(c),I(e.strengthMeter)){const h=eh(m(e.value)),g=u("div",{class:"rui-password-input-strength","data-score":String(h.score)});for(let v=0;v<4;v+=1)g.append(u("span",{class:"rui-password-input-strength-bar","data-filled":v<h.score?"true":"false"}));const y=u("div",{class:"rui-password-input-strength-row"});y.append(g),h.label&&y.append(u("span",{class:"rui-password-input-strength-label"},[h.label])),s.append(y)}return s}},rh={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 n=m(e.id),a=T(e.value).map(f=>m(f)).filter(Boolean),i=Math.max(0,Math.floor(P(e.max,0))),o=I(e.disabled),s=t.argMeta?.[1]?.stateRef,l=f=>{s&&r.setState(s,f),r.invoke(e.onChange,f)},c=m(e.label),d=u("div",{class:"rui-tag-input","data-disabled":o?"true":"false"});for(const f of a){const b=u("span",{class:"rui-tag-input-chip"});b.append(u("span",{},[f]));const h=u("button",{type:"button",class:"rui-tag-input-remove","aria-label":`Remove ${f}`},["×"]);h.onclick=()=>l(a.filter(g=>g!==f)),b.append(h),d.append(b)}const p=u("input",{type:"text",class:"rui-tag-input-field",id:n,name:n,placeholder:m(e.placeholder,a.length===0?"Add tags…":""),disabled:o?"":null,autocomplete:"off"});if(p.onkeydown=f=>{const b=f,h=b.currentTarget;if(b.key==="Enter"||b.key===","){b.preventDefault();const g=h.value.trim();if(!g||i>0&&a.length>=i)return;if(a.includes(g)){h.value="";return}l([...a,g]),h.value=""}else b.key==="Backspace"&&h.value===""&&a.length>0&&(b.preventDefault(),l(a.slice(0,-1)))},d.append(p),c){const f=u("div",{class:"rui-tag-input-wrapper"});return f.append(u("label",{class:"rui-tag-input-label",for:n},[c])),f.append(d),f}return d}};function nh(t){return T(t).map(e=>{if(typeof e=="string")return{value:e,label:e};if(e&&typeof e=="object"){const r=e,n=m(r.label??r.name??r.value??r.id);return{value:m(r.handle??r.value??r.id??r.name??r.label),label:n}}return{value:"",label:""}}).filter(e=>e.value||e.label)}const ah={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 n=m(e.id),a=nh(e.people),i=I(e.disabled),o=u("div",{class:"rui-mention-input","data-disabled":i?"true":"false"}),s=u("textarea",{class:"rui-mention-input-field",id:n,name:n,rows:String(Math.max(2,Math.floor(P(e.rows,3)))),placeholder:m(e.placeholder,"Type @ to mention someone"),disabled:i?"":null});s.value=m(e.value);const l=u("div",{class:"rui-mention-input-suggestions","data-open":"false"}),c=r.useInstanceState("activeIndex",0),d=r.useInstanceState("matches",[]),p=r.useInstanceState("query",null),f=x=>x.closest(".rui-mention-input")?.querySelector(".rui-mention-input-suggestions")??null,b=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 C=k.slice(A),M=`@${w.value} `,L=S.slice(0,$)+M+C;x.value=L;const z=$+M.length;x.selectionStart=x.selectionEnd=z,x.dispatchEvent(new Event("input",{bubbles:!0})),x.focus()},g=(x,w)=>{if(x.replaceChildren(),w===null){x.setAttribute("data-open","false"),d.set([]);return}const k=w.toLowerCase(),S=a.filter(C=>C.label.toLowerCase().includes(k)||C.value.toLowerCase().includes(k)).slice(0,6);if(d.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((C,M)=>{const L=u("button",{type:"button",class:"rui-mention-input-option","data-value":C.value,"data-active":M===$?"true":"false"});L.append(u("span",{class:"rui-mention-input-option-label"},[C.label])),C.value&&C.value!==C.label&&L.append(u("span",{class:"rui-mention-input-option-handle"},[`@${C.value}`])),L.onmousedown=z=>z.preventDefault(),L.onclick=z=>{const H=z.currentTarget,F=b(H),V=f(H);F&&h(F,C),p.set(null),V&&g(V,null)},x.append(L)})},y=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;p.set($),g(w,$)},v=t.argMeta?.[2]?.stateRef;return v?r.bindState(s,v,{event:"input",getValue:x=>{const w=x;return y(w),w.value}}):s.oninput=x=>{y(x.currentTarget)},pe(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=d.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((C,M)=>C.setAttribute("data-active",M===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((C,M)=>C.setAttribute("data-active",M===S?"true":"false"))}else if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();const S=A[c.get()];S&&(h(w,S),p.set(null),g(k,null))}else x.key==="Escape"&&(p.set(null),g(k,null))},s.onblur=x=>{const w=x.currentTarget;setTimeout(()=>{const k=f(w);p.set(null),k&&g(k,null)},120)},o.append(s),o.append(l),g(l,p.get()),o}},ih={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 n=m(e.id),a=u("div",{class:"rui-time-picker"}),i=m(e.label);i&&a.append(u("label",{class:"rui-time-picker-label",for:n},[i]));const o=u("input",{type:"time",class:"rui-time-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(P(e.step,60)):null,disabled:I(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),pe(o,e.onChange,r,{event:"change",getValue:l=>l.value}),a.append(o),a}},oh={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 n=m(e.id),a=u("div",{class:"rui-datetime-picker"}),i=m(e.label);i&&a.append(u("label",{class:"rui-datetime-picker-label",for:n},[i]));const o=u("input",{type:"datetime-local",class:"rui-datetime-picker-input",id:n,name:n,value:m(e.value),min:m(e.min)||null,max:m(e.max)||null,step:e.step!=null?String(P(e.step,60)):null,disabled:I(e.disabled)?"":null}),s=t.argMeta?.[1]?.stateRef;return s&&r.bindState(o,s),pe(o,e.onChange,r,{event:"change",getValue:l=>l.value}),a.append(o),a}};function es(t,e){if(!e)return t;let r="",n=0;const a=String(t??"");for(const i of e){if(n>=a.length)break;if(i==="9"){for(;n<a.length&&!/\d/.test(a[n]??"");)n+=1;if(n>=a.length)break;r+=a[n],n+=1}else if(i==="A"){for(;n<a.length&&!/[a-zA-Z]/.test(a[n]??"");)n+=1;if(n>=a.length)break;r+=a[n],n+=1}else i==="*"?(r+=a[n],n+=1):(r+=i,a[n]===i&&(n+=1))}return r}const sh={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 n=m(e.id),a=m(e.mask),i=I(e.disabled),o=es(m(e.value),a),s=m(e.label),l=u("input",{type:"text",class:"rui-masked-input",id:n,name:n,value:o,placeholder:m(e.placeholder,a),disabled:i?"":null,autocomplete:"off"});l.value=o;const c=t.argMeta?.[2]?.stateRef,d=p=>{const f=p.value,b=es(f,a);if(b===f)return b;const h=p.selectionStart??b.length;p.value=b;const g=Math.min(b.length,h);try{p.setSelectionRange(g,g)}catch{}return b};if(c?r.bindState(l,c,{event:"input",getValue:p=>d(p)}):l.oninput=p=>{d(p.currentTarget??p.target)},pe(l,e.onChange,r,{event:"input",getValue:p=>p.value}),s){const p=u("div",{class:"rui-masked-input-wrapper"});return p.append(u("label",{class:"rui-masked-input-label",for:n},[s])),p.append(l),p}return l}},lh={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 n=u("section",{class:"rui-form-section"}),a=u("header",{class:"rui-form-section-header"});a.append(u("h3",{class:"rui-form-section-label"},[m(e.label)]));const i=m(e.helper);i&&a.append(u("p",{class:"rui-form-section-helper"},[i])),n.append(a);const o=u("div",{class:"rui-form-section-body"});for(const s of T(e.children))o.append(r.renderNode(s));return n.append(o),n}},ch={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 n=u("fieldset",{class:"rui-fieldset",disabled:I(e.disabled)?"":null});n.append(u("legend",{class:"rui-fieldset-legend"},[m(e.legend)]));const a=m(e.helper);a&&n.append(u("p",{class:"rui-fieldset-helper"},[a]));for(const i of T(e.children))n.append(r.renderNode(i));return n}},uh={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=T(e.errors).map(l=>{if(!l)return null;if(typeof l=="string")return{label:"",message:l,field:""};if(typeof l=="object"){const c=l;return{label:m(c.label),message:m(c.message??c.error),field:m(c.field)}}return null}).filter(l=>l!==null&&l.message!=="");if(r.length===0)return u("div",{class:"rui-validation-summary","data-empty":"true",hidden:""});const n=m(e.tone,"danger"),a=u("aside",{class:"rui-validation-summary","data-tone":n,role:"alert"}),i=u("div",{class:"rui-validation-summary-title"}),o=j(n==="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:"))),a.append(i);const s=u("ul",{class:"rui-validation-summary-list"});for(const l of r){const c=u("li",{class:"rui-validation-summary-item"});l.label&&c.append(u("strong",{},[`${l.label}: `])),c.append(document.createTextNode(l.message)),s.append(c)}return a.append(s),a}};function dh(t){return T(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 ph={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 n=dh(e.steps),a=n.length,i=Math.max(0,Math.min(a-1,Math.floor(P(e.current,0)))),o=t.argMeta?.[1]?.stateRef,s=m(e.stepsLayout,"column").toLowerCase(),l=s==="row"||s==="horizontal"?"row":"column",c=u("div",{class:"rui-multi-step-form","data-layout":l}),d=u("ol",{class:"rui-steps rui-multi-step-form-steps","data-layout":l});n.forEach((x,w)=>{const k=u("li",{class:"rui-steps-item","data-active":w===i?"true":"false","data-complete":w<i?"true":"false"});k.append(u("div",{class:"rui-steps-title"},[x.title||`Step ${w+1}`])),x.details&&k.append(u("div",{class:"rui-steps-details"},[x.details])),d.append(k)}),c.append(d);const p=u("div",{class:"rui-multi-step-form-body"}),f=n[i];f&&f.content&&p.append(r.renderNode(f.content)),c.append(p);const b=u("div",{class:"rui-multi-step-form-footer"}),h=u("button",{type:"button",class:"rui-button","data-variant":"ghost",disabled:i<=0?"":null},[m(e.prevLabel,"Back")]);o&&i>0&&(h.onclick=()=>r.setState(o,i-1));const g=i>=a-1,y=g?m(e.submitLabel,"Submit"):m(e.nextLabel,"Continue"),v=u("button",{type:"button",class:"rui-button","data-variant":"primary"},[y]);return v.onclick=()=>{g?r.invoke(e.onSubmit):o&&r.setState(o,i+1)},b.append(h),b.append(u("span",{class:"rui-multi-step-form-progress"},[`${i+1} / ${a}`])),b.append(v),c.append(b),c}};function mh(t){return T(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:I(r.unread),avatarSrc:m(r.avatarSrc),onClick:r.onClick??r.action}}).filter(e=>e!==null)}const fh={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 n=mh(e.items),a=n.filter(l=>l.unread),i=n.filter(l=>!l.unread),o=u("div",{class:"rui-inbox-panel"});if(typeof e.onMarkAllRead=="function"&&a.length>0){const l=u("div",{class:"rui-inbox-panel-toolbar"}),c=u("button",{type:"button",class:"rui-inbox-panel-mark-all"},["Mark all as read"]);c.onclick=()=>r.invoke(e.onMarkAllRead),l.append(c),o.append(l)}if(n.length===0)return o.append(u("div",{class:"rui-inbox-panel-empty"},[m(e.emptyLabel,"You're all caught up.")])),o;const s=(l,c)=>{if(c.length===0)return;const d=u("section",{class:"rui-inbox-panel-group"}),p=u("header",{class:"rui-inbox-panel-group-head"});p.append(u("span",{class:"rui-inbox-panel-group-label"},[l])),p.append(u("span",{class:"rui-inbox-panel-group-count"},[String(c.length)])),d.append(p);for(const f of c){const b=Ro.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"&&(b.setAttribute("data-clickable","true"),b.onclick=()=>r.invoke(f.onClick)),d.append(b)}o.append(d)};return s(`Unread (${a.length})`,a),s("Earlier",i),o}};function gh(t){return T(t).map(e=>{if(!e||typeof e!="object")return null;const r=e;return{title:m(r.title),description:m(r.description),done:I(r.done),onClick:r.onClick??r.action,cta:m(r.cta,"Start")}}).filter(e=>e!==null)}const hh={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 n=gh(e.items),a=n.filter(p=>p.done).length,i=Math.max(1,n.length),o=Math.round(a/i*100),s=u("div",{class:"rui-onboarding-checklist"}),l=u("header",{class:"rui-onboarding-checklist-header"});l.append(u("h3",{class:"rui-onboarding-checklist-title"},[m(e.title,"Getting started")]));const c=m(e.subtitle);c&&l.append(u("p",{class:"rui-onboarding-checklist-subtitle"},[c])),l.append(u("div",{class:"rui-onboarding-checklist-progress"},[u("div",{class:"rui-onboarding-checklist-bar"},[u("div",{class:"rui-onboarding-checklist-fill",style:`width:${o}%`})]),u("span",{class:"rui-onboarding-checklist-meta"},[`${a}/${n.length} complete`])])),s.append(l);const d=u("ol",{class:"rui-onboarding-checklist-list"});for(const p of n){const f=u("li",{class:"rui-onboarding-checklist-item","data-done":p.done?"true":"false"}),b=u("span",{class:"rui-onboarding-checklist-marker"}),h=j(p.done?"circle-check":"circle",{className:"rui-onboarding-checklist-marker-icon"});h&&b.append(h),f.append(b);const g=u("div",{class:"rui-onboarding-checklist-body"});if(g.append(u("div",{class:"rui-onboarding-checklist-item-title"},[p.title])),p.description&&g.append(u("p",{class:"rui-onboarding-checklist-item-description"},[p.description])),f.append(g),!p.done&&typeof p.onClick=="function"){const y=u("button",{type:"button",class:"rui-button","data-variant":"secondary","data-size":"sm"},[p.cta]);y.onclick=()=>r.invoke(p.onClick),f.append(y)}d.append(f)}return s.append(d),s}};function ts(t){const e=u("div",{class:`rui-${t.klass}`});if(t.iconName){const n=j(t.iconName,{className:t.iconClass});n&&e.append(n)}t.title&&e.append(u("h3",{class:`rui-${t.klass}-title`},[t.title])),t.description&&e.append(u("p",{class:`rui-${t.klass}-description`},[t.description]));const r=T(t.actions);if(r.length>0){const n=u("div",{class:`rui-${t.klass}-actions`});for(const a of r)n.append(t.helpers.renderNode(a));e.append(n)}return e}const bh={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=u("div",{class:"rui-loading-state"}),n=u("span",{class:"rui-spinner","data-size":"lg","data-tone":"primary"});n.append(u("span",{class:"rui-spinner-ring","aria-hidden":"true"})),r.append(n),r.append(u("h3",{class:"rui-loading-state-title"},[m(e.title,"Loading…")]));const a=m(e.description);return a&&r.append(u("p",{class:"rui-loading-state-description"},[a])),r}},vh={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)=>ts({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})},yh={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)=>ts({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})},xh={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 n=T(e.steps).map(y=>{if(!y||typeof y!="object")return{title:m(y),description:"",target:""};const v=y;return{title:m(v.title),description:m(v.description),target:m(v.target)}}),a=e.open===void 0?!0:I(e.open),i=n.length,o=Math.max(0,Math.min(i-1,Math.floor(P(e.current,0)))),s=t.argMeta?.[1]?.stateRef,l=u("div",{class:"rui-tour","data-open":a?"true":"false"});if(!a||i===0)return l;const c=n[o];if(!c)return l;const d=u("div",{class:"rui-tour-card",role:"dialog","aria-modal":"false"});d.append(u("div",{class:"rui-tour-step"},[`Step ${o+1} of ${i}`])),d.append(u("h3",{class:"rui-tour-title"},[c.title])),c.description&&d.append(u("p",{class:"rui-tour-description"},[c.description])),c.target&&d.append(u("div",{class:"rui-tour-target"},[`Target: ${c.target}`]));const p=u("div",{class:"rui-tour-footer"}),f=u("button",{type:"button",class:"rui-button","data-variant":"ghost"},["Skip"]);f.onclick=()=>r.invoke(e.onComplete);const b=u("button",{type:"button",class:"rui-button","data-variant":"secondary",disabled:o<=0?"":null},["Back"]);s&&o>0&&(b.onclick=()=>r.setState(s,o-1));const h=o>=i-1,g=u("button",{type:"button",class:"rui-button","data-variant":"primary"},[h?"Finish":"Next"]);return g.onclick=()=>{h?r.invoke(e.onComplete):s&&r.setState(s,o+1)},p.append(f,b,g),d.append(p),l.append(d),l}},wh={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 n=e.open===void 0?!0:I(e.open),a=u("div",{class:"rui-spotlight","data-open":n?"true":"false"});if(!n)return a;const i=u("div",{class:"rui-spotlight-card"});i.append(u("h3",{class:"rui-spotlight-title"},[m(e.title)]));const o=m(e.description);o&&i.append(u("p",{class:"rui-spotlight-description"},[o]));const s=T(e.actions);if(s.length>0){const c=u("div",{class:"rui-spotlight-actions"});for(const d of s)c.append(r.renderNode(d));i.append(c)}const l=t.argMeta?.[1]?.stateRef;return l&&(a.onclick=c=>{c.target===a&&r.setState(l,!1)}),a.append(i),a}},kh={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. Sets `data-stuck="true"` on itself once pinned, so a CSS hook (a shadow/border) can flag the pinned state.',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 n=m(e.side,"top"),a=Z(e.offset,"0"),i=Math.max(0,Math.floor(P(e.zIndex,10))),o=`position:sticky;${n}:${a};z-index:${i};`,s=u("div",{class:"rui-sticky",style:o});for(const l of T(e.children))s.append(r.renderNode(l));if(typeof IntersectionObserver<"u"){const l=/^(\d+(?:\.\d+)?)px$/.exec(a)?.[1]??"0",c=n==="bottom"?`0px 0px -${Number(l)+1}px 0px`:`-${Number(l)+1}px 0px 0px 0px`;setTimeout(()=>{const d=new IntersectionObserver(([p])=>{p&&s.setAttribute("data-stuck",p.intersectionRatio<1?"true":"false")},{threshold:[1],rootMargin:c});d.observe(s),r.registerDisposer(()=>d.disconnect(),"rui-sticky-io")},0)}return s}},Sh={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 n=Z(e.initialPrimaryWidth,"40%"),a=Z(e.minPrimaryWidth,"240px"),i=u("div",{class:"rui-resizable-panels",style:`--rui-resizable-primary:${n};--rui-resizable-min:${a};`}),o=u("div",{class:"rui-resizable-panel rui-resizable-panel-primary"});for(const c of T(e.primary))o.append(r.renderNode(c));const s=u("div",{class:"rui-resizable-divider",role:"separator","aria-orientation":"vertical",tabindex:"0"}),l=u("div",{class:"rui-resizable-panel rui-resizable-panel-secondary"});for(const c of T(e.secondary))l.append(r.renderNode(c));return i.append(o,s,l),s.onpointerdown=c=>{const d=c,p=d.currentTarget;p.setPointerCapture(d.pointerId);const f=p.closest(".rui-resizable-panels");if(!f)return;const b=f.getBoundingClientRect(),h=y=>{const v=(y.clientX-b.left)/b.width*100,x=Math.max(15,Math.min(85,v));f.style.setProperty("--rui-resizable-primary",`${x}%`)},g=y=>{p.releasePointerCapture(y.pointerId),p.removeEventListener("pointermove",h),p.removeEventListener("pointerup",g)};p.addEventListener("pointermove",h),p.addEventListener("pointerup",g)},i}},$h={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:me}],render:(t,e,r)=>{const n=Math.max(1,Math.min(6,Math.floor(P(e.columns,3)))),a=ve(e.gap,"md"),i=u("div",{class:"rui-masonry-grid","data-columns":String(n),"data-gap":a});for(const o of T(e.items))i.append(r.renderNode(o));return i}},Ch={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 n=I(e.open),a=m(e.side,"right"),i=u("div",{class:"rui-sheet-overlay","data-open":n?"true":"false","data-side":a}),o=u("aside",{class:"rui-sheet",role:"dialog","aria-modal":"true","data-side":a}),s=u("header",{class:"rui-sheet-header"});s.append(u("h3",{class:"rui-sheet-title"},[m(e.title)]));const l=u("button",{type:"button",class:"rui-sheet-close","aria-label":"Close"},["×"]),c=t.argMeta?.[1]?.stateRef,d=()=>{c&&r.setState(c,!1),r.invoke(e.onClose)};l.onclick=d,i.onclick=b=>{b.target===i&&d()},s.append(l),o.append(s);const p=u("div",{class:"rui-sheet-body"});for(const b of T(e.children))p.append(r.renderNode(b));o.append(p);const f=T(e.footer);if(f.length>0){const b=u("footer",{class:"rui-sheet-footer"});for(const h of f)b.append(r.renderNode(h));o.append(b)}return i.append(o),i}},Ah={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 n=u("header",{class:"rui-topbar","data-sticky":I(e.sticky)?"true":"false"}),a=u("div",{class:"rui-topbar-side rui-topbar-left"}),i=m(e.title);if(i){const l=u("div",{class:"rui-topbar-title-block"});l.append(u("h2",{class:"rui-topbar-title"},[i]));const c=m(e.subtitle);c&&l.append(u("p",{class:"rui-topbar-subtitle"},[c])),a.append(l)}for(const l of T(e.left))a.append(r.renderNode(l));n.append(a);const o=T(e.center);if(o.length>0){const l=u("div",{class:"rui-topbar-side rui-topbar-center"});for(const c of o)l.append(r.renderNode(c));n.append(l)}const s=u("div",{class:"rui-topbar-side rui-topbar-right"});for(const l of T(e.right))s.append(r.renderNode(l));return n.append(s),n}},Th={name:"NavLink",description:'Anchor that navigates to a route on click and stays in sync with the URL hash. Reflects `data-active="true"` (and `aria-current="page"` for assistive tech) 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."},{name:"prefetch",type:"callable",optional:!0,description:"Called once on first hover/focus (warm a `$query` cache for the target route)."}],render:(t,e,r)=>{const n=m(e.label,""),a=m(e.to,"/"),i=m(e.variant,"default"),o=I(e.exact,!1),s=r.router,l=s.getPath(),c=l?o?l===a:a==="/"?l==="/":l===a?!0:l.startsWith(a+"/"):!1,d=u("a",{class:"rui-nav-link","data-variant":i,"data-active":c?"true":"false","aria-current":c?"page":null,href:"#"+(a.startsWith("/")?a:"/"+a)}),p=j(e.icon,{className:"rui-nav-link-icon"});if(p&&d.append(p),d.append(u("span",{class:"rui-nav-link-label"},[n])),typeof e.prefetch=="function"){let f=!1;const b=()=>{f||(f=!0,r.invoke(e.prefetch,a))};d.addEventListener("pointerenter",b,{once:!0}),d.addEventListener("focus",b,{once:!0})}return d.onclick=f=>{f.defaultPrevented||f.button===0&&(f.metaKey||f.ctrlKey||f.shiftKey||f.altKey||(f.preventDefault(),s.navigate(a)))},d}},Mh=["primary","secondary","ghost","danger"],Nh=["xs","sm","md","lg","xl"];function Ih(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 Ph(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.value??n.label);return{value:a,label:m(n.label,a)}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function $r(t){return T(t).filter(e=>!!e&&typeof e=="object"&&!Array.isArray(e))}function Rh(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.value??n.label);return{value:a,label:m(n.label,a),group:m(n.group)||void 0,shortcut:m(n.shortcut)||void 0,action:n.action}}const r=m(e);return{value:r,label:r}}).filter(e=>e.label!=="")}function rs(t){return T(t).map(e=>{if(e&&typeof e=="object"){const n=e,a=m(n.name??n.label);return{name:a,label:m(n.label,a),type:m(n.type,"text")||"text"}}const r=m(e);return{name:r,label:r,type:"text"}}).filter(e=>e.name!=="")}function Eh(t){return $r(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?P(e.progress,0):void 0}))}function dt(t){const e=Date.parse(t);return Number.isNaN(e)?Date.now():e}function Lh(t,e){const r=t.split(`
|
|
100
100
|
`),n=e.split(`
|
|
101
|
-
`),a=Math.max(r.length,n.length),i=[];for(let o=0;o<a;o++){const s=r[o],l=n[o];s===l?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),l!==void 0&&i.push({type:"add",text:l}))}return i}function jo(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Bo(t,e,r,n){for(const[a,i]of e){const o=c("div",{class:"rui-json-tree-row"});o.append(c("span",{class:"rui-json-tree-key"},[`${a}: `])),i!==null&&typeof i=="object"?o.append(Oo(i,r,n+1)):o.append(c("span",{class:"rui-json-tree-leaf"},[jo(i)])),t.append(o)}}function Oo(t,e,r=0){const n=c("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return n.append(c("span",{class:"rui-json-tree-leaf"},[jo(t)])),n;const a=Array.isArray(t),i=a?t.map((u,d)=>[String(d),u]):Object.entries(t),o=e||r<1,s=c("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",a?` Array(${i.length})`:" Object"]),l=c("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&Bo(l,i,e,r),s.onclick=u=>{const d=u.currentTarget,p=d.nextElementSibling;if(!p)return;const f=p.getAttribute("data-open")!=="true";p.setAttribute("data-open",f?"true":"false"),d.setAttribute("aria-expanded",f?"true":"false"),d.firstChild&&(d.firstChild.textContent=f?"▼":"▶"),f&&p.childElementCount===0?Bo(p,i,e,r):f||p.replaceChildren()},n.append(s,l),n}const zg={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:Ag},{name:"size",type:"string",optional:!0,enum:Tg},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=c("button",{class:"rui-icon-button",type:"button","data-variant":m(e.variant,"ghost"),"data-size":Mg(e.size),"aria-label":m(e.label),title:m(e.label),disabled:N(e.disabled)?"":null}),a=L(e.icon,{className:"rui-icon-button-icon"});return a&&n.append(a),n.onclick=()=>r.invoke(e.onClick),n}},Rg={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 n=Ig(e.items),a=e.open!==void 0,i=a?N(e.open):!0,o=r.useInstanceState("open",i);a&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),l=a?i:o.get(),u=c("div",{class:"rui-command-palette","data-open":l?"true":"false"});if(!l)return u;const d=c("div",{class:"rui-command-palette-backdrop"}),p=c("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),f=c("div",{class:"rui-command-palette-header"}),b=c("input",{type:"text",class:"rui-command-palette-input",placeholder:m(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(b);const h=m(e.shortcut);h&&f.append(c("span",{class:"rui-command-palette-shortcut"},[h])),p.append(f);const g=c("div",{class:"rui-command-palette-list",role:"listbox"}),y=(v,x)=>{v.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?n:n.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,v.append(c("div",{class:"rui-command-palette-group"},[A])));const $=c("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&$.append(c("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),$.onclick=C=>{C.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const M=C.currentTarget.closest(".rui-command-palette"),E=M?.querySelector(".rui-command-palette-panel");M?.setAttribute("data-open","false"),Ue(E??null)},v.append($)}k.length===0&&v.append(c("div",{class:"rui-command-palette-empty"},["No commands found"]))};return y(g,s.get()),p.append(g),d.onclick=v=>{const x=v.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ue(w??null)},u.append(d,p),b.oninput=v=>{const x=v.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&y(w,x.value)},b.onkeydown=v=>{if(v.key==="Escape"){const x=v.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),Ue(w??null)}},setTimeout(()=>b.focus(),0),xt({liveRoot:p,onDismiss:()=>{o.set(!1),u.setAttribute("data-open","false")}}),u}},Lg={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 n=Ng(e.chips),a=c("div",{class:"rui-filter-chips"}),i=c("div",{class:"rui-filter-chips-row"});for(const o of n){const s=c("span",{class:"rui-filter-chip","data-value":o.value});s.append(c("span",{class:"rui-filter-chip-label"},[o.label]));const l=c("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),u=L("xmark",{className:"rui-filter-chip-remove-icon"});u&&l.append(u),l.onclick=()=>r.invoke(e.onRemove,o.value),s.append(l),i.append(s)}if(a.append(i),n.length>0&&typeof e.onClear=="function"){const o=c("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),a.append(o)}return a}},Dg={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 n=br(e.items),a=Do(e.fields),i=c("div",{class:"rui-field-repeater"});if(n.forEach((o,s)=>{const l=c("div",{class:"rui-field-repeater-row","data-index":String(s)}),u=c("div",{class:"rui-field-repeater-grid"});for(const d of a){const p=c("label",{class:"rui-field-repeater-field"});p.append(c("span",{class:"rui-field-repeater-label"},[d.label]));const f=c("input",{class:"rui-input",type:d.type==="number"?"number":"text",name:`${d.name}-${s}`,value:m(o[d.name]),readonly:""});p.append(f),u.append(p)}if(l.append(u),typeof e.onRemove=="function"){const d=c("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);d.onclick=()=>r.invoke(e.onRemove,s),l.append(d)}i.append(l)}),typeof e.onAdd=="function"){const o=c("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}},jg={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 n=Math.max(24,I(e.itemHeight,40)),a=T(e.items),i=c("div",{class:"rui-virtual-list"}),o=c("div",{class:"rui-virtual-list-scroller"}),s=c("div",{class:"rui-virtual-list-spacer"}),l=c("div",{class:"rui-virtual-list-window"}),u=a.length;s.style.height=`${u*n}px`,s.style.position="relative",l.style.position="absolute",l.style.top="0",l.style.left="0",l.style.right="0",o.style.maxHeight=`${Math.min(Math.max(u,1),12)*n}px`,o.style.overflow="auto";const d=p=>{l.replaceChildren();const f=o.clientHeight||n*12,b=Math.ceil(f/n)+2,h=Math.max(0,p),g=Math.min(u,h+b);l.style.transform=`translateY(${h*n}px)`;for(let y=h;y<g;y++){const v=a[y];if(e.renderItem)l.append(r.renderNode(v??e.renderItem));else if(v&&typeof v=="object"&&v.__kind)l.append(r.renderNode(v));else{const x=c("div",{class:"rui-virtual-list-item",style:`height:${n}px`});x.append(c("span",{},[m(v)])),l.append(x)}}};return o.onscroll=()=>{const p=Math.floor(o.scrollTop/n);d(p)},d(0),o.append(s,l),i.append(o),i}},Bg={name:"VirtualGrid",description:"Windowed 2-D grid for very large collections (galleries, tiles, thumbnails). Only the visible rows of cells are mounted. Pass pre-rendered nodes (or plain values) as `items`; set `columns`, `itemHeight`, and `gap`. Virtualizes by row so thousands of items scroll smoothly (XI.3).",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Cells per row (default 4)"},{name:"itemHeight",type:"number",optional:!0,description:"Row height in px (default 120)"},{name:"gap",type:"number",optional:!0,description:"Gap between cells in px (default 8)"},{name:"height",type:"number",optional:!0,description:"Viewport height in px (default 480)"}],render:(t,e,r)=>{const n=Math.max(1,Math.min(12,Math.floor(I(e.columns,4)))),a=Math.max(24,I(e.itemHeight,120)),i=Math.max(0,I(e.gap,8)),o=Math.max(120,I(e.height,480)),s=T(e.items),l=s.length,u=Math.ceil(l/n),d=a+i,p=c("div",{class:"rui-virtual-grid"}),f=c("div",{class:"rui-virtual-grid-scroller",style:`max-height:${o}px;overflow:auto`}),b=c("div",{class:"rui-virtual-grid-spacer",style:`position:relative;height:${u*d}px`}),h=c("div",{class:"rui-virtual-grid-window",style:`position:absolute;left:0;right:0;top:0;display:grid;grid-template-columns:repeat(${n},minmax(0,1fr));gap:${i}px`}),g=(y,v)=>{y.replaceChildren();const x=Math.max(0,Math.floor((Number.isFinite(v)?v:0)/d)-1),w=Math.ceil(o/d)+2,k=Math.min(u,x+w);y.style.transform=`translateY(${x*d}px)`;for(let A=x;A<k;A+=1)for(let S=0;S<n;S+=1){const $=A*n+S;if($>=l)break;const C=s[$],M=c("div",{class:"rui-virtual-grid-cell",style:`height:${a}px`});C&&typeof C=="object"&&C.__kind?M.append(r.renderNode(C)):M.append(c("span",{},[m(C)])),y.append(M)}};return f.onscroll=y=>{const v=y?.currentTarget??y?.target??f,x=v.querySelector(".rui-virtual-grid-window");x&&g(x,v.scrollTop)},g(h,0),f.append(b,h),p.append(f),p}},Og={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 n=Do(e.fields),a=br(e.value),i=t.argMeta?.[1]?.stateRef,o=c("div",{class:"rui-query-builder"}),s=l=>{o.replaceChildren(),l.forEach((d,p)=>{const f=c("div",{class:"rui-query-builder-row","data-index":String(p)}),b=c("select",{class:"rui-select rui-query-builder-field"});for(const v of n)b.append(c("option",{value:v.name},[v.label]));b.value=m(d.field??n[0]?.name);const h=c("select",{class:"rui-select rui-query-builder-op"},[]);for(const v of["equals","contains","gt","lt"])h.append(c("option",{value:v},[v]));h.value=m(d.op,"equals");const g=c("input",{class:"rui-input rui-query-builder-value",value:m(d.value)});f.append(b,h,g);const y=c("button",{type:"button",class:"rui-query-builder-remove"},["×"]);y.onclick=()=>{const v=l.filter((x,w)=>w!==p);i?r.setState(i,v):r.invoke(e.onChange,v),s(v)},f.append(y),o.append(f)});const u=c("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);u.onclick=()=>{const d=[...l,{field:n[0]?.name??"",op:"equals",value:""}];i?r.setState(i,d):r.invoke(e.onChange,d),s(d)},o.append(u)};return s(a.length>0?a:[{field:n[0]?.name??"",op:"equals",value:""}]),o}},Fg={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),n=m(e.right),a=m(e.mode,"split"),i=c("div",{class:"rui-diff-viewer","data-mode":a});if(a==="unified"){const u=c("pre",{class:"rui-diff-viewer-unified"});for(const d of Eg(r,n))u.append(c("div",{class:`rui-diff-line rui-diff-line-${d.type}`},[(d.type==="add"?"+ ":d.type==="remove"?"- ":" ")+d.text]));return i.append(u),i}const o=c("div",{class:"rui-diff-viewer-panes"}),s=c("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),l=c("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[n]);return o.append(s,l),i.append(o),i}},_g={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=c("div",{class:"rui-json-tree"});return r.append(Oo(e.data,N(e.expanded))),r}},Ug={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=Pg(e.tasks),n=r.map(d=>st(d.start)),a=r.map(d=>st(d.end)),i=e.startDate?st(m(e.startDate)):n.length?Math.min(...n):Date.now(),o=e.endDate?st(m(e.endDate)):a.length?Math.max(...a):i+864e5,s=Math.max(o-i,1),l=c("div",{class:"rui-gantt"}),u=c("div",{class:"rui-gantt-track"});for(const d of r){const p=c("div",{class:"rui-gantt-row"});p.append(c("div",{class:"rui-gantt-label"},[d.label]));const f=c("div",{class:"rui-gantt-bars"}),b=(st(d.start)-i)/s*100,h=Math.max((st(d.end)-st(d.start))/s*100,2),g=c("div",{class:"rui-gantt-bar",style:`left:${b}%;width:${h}%`,title:`${d.start} → ${d.end}`});d.progress!=null&&g.append(c("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,d.progress))}%`})),f.append(g),p.append(f),u.append(p)}return l.append(u),l}},Hg={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 n=Math.max(1,Math.floor(I(e.maxLines,3))),a=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${n};-webkit-box-orient:vertical;overflow:hidden`,o=c("div",{class:"rui-truncate","data-expanded":a.get()?"true":"false"}),s=c("p",{class:"rui-truncate-text",style:a.get()?"":i},[m(e.text)]),l=c("button",{type:"button",class:"rui-truncate-toggle"},[a.get()?"Show less":m(e.expandLabel,"Show more")]);return l.onclick=u=>{const d=u.currentTarget,p=d.closest(".rui-truncate"),f=p?.querySelector(".rui-truncate-text");if(!p||!f)return;const b=!a.get();a.set(b),f.style.cssText=b?"":i,d.textContent=b?"Show less":m(e.expandLabel,"Show more"),p.setAttribute("data-expanded",b?"true":"false")},o.append(s,l),o}},qg={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 n=r.useInstanceState("editing",!1),a=r.useInstanceState("draft",m(e.value)),i=t.argMeta?.[0]?.stateRef,o=c("div",{class:"rui-inline-edit","data-editing":n.get()?"true":"false"}),s=m(e.label);s&&o.append(c("span",{class:"rui-inline-edit-label"},[s]));const l=c("button",{type:"button",class:"rui-inline-edit-display"},[m(e.value)]),u=c("input",{class:"rui-inline-edit-input rui-input",value:a.get()}),d=f=>{const b=f.closest(".rui-inline-edit"),h=b?.querySelector(".rui-inline-edit-input");return!b||!h?null:{root:b,input:h}},p=f=>{const b=d(f);n.set(!1),b?.root.setAttribute("data-editing","false");const h=a.get();i&&r.setState(i,h),r.invoke(e.onSave,h)};return l.onclick=f=>{const b=d(f.currentTarget);a.set(m(e.value)),n.set(!0),b&&(b.root.setAttribute("data-editing","true"),b.input.value=a.get(),setTimeout(()=>b.input.focus(),0))},u.oninput=f=>a.set(f.currentTarget.value),u.onkeydown=f=>{const b=f;if(b.key==="Enter"&&p(f.currentTarget),b.key==="Escape"){const h=d(f.currentTarget);n.set(!1),h?.root.setAttribute("data-editing","false")}},u.onblur=f=>p(f.currentTarget),o.append(l,u),o}},Vg={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 n=Math.max(0,Math.floor(I(e.count,0))),a=br(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=c("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),l=c("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),u=L("bell",{className:"rui-notification-bell-icon"});u&&l.append(u),n>0&&l.append(c("span",{class:"rui-notification-bell-badge"},[n>99?"99+":String(n)])),s.append(l);const d=c("div",{class:"rui-notification-bell-panel",role:"menu"});if(a.length===0)d.append(c("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const p of a){const f=c("div",{class:"rui-notification-bell-item"});f.append(c("div",{class:"rui-notification-bell-item-title"},[m(p.title)]));const b=m(p.message);b&&f.append(c("div",{class:"rui-notification-bell-item-message"},[b]));const h=m(p.time);h&&f.append(c("div",{class:"rui-notification-bell-item-time"},[h])),d.append(f)}return s.append(d),l.onclick=p=>{p.stopPropagation();const f=p.currentTarget,b=f.closest(".rui-notification-bell");if(!b)return;const h=!i.get();i.set(h),b.setAttribute("data-open",h?"true":"false"),f.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),xt({liveRoot:b,onDismiss:()=>{i.set(!1),b.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):Ue(b)},s}},He=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Wg=t=>!!(t&&typeof t=="object"),Gg={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 n=e.resource,a={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Wg(n))return He(r,a.empty??a.data??null);const i=n.state;if(i==="loading"||n.loading)return He(r,a.loading??null);if(i==="error"||n.error)return He(r,a.error??null);const o=n.data;return o==null||Array.isArray(o)&&o.length===0?He(r,a.empty??a.data??null):He(r,a.data??null)}},Kg={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)},Yg={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 n=m(e.target);let a=null;if(n)try{a=document.querySelector(n)}catch{a=null}a||(a=document.body);const i=c("div",{class:"rui-portal"});for(const o of T(e.children))i.append(r.renderNode(o));return a&&(a.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)},"rui-portal-container")),c("span",{class:"rui-portal-anchor","data-portal":n??"body"})}},Xg={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 n=m(e.path);if(n)try{r.router.navigate(n)}catch{}return c("span",{class:"rui-redirect","data-path":n,hidden:"true"})}},Zg={name:"Lazy",description:"Defer rendering until an async `loader` resolves: show `fallback` while pending, then render the resolved value (or `children`). A synchronous loader value renders immediately.",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 n=e.loader,a=r.useInstanceState("rui-lazy",{status:"init"}),i=c("span",{class:"rui-lazy",style:"display: contents;"}),o=p=>{i.replaceChildren(He(r,p))},s=()=>e.fallback??null,l=p=>p??e.children??null,u=a.get();if(u.status==="resolved")return o(l(u.value)),i;if(u.status==="pending"||u.status==="error")return o(s()),i;let d;try{d=typeof n=="function"?n():n}catch{return a.set({status:"error"}),o(s()),i}if(d&&typeof d.then=="function"){a.set({status:"pending"}),o(s());let p=!1;return r.registerDisposer(()=>{p=!0},"rui-lazy-cancel"),d.then(f=>{p||(a.set({status:"resolved",value:f}),o(l(f)))},()=>{p||(a.set({status:"error"}),o(s()))}),i}return a.set({status:"resolved",value:d}),o(l(d)),i}},Qg={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws. Pass a `fallback` node (or omit it for a built-in friendly error card showing the message + a Retry button); `onError(err)` fires with the error. Set `showDetails=true` to reveal the message inline (great in dev).",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"showDetails",type:"boolean",optional:!0,description:"Show the error message inline (default false)"},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const n=c("div",{class:"rui-error-boundary"});try{for(const a of T(e.children))n.append(r.renderNode(a));return n}catch(a){try{r.invoke(e.onError,a)}catch{}const i=a instanceof Error?a.message:String(a),o=c("div",{class:"rui-error-boundary rui-error-boundary--fallback"});if(o.setAttribute("role","alert"),e.fallback!=null)o.append(He(r,e.fallback));else{const s=c("div",{class:"rui-error-card"}),l=L("triangle-exclamation",{className:"rui-error-card-icon"});l&&s.append(l),s.append(c("div",{class:"rui-error-card-title"},["Something went wrong"])),(e.showDetails===!0||e.showDetails==="true")&&s.append(c("div",{class:"rui-error-card-message"},[i])),o.append(s)}return o.setAttribute("data-error",i),o}}},Jg=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"]),eh=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,th=new Set(["href","ping","action","formaction"]),rh=new Set(["src","poster"]);function nh(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function ah(t){const e=m(t).trim().toLowerCase();return!e||!Jg.has(e)?"div":e}function ih(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t)){const a=r.trim();if(!a||!eh.test(a))continue;const i=a.toLowerCase();if(!i.startsWith("on")&&!(n==null||n===!1)){if(i==="style"){const o=nh(n);o&&(e.style=o);continue}if(th.has(i)){const o=Fe(n,"");o&&(e[a]=o);continue}if(rh.has(i)){const o=re(n);o&&(e[a]=o);continue}e[a]=n===!0?"":m(n)}}return e}const oh={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 n=ah(e.tag),a=ih(e.attributes),i=c(n,a);for(const o of T(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}},sh=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,lh=64*1024;function ch(t){const e=m(t);return!e||e.length>lh||sh.test(e)?"":e}function uh(t){return t.replace(/\{\s*([a-zA-Z]+)\.([a-zA-Z0-9-]+)\s*\}/g,(e,r,n)=>{const a=n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r==="colors"||r==="color"?"color":r==="spacing"?"spacing":r==="radius"?"radius":r==="shadows"||r==="shadow"?"shadow":r==="gradients"||r==="gradient"?"gradient":r==="font"||r==="fonts"?"font":null;return i?`var(--rui-${i}-${a})`:e})}function Fo(t,e){const r=[];let n=0;const a=t.length;for(;n<a;){const i=t.indexOf("{",n);if(i===-1){r.push(t.slice(n));break}const o=t.slice(n,i).trim();let s=1,l=i+1;for(;l<a&&s>0;l+=1)t[l]==="{"?s+=1:t[l]==="}"&&(s-=1);const u=t.slice(i+1,l-1);if(o.startsWith("@media")||o.startsWith("@supports"))r.push(`${o} { ${Fo(u,e)} }`);else if(o.startsWith("@"))r.push(`${o} { ${u} }`);else{const d=o.split(",").map(p=>{const f=p.trim();return f&&(f.startsWith(":root")?f:`${e} ${f}`)}).join(", ");r.push(`${d} { ${u} }`)}n=l}return r.join(`
|
|
102
|
-
`)}const dh={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; }"`).'},{name:"scope",type:"string",optional:!0,description:'Selector to scope every rule under, e.g. `".my-widget"` (I.6)'},{name:"tokens",type:"boolean",optional:!0,description:"Interpolate `{group.key}` token refs to CSS vars (default true)"}],render:(t,e)=>{let r=ch(e.css);r&&(e.tokens===void 0||e.tokens===!0||e.tokens==="true")&&(r=uh(r));const n=m(e.scope).trim();r&&n&&(r=Fo(r,n));const a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}},ph={name:"GradientText",description:'Inline text painted with a brand gradient. Use inside a Display/Heading title to emphasise a phrase: `Display(["Build in ", GradientText("record time")])`. `gradient` selects a named theme gradient (brand|accent|warm|cool|success|danger).',props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["children","label"]},{name:"gradient",type:"string",optional:!0,enum:["brand","accent","warm","cool","success","danger"]}],render:(t,e)=>{const r=c("span",{class:"rui-gradient-text","data-gradient":m(e.gradient,"brand")});return r.append(document.createTextNode(m(e.text))),r}};function Nn(t,e,r){for(const n of T(e))n!=null&&(typeof n=="string"||typeof n=="number"?t.append(document.createTextNode(String(n))):t.append(r.renderNode(n)))}const mh={name:"Display",description:"Oversized display headline with built-in responsive `clamp()` sizing. The positional argument may be a plain string OR an array mixing strings and `GradientText(...)` runs. `size`: hero|xl|lg. `balance` wraps for even line lengths.",props:[{name:"content",type:"string | Node[]",positional:!0,required:!0,aliases:["children","title"]},{name:"size",type:"string",optional:!0,enum:["hero","xl","lg"]},{name:"align",type:"string",optional:!0,enum:["left","center","right"]},{name:"balance",type:"boolean",optional:!0},{name:"weight",type:"number",optional:!0}],render:(t,e,r)=>{const n=c("h1",{class:"rui-display","data-size":m(e.size,"hero"),"data-align":m(e.align)||null,"data-balance":N(e.balance)?"true":null,style:e.weight!=null?`font-weight:${I(e.weight,900)}`:null});return Nn(n,e.content,r),n}},fh={name:"Heading",description:"Section/subsection heading with token-driven sizing. `level` sets the semantic tag (1–6); `size`: section|lg|md|sm. Accepts string or mixed string/GradientText array like Display.",props:[{name:"content",type:"string | Node[]",positional:!0,required:!0,aliases:["children","title"]},{name:"level",type:"number",optional:!0,description:"Heading level 1–6 (default 2)"},{name:"size",type:"string",optional:!0,enum:["section","lg","md","sm"]},{name:"align",type:"string",optional:!0,enum:["left","center","right"]}],render:(t,e,r)=>{const n=Math.min(6,Math.max(1,Math.round(I(e.level,2)))),a=c(`h${n}`,{class:"rui-heading","data-size":m(e.size,"section"),"data-align":m(e.align)||null});return Nn(a,e.content,r),a}},gh={name:"Eyebrow",description:"Small uppercase, letter-spaced, primary-toned label above a heading.",props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["label","children"]}],render:(t,e)=>c("span",{class:"rui-eyebrow"},[m(e.text)])},hh={name:"Section",description:"Full-bleed page band → centered max-width container → optional tinted background → optional eyebrow/title/subtitle header. The single most useful primitive for marketing, docs, and settings pages. Children render below the header.",props:[{name:"children",type:"Node[]",positional:!0,required:!0},{name:"background",type:"string",optional:!0,enum:["base","soft","surface","muted","brand"],aliases:["bg"]},{name:"width",type:"string",optional:!0,enum:["sm","md","lg","xl","full"]},{name:"padding",type:"string",optional:!0,enum:["none","xs","sm","md","lg","xl"],description:"Band padding preset (default md)"},{name:"align",type:"string",optional:!0,enum:["left","center"]},{name:"eyebrow",type:"string",optional:!0},{name:"title",type:"string | Node[]",optional:!0},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"id",type:"string",optional:!0}],render:(t,e,r)=>{const n=m(e.background,"base"),a=c("section",{class:"rui-section","data-bg":n!=="base"?n:null,"data-pad":ge(e.padding,m(e.padding))||null,"data-align":m(e.align)||null,id:m(e.id)||null}),i=c("div",{class:"rui-section-inner","data-w":m(e.width,"lg")}),o=m(e.eyebrow),s=e.title!=null&&(typeof e.title!="string"||e.title!==""),l=m(e.subtitle);if(o||s||l){const u=c("div",{class:"rui-section-head"});if(o&&u.append(c("span",{class:"rui-eyebrow"},[o])),s){const d=c("h2",{class:"rui-section-title"});Nn(d,e.title,r),u.append(d)}l&&u.append(c("p",{class:"rui-section-sub"},[l])),i.append(u)}for(const u of T(e.children))i.append(r.renderNode(u));return a.append(i),a}},bh={name:"OverlayItem",description:"A child positioned over an Overlay's base. `anchor` picks a corner/edge/center.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"anchor",type:"string",optional:!0,enum:["top-left","top-right","bottom-left","bottom-right","top","bottom","left","right","center"]},{name:"offset",type:"string",optional:!0,description:"Inset distance (CSS length, e.g. 8px or 1rem)"}],render:(t,e,r)=>{const n=c("div",{class:"rui-overlay-item","data-anchor":m(e.anchor,"top-right"),style:e.offset?`--ak-ov-off:${m(e.offset)}`:null});return e.child!=null&&n.append(r.renderNode(e.child)),n}},vh={name:"Overlay",description:"Layers OverlayItem children on top of a base node — corner badges, play buttons over thumbnails, sale ribbons, floating actions. Pass the base as the positional argument and `items` as OverlayItem entries.",props:[{name:"base",type:"Node",positional:!0,required:!0},{name:"items",type:"OverlayItem[]",aliases:["overlays"]}],render:(t,e,r)=>{const n=c("div",{class:"rui-overlay"});if(e.base!=null){const a=c("div",{class:"rui-overlay-base"});a.append(r.renderNode(e.base)),n.append(a)}for(const a of T(e.items))n.append(r.renderNode(a));return n}},yh={name:"Brand",description:"Logo + product name (+ optional version pill), linking home. Use in NavBar/Footer.",props:[{name:"name",type:"string",positional:!0,required:!0,aliases:["label"]},{name:"logo",type:"string",optional:!0,description:"Logo image src URL, e.g. https://example.com/logo.png"},{name:"version",type:"string",optional:!0},{name:"href",type:"string",optional:!0}],render:(t,e)=>{const r=c("a",{class:"rui-brand",href:Fe(e.href,"#")}),n=re(e.logo);n&&r.append(c("img",{class:"rui-brand-logo",src:n,alt:""})),r.append(c("span",{},[m(e.name)]));const a=m(e.version);return a&&r.append(c("span",{class:"rui-brand-version"},[a])),r}},xh={name:"NavBar",description:"Marketing top navigation: brand on the left, links in the middle, actions (buttons/toggles) on the right. `sticky` pins it; `blur` adds a frosted-glass backdrop. On narrow viewports the links collapse behind a burger toggle. Distinct from the app-shell Navbar/TopBar.",props:[{name:"brand",type:"Node",optional:!0},{name:"links",type:"Node[]",optional:!0,description:"NavLink / Link nodes"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons, ThemeToggle, IconButton, etc."},{name:"sticky",type:"boolean",optional:!0},{name:"blur",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=c("header",{class:"rui-navbar2","data-sticky":N(e.sticky)?"true":null,"data-blur":N(e.blur)?"true":null});e.brand!=null&&n.append(r.renderNode(e.brand));const a=T(e.links);if(a.length>0){const o=c("nav",{class:"rui-navbar2-links",id:"rui-navbar2-menu","aria-label":"Primary"});for(const u of a)o.append(r.renderNode(u));n.append(o);const s=c("button",{class:"rui-navbar2-burger",type:"button","aria-label":"Menu","aria-expanded":"false","aria-controls":"rui-navbar2-menu"}),l=L("bars");l?s.append(l):s.textContent="≡",s.onclick=u=>{const d=u.currentTarget??u.target,p=d?.closest(".rui-navbar2");if(!p)return;const f=p.getAttribute("data-menu-open")==="true";p.setAttribute("data-menu-open",f?"false":"true"),d?.setAttribute("aria-expanded",f?"false":"true")},n.append(s)}const i=c("div",{class:"rui-navbar2-actions"});for(const o of T(e.actions))i.append(r.renderNode(o));return n.append(i),n}},wh={name:"FooterColumn",description:"A titled column of links inside a Footer.",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"links",type:"Node[]",aliases:["children","items"]}],render:(t,e,r)=>{const n=c("div",{class:"rui-footer-col"});n.append(c("h5",{},[m(e.title)]));const a=c("div",{class:"rui-footer-col-links"});for(const i of T(e.links))a.append(r.renderNode(i));return n.append(a),n}},kh={name:"Footer",description:"Site footer: brand + tagline in a wide first column, then link columns, and a legal/copyright line. Pass `columns` as FooterColumn nodes.",props:[{name:"brand",type:"Node",optional:!0},{name:"tagline",type:"string",optional:!0},{name:"columns",type:"FooterColumn[]",optional:!0},{name:"legal",type:"string",optional:!0,aliases:["copyright"]}],render:(t,e,r)=>{const n=c("footer",{class:"rui-footer"}),a=T(e.columns),i=c("div",{class:"rui-footer-grid",style:`--ak-foot-cols:${Math.max(1,a.length)}`}),o=c("div",{class:"rui-footer-brand"});e.brand!=null&&o.append(r.renderNode(e.brand));const s=m(e.tagline);s&&o.append(c("p",{class:"rui-footer-tagline"},[s])),i.append(o);for(const u of a)i.append(r.renderNode(u));n.append(i);const l=m(e.legal);return l&&n.append(c("div",{class:"rui-footer-legal"},[l])),n}},Sh={name:"LogoChip",description:"A single labelled chip (icon + name) for a LogoCloud.",props:[{name:"label",type:"string",positional:!0,required:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome name (e.g. brands:react)"}],render:(t,e)=>{const r=c("span",{class:"rui-logochip"}),n=L(e.icon);return n&&r.append(n),r.append(document.createTextNode(m(e.label))),r}},$h={name:"LogoCloud",description:"A centered, wrapping row of LogoChip items with an optional label — 'works with' / 'trusted by' bands.",props:[{name:"items",type:"LogoChip[]",positional:!0,required:!0,aliases:["children","chips"]},{name:"label",type:"string",optional:!0}],render:(t,e,r)=>{const n=c("div",{class:"rui-logocloud"}),a=m(e.label);a&&n.append(c("p",{class:"rui-logocloud-label"},[a]));const i=c("div",{class:"rui-logocloud-row"});for(const o of T(e.items))i.append(r.renderNode(o));return n.append(i),n}};function _o(t,e,r,n,a,i){const o=u=>{t.textContent=`${n}${Math.round(u)}${r}`};o(0);let s=!1;const l=()=>{if(s)return;s=!0;const u=performance.now(),d=p=>{const f=Math.min(1,(p-u)/a),b=1-Math.pow(1-f,3);o(e*b),f<1&&t.isConnected&&requestAnimationFrame(d)};requestAnimationFrame(d)};setTimeout(()=>{if(typeof IntersectionObserver>"u"){l();return}const u=new IntersectionObserver(d=>{for(const p of d)p.isIntersecting&&(l(),u.disconnect())},{threshold:.4});u.observe(t),i?.registerDisposer(()=>u.disconnect(),"rui-countup-io")},0)}const Ch={name:"CountUp",description:"A number that animates from 0 to `value` when scrolled into view. `prefix`/`suffix` wrap it (e.g. `$`, `+`, `%`). Respects reduced motion.",props:[{name:"value",type:"number",positional:!0,required:!0},{name:"suffix",type:"string",optional:!0},{name:"prefix",type:"string",optional:!0},{name:"duration",type:"number",optional:!0,description:"Animation ms (default 1000)"}],render:(t,e,r)=>{const n=c("span",{class:"rui-countup"}),a=I(e.value,0);return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches?n.textContent=`${m(e.prefix)}${a}${m(e.suffix)}`:_o(n,a,m(e.suffix),m(e.prefix),Math.max(200,I(e.duration,1e3)),r),n}},Ah={name:"Metric",description:"A single big-number metric tile with a gradient accent bar and label. Use inside MetricStrip. Set `countUp` to animate.",props:[{name:"value",type:"string | number",positional:!0,required:!0},{name:"label",type:"string",optional:!0},{name:"gradient",type:"boolean",optional:!0,description:"Paint the number with the brand gradient"},{name:"countUp",type:"boolean",optional:!0,description:"Animate numeric value from 0 on scroll-in"}],render:(t,e,r)=>{const n=c("div",{class:"rui-metric"}),a=e.gradient===void 0?!0:N(e.gradient),i=c("div",{class:"rui-metric-value","data-gradient":a?"true":null}),o=m(e.value),s=Number(o.replace(/[^0-9.]/g,"")),l=o.replace(/[0-9.,\s]/g,""),u=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;N(e.countUp)&&Number.isFinite(s)&&s>0&&!u?_o(i,s,l,"",1e3,r):i.textContent=o,n.append(i);const d=m(e.label);return d&&n.append(c("div",{class:"rui-metric-label"},[d])),n}},Th={name:"MetricStrip",description:"A responsive row/grid of Metric tiles. `columns` sets the preferred count.",props:[{name:"items",type:"Metric[]",positional:!0,required:!0,aliases:["children","metrics"]},{name:"columns",type:"number",optional:!0}],render:(t,e,r)=>{const n=Math.max(1,Math.min(6,Math.round(I(e.columns,4)))),a=c("div",{class:"rui-metricstrip",style:`--ak-metric-cols:${n}`});for(const i of T(e.items))a.append(r.renderNode(i));return a}};function Uo(t,e,r){const n=c("div",{class:"rui-window-bar"}),a=c("span",{class:"rui-window-dots"});if(a.append(c("i"),c("i"),c("i")),n.append(a),t&&n.append(c("span",{class:"rui-window-file"},[t])),e!=null){const i=c("span",{class:"rui-window-status"});i.append(e instanceof Node?e:r.renderNode(e)),n.append(i)}return n}function Mh(t){if(typeof t=="string")return t;if(t==null||typeof t!="object")return"";const e=t;return e.__kind!=="Component"||!Array.isArray(e.args)?"":e.name==="CodeBlock"?m(rr(sr,e.args).codeString):m(e.args.find(r=>typeof r=="string"))}const Nh={aktion:"aktion",js:"js",mjs:"js",cjs:"js",jsx:"jsx",ts:"ts",tsx:"tsx",py:"py",css:"css",scss:"scss",less:"less",json:"json",html:"html",xml:"xml",svg:"svg",vue:"vue",sh:"bash",bash:"bash",zsh:"bash",md:"md",yml:"yaml",yaml:"yaml",sql:"sql"};function Ih(t){const e=/\.([a-z0-9]+)$/i.exec(t.trim())?.[1]?.toLowerCase();return e?Nh[e]??"":""}const Ho=new WeakSet,Ph={name:"CodeWindow",description:"An editor/IDE window chrome (traffic-light dots + filename + status area) around source code. Pass the code as a plain STRING — it renders through a chromeless CodeBlock that fills the pane (no inner border, language label, or copy button), syntax-highlighted via `language` (default: inferred from the `file` extension, else aktion). Set `preview: true` to run the source as a LIVE app beside the code (split view with a pulsing 'Live render' badge); a custom node is also accepted for non-Aktion previews. The canonical way to show code in docs/marketing.",props:[{name:"code",type:"string",positional:!0,required:!0,aliases:["codeString"],description:"Source text (a legacy CodeBlock(...) node is also accepted)"},{name:"file",type:"string",optional:!0,description:"Filename shown in the title bar"},{name:"language",type:"string",optional:!0,description:"Highlight language (default: from the file extension, else aktion)"},{name:"status",type:"Node",optional:!0,description:"A Badge shown at the right of the bar"},{name:"preview",type:"boolean | Node",optional:!0,description:"true → run the source as a live Aktion preview; or a custom node"}],render:(t,e,r)=>{const n=m(e.file),a=e.code!=null&&typeof e.code=="object"?e.code:null,i=Mh(e.code);let o=m(e.language);!o&&a?.name==="CodeBlock"&&Array.isArray(a.args)&&(o=m(rr(sr,a.args).language)),o||(o=Ih(n)||"aktion");const s=e.preview===!0||e.preview==="true",l=!s&&e.preview!=null&&e.preview!==!1&&e.preview!=="false"?e.preview:null,u=s||l!=null,d=c("div",{class:"rui-codewindow"}),p=u&&e.status==null?c("span",{class:"rui-window-live"},[c("span",{class:"rui-window-live-dot"}),"Live render"]):e.status;d.append(Uo(n,p,r));const f=c("div",{class:"rui-codewindow-body","data-split":u?"true":null}),b=c("div",{class:"rui-codewindow-code"});if(i||a==null?b.append(sr.render({__kind:"Component",name:"CodeBlock",args:[],argMeta:[]},{codeString:i,language:o,header:!1},r)):b.append(r.renderNode(a)),f.append(b),u){const h=c("div",{class:"rui-codewindow-preview"});s?h.append(Eh(i,d,r)):h.append(r.renderNode(l)),f.append(h)}return d.append(f),d}};function Eh(t,e,r){const n=document.createElement("aktion-app");n.setAttribute("response",t);const a=r.useInstanceState("rui-codewindow-theme","");return a.get()&&n.setAttribute("theme",a.get()),setTimeout(()=>{if(!n.isConnected||Ho.has(n))return;Ho.add(n);const i=e.getRootNode(),o=i instanceof ShadowRoot?i.host:null;if(!o)return;const s=()=>{const u=o.getAttribute("theme")??"";a.set(u),u?n.setAttribute("theme",u):n.removeAttribute("theme")};s();const l=new MutationObserver(s);l.observe(o,{attributes:!0,attributeFilter:["theme"]}),r.registerDisposer(()=>l.disconnect(),"rui-codewindow-theme-sync")},0),n}const zh={name:"BrowserFrame",description:"A browser-window chrome (dots + URL bar) wrapping a child — for screenshots/demos of web UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children","content"]},{name:"url",type:"string",optional:!0}],render:(t,e,r)=>{const n=c("div",{class:"rui-browserframe"}),a=c("div",{class:"rui-browserframe-bar"}),i=c("span",{class:"rui-window-dots"});i.append(c("i"),c("i"),c("i")),a.append(i),a.append(c("span",{class:"rui-browserframe-url"},[m(e.url,"example.com")])),n.append(a);const o=c("div",{class:"rui-browserframe-body"});return e.child!=null&&o.append(r.renderNode(e.child)),n.append(o),n}},Rh={name:"Terminal",description:"A terminal window rendering monospace lines. Pass `lines` as an array of strings.",props:[{name:"lines",type:"string[]",positional:!0,required:!0,aliases:["children","content"]},{name:"file",type:"string",optional:!0,description:"Title-bar label (default 'bash')"}],render:(t,e,r)=>{const n=c("div",{class:"rui-terminal"});n.append(Uo(m(e.file,"bash"),null,r));const a=c("div",{class:"rui-terminal-body"}),i=T(e.lines);return a.textContent=i.map(o=>m(o)).join(`
|
|
103
|
-
`),n.append(a),n}},Lh=[{t:"-160px",l:"-120px",d:"0s"},{t:"-80px",r:"-120px",d:"-6s"},{t:"46%",l:"34%",d:"-12s"}],In=["network","drift","snow","stars","bubbles"],qo=["#6366f1","#8b5cf6","#ec4899","#22d3ee"],Vo=(t,e)=>/^[#a-zA-Z0-9(),.%\s-]+$/.test(t)&&t.length<=64&&t.trim()!==""?t.trim():e,vr=new WeakSet;function Dh(t,e){if(!t.isConnected||vr.has(t))return;const r=t.getContext("2d");if(!r)return;vr.add(t);const n=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;let a=[],i=0,o=0,s=1,l="",u=0,d=0;const p=()=>{const v=Math.max(0,Math.min(120,Math.round(Number(t.dataset.count)||0))),x=t.dataset.type??"network",w=In.includes(x)?x:"network",k=Math.max(.1,Math.min(4,Number(t.dataset.speed)||1)),A=Math.max(40,Math.min(240,Number(t.dataset.link)||130)),S=Math.max(.5,Math.min(6,Number(t.dataset.size)||2.2)),$=(t.dataset.colors??"").split(",").map(C=>C.trim()).filter(Boolean);return{count:v,type:w,speed:k,link:A,size:S,colors:$.length>0?$:qo}},f=()=>{const v=p();a=Array.from({length:v.count},(x,w)=>({x:Math.random()*i,y:Math.random()*o,vx:(Math.random()-.5)*.5*s,vy:(Math.random()-.5)*.5*s,r:(Math.random()*(v.size-.5)+.5)*s,c:v.colors[w%v.colors.length],phase:Math.random()*Math.PI*2}))},b=()=>{const x=(t.parentElement??t).getBoundingClientRect();s=Math.min((typeof window<"u"?window.devicePixelRatio:1)||1,2),i=Math.max(1,Math.round(x.width*s)),o=Math.max(1,Math.round(x.height*s)),t.width=i,t.height=o,f()},h=()=>{const v=p(),x=`${v.count}|${v.type}|${v.colors.join(",")}`;x!==l&&(l=x,f()),t.width!==i&&(t.width=i),t.height!==o&&(t.height=o),r.clearRect(0,0,i,o),d+=1;const w=v.speed;for(const k of a){switch(v.type){case"drift":k.x+=k.vx*.5*w,k.y+=k.vy*.5*w,k.x<-10&&(k.x=i+10),k.x>i+10&&(k.x=-10),k.y<-10&&(k.y=o+10),k.y>o+10&&(k.y=-10),r.globalAlpha=.35+.3*Math.abs(Math.sin(d/60+k.phase));break;case"snow":k.y+=(.4+Math.abs(k.vy))*w,k.x+=Math.sin(d/50+k.phase)*.4*s,k.y>o+6&&(k.y=-6,k.x=Math.random()*i),r.globalAlpha=.8;break;case"stars":r.globalAlpha=.15+.65*Math.abs(Math.sin(d/40*w+k.phase));break;case"bubbles":k.y-=(.5+Math.abs(k.vy))*w,k.x+=Math.sin(d/40+k.phase)*.5*s,k.y<-10&&(k.y=o+10,k.x=Math.random()*i),r.globalAlpha=.5;break;default:k.x+=k.vx*w,k.y+=k.vy*w,(k.x<0||k.x>i)&&(k.vx*=-1),(k.y<0||k.y>o)&&(k.vy*=-1),r.globalAlpha=.7}r.beginPath(),r.arc(k.x,k.y,k.r,0,Math.PI*2),v.type==="bubbles"?(r.strokeStyle=k.c,r.lineWidth=s,r.stroke(),r.globalAlpha=.08,r.fillStyle=k.c,r.fill()):(r.fillStyle=k.c,r.fill())}if(v.type==="network"){const k=v.link*s;for(let A=0;A<a.length;A+=1)for(let S=A+1;S<a.length;S+=1){const $=a[A],C=a[S],M=Math.hypot($.x-C.x,$.y-C.y);M<k&&(r.beginPath(),r.moveTo($.x,$.y),r.lineTo(C.x,C.y),r.strokeStyle=$.c,r.globalAlpha=(1-M/k)*.18,r.lineWidth=s*.6,r.stroke())}}r.globalAlpha=1},g=()=>{if(u=0,!t.isConnected){vr.delete(t);return}h(),u=requestAnimationFrame(g)};b(),n?h():u=requestAnimationFrame(g);const y=typeof ResizeObserver<"u"?new ResizeObserver(b):null;y?.observe(t.parentElement??t),e.registerDisposer(()=>{u&&cancelAnimationFrame(u),y?.disconnect(),vr.delete(t)},"rui-backdrop-engine")}const jh={name:"Backdrop",description:"Decorative background layer for hero/marketing sections: a masked grid, floating blurred color 'blobs', and an animated canvas particle field. `type` picks the particle behaviour — `network` (drifting dots joined by constellation lines, the default), `drift`, `snow`, `stars`, or `bubbles` — tuned via `particleColors`, `speed`, `linkDistance`, and `particleSize`. All theme-aware and motion-safe. Place as the first child of a Section (which is `position: relative`).",props:[{name:"grid",type:"boolean",optional:!0,description:"Show the masked line grid"},{name:"blobs",type:"string[]",optional:!0,description:"Colors for floating blur orbs (CSS colors)"},{name:"particles",type:"number",optional:!0,description:"Particle count (0 = none, max 120)"},{name:"type",type:"string",optional:!0,enum:[...In],aliases:["particleType"],description:"Particle behaviour (default network)"},{name:"particleColors",type:"string[]",optional:!0,aliases:["colors"],description:"Particle palette (CSS colors; defaults to the brand palette)"},{name:"speed",type:"number",optional:!0,description:"Animation speed multiplier 0.1–4 (default 1)"},{name:"linkDistance",type:"number",optional:!0,description:"Max px between linked network particles (default 130)"},{name:"particleSize",type:"number",optional:!0,description:"Max particle radius in px (default 2.2)"},{name:"fixed",type:"boolean",optional:!0,description:"Pin to the viewport instead of the section"}],render:(t,e,r)=>{const n=c("div",{class:"rui-backdrop","data-fixed":N(e.fixed)?"true":null,"aria-hidden":"true"});N(e.grid)&&n.append(c("div",{class:"rui-backdrop-grid"})),T(e.blobs).slice(0,3).forEach((o,s)=>{const l=m(o),u=Lh[s],d=460-s*40,p=[`width:${d}px`,`height:${d}px`,u.t?`top:${u.t}`:"",u.l?`left:${u.l}`:"",u.r?`right:${u.r}`:"",`background:radial-gradient(circle, ${Vo(l,"#6366f1")}, transparent 70%)`,`animation-delay:${u.d}`].filter(Boolean).join(";");n.append(c("div",{class:"rui-backdrop-blob",style:p}))});const i=Math.max(0,Math.min(120,Math.round(I(e.particles||50,0))));if(i>0){const o=m(e.type,"network"),s=T(e.particleColors).map(u=>Vo(m(u),"")).filter(Boolean).slice(0,8),l=c("canvas",{class:"rui-backdrop-canvas","data-count":String(i),"data-type":In.includes(o)?o:"network","data-speed":String(Math.max(.1,Math.min(4,I(e.speed,1)))),"data-link":String(Math.max(40,Math.min(240,I(e.linkDistance,130)))),"data-size":String(Math.max(.5,Math.min(6,I(e.particleSize,2.2)))),"data-colors":(s.length>0?s:qo).join(",")});n.append(l),setTimeout(()=>Dh(l,r),0)}return n}},Bh={name:"ThemeToggle",description:"A sun/moon button that toggles the host between light and dark themes — no host glue required. It flips the <aktion-app> `theme` attribute and dispatches a `theme-change` event the host can listen for.",props:[{name:"light",type:"string",optional:!0,description:"Theme name when toggled to light (default 'light')"},{name:"dark",type:"string",optional:!0,description:"Theme name when toggled to dark (default 'dark')"}],render:(t,e)=>{const r=m(e.light,"light"),n=m(e.dark,"dark"),a=c("button",{class:"rui-theme-toggle",type:"button","aria-label":"Toggle dark mode",title:"Toggle theme"}),i=L("moon");i&&a.append(i);const o=l=>{const u=l?.getRootNode?.();return u&&u.host?u.host:void 0},s=l=>{const u=o(l),d=u?(u.getAttribute("theme")||"").toLowerCase().includes("dark"):!1;(l??a).replaceChildren(L(d?"sun":"moon")??document.createTextNode(""))};return setTimeout(()=>s(a),0),a.onclick=l=>{const u=l.currentTarget??l.target,d=o(u);if(!d)return;const f=(d.getAttribute("theme")||r).toLowerCase().includes("dark")?r:n;d.setAttribute("theme",f),d.dispatchEvent(new CustomEvent("theme-change",{detail:{theme:f},bubbles:!0,composed:!0})),setTimeout(()=>s(u),0)},a}},Oh={name:"Swatch",description:"A theme/palette preview tile — color dots over a named background. For theming galleries.",props:[{name:"name",type:"string",positional:!0,required:!0},{name:"background",type:"string",optional:!0,description:"Tile background CSS color"},{name:"foreground",type:"string",optional:!0,description:"Tile text CSS color"},{name:"colors",type:"string[]",optional:!0,description:"Accent dot colors"}],render:(t,e)=>{const r=(s,l)=>/^[#a-zA-Z0-9(),.%\s-]+$/.test(s)&&s.length<=64?s:l,n=r(m(e.background,"#ffffff"),"#ffffff"),a=r(m(e.foreground,"#0f172a"),"#0f172a"),i=c("div",{class:"rui-swatch",style:`background:${n};color:${a}`}),o=c("div",{class:"rui-swatch-dots"});for(const s of T(e.colors).slice(0,5))o.append(c("i",{style:`background:${r(m(s),"#6366f1")}`}));return i.append(o),i.append(c("div",{class:"rui-swatch-name"},[m(e.name)])),i}},Pn=new WeakMap,Fh={name:"CopyButton",description:"A button that copies `text` to the clipboard and confirms it — the label flips to `copiedLabel` (default 'Copied!') with a check icon for a couple of seconds, then reverts. Bounded, no host glue.",props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["value"]},{name:"label",type:"string",optional:!0,description:"Button label (default 'Copy')"},{name:"copiedLabel",type:"string",optional:!0,description:"Confirmation label (default 'Copied!')"}],render:(t,e)=>{const r=m(e.label,"Copy"),n=m(e.copiedLabel,"Copied!"),a=c("button",{class:"rui-copy-button",type:"button"}),i=L("copy",{className:"rui-copy-button-icon"});return i&&a.append(i),a.append(c("span",{class:"rui-copy-button-label"},[r])),a.onclick=o=>{const s=o.currentTarget??o.target??a,l=m(e.text),u=()=>{try{const f=document.createElement("textarea");f.value=l,f.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none",document.body.append(f),f.select(),document.execCommand("copy"),f.remove()}catch{}};try{const f=navigator.clipboard?.writeText(l);f&&typeof f.catch=="function"?f.catch(u):navigator.clipboard||u()}catch{u()}const d=f=>{f?s.setAttribute("data-copied","true"):s.removeAttribute("data-copied");const b=s.querySelector(".rui-copy-button-label");b&&(b.textContent=f?n:r);const h=s.querySelector(".rui-copy-button-icon");if(h){const g=L(f?"check":"copy",{className:"rui-copy-button-icon"});g&&h.replaceWith(g)}};d(!0);const p=Pn.get(s);p&&clearTimeout(p),Pn.set(s,setTimeout(()=>{Pn.delete(s),d(!1)},2e3))},a}},_h={name:"SegmentedControl",description:"A compact segmented toggle (iOS-style). `options` is an array of strings or {label, value}. Bind `value` to a $variable; `onChange(value)` fires on select.",props:[{name:"options",type:"any[]",positional:!0,required:!0,aliases:["items"]},{name:"value",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=c("div",{class:"rui-segmented",role:"tablist"}),a=m(e.value);for(const i of T(e.options)){const o=i&&typeof i=="object"?i:{label:i,value:i},s=m(o.value??o.label),l=m(o.label??o.value),u=c("button",{type:"button",role:"tab","aria-pressed":s===a?"true":"false"},[l]);u.onclick=()=>{const d=t.argMeta?.[1];d?.stateRef&&r.setState(d.stateRef,s),r.invoke(e.onChange,s)},n.append(u)}return n}},Uh={name:"FloatingActionButton",description:"A fixed circular action button (FAB) anchored bottom-right. `icon` + `onClick`.",props:[{name:"icon",type:"string",positional:!0,required:!0},{name:"label",type:"string",optional:!0,description:"Accessible label"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const n=c("button",{class:"rui-fab",type:"button","aria-label":m(e.label,"Action")}),a=L(e.icon,{size:"lg"});return a&&n.append(a),n.onclick=()=>r.invoke(e.onClick),n}},Hh={name:"Prose",description:"A styled long-form reading container — applies typographic defaults to headings, lists, blockquotes, code, links inside. Wrap Markdown(...) or raw nodes for blog posts, docs bodies, product descriptions.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]}],render:(t,e,r)=>{const n=c("div",{class:"rui-prose","data-size":m(e.size,"md")});for(const a of T(e.children))typeof a=="string"?n.append(document.createTextNode(a)):n.append(r.renderNode(a));return n}},qh={name:"RelativeTime",description:"Renders a human relative time ('3m ago', 'in 2 days') from an ISO date/timestamp, localized via Intl.",props:[{name:"value",type:"string | number",positional:!0,required:!0,aliases:["date","time"]}],render:(t,e)=>{const r=e.value,n=typeof r=="number"?new Date(r):new Date(m(r)),a=c("span",{class:"rui-relative-time"});if(Number.isNaN(n.getTime()))return a.textContent=m(r),a;const i=n.getTime()-Date.now(),o=Math.abs(i),s=[["year",31536e6],["month",2592e6],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];let l="just now";try{const u=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[d,p]of s)if(o>=p||d==="second"){l=u.format(Math.round(i/p),d);break}}catch{l=n.toLocaleString()}return a.textContent=l,a.setAttribute("title",n.toLocaleString()),a}},Wo={name:"PriceTag",description:"A formatted price with an optional struck-through compare-at price and a discount badge.",props:[{name:"price",type:"string | number",positional:!0,required:!0},{name:"compareAt",type:"string | number",optional:!0,aliases:["was","original"]},{name:"currency",type:"string",optional:!0,description:"Currency symbol/prefix (default '$')"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]}],render:(t,e)=>{const r=m(e.currency,"$"),n=i=>`${r}${m(i)}`,a=c("span",{class:"rui-pricetag","data-size":m(e.size,"md")});if(a.append(c("span",{class:"rui-pricetag-now"},[n(e.price)])),e.compareAt!=null&&m(e.compareAt)!==""){a.append(c("span",{class:"rui-pricetag-was"},[n(e.compareAt)]));const i=Number(m(e.price).replace(/[^0-9.]/g,"")),o=Number(m(e.compareAt).replace(/[^0-9.]/g,""));if(Number.isFinite(i)&&Number.isFinite(o)&&o>i&&o>0){const s=Math.round((1-i/o)*100);a.append(c("span",{class:"rui-pricetag-off"},[`-${s}%`]))}}return a}},Vh={name:"QuantityStepper",description:"A −/value/+ numeric stepper. Bind `value` to a $variable; `onChange(value)` fires on change. Respects min/max.",props:[{name:"value",type:"number",positional:!0,required:!0},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=e.min!=null?I(e.min):-1/0,a=e.max!=null?I(e.max):1/0,i=I(e.step,1),o=I(e.value,0),s=t.argMeta?.[0]?.stateRef,l=c("div",{class:"rui-qty"}),u=b=>{const h=Math.min(a,Math.max(n,b));s&&r.setState(s,h),r.invoke(e.onChange,h)},d=c("button",{type:"button","aria-label":"Decrease",disabled:o<=n?"":null},["−"]);d.onclick=()=>u(o-i);const p=c("span",{class:"rui-qty-value"},[String(o)]),f=c("button",{type:"button","aria-label":"Increase",disabled:o>=a?"":null},["+"]);return f.onclick=()=>u(o+i),l.append(d,p,f),l}},Wh={name:"ProductCard",description:"An e-commerce product card: image, title, optional rating, a PriceTag, and an add-to-cart action. Pass `price`/`compareAt` directly or a custom `price` node.",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"image",type:"string",optional:!0,aliases:["src"]},{name:"price",type:"string | number",optional:!0},{name:"compareAt",type:"string | number",optional:!0},{name:"currency",type:"string",optional:!0},{name:"rating",type:"number",optional:!0,description:"0–5 stars"},{name:"badge",type:"string",optional:!0,description:"Corner ribbon label (e.g. 'Sale')"},{name:"action",type:"Node",optional:!0,description:"Add-to-cart Button (defaults to one)"},{name:"onAdd",type:"callable",optional:!0,description:"Fired by the default add button"}],render:(t,e,r)=>{const n=c("div",{class:"rui-product-card"}),a=c("div",{class:"rui-product-media"}),i=re(e.image);i&&a.append(c("img",{src:i,alt:m(e.title),loading:"lazy"}));const o=m(e.badge);o&&a.append(c("span",{class:"rui-product-badge"},[o])),n.append(a);const s=c("div",{class:"rui-product-body"});s.append(c("h3",{class:"rui-product-title"},[m(e.title)]));const l=Math.max(0,Math.min(5,Math.round(I(e.rating,0))));if(l>0){const d=c("div",{class:"rui-product-rating"});for(let p=0;p<5;p+=1){const f=L(p<l?"star":"regular:star");f&&d.append(f)}s.append(d)}const u=c("div",{class:"rui-product-foot"});if(e.price!=null&&u.append(Wo.render({__kind:"Component",name:"PriceTag",args:[],argMeta:[]},{price:e.price,compareAt:e.compareAt,currency:e.currency},r)),e.action!=null)u.append(r.renderNode(e.action));else if(typeof e.onAdd=="function"){const d=c("button",{class:"rui-product-add",type:"button","aria-label":"Add to cart"}),p=L("cart-plus");p&&d.append(p),d.onclick=()=>r.invoke(e.onAdd),u.append(d)}return s.append(u),n.append(s),n}},Gh={name:"TableOfContents",description:"A navigable table of contents. `items` is an array of {label, href, level?}.",props:[{name:"items",type:"object[]",positional:!0,required:!0,aliases:["children"]},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=c("nav",{class:"rui-toc","aria-label":"Table of contents"}),n=m(e.title);n&&r.append(c("div",{class:"rui-toc-title"},[n]));const a=c("ul",{class:"rui-toc-list"});for(const i of T(e.items)){const o=i??{},s=c("li",{class:"rui-toc-item","data-level":String(Math.max(1,Math.min(4,Math.round(I(o.level,1)))))});s.append(c("a",{href:Fe(o.href,"#")},[m(o.label)])),a.append(s)}return r.append(a),r}},Kh={name:"TypingIndicator",description:"Three animated bouncing dots — a chat 'is typing…' affordance. Optional `name` prefix.",props:[{name:"name",type:"string",optional:!0,positional:!0}],render:(t,e)=>{const r=c("div",{class:"rui-typing",role:"status"}),n=m(e.name);n&&r.append(c("span",{class:"rui-typing-name"},[`${n} is typing`]));const a=c("span",{class:"rui-typing-dots","aria-label":"typing"});return a.append(c("i"),c("i"),c("i")),r.append(a),r}},Yh={name:"CountdownTimer",description:"Live countdown to a target date/time (ISO string or timestamp). Ticks every second, then shows `endLabel`.",props:[{name:"to",type:"string | number",positional:!0,required:!0,aliases:["target","date"]},{name:"endLabel",type:"string",optional:!0,description:"Shown when the countdown finishes (default 'Done')"}],render:(t,e,r)=>{const n=typeof e.to=="number"?e.to:new Date(m(e.to)).getTime(),a=c("div",{class:"rui-countdown",role:"timer"}),i=f=>{const b=c("div",{class:"rui-countdown-unit"}),h=c("div",{class:"rui-countdown-value"},["00"]);return b.append(h,c("div",{class:"rui-countdown-label"},[f])),{u:b,v:h}},o=i("days"),s=i("hrs"),l=i("min"),u=i("sec");a.append(o.u,s.u,l.u,u.u);const d=f=>String(Math.max(0,f)).padStart(2,"0"),p=()=>{const f=n-Date.now();if(!Number.isFinite(n)||f<=0)return a.replaceChildren(c("div",{class:"rui-countdown-done"},[m(e.endLabel,"Done")])),!1;const b=Math.floor(f/1e3);return o.v.textContent=d(Math.floor(b/86400)),s.v.textContent=d(Math.floor(b%86400/3600)),l.v.textContent=d(Math.floor(b%3600/60)),u.v.textContent=d(b%60),!0};if(p()){const f=setInterval(()=>{p()||clearInterval(f)},1e3);r.registerDisposer(()=>clearInterval(f),"countdown")}return a}},Xh={name:"BackToTop",description:"A floating button that smoothly scrolls the page (and the host) back to the top.",props:[{name:"label",type:"string",optional:!0}],render:(t,e)=>{const r=c("button",{class:"rui-fab rui-backtotop",type:"button","aria-label":m(e.label,"Back to top")}),n=L("arrow-up",{size:"lg"});return n&&r.append(n),r.onclick=()=>{try{window.scrollTo({top:0,behavior:"smooth"})}catch{window.scrollTo(0,0)}r.getRootNode()?.host?.scrollIntoView?.({behavior:"smooth",block:"start"})},r}};function Ae(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=document.createDocumentFragment();for(const n of e)n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}const Zh={"1/1":"1fr 1fr","1/2":"1fr 2fr","2/1":"2fr 1fr","2/3":"2fr 3fr","3/2":"3fr 2fr","1/3":"1fr 3fr","3/1":"3fr 1fr","2/5":"2fr 5fr","5/2":"5fr 2fr"},Qh={name:"Split",description:"Two-pane layout: a left/primary node and a right/secondary node, with a controllable `ratio` (1/1, 3/2, 2/3…), optional `divider`, an optional `sticky` pane that pins on scroll, and a `stackAt` breakpoint where it collapses to a single column. The canonical 'text + media' / 'code + preview' / 'content + sidebar' section.",props:[{name:"left",type:"Node",positional:!0,required:!0,aliases:["primary"]},{name:"right",type:"Node",required:!0,aliases:["secondary"]},{name:"ratio",type:"string",optional:!0,description:"Column ratio: 1/1, 3/2, 2/3, 1/3, 2/1, etc."},{name:"gap",type:"string",optional:!0,enum:ue},{name:"divider",type:"boolean",optional:!0},{name:"sticky",type:"string",optional:!0,enum:["left","right"],description:"Pin one pane while the other scrolls"},{name:"stackAt",type:"string",optional:!0,enum:["sm","md","lg"],description:"Breakpoint below which it stacks (default md)"},{name:"align",type:"string",optional:!0,enum:["start","center","stretch"]}],render:(t,e,r)=>{const n=Zh[m(e.ratio,"1/1")]??"1fr 1fr",a=mi(m(e.gap,"lg"))||"var(--rui-spacing-l)",i=c("div",{class:"rui-split","data-divider":N(e.divider)?"true":null,"data-stack":m(e.stackAt,"md"),"data-align":m(e.align)||null,style:`grid-template-columns:${n};gap:${a}`}),o=c("div",{class:"rui-split-pane","data-sticky":m(e.sticky)==="left"?"true":null});o.append(Ae(r,e.left));const s=c("div",{class:"rui-split-pane","data-sticky":m(e.sticky)==="right"?"true":null});return s.append(Ae(r,e.right)),i.append(o,s),i}},Go={tile:{col:1,row:1},wide:{col:2,row:1},tall:{col:1,row:2},hero:{col:2,row:2}};function Jh(t){const e=n=>Math.max(1,Math.min(8,Math.round(n))),r=n=>Math.max(1,Math.min(4,Math.round(n)));if(typeof t=="number")return{col:e(t),row:1,name:null};if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="full")return{col:1,row:1,name:"full"};if(Go[n])return{...Go[n],name:n};const a=/^(\d+)\s*[x×]\s*(\d+)$/.exec(n);if(a)return{col:e(Number(a[1])),row:r(Number(a[2])),name:null};const i=Number(n);return Number.isFinite(i)&&i>0?{col:e(i),row:1,name:null}:{col:1,row:1,name:null}}if(t&&typeof t=="object"){const n=t;return{col:e(I(n.col,1)),row:r(I(n.row,1)),name:null}}return{col:1,row:1,name:null}}const eb={name:"BentoCell",description:'A single cell in a Bento grid. `span` names a size — `tile` 1×1, `wide` 2×1 (2 columns), `tall` 1×2 (2 rows), `hero` 2×2, `full` (a whole row) — or use a "CxR" string ("2x1"), a bare column-span number, or `{ col, row }`; `rowSpan` adds rows to a named/numeric span. The child stretches to fill the cell, so images/cards crop to the cell\'s shape. Pick spans that tile the parent Bento with no leftover tracks.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"span",type:"string | number | object",optional:!0,description:'tile (1×1) | wide (2×1) | tall (1×2) | hero (2×2) | full (whole row), "2x1", 2, or { col, row }'},{name:"rowSpan",type:"number",optional:!0,description:"Rows to span (combines with a numeric/named span)"}],render:(t,e,r)=>{let{col:n,row:a,name:i}=Jh(e.span);e.rowSpan!==void 0&&(a=Math.max(1,Math.min(4,Math.round(I(e.rowSpan,a)))));const o=c("div",{class:"rui-bento-cell","data-span":i,style:`--rui-cell-col:${n};--rui-cell-row:${a}`});return o.append(Ae(r,e.child)),o}},tb={name:"Bento",description:"Asymmetric 'bento box' grid — the marquee feature-section layout. Children must be BentoCell nodes (a plain node becomes a 1×1 tile). Two rules make it look right: (1) spans must tile the grid exactly — each row's column spans sum to `columns` and row-spans pair up with neighbouring cells, never leaving a dangling track (e.g. `columns: 3` with 4 cells: hero 2×2 + tall 1×2 fill rows 1–2, wide 2×1 + tile fill row 3); (2) set a fixed `rowHeight` (e.g. \"180px\") whenever cells hold images or cards — the default auto row stretches to the tallest cell and makes the mosaic ragged. Give 1–2 standout cells a big span (hero/wide/tall) and keep the rest 1×1 tiles. `dense` (default true) backfills gaps. Collapses to 2 columns below 920px and 1 below 640px.",props:[{name:"items",type:"BentoCell[]",positional:!0,required:!0,aliases:["children","cells"]},{name:"columns",type:"number",optional:!0,description:"Track count 1–8 (default 6) — pick it so the cell spans in every row can sum to it"},{name:"gap",type:"string",optional:!0,enum:ue},{name:"rowHeight",type:"string",optional:!0,description:'Fixed row track size, e.g. "180px" — set it whenever any cell spans rows or holds images (default minmax(110px, auto) stretches rows to content)'},{name:"dense",type:"boolean",optional:!0,description:"Backfill holes with later cells (default true)"}],render:(t,e,r)=>{const n=Math.max(1,Math.min(8,Math.round(I(e.columns,6)))),a=ge(e.gap,"md"),i=X(e.rowHeight,""),o=e.dense===void 0?!0:N(e.dense),s=c("div",{class:"rui-bento","data-cols":String(n),"data-gap":a,"data-dense":o?"true":null,style:i?`--rui-bento-row:${i}`:null});for(const l of T(e.items)){const u=r.renderNode(l);if(u instanceof HTMLElement&&u.classList.contains("rui-bento-cell")){const d=Number.parseInt(u.style.getPropertyValue("--rui-cell-col"),10);Number.isFinite(d)&&d>n&&u.style.setProperty("--rui-cell-col",String(n))}s.append(u)}return s}},Ko=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","slide-up"]),rb={name:"Reveal",description:"Animates its child in the first time it scrolls into view (scroll choreography). `animation` is a preset (fade-up|fade|zoom|…), `delay` staggers it (ms), `once` (default true) plays a single time. Honours prefers-reduced-motion (renders immediately).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"animation",type:"string",optional:!0,enum:[...Ko]},{name:"delay",type:"number",optional:!0,description:"Stagger delay in ms"},{name:"once",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=m(e.animation,"fade-up"),a=Ko.has(n)?n:"fade-up",i=Math.max(0,Math.min(5e3,I(e.delay,0))),o=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,s=r.useInstanceState("rui-reveal-shown",!1),l=s.get()||o||typeof IntersectionObserver>"u",u=c("div",{class:l?"rui-reveal is-revealed":"rui-reveal","data-anim":a,style:i?`transition-delay:${i}ms`:null});if(u.append(Ae(r,e.child)),l&&(e.once===void 0||N(e.once))||o||typeof IntersectionObserver>"u")return u;const d=e.once===void 0?!0:N(e.once);return setTimeout(()=>{if(!u.isConnected)return;const p=new IntersectionObserver(f=>{for(const b of f)if(b.isIntersecting){if(s.set(!0),b.target.classList.add("is-revealed"),d){p.disconnect();return}}else d||(s.set(!1),b.target.classList.remove("is-revealed"))},{threshold:.15,rootMargin:"0px 0px -8% 0px"});p.observe(u),r.registerDisposer(()=>p.disconnect(),"rui-reveal-io")},0),u}},Yo=new WeakMap;function yr(t){let e=Yo.get(t);return e||(e={x:0,y:0,lastTap:0,longTimer:null,longFired:!1},Yo.set(t,e)),e}function xr(t){t.longTimer&&(clearTimeout(t.longTimer),t.longTimer=null)}const nb={name:"OnGesture",description:"Attach high-level pointer gestures to any component without raw DOM: `swipe(dir)` (left/right/up/down), `longPress()`, `doubleTap()`, and `pan({dx, dy})`. Powers swipe-to-dismiss, pull-to-refresh, carousels, and drag affordances on touch + mouse.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"swipe",type:"callable",optional:!0,aliases:["onSwipe"],description:"(dir) => … — fired on a swipe; dir is left|right|up|down"},{name:"longPress",type:"callable",optional:!0,aliases:["onLongPress"]},{name:"doubleTap",type:"callable",optional:!0,aliases:["onDoubleTap"]},{name:"pan",type:"callable",optional:!0,aliases:["onPan"],description:"({dx, dy}) => … — fired during a drag"},{name:"threshold",type:"number",optional:!0,description:"Swipe distance in px (default 40)"}],render:(t,e,r)=>{const n=c("div",{class:"rui-gesture",style:`touch-action:${e.pan!=null?"none":"pan-y"}`});n.append(Ae(r,e.child));const a=Math.max(8,I(e.threshold,40)),i=o=>o.currentTarget??n;return n.onpointerdown=o=>{const s=i(o),l=yr(s);l.x=o.clientX,l.y=o.clientY,l.longFired=!1,xr(l);try{s.setPointerCapture(o.pointerId)}catch{}e.longPress!=null&&(l.longTimer=setTimeout(()=>{l.longTimer=null,s.isConnected&&(l.longFired=!0,r.invoke(e.longPress))},500))},n.onpointermove=o=>{const s=yr(i(o)),l=o.clientX-s.x,u=o.clientY-s.y;(Math.abs(l)>6||Math.abs(u)>6)&&xr(s),e.pan!=null&&o.buttons&1&&r.invoke(e.pan,{dx:l,dy:u})},n.onpointerup=o=>{const s=yr(i(o));if(xr(s),s.longFired){s.longFired=!1,s.lastTap=0;return}const l=o.clientX-s.x,u=o.clientY-s.y,d=Math.abs(l),p=Math.abs(u);if(e.swipe!=null&&(d>a||p>a)){const f=d>p?l>0?"right":"left":u>0?"down":"up";s.lastTap=0,r.invoke(e.swipe,f);return}if(e.doubleTap!=null&&d<8&&p<8){const f=Date.now();f-s.lastTap<300?(s.lastTap=0,r.invoke(e.doubleTap)):s.lastTap=f}},n.onpointercancel=o=>{const s=yr(i(o));xr(s),s.longFired=!1},n}},ab={name:"Sortable",description:"A vertical list whose items can be drag-reordered. Pass already-rendered `items`; `onReorder(fromIndex, toIndex)` fires after a drop so you can reorder the backing reactive array. Works with mouse + touch.",props:[{name:"items",type:"Node[]",positional:!0,required:!0,aliases:["children"]},{name:"onReorder",type:"callable",optional:!0,description:"(fromIndex, toIndex) => …"},{name:"handle",type:"boolean",optional:!0,description:"Show a drag handle on each row (default true)"}],render:(t,e,r)=>{const n=c("div",{class:"rui-sortable"}),a=e.handle===void 0?!0:N(e.handle),i=s=>(s.currentTarget??s.target)?.closest?.(".rui-sortable-item")??null,o=s=>{const l=Number(s?.getAttribute("data-index"));return Number.isFinite(l)?l:-1};return T(e.items).forEach((s,l)=>{const u=c("div",{class:"rui-sortable-item",draggable:"true","data-index":String(l)});if(a){const p=c("span",{class:"rui-sortable-handle","aria-hidden":"true"});p.append(c("i",{class:"rui-icon fa-solid fa-grip-vertical"})),u.append(p)}const d=c("div",{class:"rui-sortable-body"});d.append(r.renderNode(s)),u.append(d),u.ondragstart=p=>{const f=i(p);f?.classList.add("is-dragging"),f?.closest(".rui-sortable")?.setAttribute("data-drag-from",String(o(f)))},u.ondragend=p=>{const f=i(p);f?.classList.remove("is-dragging"),f?.closest(".rui-sortable")?.removeAttribute("data-drag-from")},u.ondragover=p=>{p.preventDefault(),i(p)?.classList.add("is-over")},u.ondragleave=p=>i(p)?.classList.remove("is-over"),u.ondrop=p=>{p.preventDefault();const f=i(p);f?.classList.remove("is-over");const b=f?.closest(".rui-sortable"),h=Number(b?.getAttribute("data-drag-from")),g=o(f);b?.removeAttribute("data-drag-from"),Number.isFinite(h)&&h>=0&&g>=0&&h!==g&&r.invoke(e.onReorder,h,g)},n.append(u)}),n}},ib={name:"Draggable",description:"Makes its child draggable, carrying a `data` payload picked up by a DropZone. `onDragStart`/`onDragEnd` optional.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"data",type:"any",optional:!0,description:"Payload (stringified) handed to the DropZone"},{name:"onDragStart",type:"callable",optional:!0},{name:"onDragEnd",type:"callable",optional:!0}],render:(t,e,r)=>{const n=c("div",{class:"rui-draggable",draggable:"true"});return n.append(Ae(r,e.child)),n.ondragstart=a=>{try{a.dataTransfer?.setData("text/plain",typeof e.data=="string"?e.data:JSON.stringify(e.data??null))}catch{}(a.currentTarget??a.target)?.classList.add("is-dragging"),r.invoke(e.onDragStart,e.data)},n.ondragend=a=>{(a.currentTarget??a.target)?.classList.remove("is-dragging"),r.invoke(e.onDragEnd)},n}},ob={name:"DropZone",description:"A target that accepts a Draggable. `onDrop(data)` receives the dropped payload (parsed JSON when possible).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onDrop",type:"callable",optional:!0},{name:"label",type:"string",optional:!0}],render:(t,e,r)=>{const n=c("div",{class:"rui-dropzone"});e.child!=null?n.append(Ae(r,e.child)):m(e.label)&&n.append(c("span",{class:"rui-dropzone-label"},[m(e.label)]));const a=i=>(i.currentTarget??i.target)?.closest?.(".rui-dropzone")??null;return n.ondragover=i=>{i.preventDefault(),a(i)?.classList.add("is-over")},n.ondragleave=i=>a(i)?.classList.remove("is-over"),n.ondrop=i=>{i.preventDefault(),a(i)?.classList.remove("is-over");const o=i.dataTransfer?.getData("text/plain")??"";let s=o;try{s=JSON.parse(o)}catch{}r.invoke(e.onDrop,s)},n}},sb={name:"Parallax",description:"Translates its child vertically as the page scrolls for a depth effect. `speed` (−1…1) sets intensity/direction. Honours prefers-reduced-motion.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"speed",type:"number",optional:!0,description:"−1…1 (default 0.3)"}],render:(t,e,r)=>{const n=c("div",{class:"rui-parallax",style:"will-change:transform"});if(n.append(Ae(r,e.child)),typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches||typeof window>"u")return n;const i=Math.max(-1,Math.min(1,I(e.speed,.3)));let o=0;const s=()=>{o=0;const u=n.getBoundingClientRect(),d=window.innerHeight||800,p=u.top+u.height/2-d/2;n.style.transform=`translateY(${(-p*i).toFixed(1)}px)`},l=()=>{o||(o=requestAnimationFrame(s))};return setTimeout(s,0),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0}),r.registerDisposer(()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),o&&cancelAnimationFrame(o)},"rui-parallax"),n}},lb={name:"ReadingProgress",description:"A thin progress bar that fills as the page scrolls — article/docs reading affordance. Optional gradient fill.",props:[{name:"gradient",type:"boolean",optional:!0},{name:"height",type:"string",optional:!0,description:"Bar thickness (CSS length, default 3px)"}],render:(t,e,r)=>{const n=c("div",{class:"rui-reading-progress",style:`height:${X(e.height,"3px")}`}),a=c("div",{class:"rui-reading-progress-bar","data-gradient":N(e.gradient)?"true":null});if(n.append(a),typeof window>"u")return n;let i=0;const o=()=>{i=0;const l=document.documentElement,u=l.scrollHeight-l.clientHeight||1,d=Math.max(0,Math.min(100,l.scrollTop/u*100));a.style.width=`${d}%`},s=()=>{i||(i=requestAnimationFrame(o))};return setTimeout(o,0),window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s,{passive:!0}),r.registerDisposer(()=>{window.removeEventListener("scroll",s),window.removeEventListener("resize",s),i&&cancelAnimationFrame(i)},"rui-reading-progress"),n}},Xo=new Set(["fade","scale","slide-up","slide-down","slide-left","slide-right"]),cb={name:"Transition",description:"Animates its child IN when `show` becomes true and OUT when it becomes false (mount/unmount choreography) — modals, toasts, dropdowns, list rows. `preset` is fade|scale|slide-up|slide-down|slide-left|slide-right, `duration` is ms. The child stays mounted through the exit animation, then is removed. Honours prefers-reduced-motion (instant swap).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"show",type:"boolean",description:"Whether the child is visible"},{name:"preset",type:"string",optional:!0,enum:[...Xo]},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 280)"}],render:(t,e,r)=>{const n=N(e.show),a=m(e.preset,"fade"),i=Xo.has(a)?a:"fade",o=Math.max(0,Math.min(5e3,I(e.duration,280))),s=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,l=r.useInstanceState("rui-transition",{mounted:!1}),u=l.get().mounted,d=c("div",{class:"rui-transition","data-preset":i,style:`--rui-transition-ms:${o}ms`}),p=b=>d.setAttribute("data-state",b),f=b=>{if(s||typeof requestAnimationFrame>"u"){p(b);return}requestAnimationFrame(()=>requestAnimationFrame(()=>p(b)))};if(n)return d.append(Ae(r,e.child)),p(u?"enter":"exit"),u||f("enter"),l.set({mounted:!0}),d;if(u&&o>0&&!s){d.append(Ae(r,e.child)),p("enter"),f("exit");const b=setTimeout(()=>d.replaceChildren(),o);r.registerDisposer(()=>clearTimeout(b),"rui-transition-exit")}else p("exit");return l.set({mounted:!1}),d}},ub={name:"FlipList",description:"Smoothly animates its children when they reorder, are added, or removed (the FLIP technique — First/Last/Invert/Play). Wrap a keyed list whose order changes (drag-sort, filter, sort toggle) so items glide to their new positions instead of jumping. `duration` is ms. Honours prefers-reduced-motion (no animation). Use stable `key:`s on the items so their DOM nodes persist across the reorder.",props:[{name:"children",type:"Node[]",description:"The list items (use stable keys)"},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 300)"}],render:(t,e,r)=>{const n=Math.max(0,Math.min(2e3,I(e.duration,300))),a=c("div",{class:"rui-flip-list"});for(const f of T(e.children))a.append(Ae(r,f));if(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches||typeof requestAnimationFrame>"u"||typeof MutationObserver>"u")return a;const o=r.useInstanceState("rui-flip-setup",{done:!1});if(o.get().done)return a;o.set({done:!0});const s=new WeakMap,l=()=>{for(const f of Array.from(a.children)){const b=f.getBoundingClientRect();s.set(f,{left:b.left,top:b.top})}},u=()=>{const f=Array.from(a.children),b=f.map(h=>h.getBoundingClientRect());f.forEach((h,g)=>{const y=s.get(h),v=b[g];if(y){const x=y.left-v.left,w=y.top-v.top;(x!==0||w!==0)&&(h.style.transition="none",h.style.transform=`translate(${x}px, ${w}px)`,requestAnimationFrame(()=>{h.style.transition=`transform ${n}ms cubic-bezier(.22,1,.36,1)`,h.style.transform=""}))}}),f.forEach((h,g)=>s.set(h,{left:b[g].left,top:b[g].top}))};let d=0;const p=new MutationObserver(()=>{d||(d=requestAnimationFrame(()=>{d=0,u()}))});return setTimeout(()=>{l(),p.observe(a,{childList:!0})},0),r.registerDisposer(()=>{p.disconnect(),d&&cancelAnimationFrame(d)},"rui-flip-list"),a}},Zo=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","slide-up"]),db={name:"RouteView",description:"Wraps a router's output so the page animates whenever the route changes. Pass `routeKey: route.path` so it knows when to replay the entrance animation; `animation` is fade|fade-up|zoom|… and `duration` is ms. Works by swapping a keyed inner wrapper, so the fresh page element plays its CSS entrance on mount. Honours prefers-reduced-motion.",props:[{name:"children",type:"Node",positional:!0,required:!0,description:"The $router(...) result"},{name:"routeKey",type:"string",description:"Pass route.path so the view animates on change"},{name:"animation",type:"string",optional:!0,enum:[...Zo]},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 300)"}],render:(t,e,r)=>{const n=m(e.animation,"fade"),a=Zo.has(n)?n:"fade",i=Math.max(0,Math.min(2e3,I(e.duration,300))),o=m(e.routeKey,"page")||"page",s=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,l=c("div",{class:"rui-route-view"}),u=c("div",{class:"rui-route-page","data-rui-key":o,"data-anim":s?null:a,style:s?null:`--rui-route-ms:${i}ms`});return u.append(Ae(r,e.children)),l.append(u),l}};function En(t,e){const r=document.createDocumentFragment();for(const n of T(e))n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}const pb={name:"VisuallyHidden",description:"Renders content that is invisible on screen but available to screen readers (the `sr-only` pattern). Use for icon-button labels, form hints, and context that sighted users get from layout but assistive tech needs.",props:[{name:"children",type:"Node[]",description:"Content exposed only to assistive tech"}],render:(t,e,r)=>{const n=c("span",{class:"rui-visually-hidden"});return n.append(En(r,e.children)),n}},mb={name:"SkipLink",description:"A keyboard-only 'skip to content' link that is hidden until focused, then jumps to the element with the given id. Place it as the first node in a page so keyboard users can bypass the nav.",props:[{name:"to",type:"string",positional:!0,required:!0,description:"Target element id (with or without #)"},{name:"label",type:"string",optional:!0,description:"Link text (default 'Skip to content')"}],render:(t,e)=>{const n=m(e.to,"main").replace(/^#/,""),a=c("a",{class:"rui-skip-link",href:`#${n}`});return a.textContent=m(e.label,"Skip to content"),a.onclick=i=>{const s=(i.currentTarget??i.target??a).getRootNode();let l=null;try{l=s.getElementById?.(n)??document.getElementById(n)}catch{l=null}if(l){i.preventDefault(),l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{l.focus()}try{l.scrollIntoView?.({behavior:"smooth",block:"start"})}catch{}}},a}},fb={name:"LiveRegion",description:"An aria-live region that announces its text to screen readers whenever it changes — toasts, validation summaries, async status. `politeness` is `polite` (default) or `assertive`. Visually hidden by default; set `visible` to also show it.",props:[{name:"text",type:"string",positional:!0,aliases:["children"]},{name:"politeness",type:"string",optional:!0,enum:["polite","assertive"]},{name:"visible",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=m(e.politeness,"polite")==="assertive"?"assertive":"polite",a=e.visible===!0||e.visible==="true",i=c("div",{class:a?"rui-live-region":"rui-live-region rui-visually-hidden",role:"status","aria-live":n,"aria-atomic":"true"});return e.text!=null&&typeof e.text!="object"?i.textContent=String(e.text):i.append(En(r,e.text??e.children)),i}},Qo=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(","),gb={name:"FocusTrap",description:"Confines keyboard focus to its subtree while `active` (default true) — Tab from the last focusable wraps to the first and vice-versa. Use inside modals, drawers, and command palettes. Auto-focuses the first focusable on mount.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"active",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=e.active===void 0?!0:e.active===!0||e.active==="true",a=c("div",{class:"rui-focus-trap"});if(a.append(En(r,e.child??e.children)),!n)return a;const i=o=>{if(o.key!=="Tab")return;const s=Array.from(a.querySelectorAll(Qo)).filter(p=>p.offsetParent!==null||p===document.activeElement);if(s.length===0)return;const l=s[0],u=s[s.length-1],d=a.getRootNode().activeElement;o.shiftKey&&d===l?(o.preventDefault(),u.focus()):!o.shiftKey&&d===u&&(o.preventDefault(),l.focus())};return a.addEventListener("keydown",i),setTimeout(()=>{const o=a.querySelector(Qo);o&&typeof o.focus=="function"&&o.focus()},0),r.registerDisposer(()=>a.removeEventListener("keydown",i),"rui-focus-trap"),a}},Jo={L:[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],M:[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],Q:[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],H:[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},es={L:[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],M:[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Q:[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],H:[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},hb=(()=>{const t=[[]];for(let e=1;e<=40;e+=1){if(e===1){t.push([]);continue}const r=Math.floor(e/7)+2,n=e===32?26:Math.ceil((e*4+4)/(r*2-2))*2,a=[6];for(let i=e*4+10;a.length<r;i-=n)a.splice(1,0,i);t.push(a)}return t})(),wr=new Uint8Array(512),zn=new Uint8Array(256);(()=>{let t=1;for(let e=0;e<255;e+=1)wr[e]=t,zn[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e+=1)wr[e]=wr[e-255]})();function Rn(t,e){return t===0||e===0?0:wr[zn[t]+zn[e]]}function bb(t){const e=new Uint8Array(t);e[t-1]=1;let r=1;for(let n=0;n<t;n+=1){for(let a=0;a<t;a+=1)e[a]=Rn(e[a],r),a+1<t&&(e[a]=e[a]^e[a+1]);r=Rn(r,2)}return e}function vb(t,e){const r=new Uint8Array(e.length);for(const n of t){const a=n^r[0];r.copyWithin(0,1),r[r.length-1]=0;for(let i=0;i<r.length;i+=1)r[i]=r[i]^Rn(e[i],a)}return r}function ts(t,e){const r=rs(t)>>>3,n=es[e][t],a=Jo[e][t];return r-a*n}function rs(t){let e=(16*t+128)*t+64;if(t>=2){const r=Math.floor(t/7)+2;e-=(25*r-10)*r-55,t>=7&&(e-=36)}return e}const yb={L:1,M:0,Q:3,H:2};function xb(t,e="M"){const r=Ab(t);let n=1;for(;n<=40;n+=1){const u=ts(n,e)*8;if(4+(n<=9?8:16)+r.length*8<=u)break}if(n>40)throw new Error("Data too long for QR code");const a=[],i=(u,d)=>{for(let p=d-1;p>=0;p-=1)a.push(u>>>p&1)};i(4,4),i(r.length,n<=9?8:16);for(const u of r)i(u,8);const o=ts(n,e)*8;for(i(0,Math.min(4,o-a.length));a.length%8!==0;)a.push(0);for(let u=236;a.length<o;u^=253)i(u,8);const s=new Uint8Array(a.length>>>3);for(let u=0;u<a.length;u+=1)s[u>>>3]=s[u>>>3]|a[u]<<7-(u&7);const l=wb(s,n,e);return kb(n,e,l)}function wb(t,e,r){const n=es[r][e],a=Jo[r][e],i=rs(e)>>>3,o=n-i%n,s=Math.floor(i/n),l=[],u=bb(a);let d=0;for(let b=0;b<n;b+=1){const h=s-a+(b<o?0:1),g=t.slice(d,d+h);d+=h;const y=vb(g,u),v=new Uint8Array(s+1);v.set(g,0),v.set(y,v.length-a),l.push(v)}const p=new Uint8Array(i);let f=0;for(let b=0;b<l[0].length;b+=1)for(let h=0;h<l.length;h+=1)(b!==s-a||h>=o)&&(p[f++]=l[h][b]);return p}function kb(t,e,r){const n=t*4+17,a=Array.from({length:n},()=>new Array(n).fill(!1)),i=Array.from({length:n},()=>new Array(n).fill(!1)),o=(h,g,y)=>{a[g][h]=y,i[g][h]=!0},s=(h,g)=>{for(let y=-4;y<=4;y+=1)for(let v=-4;v<=4;v+=1){const x=Math.max(Math.abs(v),Math.abs(y)),w=h+v,k=g+y;w>=0&&w<n&&k>=0&&k<n&&o(w,k,x!==2&&x!==4)}};for(let h=0;h<n;h+=1)o(6,h,h%2===0),o(h,6,h%2===0);s(3,3),s(n-4,3),s(3,n-4);const l=hb[t];for(const h of l)for(const g of l)if(!(g===6&&h===6||g===6&&h===n-7||g===n-7&&h===6))for(let y=-2;y<=2;y+=1)for(let v=-2;v<=2;v+=1)o(g+v,h+y,Math.max(Math.abs(v),Math.abs(y))!==1);if((()=>{for(let h=0;h<9;h+=1)i[h][8]||o(8,h,!1),i[8][h]||o(h,8,!1);for(let h=0;h<8;h+=1)o(n-1-h,8,!1),o(8,n-1-h,!1);o(8,n-8,!0)})(),t>=7)for(let h=0;h<18;h+=1){const g=h%3,y=Math.floor(h/3);o(n-11+g,y,!1),o(y,n-11+g,!1)}let d=0;const p=r.length*8;for(let h=n-1;h>=1;h-=2){const g=h===6?5:h;for(let y=0;y<n;y+=1)for(let v=0;v<2;v+=1){const x=g-v,k=(g+1&2)===0?n-1-y:y;if(i[k][x])continue;let A=!1;d<p&&(A=(r[d>>>3]>>>7-(d&7)&1)!==0,d+=1),a[k][x]=A}}let f=1/0,b=a;for(let h=0;h<8;h+=1){const g=a.map(v=>v.slice());Sb(g,i,h),$b(g,i,e,h,n);const y=Cb(g,n);y<f&&(f=y,b=g)}return b}function Sb(t,e,r){const n=t.length;for(let a=0;a<n;a+=1)for(let i=0;i<n;i+=1){if(e[a][i])continue;let o=!1;switch(r){case 0:o=(i+a)%2===0;break;case 1:o=a%2===0;break;case 2:o=i%3===0;break;case 3:o=(i+a)%3===0;break;case 4:o=(Math.floor(i/3)+Math.floor(a/2))%2===0;break;case 5:o=i*a%2+i*a%3===0;break;case 6:o=(i*a%2+i*a%3)%2===0;break;case 7:o=((i+a)%2+i*a%3)%2===0;break}o&&(t[a][i]=!t[a][i])}}function $b(t,e,r,n,a){const i=yb[r]<<3|n;let o=i;for(let u=0;u<10;u+=1)o=o<<1^(o>>>9)*1335;const s=(i<<10|o)^21522,l=u=>(s>>>u&1)!==0;for(let u=0;u<=5;u+=1)t[u][8]=l(u);t[7][8]=l(6),t[8][8]=l(7),t[8][7]=l(8);for(let u=9;u<15;u+=1)t[8][14-u]=l(u);for(let u=0;u<8;u+=1)t[8][a-1-u]=l(u);for(let u=8;u<15;u+=1)t[a-15+u][8]=l(u);t[a-8][8]=!0}function Cb(t,e){let r=0;for(let n=0;n<e;n+=1){let a=t[n][0],i=1;for(let o=1;o<e;o+=1)t[n][o]===a?(i+=1,i===5?r+=3:i>5&&(r+=1)):(a=t[n][o],i=1)}for(let n=0;n<e;n+=1){let a=t[0][n],i=1;for(let o=1;o<e;o+=1)t[o][n]===a?(i+=1,i===5?r+=3:i>5&&(r+=1)):(a=t[o][n],i=1)}for(let n=0;n<e-1;n+=1)for(let a=0;a<e-1;a+=1){const i=t[n][a];i===t[n][a+1]&&i===t[n+1][a]&&i===t[n+1][a+1]&&(r+=3)}return r}function Ab(t){if(typeof TextEncoder<"u")return new TextEncoder().encode(t);const e=[];for(const r of t){const n=r.codePointAt(0);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):e.push(224|n>>12,128|n>>6&63,128|n&63)}return new Uint8Array(e)}const Tb="http://www.w3.org/2000/svg";function Et(t,e){const r=document.createElementNS(Tb,t);for(const[n,a]of Object.entries(e))a!=null&&r.setAttribute(n,a);return r}const Mb={name:"QRCode",description:"Renders an offline QR code as crisp SVG from `data` (a URL or text). `size` is the pixel side length, `ecc` the error-correction level (L|M|Q|H, default M), `color`/`background` override the modules. No network — encodes fully in the browser.",props:[{name:"data",type:"string",positional:!0,required:!0,aliases:["value","text"],description:"URL or text to encode"},{name:"size",type:"number",optional:!0,description:"Side length in px (default 160)"},{name:"ecc",type:"string",optional:!0,enum:["L","M","Q","H"]},{name:"color",type:"string",optional:!0,description:"Module (dark) color"},{name:"background",type:"string",optional:!0,description:"Background color (default transparent-white)"},{name:"margin",type:"number",optional:!0,description:"Quiet-zone modules (default 2)"}],render:(t,e)=>{const r=m(e.data),n=Math.max(48,Math.min(1024,I(e.size,160))),a=m(e.ecc,"M").toUpperCase(),i=["L","M","Q","H"].includes(a)?a:"M",o=Oe(e.color)||"#000000",s=Oe(e.background)||"#ffffff",l=Math.max(0,Math.min(8,I(e.margin,2))),u=c("div",{class:"rui-qrcode"});let d;try{d=xb(r||" ",i)}catch{return u.append(c("div",{class:"rui-qrcode-error"},["Data too long for QR"])),u}const p=d.length,f=p+l*2,b=Et("svg",{viewBox:`0 0 ${f} ${f}`,width:String(n),height:String(n),role:"img","aria-label":`QR code for ${r}`,"shape-rendering":"crispEdges"});b.append(Et("rect",{x:"0",y:"0",width:String(f),height:String(f),fill:s}));let h="";for(let g=0;g<p;g+=1)for(let y=0;y<p;y+=1)d[g][y]&&(h+=`M${y+l},${g+l}h1v1h-1z`);return b.append(Et("path",{d:h,fill:o})),u.append(b),u}},Nb={name:"ReactionPicker",description:"A row of emoji reactions with counts. `reactions` is a list of { emoji, count?, active? }; `onReact(emoji)` fires on click. Use under messages, comments, and posts.",props:[{name:"reactions",type:"object[]",positional:!0,required:!0,description:"[{ emoji, count?, active? }]"},{name:"onReact",type:"callable",optional:!0,description:"(emoji) => …"}],render:(t,e)=>{const r=T(e.reactions),n=typeof e.onReact=="function"?e.onReact:null,a=c("div",{class:"rui-reaction-picker",role:"group","aria-label":"Reactions"});for(const i of r){const o=i&&typeof i=="object"?i:{},s=m(o.emoji,"👍"),l=I(o.count,0),u=N(o.active),d=c("button",{type:"button",class:"rui-reaction","data-active":u?"true":null,"aria-pressed":u?"true":"false"});d.append(c("span",{class:"rui-reaction-emoji"},[s])),l>0&&d.append(c("span",{class:"rui-reaction-count"},[String(l)])),n&&(d.onclick=()=>n(s)),a.append(d)}return a}},Ib={name:"LiveCursor",description:"A floating collaborator cursor positioned at `x`/`y` (px) with a name label — drive it from presence/`$socket` state for multiplayer UIs. Pointer-events are disabled so it never blocks interaction.",props:[{name:"x",type:"number",description:"X position in px"},{name:"y",type:"number",description:"Y position in px"},{name:"label",type:"string",optional:!0,description:"Collaborator name"},{name:"color",type:"string",optional:!0}],render:(t,e)=>{const r=I(e.x,0),n=I(e.y,0),a=Oe(e.color)||"var(--rui-color-primary)",i=c("div",{class:"rui-live-cursor",style:`transform:translate(${r}px,${n}px);--rui-cursor-color:${a}`}),o=Et("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"});o.append(Et("path",{d:"M3 3l14 6-6 2-2 6z",fill:a,stroke:"#fff","stroke-width":"1"})),i.append(o);const s=m(e.label);return s&&i.append(c("span",{class:"rui-live-cursor-label",style:`background:${a}`},[s])),i}},Pb={name:"TabBar",description:"Bottom navigation bar for mobile layouts — a row of icon+label tabs. `items` is [{ id, label, icon?, badge? }]; `active` is the current id; `onChange(id)` fires on tap. Pins to the bottom with safe-area padding.",props:[{name:"items",type:"object[]",positional:!0,required:!0,description:"[{ id, label, icon?, badge? }]"},{name:"active",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"(id) => …"}],render:(t,e)=>{const r=T(e.items),n=m(e.active),a=typeof e.onChange=="function"?e.onChange:null,i=c("nav",{class:"rui-tabbar",role:"tablist","aria-label":"Primary"});for(const o of r){const s=o&&typeof o=="object"?o:{},l=m(s.id??s.label),u=l===n&&l!=="",d=c("button",{type:"button",class:"rui-tabbar-item",role:"tab","data-active":u?"true":null,"aria-selected":u?"true":"false","aria-current":u?"page":null}),p=m(s.icon);if(p){const b=L(p,{className:"rui-tabbar-icon"});if(b){const h=c("span",{class:"rui-tabbar-icon-wrap"});h.append(b);const g=m(s.badge);g&&h.append(c("span",{class:"rui-tabbar-badge"},[g])),d.append(h)}}const f=m(s.label);f&&d.append(c("span",{class:"rui-tabbar-label"},[f])),a&&l&&(d.onclick=()=>a(l)),i.append(d)}return i}};function Eb(t,e){return e==null?null:typeof e=="string"?document.createTextNode(e):t.renderNode(e)}const zb={name:"Cart",description:"A shopping-cart line list: each item shows image, name, unit price, a quantity stepper, and a remove button, with a running subtotal. `items` is [{ id, name, price, qty, image? }]; `onQty(id, qty)` and `onRemove(id)` fire on interaction. `currency` is an ISO code (default USD).",props:[{name:"items",type:"object[]",positional:!0,required:!0,description:"[{ id, name, price, qty, image? }]"},{name:"onQty",type:"callable",optional:!0,description:"(id, qty) => …"},{name:"onRemove",type:"callable",optional:!0,description:"(id) => …"},{name:"currency",type:"string",optional:!0},{name:"footer",type:"Node",optional:!0,description:"Custom footer (e.g. a checkout button)"}],render:(t,e,r)=>{const n=T(e.items),a=m(e.currency,"USD")||"USD",i=typeof e.onQty=="function"?e.onQty:null,o=typeof e.onRemove=="function"?e.onRemove:null,s=f=>{try{return new Intl.NumberFormat(void 0,{style:"currency",currency:a}).format(f)}catch{return`${f.toFixed(2)} ${a}`}},l=c("div",{class:"rui-cart"});let u=0;n.length===0&&l.append(c("div",{class:"rui-cart-empty"},["Your cart is empty"]));for(const f of n){const b=f&&typeof f=="object"?f:{},h=m(b.id??b.name),g=m(b.name),y=I(b.price,0),v=Math.max(0,I(b.qty,1));u+=y*v;const x=c("div",{class:"rui-cart-line"}),w=re(b.image);w&&x.append(c("img",{class:"rui-cart-thumb",src:w,alt:g,loading:"lazy"}));const k=c("div",{class:"rui-cart-body"});k.append(c("div",{class:"rui-cart-name"},[g])),k.append(c("div",{class:"rui-cart-price"},[s(y)])),x.append(k);const A=c("div",{class:"rui-cart-qty"}),S=c("button",{type:"button",class:"rui-cart-qty-btn","aria-label":"Decrease quantity"},["−"]),$=c("button",{type:"button",class:"rui-cart-qty-btn","aria-label":"Increase quantity"},["+"]);if(i&&h&&(S.onclick=()=>i(h,Math.max(0,v-1)),$.onclick=()=>i(h,v+1)),A.append(S,c("span",{class:"rui-cart-qty-value"},[String(v)]),$),x.append(A),x.append(c("div",{class:"rui-cart-line-total"},[s(y*v)])),o&&h){const C=c("button",{type:"button",class:"rui-cart-remove","aria-label":`Remove ${g}`}),M=L("xmark",{className:"rui-cart-remove-icon"});M?C.append(M):C.append(document.createTextNode("×")),C.onclick=()=>o(h),x.append(C)}l.append(x)}const d=c("div",{class:"rui-cart-foot"});d.append(c("span",{class:"rui-cart-subtotal-label"},["Subtotal"])),d.append(c("span",{class:"rui-cart-subtotal-value"},[s(u)])),l.append(d);const p=Eb(r,e.footer);return p&&l.append(p),l}},Rb=["SUN","MON","TUE","WED","THU","FRI","SAT"],ns=["January","February","March","April","May","June","July","August","September","October","November","December"],as={primary:"var(--rui-color-primary)",success:"var(--rui-color-success, #10b981)",warning:"var(--rui-color-warning, #f59e0b)",danger:"var(--rui-color-danger, #ef4444)",info:"var(--rui-color-info, #06b6d4)"},is=t=>String(t).padStart(2,"0"),os=(t,e,r)=>`${t}-${is(e+1)}-${is(r)}`;function Lb(t){const e=new Map,r=new Map;for(const n of T(t)){if(n==null)continue;if(typeof n=="string"){const d=n.slice(0,10);d&&r.set(d,(r.get(d)??0)+1);continue}if(typeof n!="object")continue;const a=n,i=m(a.date).slice(0,10);if(!i)continue;const o=m(a.label??a.title);if(!o){r.set(i,(r.get(i)??0)+1);continue}const s=m(a.color??a.tone,"primary"),l=as[s]??Oe(s)??as.primary,u=e.get(i)??[];u.push({label:o,color:l,time:m(a.time)}),e.set(i,u)}return{chips:e,dots:r}}function ss(t,e,r,n){const a=h=>(h.currentTarget??h.target)?.closest(".rui-gcal")??t,i=(h,g,y)=>{const v=a(h),x=n.viewSlot.get();n.viewSlot.set({propsYear:x?.propsYear??g,propsMonth:x?.propsMonth??y,year:g,month:y}),ss(v,g,y,n),n.helpers.invoke(n.onNavigate,g,y)},o=(h,g)=>{const y=n.viewSlot.get(),v=y?.year??e,x=y?.month??r,w=new Date(v,x+g,1);i(h,w.getFullYear(),w.getMonth())},s=c("div",{class:"rui-gcal-toolbar"});if(n.navigable){const h=c("button",{type:"button",class:"rui-gcal-today"},["Today"]);h.onclick=w=>{const k=new Date;i(w,k.getFullYear(),k.getMonth())};const g=c("button",{type:"button",class:"rui-gcal-nav","data-dir":"prev","aria-label":"Previous month"}),y=L("chevron-left");y?g.append(y):g.textContent="‹",g.onclick=w=>o(w,-1);const v=c("button",{type:"button",class:"rui-gcal-nav","data-dir":"next","aria-label":"Next month"}),x=L("chevron-right");x?v.append(x):v.textContent="›",v.onclick=w=>o(w,1),s.append(h,g,v)}s.append(c("span",{class:"rui-gcal-title"},[`${ns[r]} ${e}`]));const l=c("div",{class:"rui-gcal-grid",role:"grid"});for(let h=0;h<7;h+=1)l.append(c("div",{class:"rui-gcal-weekday",role:"columnheader"},[Rb[(n.firstDay+h)%7]]));l.onkeydown=h=>{const g=h.key;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(g))return;const y=a(h),v=Array.from(y.querySelectorAll(".rui-gcal-day")),x=y.getRootNode(),w=v.indexOf(x.activeElement);if(w<0)return;let k=w;g==="ArrowLeft"?k=w-1:g==="ArrowRight"?k=w+1:g==="ArrowUp"?k=w-7:g==="ArrowDown"?k=w+7:g==="Home"?k=w-w%7:g==="End"&&(k=w-w%7+6),!(k<0||k>=v.length)&&(h.preventDefault(),v[k]?.focus())};const u=new Date(e,r,1),d=new Date(e,r+1,0).getDate(),p=(u.getDay()-n.firstDay+7)%7,f=Math.ceil((p+d)/7)*7,b=new Date(e,r,1-p);for(let h=0;h<f;h+=1){const g=new Date(b.getFullYear(),b.getMonth(),b.getDate()+h),y=os(g.getFullYear(),g.getMonth(),g.getDate()),v=g.getMonth()===r,x=c("button",{type:"button",class:"rui-gcal-day",role:"gridcell","data-in-month":v?"true":"false","data-today":y===n.todayIso?"true":null,"data-selected":n.selected&&y===n.selected?"true":null,"data-iso":y,"aria-label":`${ns[g.getMonth()]} ${g.getDate()}, ${g.getFullYear()}`,"aria-pressed":n.selected&&y===n.selected?"true":"false"});x.append(c("span",{class:"rui-gcal-daynum"},[String(g.getDate())]));const w=n.chips.get(y)??[],k=n.dots.get(y)??0;if(w.length>0||k>0){const A=c("div",{class:"rui-gcal-events"}),S=w.slice(0,2);for(const C of S)A.append(c("span",{class:"rui-gcal-chip",style:`--rui-gcal-chip:${C.color}`,title:C.time?`${C.time} — ${C.label}`:C.label},[C.time?`${C.time} ${C.label}`:C.label]));if(k>0){const C=c("div",{class:"rui-gcal-dots"});for(let M=0;M<Math.min(3,k);M+=1)C.append(c("span",{class:"rui-gcal-dot"}));A.append(C)}const $=w.length-S.length;$>0&&A.append(c("span",{class:"rui-gcal-more"},[`+${$} more`])),x.append(A)}x.onclick=A=>{const S=a(A);for(const M of S.querySelectorAll('.rui-gcal-day[data-selected="true"]'))M.removeAttribute("data-selected"),M.setAttribute("aria-pressed","false");const C=(A.currentTarget??A.target)?.closest?.(".rui-gcal-day");C?.setAttribute("data-selected","true"),C?.setAttribute("aria-pressed","true"),n.selRef&&n.helpers.setState(n.selRef,y),n.helpers.invoke(n.onSelect,y)},l.append(x)}t.replaceChildren(s,l)}const Db={name:"Calendar",description:"A Google Calendar-style month grid with Today/prev/next navigation. `month` (0–11) and `year` set the view (default current month); `selected` is an ISO date (YYYY-MM-DD) to highlight — bind a $variable for two-way selection; `onSelect(iso)` fires on a day click. `events` mixes bare ISO strings (rendered as dots) and `{date, label, color?, time?}` objects (rendered as colored chips with a '+N more' overflow; `color` is a tone name or CSS color). `onNavigate(year, month)` fires when the user pages months; `navigable=false` hides the toolbar buttons. Use for schedules, bookings, and availability calendars.",props:[{name:"month",type:"number",optional:!0,description:"0–11 (default current month)"},{name:"year",type:"number",optional:!0,description:"Full year (default current)"},{name:"selected",type:"string",optional:!0,description:"ISO date to highlight; bind a $variable"},{name:"onSelect",type:"callable",optional:!0,description:"(isoDate) => …"},{name:"events",type:"any[]",optional:!0,description:"ISO strings (dots) and/or {date, label, color?, time?} chips"},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday (default), 1=Monday"},{name:"navigable",type:"boolean",optional:!0,description:"Show Today/prev/next controls (default true)"},{name:"onNavigate",type:"callable",optional:!0,description:"(year, month) => … after paging"}],render:(t,e,r)=>{const n=new Date,a=e.month!==void 0&&Number.isFinite(Number(e.month)),i=e.year!==void 0&&Number.isFinite(Number(e.year)),o=a?Math.max(0,Math.min(11,Math.floor(I(e.month,n.getMonth())))):n.getMonth(),s=i?Math.floor(I(e.year,n.getFullYear())):n.getFullYear(),l=r.useInstanceState("rui-gcal-view",null),u=l.get(),p=!u||u.propsYear!==s||u.propsMonth!==o?{propsYear:s,propsMonth:o,year:s,month:o}:u;l.set(p);const{chips:f,dots:b}=Lb(e.events),h={todayIso:os(n.getFullYear(),n.getMonth(),n.getDate()),selected:m(e.selected),chips:f,dots:b,firstDay:(Math.round(I(e.firstDay,0))%7+7)%7,navigable:e.navigable===void 0?!0:N(e.navigable),onSelect:e.onSelect,onNavigate:e.onNavigate,selRef:t.argMeta?.[2]?.stateRef,helpers:r,viewSlot:l},g=c("div",{class:"rui-gcal"});return ss(g,p.year,p.month,h),g}},lt=new WeakMap;function jb(t,e,r){const n=typeof window<"u"&&window.devicePixelRatio||1;t.width=Math.round(e*n),t.height=Math.round(r*n),t.style.width=`${e}px`,t.style.height=`${r}px`;const a=t.getContext("2d");return a&&(a.scale(n,n),a.lineCap="round",a.lineJoin="round"),a}function ls(t){let e=t.dataset.stroke??"";if(!e)try{e=getComputedStyle(t).color||"#1a1a1a"}catch{e="#1a1a1a"}return{stroke:e,lineWidth:Math.max(1,Math.min(40,Number(t.dataset.lineWidth)||2)),background:t.dataset.bg??"transparent"}}function cs(t,e){if(!e.ctx)return;const{background:r}=ls(t);r&&r!=="transparent"&&(e.ctx.fillStyle=r,e.ctx.fillRect(0,0,e.width,e.height))}function us(t){const e=lt.get(t);if(!e?.ctx)return;const{stroke:r,lineWidth:n}=ls(t);e.ctx.clearRect(0,0,e.width,e.height),cs(t,e),e.ctx.strokeStyle=r,e.ctx.lineWidth=n;for(const a of e.strokes)if(!(a.length<1)){e.ctx.beginPath(),e.ctx.moveTo(a[0].x,a[0].y);for(let i=1;i<a.length;i+=1)e.ctx.lineTo(a[i].x,a[i].y);e.ctx.stroke()}}function ds(t){const e=lt.get(t);e&&(e.strokes=[],e.current=[],us(t))}function ps(t){const{width:e,height:r,stroke:n,lineWidth:a,background:i,rootClass:o,helpers:s}=t,l=c("div",{class:o,style:`width:${e}px`}),u=c("canvas",{class:"rui-canvas-surface",style:"touch-action:none","data-stroke":n||null,"data-line-width":String(a),"data-bg":i});l.append(u);const d=jb(u,e,r);lt.set(u,{strokes:[],current:[],drawing:!1,ctx:d,width:e,height:r}),cs(u,lt.get(u));const p=h=>h.currentTarget??u,f=(h,g)=>{const y=h.getBoundingClientRect();return{x:g.clientX-y.left,y:g.clientY-y.top}};u.onpointerdown=h=>{const g=p(h),y=lt.get(g);if(y){y.drawing=!0;try{g.setPointerCapture(h.pointerId)}catch{}y.current=[f(g,h)],y.strokes.push(y.current)}},u.onpointermove=h=>{const g=p(h),y=lt.get(g);y?.drawing&&(y.current.push(f(g,h)),us(g),s.invoke(t.onChange,y.strokes.length))};const b=h=>{const g=p(h),y=lt.get(g);if(!y?.drawing)return;y.drawing=!1;let v="";try{v=g.toDataURL("image/png")}catch{}s.invoke(t.onEnd,v)};return u.onpointerup=b,u.onpointercancel=b,{root:l,canvas:u}}function ms(t,e,r){return(t.currentTarget??t.target)?.closest?.(`.${e}`)?.querySelector("canvas.rui-canvas-surface")??r}const Bb={name:"DrawingCanvas",description:"A freehand drawing surface (pointer / touch / stylus). `onChange(count)` fires while drawing; `onEnd(dataUrl)` fires when a stroke finishes with a PNG data URL. `color`/`lineWidth`/`background` style the ink. Includes a Clear button unless `clearable=false`.",props:[{name:"width",type:"number",optional:!0,description:"px (default 360)"},{name:"height",type:"number",optional:!0,description:"px (default 220)"},{name:"color",type:"string",optional:!0,description:"Ink color"},{name:"lineWidth",type:"number",optional:!0},{name:"background",type:"string",optional:!0},{name:"clearable",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"(strokeCount) => …"},{name:"onEnd",type:"callable",optional:!0,description:"(pngDataUrl) => …"}],render:(t,e,r)=>{const n=Math.max(80,Math.min(2e3,I(e.width,360))),a=Math.max(80,Math.min(2e3,I(e.height,220))),i=Oe(e.color)||"",o=Math.max(1,Math.min(40,I(e.lineWidth,2))),s=Oe(e.background)||"transparent",l=ps({width:n,height:a,stroke:i,lineWidth:o,background:s,rootClass:"rui-drawing-canvas",onChange:e.onChange,onEnd:e.onEnd,helpers:r});if(e.clearable===void 0||N(e.clearable)){const u=c("div",{class:"rui-canvas-toolbar"}),d=c("button",{type:"button",class:"rui-canvas-clear"},["Clear"]);d.onclick=p=>{ds(ms(p,"rui-drawing-canvas",l.canvas)),r.invoke(e.onChange,0)},u.append(d),l.root.append(u)}return l.root}},Ob={name:"SignaturePad",description:"A signature capture pad — a DrawingCanvas tuned for signing, with a baseline and a Clear button. `onChange(pngDataUrl)` fires when the signature changes (empty string when cleared). Use in contracts, delivery confirmation, and consent flows.",props:[{name:"width",type:"number",optional:!0,description:"px (default 400)"},{name:"height",type:"number",optional:!0,description:"px (default 160)"},{name:"color",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,description:'(pngDataUrl|"") => …'}],render:(t,e,r)=>{const n=Math.max(120,Math.min(1200,I(e.width,400))),a=Math.max(80,Math.min(600,I(e.height,160))),i=Oe(e.color)||"#1a1a1a",o=ps({width:n,height:a,stroke:i,lineWidth:2.5,background:"#ffffff",rootClass:"rui-signature-pad",onEnd:d=>r.invoke(e.onChange,d),helpers:r}),s=c("div",{class:"rui-signature-baseline"});o.root.append(s);const l=c("div",{class:"rui-canvas-toolbar"}),u=c("button",{type:"button",class:"rui-canvas-clear"},["Clear"]);return u.onclick=d=>{ds(ms(d,"rui-signature-pad",o.canvas)),r.invoke(e.onChange,"")},l.append(u),o.root.append(l),o.root}},Fb=/<script|<foreignObject|on\w+\s*=|javascript\s*:|<!ENTITY|<iframe|<embed|<object/i;function _b(t){return!t||t.length>32768||Fb.test(t)?"":t}const Ub=/^[\d.\s-]+$/,fs=[qu,Vu,Gu,Wu,Uu,Wi,id,od,sd,Ku,Yu,Xu,Zu,ed,Ju,nd,rd,md,Qu,ld,ud,Ld,Dd,kd,Sd,$d,lo,Ad,Td,Md,sr,Pd,Rd,Bd,yd,jd,yp,vp,up,dp,mp,pp,fp,hp,gp,bp,lp,cp,co,xp,wp,kp,Sp,uo,$p,Cp,cm,lm,dm,um,pm,mm,gm,fm,ym,xm,wm,vm,Am,Tm,Mm,Pm,Em,Wm,xo,Lm,Dm,Vm,jm,Bm,Fm,_m,Km,Xm,Zm,Gm,Um,Jm,$o,tf,af,nf,cf,uf,df,pf,Pp,Ep,im,om,zp,Lp,Rp,jp,Dp,Bp,Op,sm,Fp,_p,po,nm,qp,Hp,Up,Vp,Wp,Yp,Kp,Gp,Xp,Zp,Jp,Qp,em,rm,tm,bf,yf,kf,Sf,$f,Af,Tf,Nf,If,Pf,zf,Lf,Df,Bf,Ff,Uf,qf,Vf,Gf,Kf,Zf,Jf,eg,rg,ng,ag,ig,og,sg,lg,ug,pg,fg,gg,hg,bg,vg,yg,xg,wg,kg,Sg,$g,Cg,zg,Rg,Lg,Dg,jg,Bg,Og,Fg,_g,Ug,Hg,qg,Vg,Gg,Kg,Yg,Xg,Zg,Qg,Gd,Yd,Zd,Qd,Jd,ep,rp,lo,ph,mh,fh,gh,hh,vh,bh,yh,xh,kh,wh,$h,Sh,Ch,Ah,Th,Ph,zh,Rh,jh,Bh,Oh,Fh,_h,Uh,Hh,qh,Wo,Vh,Wh,Gh,Kh,Yh,Xh,Qh,tb,eb,rb,nb,ab,ib,ob,sb,lb,cb,ub,db,{name:"Svg",description:"Render inline SVG markup safely (paths, shapes, gradients) — for brand illustrations, custom icons, and data-viz overlays without the HTMLTag escape hatch. Pass the inner markup (everything inside <svg>) plus a `viewBox`. Script/event-handler payloads are stripped.",props:[{name:"content",type:"string",positional:!0,required:!0,aliases:["paths","markup"]},{name:"viewBox",type:"string",optional:!0,description:'e.g. "0 0 24 24" (default)'},{name:"width",type:"string",optional:!0},{name:"height",type:"string",optional:!0},{name:"fill",type:"string",optional:!0,description:"currentColor (default), none, or a token color"}],render:(t,e)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","rui-svg");const a=m(e.viewBox,"0 0 24 24");n.setAttribute("viewBox",Ub.test(a)?a:"0 0 24 24");const i=m(e.fill,"currentColor");return n.setAttribute("fill",/^[a-zA-Z#()0-9,.\s-]+$/.test(i)?i:"currentColor"),e.width&&n.setAttribute("width",m(e.width).replace(/[^0-9a-z%.]/gi,"")),e.height&&n.setAttribute("height",m(e.height).replace(/[^0-9a-z%.]/gi,"")),n.setAttribute("aria-hidden","true"),n.innerHTML=_b(m(e.content)),n}},{name:"Sheet",description:"A panel that slides in from an edge over a dimmed backdrop. `side` is left|right|top|bottom. Bind `open` to a $variable; `onClose` fires on backdrop click / Escape. Use BottomSheet for the mobile bottom variant.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"open",type:"boolean",optional:!0},{name:"side",type:"string",optional:!0,enum:["left","right","top","bottom"]},{name:"title",type:"string",optional:!0},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"]}],render:(t,e,r)=>{const n=N(e.open),a=c("div",{class:"rui-sheet-root","data-open":n?"true":"false","data-side":m(e.side,"right")}),i=t.argMeta?.find(p=>p?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1),r.invoke(e.onClose)},s=c("div",{class:"rui-sheet-backdrop"});s.onclick=o;const l=c("div",{class:"rui-sheet-panel",role:"dialog","aria-modal":"true",tabindex:"-1"}),u=m(e.title);if(u){const p=c("div",{class:"rui-sheet-head"});p.append(c("h3",{class:"rui-sheet-title",id:"rui-sheet-label"},[u])),l.setAttribute("aria-labelledby","rui-sheet-label");const f=c("button",{class:"rui-sheet-close",type:"button","aria-label":"Close"}),b=L("xmark");b&&f.append(b),f.onclick=o,p.append(f),l.append(p)}const d=c("div",{class:"rui-sheet-body"});for(const p of T(e.children))d.append(r.renderNode(p));return l.append(d),a.append(s,l),a.onkeydown=vn(".rui-sheet-panel",()=>o()),yn(a,".rui-sheet-panel",r),a}},{name:"BottomSheet",description:"A mobile bottom sheet — Sheet pinned to the bottom edge with a drag handle. Bind `open`; `onClose` on dismiss.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"open",type:"boolean",optional:!0},{name:"title",type:"string",optional:!0},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"]}],render:(t,e,r)=>{const n=N(e.open),a=c("div",{class:"rui-sheet-root rui-bottomsheet","data-open":n?"true":"false","data-side":"bottom"}),i=t.argMeta?.find(p=>p?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1),r.invoke(e.onClose)},s=c("div",{class:"rui-sheet-backdrop"});s.onclick=o;const l=c("div",{class:"rui-sheet-panel",role:"dialog","aria-modal":"true",tabindex:"-1"});l.append(c("div",{class:"rui-bottomsheet-grip","aria-hidden":"true"}));const u=m(e.title);u&&l.append(c("h3",{class:"rui-sheet-title"},[u]));const d=c("div",{class:"rui-sheet-body"});for(const p of T(e.children))d.append(r.renderNode(p));return l.append(d),a.append(s,l),a.onkeydown=vn(".rui-sheet-panel",()=>o()),yn(a,".rui-sheet-panel",r),a}},{name:"ConfirmDialog",description:"A confirm/cancel modal dialog. Bind `open` to a $variable; `onConfirm` fires on accept, `onCancel`/backdrop on dismiss. `tone` colors the confirm button (danger for destructive actions).",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"open",type:"boolean",optional:!0},{name:"message",type:"string",optional:!0,aliases:["body"]},{name:"confirmLabel",type:"string",optional:!0},{name:"cancelLabel",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","danger","warning"]},{name:"onConfirm",type:"callable",optional:!0},{name:"onCancel",type:"callable",optional:!0}],render:(t,e,r)=>{const n=N(e.open),a=c("div",{class:"rui-confirm-root","data-open":n?"true":"false"}),i=t.argMeta?.find(b=>b?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1)},s=c("div",{class:"rui-confirm-backdrop"});s.onclick=()=>{r.invoke(e.onCancel),o()};const l=c("div",{class:"rui-confirm-card",role:"alertdialog","aria-modal":"true","aria-labelledby":"rui-confirm-label",tabindex:"-1"});l.append(c("h3",{class:"rui-confirm-title",id:"rui-confirm-label"},[m(e.title)]));const u=m(e.message);u&&l.append(c("p",{class:"rui-confirm-message"},[u]));const d=c("div",{class:"rui-confirm-actions"}),p=c("button",{class:"rui-confirm-cancel",type:"button"},[m(e.cancelLabel,"Cancel")]);p.onclick=()=>{r.invoke(e.onCancel),o()};const f=c("button",{class:"rui-confirm-ok",type:"button","data-tone":m(e.tone,"primary")},[m(e.confirmLabel,"Confirm")]);return f.onclick=()=>{r.invoke(e.onConfirm),o()},d.append(p,f),l.append(d),a.append(s,l),a.onkeydown=vn(".rui-confirm-card",()=>{r.invoke(e.onCancel),o()}),yn(a,".rui-confirm-card",r),a}},{name:"PresenceAvatars",description:"An overlapping stack of avatars with online status dots — 'who's here' for collab/social. Pass `people` as {name, src?, online?}.",props:[{name:"people",type:"object[]",positional:!0,required:!0,aliases:["users","children"]},{name:"max",type:"number",optional:!0,description:"Max avatars before a +N chip (default 5)"}],render:(t,e)=>{const r=T(e.people),n=Math.max(1,Math.round(I(e.max,5))),a=c("div",{class:"rui-presence"});return r.slice(0,n).forEach(i=>{const o=i??{},s=c("div",{class:"rui-presence-avatar","data-online":N(o.online)?"true":null,title:m(o.name)}),l=re(o.src);l?s.append(c("img",{src:l,alt:m(o.name)})):s.append(c("span",{class:"rui-presence-initials"},[m(o.name).split(/\s+/).filter(Boolean).slice(0,2).map(u=>u[0].toUpperCase()).join("")])),a.append(s)}),r.length>n&&a.append(c("div",{class:"rui-presence-more"},[`+${r.length-n}`])),a}},{name:"ShareButtons",description:"A row of social share buttons (twitter|facebook|linkedin|reddit|email) plus a copy-link button, for the given `url`/`title`.",props:[{name:"url",type:"string",positional:!0,required:!0},{name:"title",type:"string",optional:!0},{name:"networks",type:"string[]",optional:!0,description:"Which to show (default twitter, facebook, linkedin, copy)"}],render:(t,e)=>{const r=Fe(e.url,""),n=m(e.title),a=encodeURIComponent(r),i=encodeURIComponent(n),o=T(e.networks).map(d=>m(d)),s=o.length>0?o:["twitter","facebook","linkedin","copy"],l={twitter:{icon:"brands:x-twitter",href:`https://twitter.com/intent/tweet?url=${a}&text=${i}`},facebook:{icon:"brands:facebook",href:`https://www.facebook.com/sharer/sharer.php?u=${a}`},linkedin:{icon:"brands:linkedin",href:`https://www.linkedin.com/sharing/share-offsite/?url=${a}`},reddit:{icon:"brands:reddit",href:`https://www.reddit.com/submit?url=${a}&title=${i}`},email:{icon:"envelope",href:`mailto:?subject=${i}&body=${a}`}},u=c("div",{class:"rui-share"});for(const d of s){if(d==="copy"){const h=c("button",{class:"rui-share-btn",type:"button","aria-label":"Copy link",title:"Copy link"}),g=L("link");g&&h.append(g),h.onclick=()=>{try{navigator.clipboard?.writeText(r)}catch{}},u.append(h);continue}const p=l[d];if(!p)continue;const f=c("a",{class:"rui-share-btn",href:p.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Share on ${d}`}),b=L(p.icon);b&&f.append(b),u.append(f)}return u}},{name:"AuthorByline",description:"An author byline: avatar, name, optional role and date — for articles/blog posts.",props:[{name:"name",type:"string",positional:!0,required:!0},{name:"avatar",type:"string",optional:!0,aliases:["src"]},{name:"role",type:"string",optional:!0},{name:"date",type:"string",optional:!0}],render:(t,e)=>{const r=c("div",{class:"rui-byline"}),n=re(e.avatar),a=c("div",{class:"rui-byline-avatar"});n?a.append(c("img",{src:n,alt:m(e.name)})):a.append(c("span",{},[m(e.name).split(/\s+/).filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")])),r.append(a);const i=c("div",{class:"rui-byline-meta"});i.append(c("div",{class:"rui-byline-name"},[m(e.name)]));const o=[m(e.role),m(e.date)].filter(Boolean).join(" · ");return o&&i.append(c("div",{class:"rui-byline-sub"},[o])),r.append(i),r}},{name:"VariantSelector",description:"Product variant picker — color swatches or size pills. `options` is an array of strings or {label, value, color?}. Bind `value` to a $variable; `onChange(value)` fires on select.",props:[{name:"options",type:"any[]",positional:!0,required:!0,aliases:["items"]},{name:"value",type:"string",optional:!0},{name:"kind",type:"string",optional:!0,enum:["pill","swatch"]},{name:"label",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=m(e.kind,"pill"),a=c("div",{class:"rui-variants","data-kind":n}),i=m(e.label);i&&a.append(c("div",{class:"rui-variants-label"},[i]));const o=c("div",{class:"rui-variants-row"}),s=m(e.value),l=t.argMeta?.find(u=>u?.stateRef)?.stateRef;for(const u of T(e.options)){const d=u&&typeof u=="object"?u:{label:u,value:u},p=m(d.value??d.label),f=p===s,b=c("button",{class:"rui-variant",type:"button","aria-pressed":f?"true":"false","data-selected":f?"true":null});if(n==="swatch"){const h=m(d.color??d.value);b.style.background=/^[a-zA-Z#()0-9,.\s-]+$/.test(h)?h:"var(--rui-color-surface-muted)",b.title=m(d.label??d.value)}else b.textContent=m(d.label??d.value);b.onclick=()=>{l&&r.setState(l,p),r.invoke(e.onChange,p)},o.append(b)}return a.append(o),a}},{name:"OrderSummary",description:"An order/cart summary: line items, subtotal, shipping, tax, and a bold total. Pass `items` as {label, amount} and the named totals; `currency` prefixes amounts.",props:[{name:"items",type:"object[]",positional:!0,required:!0,aliases:["lines"]},{name:"subtotal",type:"string | number",optional:!0},{name:"shipping",type:"string | number",optional:!0},{name:"tax",type:"string | number",optional:!0},{name:"total",type:"string | number",optional:!0},{name:"currency",type:"string",optional:!0}],render:(t,e)=>{const r=m(e.currency,"$"),n=s=>s==null||m(s)===""?"":`${r}${m(s)}`,a=c("div",{class:"rui-order-summary"}),i=c("div",{class:"rui-order-lines"});for(const s of T(e.items)){const l=s??{},u=c("div",{class:"rui-order-line"});u.append(c("span",{},[m(l.label)]),c("span",{},[n(l.amount)])),i.append(u)}a.append(i);const o=(s,l,u=!1)=>{if(l==null||m(l)==="")return;const d=c("div",{class:u?"rui-order-total":"rui-order-sub"});d.append(c("span",{},[s]),c("span",{},[n(l)])),a.append(d)};return o("Subtotal",e.subtotal),o("Shipping",e.shipping),o("Tax",e.tax),o("Total",e.total,!0),a}},{name:"ScrollSpy",description:"A sticky in-page nav that highlights the section currently in view. `sections` is an array of {label, id} matching element ids on the page (set via the universal `id` prop). Clicking smooth-scrolls to a section.",props:[{name:"sections",type:"object[]",positional:!0,required:!0,aliases:["items"]},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const n=c("nav",{class:"rui-scrollspy","aria-label":"On this page"}),a=m(e.title);a&&n.append(c("div",{class:"rui-scrollspy-title"},[a]));const i=c("ul",{class:"rui-scrollspy-list"}),o=T(e.sections).map(l=>{const u=l??{};return{label:m(u.label),id:m(u.id).replace(/[^A-Za-z0-9_-]/g,"")}}).filter(l=>l.id),s=new Map;for(const l of o){const u=c("li",{class:"rui-scrollspy-item"}),d=c("a",{href:`#${l.id}`},[l.label]);d.onclick=p=>{p.preventDefault(),(d.getRootNode()?.getElementById?.(l.id)??document.getElementById(l.id))?.scrollIntoView({behavior:"smooth",block:"start"})},u.append(d),i.append(u),s.set(l.id,d)}return n.append(i),typeof IntersectionObserver<"u"&&setTimeout(()=>{const l=n.getRootNode(),u=new IntersectionObserver(d=>{for(const p of d)if(p.isIntersecting){s.forEach(b=>b.classList.remove("is-active"));const f=p.target.id;s.get(f)?.classList.add("is-active")}},{rootMargin:"0px 0px -70% 0px",threshold:0});for(const d of o){const p=l.getElementById?.(d.id)??document.getElementById(d.id);p&&u.observe(p)}r.registerDisposer(()=>u.disconnect(),"rui-scrollspy-io")},0),n}},{name:"SpeedDial",description:"A floating action button that expands a stack of mini-actions on click. Pass `actions` as {icon, label, onClick}.",props:[{name:"actions",type:"object[]",positional:!0,required:!0,aliases:["items"]},{name:"icon",type:"string",optional:!0,description:"Main FAB icon (default 'plus')"}],render:(t,e,r)=>{const n=c("div",{class:"rui-speeddial"}),a=c("div",{class:"rui-speeddial-menu"});for(const s of T(e.actions)){const l=s??{},u=c("button",{class:"rui-speeddial-action",type:"button",title:m(l.label),"aria-label":m(l.label)}),d=L(l.icon??"circle");d&&u.append(d),u.onclick=p=>{r.invoke(l.onClick??l.action),((p.currentTarget??p.target)?.closest(".rui-speeddial")??n).classList.remove("is-open")},a.append(u)}n.append(a);const i=c("button",{class:"rui-speeddial-fab",type:"button","aria-label":"Actions","aria-expanded":"false"}),o=L(e.icon??"plus",{size:"lg"});return o&&i.append(o),i.onclick=s=>{const l=s.currentTarget??s.target??i,d=(l.closest(".rui-speeddial")??n).classList.toggle("is-open");l.setAttribute("aria-expanded",d?"true":"false")},n.append(i),n}},{name:"Confetti",description:"A one-shot confetti burst — celebration affordance after a success (checkout, completion). Renders a short CSS particle animation when `fire` is true. Honours prefers-reduced-motion.",props:[{name:"fire",type:"boolean",optional:!0,description:"Trigger the burst (default true)"},{name:"count",type:"number",optional:!0,description:"Particle count (default 40, max 120)"}],render:(t,e)=>{const r=c("div",{class:"rui-confetti","aria-hidden":"true"}),n=e.fire===void 0?!0:N(e.fire),a=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(!n||a)return r;const i=Math.max(1,Math.min(120,Math.round(I(e.count,40)))),o=["#6366f1","#8b5cf6","#ec4899","#22d3ee","#10b981","#f59e0b"];for(let s=0;s<i;s+=1){const l=Math.round((s*53+7)%100),u=s*17%50/100,d=1+s*7%10/10,p=o[s%o.length],f=s*47%360,b=c("span",{class:"rui-confetti-piece",style:`left:${l}%;background:${p};animation-delay:${u}s;animation-duration:${d}s;transform:rotate(${f}deg)`});b.onanimationend=h=>{(h.currentTarget??h.target)?.remove()},r.append(b)}return r}},{name:"KbdShortcut",description:'Render a keyboard shortcut as styled key caps. Pass `keys` as an array (e.g. ["Cmd", "K"]) or a \'+\'-joined string.',props:[{name:"keys",type:"string | string[]",positional:!0,required:!0}],render:(t,e)=>{const r=e.keys,n=Array.isArray(r)?r.map(i=>m(i)):m(r).split("+").map(i=>i.trim()).filter(Boolean),a=c("span",{class:"rui-kbd-shortcut"});return n.forEach((i,o)=>{o>0&&a.append(c("span",{class:"rui-kbd-plus"},["+"])),a.append(c("kbd",{class:"rui-kbd-key"},[i]))}),a}},{name:"Lottie",description:"Plays a Lottie/Bodymovin vector animation from `src` (a .json URL) or inline `data`. Uses the `lottie-web` library when it is present on the page (`window.lottie`); otherwise shows the `fallback` (or a poster image) so the layout never breaks. `loop`/`autoplay` default true; `speed` scales playback. No dependency is bundled.",props:[{name:"src",type:"string",optional:!0,description:"URL to a Lottie JSON file"},{name:"data",type:"object",optional:!0,description:"Inline Lottie animation data"},{name:"loop",type:"boolean",optional:!0},{name:"autoplay",type:"boolean",optional:!0},{name:"speed",type:"number",optional:!0},{name:"width",type:"string",optional:!0},{name:"height",type:"string",optional:!0},{name:"poster",type:"string",optional:!0,description:"Image shown when lottie-web is unavailable"},{name:"fallback",type:"Node",optional:!0,description:"Node shown when lottie-web is unavailable and no poster"}],render:(t,e,r)=>{const n=m(e.width,"200px"),a=m(e.height,"200px"),i=c("div",{class:"rui-lottie",style:`width:${n};height:${a}`}),o=typeof window<"u"?window.lottie:null,s=e.data&&typeof e.data=="object"?e.data:null,l=re(e.src);if(!o||!s&&!l){const u=re(e.poster);return u?i.append(c("img",{src:u,alt:"animation",class:"rui-lottie-poster",style:"width:100%;height:100%;object-fit:contain"})):e.fallback!=null?i.append(r.renderNode(e.fallback)):i.classList.add("rui-lottie-empty"),i}return setTimeout(()=>{try{const u=o.loadAnimation({container:i,renderer:"svg",loop:e.loop===void 0?!0:N(e.loop),autoplay:e.autoplay===void 0?!0:N(e.autoplay),...s?{animationData:s}:{path:l}}),d=I(e.speed,1);d!==1&&typeof u.setSpeed=="function"&&u.setSpeed(d),r.registerDisposer(()=>{try{u.destroy?.()}catch{}},"rui-lottie")}catch{i.classList.add("rui-lottie-empty")}},0),i}},pb,mb,fb,gb,Mb,Nb,Ib,Pb,zb,Db,Bb,Ob,oh,dh],Hb=[{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 `none|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl` (`none` = 0); `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","Toasts","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. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `Toasts(children, position?)` stacks toasts in a viewport corner. Pair it with the `$toast` namespace: `Toasts($toast.items.map(t => Toast({ title: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))`.","- `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 rendering until the async `loader` resolves, showing `fallback` while pending (a synchronous loader value renders immediately).","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","OnMount","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.","- `OnMount(child, { onMount?, onUnmount? })` is the DOM-ref / lifecycle wrapper. `onMount(node)` fires once after the wrapped element attaches; `onUnmount(node)` fires when it leaves the tree. Use it to measure or focus an element, or to hand a node to an imperative library (chart / map / editor). Stash the node in a `$ref(...)`.","- `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."]}];Ri(fs);const kt={root:"Column",components:fs,componentGroups:Hb},qb=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},Vb=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},Wb=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const n of r.components)e.set(n,r.name);return e};function gs(t=kt){const e=Wb(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(qb),signature:Vb(r)}))}function hs(t){const e={};for(const r of t)e[r.name]=r;return e}const bs=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function vs(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function ys(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Ln(t,e){if(t.has(e))return!0;for(const r of t)if(ys(r,e))return!0;return!1}function zt(t,e){for(const r of e)if(Ln(t,r))return!0;return!1}class Dn{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,n){if(r.length===0){this.set(e,n);return}const a=this.values.get(e),i=Rt(a,r,0,n);this.values.set(e,i),this.enqueueChange(vs(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,n)=>{e[n]=r}),e}hydrate(e){for(const[r,n]of Object.entries(e))this.values.set(r,n)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const n=this.defaults.get(r);this.values.get(r)!==n&&(this.values.set(r,n),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,n]of e)this.defaults.set(r,n),this.values.set(r,n)}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,n){if(r>=e.length)return n;const a=e[r],i=a!==""&&!Number.isNaN(Number(a))?Number(a):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=Rt(t[i],e,r+1,n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[a]=Rt(t[a],e,r+1,n),s}if(i!==null){const s=[];return s[i]=Rt(void 0,e,r+1,n),s}const o={};return o[a]=Rt(void 0,e,r+1,n),o}const kr=Symbol("aktion.httpResource");function xs(t){return typeof t=="object"&&t!==null&&t[kr]===!0}class jn{constructor(){j(this,"interceptors",{});j(this,"programInterceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}registerProgramInterceptors(e){this.programInterceptors={...this.programInterceptors,...e}}clearProgramInterceptors(){this.programInterceptors={}}fireError(e,r){this.interceptors.onError?.(e,r),this.programInterceptors.onError?.(e,r)}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};const n=[this.interceptors.onRequest,this.programInterceptors.onRequest];for(const i of n)if(i)try{r=await i(r)}catch(o){throw this.fireError(o,r),o}const a=async()=>{const i=new AbortController,o=typeof fetch=="function"?fetch:null;if(!o)throw new Error("`fetch` is not available in this environment");const s={...r.init,method:r.method,headers:r.headers,signal:r.signal??i.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(s.body=Gb(r.body,r.headers));const l=await o(r.url,s),u={};l.headers.forEach((f,b)=>{u[b]=f});const d=u["content-type"]??"";let p;return l.status===204||r.method==="HEAD"?p=null:d.includes("application/json")?p=await l.json().catch(()=>null):p=await l.text().catch(()=>""),{status:l.status,headers:u,body:p}};try{let i=await a();const o=[this.programInterceptors.onResponse,this.interceptors.onResponse];for(const s of o){if(!s)continue;let l=!1;i=await s(i,async()=>l?i:(l=!0,a()))}return i}catch(i){throw this.fireError(i,r),i}}}function Gb(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 Kb=new Set(["url","method","headers","body","query","signal","gql","variables","optimistic","invalidates"]);function Bn(t,e){const n=(Array.isArray(e)?e:e!=null?[e]:[]).map(a=>String(a)).filter(Boolean);if(n.length!==0)for(const[a,i]of t.queryCache)n.some(o=>a.includes(o))&&(i.loading||i.refetch())}function On(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",n=typeof e.gql=="string"&&e.gql.trim().length>0,a=n?"POST":typeof e.method=="string"?e.method.toUpperCase():"GET",i={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[u,d]of Object.entries(e.headers))d!=null&&(i[u]=String(d));let o=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const u=new URLSearchParams;for(const[p,f]of Object.entries(e.query))f!=null&&u.append(p,String(f));const d=u.toString();d&&(o+=(o.includes("?")?"&":"?")+d)}const s={};for(const[u,d]of Object.entries(e))Kb.has(u)||(s[u]=d);const l={url:o,method:a,headers:i,body:n?{query:e.gql,variables:qe(e.variables)}:e.body};return Object.keys(s).length>0&&(l.init=s),e.signal instanceof AbortSignal&&(l.signal=e.signal),l}function Fn(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{a+=1,n&&n.abort(),n=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,kr,{value:!0,enumerable:!1,writable:!1});let n=null,a=0;const i=()=>e.notify?.(),o=async()=>{const s=a+=1;n&&n.abort(),n=new AbortController;const l=n;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=On(t);u.url=e.http.resolveUrl(u.url),u.signal=l.signal;const d=await e.http.request(u);if(s!==a)return;const p=d.status>=200&&d.status<300,f=typeof qe(t).gql=="string",b=f?qe(d.body):null,h=b&&Array.isArray(b.errors)&&b.errors.length>0?b.errors:null;p&&!h?(r.data=f?b.data:d.body,r.state="data",r.error=void 0):(r.error=h?{graphqlErrors:h}:{status:d.status,body:d.body},r.state="error"),r.status=d.status,r.headers=d.headers,r.lastUpdated=Date.now()}catch(u){if(s!==a||u?.name==="AbortError")return;r.error=u,r.state="error"}finally{if(s===a&&(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 qe(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function ws(t){return t===!0||t==="true"}function ks(t){const e=typeof t.method=="string"?t.method.toUpperCase():"GET",r=typeof t.url=="string"?t.url:"";let n="null",a="null";try{n=JSON.stringify(t.query??null)}catch{}try{a=JSON.stringify(t.body??null)}catch{}let i="null";if(typeof t.gql=="string"){let o="null";try{o=JSON.stringify(t.variables??null)}catch{}i=`${t.gql}|${o}`}return`${e} ${r} ${n} ${a} ${i}`}function Ss(t,e){const r=qe(t);if(r.infinite&&typeof r.infinite=="object"){const d=r.key!=null?String(r.key):ks(r),p=e.queryCache.get(d);if(p)return p;const f=Yb(r,e);return e.queryCache.set(d,f),f}const n=typeof r.ttl=="number"?r.ttl:0,a=r.key!=null?String(r.key):ks(r),i=e.queryCache,o=i.get(a);if(o)return n>0&&o.lastUpdated!=null&&Date.now()-o.lastUpdated>n&&!o.loading&&o.refetch(),o;const s={};for(const[d,p]of Object.entries(r))d==="key"||d==="ttl"||d==="refetchInterval"||d==="refetchOnFocus"||d==="refetchOnReconnect"||(s[d]=p);const l=Fn(s,e);i.set(a,l);const u=typeof r.refetchInterval=="number"?r.refetchInterval:0;if(u>0){const d=setInterval(()=>{l.loading||l.refetch()},Math.max(250,u));e.disposers.push(()=>clearInterval(d))}if(ws(r.refetchOnFocus)&&typeof window<"u"){const d=()=>{l.loading||l.refetch()};window.addEventListener("focus",d),e.disposers.push(()=>window.removeEventListener("focus",d))}if(ws(r.refetchOnReconnect)&&typeof window<"u"){const d=()=>{l.loading||l.refetch()};window.addEventListener("online",d),e.disposers.push(()=>window.removeEventListener("online",d))}return l}function Yb(t,e){const r=qe(t.infinite),n=typeof r.param=="string"?r.param:"page",a=typeof r.limit=="number"&&r.limit>0?r.limit:20,i=typeof r.start=="number"?r.start:r.mode==="offset"?0:1,o=r.mode==="offset"?"offset":"page",s=typeof r.select=="function"?r.select:null,l=()=>e.notify?.(),u=[];let d=i,p=!1;const f={};for(const[v,x]of Object.entries(t))v==="key"||v==="ttl"||v==="infinite"||(f[v]=x);const b=v=>{const x=s?s(v):v;return Array.isArray(x)?x:[]},h=()=>{const v=[];for(const x of u)for(const w of b(x))v.push(w);return v},g={state:"loading",data:[],error:void 0,loading:!0,hasMore:!0,loadingMore:!1,page:i,pages:u,refetch:async()=>{p||(u.length=0,d=i,g.hasMore=!0,await y(!0))},cancel:()=>{},loadMore:async()=>{p||!g.hasMore||await y(!1)}};Object.defineProperty(g,kr,{value:!0,enumerable:!1,writable:!1});const y=async v=>{if(!e.http){g.error={message:"http runtime not available"},g.state="error",g.loading=!1,l();return}p=!0,v||u.length===0?(g.loading=!0,g.state=u.length?"stale":"loading"):g.loadingMore=!0,l();try{const x=d,w={...f,query:{...qe(f.query),[n]:x,limit:a}},k=On(w);k.url=e.http.resolveUrl(k.url);const A=await e.http.request(k);if(!(A.status>=200&&A.status<300)){g.error={status:A.status,body:A.body},g.state="error";return}const $=b(A.body);u.push(A.body),g.hasMore=$.length>=a,d=o==="offset"?d+a:d+1,g.page=o==="offset"?u.length:d-1,g.data=h(),g.error=void 0,g.state="data",g.lastUpdated=Date.now()}catch(x){if(x?.name==="AbortError")return;g.error=x,g.state="error"}finally{p=!1,g.loading=!1,g.loadingMore=!1,l()}};return y(!0),g}function $s(t,e){const r=qe(t);let n=0,a=null;const i=()=>e.notify?.(),o={data:void 0,error:void 0,loading:!1,reset:()=>{n+=1,a&&a.abort(),a=null,o.data=void 0,o.error=void 0,o.status=void 0,o.loading=!1,i()},mutate:async s=>{const l=n+=1;a&&a.abort(),a=new AbortController;const u=a;o.loading=!0,o.error=void 0;const d=r.optimistic;let p=null;if(typeof d=="function"){const f=new Map;for(const[b,h]of e.state.entries())f.set(b,h);p=()=>{for(const[b]of e.state.entries())f.has(b)||e.state.set(b,void 0);for(const[b,h]of f)e.state.set(b,h);e.notify?.()};try{d(qe(s))}catch{}}if(i(),!e.http){o.error={message:"http runtime not available"},o.loading=!1,p&&p(),i();return}try{const f={method:"POST",...r,...qe(s)},b=On(f);b.url=e.http.resolveUrl(b.url),b.signal=u.signal;const h=await e.http.request(b);if(l!==n)return;const g=h.status>=200&&h.status<300;return g?(o.data=h.body,o.error=void 0,r.invalidates!=null&&Bn(e,r.invalidates)):(o.error={status:h.status,body:h.body},p&&p()),o.status=h.status,g?h.body:void 0}catch(f){if(l!==n||f?.name==="AbortError")return;o.error=f,p&&p();return}finally{if(l===n&&(o.loading=!1,i(),typeof o.onDone=="function"))try{o.onDone(o)}catch(f){console.error("[aktion] $mutation onDone callback threw",f)}}}};return Object.defineProperty(o,kr,{value:!0,enumerable:!1,writable:!1}),o}function Cs(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function As(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}const Xb=100,Zb=500,Qb=15e3;function Jb(t,e){const r=Cs(t),n=typeof r.url=="string"?r.url:"",a=typeof r.bufferSize=="number"&&r.bufferSize>0?Math.floor(r.bufferSize):50,i=typeof r.onMessage=="function"?r.onMessage:null,o=r.reconnect===!0?1/0:typeof r.reconnect=="number"&&r.reconnect>0?Math.floor(r.reconnect):0,s=()=>e.notify?.(),l={connected:!1,status:"closed",messages:[],last:null,error:void 0,attempts:0,send:()=>{},close:()=>{}},u=v=>{l.status!==v&&(l.status=v,l.connected=v==="open",s())};if(!n||typeof WebSocket>"u")return l.error={message:"WebSocket not available"},l;let d=null,p=!1,f=null;const b=[],h=()=>{for(;b.length>0&&d&&d.readyState===WebSocket.OPEN;)d.send(b.shift())},g=()=>{if(p||l.attempts>=o){u("closed");return}l.attempts+=1;const v=Math.min(Qb,Zb*2**(l.attempts-1));u("connecting"),f=setTimeout(()=>{f=null,y()},v)},y=()=>{let v;try{v=r.protocols!=null?new WebSocket(n,r.protocols):new WebSocket(n)}catch(x){l.error=x,u("closed");return}d=v,u("connecting"),v.addEventListener("open",()=>{d===v&&(l.error=void 0,l.attempts=0,u("open"),h())}),v.addEventListener("close",()=>{d===v&&(!p&&o>0?g():u("closed"))}),v.addEventListener("error",x=>{d===v&&(l.error=x,s())}),v.addEventListener("message",x=>{if(d!==v)return;const w=As(x.data);if(l.last=w,l.messages=[...l.messages,w].slice(-a),i)try{i(w)}catch{}s()})};return l.send=v=>{const x=typeof v=="string"?v:JSON.stringify(v);if(d&&d.readyState===WebSocket.OPEN){d.send(x);return}l.status==="connecting"&&b.length<Xb&&b.push(x)},l.close=()=>{p=!0,f!=null&&(clearTimeout(f),f=null),b.length=0;try{d?.close()}catch{}u("closed")},y(),e.disposers.push(()=>{p=!0,f!=null&&(clearTimeout(f),f=null);try{d?.close()}catch{}}),l}function ev(t,e){const r=Cs(t),n=typeof r.url=="string"?r.url:"",a=typeof r.bufferSize=="number"&&r.bufferSize>0?Math.floor(r.bufferSize):50,i=typeof r.event=="string"&&r.event?r.event:"message",o=typeof r.onMessage=="function"?r.onMessage:null,s=()=>e.notify?.(),l={connected:!1,status:"closed",messages:[],last:null,error:void 0,close:()=>{}};if(!n||typeof EventSource>"u")return l.error={message:"EventSource not available"},l;let u=null;try{u=new EventSource(n,{withCredentials:r.withCredentials===!0})}catch(p){return l.error=p,l}const d=u;return l.status="connecting",l.close=()=>{try{d.close()}catch{}l.connected=!1,l.status="closed",s()},d.addEventListener("open",()=>{l.connected=!0,l.status="open",l.error=void 0,s()}),d.addEventListener("error",p=>{l.error=p,l.connected=!1,l.status=d.readyState===2?"closed":"connecting",s()}),d.addEventListener(i,p=>{const f=As(p.data);if(l.last=f,l.messages=[...l.messages,f].slice(-a),o)try{o(f)}catch{}s()}),e.disposers.push(()=>{try{d.close()}catch{}}),l}function Ts(t={}){const e=tv(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let n=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function a(s,l){if(typeof s!="string"||!s)return"";const u=e[s];let d;return u&&(n&&typeof u[n]=="string"?d=u[n]:r&&typeof u[r]=="string"&&(d=u[r])),d===void 0?s:rv(d,l,n||r||"en")}function i(s){typeof s!="string"||!s||(n=s)}function o(){return n}return{t:a,setCurrentLanguage:i,getCurrentLanguage:o}}function tv(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const a={};for(const[i,o]of Object.entries(n))typeof o=="string"&&(a[i]=o);e[r]=a}return e}function rv(t,e,r="en"){return nv(t,e??{},r).replace(/\{([^{}]+)\}/g,(a,i)=>{const o=(e??{})[i.trim()];return o==null?"":String(o)})}function nv(t,e,r){let n="",a=0;for(;a<t.length;){const i=t.indexOf("{",a);if(i===-1){n+=t.slice(a);break}const o=Ms(t,i);if(o===-1){n+=t.slice(a);break}const s=t.slice(i+1,o),l=av(s,e,r);l!==null?n+=t.slice(a,i)+l:n+=t.slice(a,o+1),a=o+1}return n}function Ms(t,e){let r=0;for(let n=e;n<t.length;n+=1)if(t[n]==="{")r+=1;else if(t[n]==="}"&&(r-=1,r===0))return n;return-1}function av(t,e,r){const n=t.indexOf(",");if(n===-1)return null;const a=t.slice(0,n).trim(),i=t.indexOf(",",n+1);if(i===-1)return null;const o=t.slice(n+1,i).trim(),s=t.slice(i+1);if(o!=="plural"&&o!=="select")return null;const l=iv(s);if(!l)return null;const u=e[a];if(o==="select")return l[String(u)]??l.other??"";const d=typeof u=="number"?u:Number(u);if(Number.isFinite(d)){let f=l[`=${d}`];if(f===void 0){let h="other";try{h=new Intl.PluralRules(r).select(d)}catch{}f=l[h]??l.other}const b=ov(d,r);return(f??"").replace(/#/g,b)}return l.other??""}function iv(t){const e={};let r=0,n=!1;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r+=1;if(r>=t.length)break;const a=t.indexOf("{",r);if(a===-1)break;const i=t.slice(r,a).trim(),o=Ms(t,a);if(o===-1)break;e[i]=t.slice(a+1,o),n=!0,r=o+1}return n?e:null}function ov(t,e){try{return new Intl.NumberFormat(e).format(t)}catch{return String(t)}}const H=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,oe=t=>Array.isArray(t)?t:[],Ke=t=>!!t&&typeof t=="object"&&!Array.isArray(t),_n=(t,e,r)=>{switch(t){case"==":return e===r;case"!=":return e!==r;case">":return H(e)>H(r);case"<":return H(e)<H(r);case">=":return H(e)>=H(r);case"<=":return H(e)<=H(r);case"contains":{const n=String(e??"").toLowerCase(),a=String(r??"").toLowerCase();return n.includes(a)}case"startsWith":return String(e??"").toLowerCase().startsWith(String(r??"").toLowerCase());case"endsWith":return String(e??"").toLowerCase().endsWith(String(r??"").toLowerCase());default:return!1}},Lt=t=>{if(Array.isArray(t))return t.map(e=>Lt(e));if(t instanceof Date)return new Date(t.getTime());if(t&&typeof t=="object"){const e={};for(const r of Object.keys(t))e[r]=Lt(t[r]);return e}return t},Ye=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const n of e.split("."))if(r&&typeof r=="object")r=r[n];else return;return r}return t[e]}},Xe=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},sv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],lv=["January","February","March","April","May","June","July","August","September","October","November","December"],cv=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],uv=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dv=(t,e)=>{const r=(s,l=2)=>String(s).padStart(l,"0"),n=t.getHours(),a=(n+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,lv[t.getMonth()]],[/MMM/g,sv[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,uv[t.getDay()]],[/ddd/g,cv[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(n)],[/hh/g,r(a)],[/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(n)],[/\bh\b/g,String(a)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,n>=12?"PM":"AM"],[/a/g,n>=12?"pm":"am"]];let o=e;for(const[s,l]of i)o=o.replace(s,l);return o},pv=(t,e=Date.now())=>{const r=e-t.getTime(),n=Math.abs(r),a=r<0,i=6e4,o=60*i,s=24*o,l=7*s,u=30*s,d=365*s;let p,f;return n<i?a?"in a moment":"just now":(n<o?(p=Math.round(n/i),f="m"):n<s?(p=Math.round(n/o),f="h"):n<l?(p=Math.round(n/s),f="d"):n<u?(p=Math.round(n/l),f="w"):n<d?(p=Math.round(n/u),f="mo"):(p=Math.round(n/d),f="y"),a?`in ${p}${f}`:`${p}${f} ago`)},mv=(t,e,r)=>{if(Ke(e)){const a={};return typeof e.currency=="string"&&(a.currency=e.currency),typeof e.locale=="string"&&(a.locale=e.locale),typeof e.decimals=="number"&&(a.decimals=e.decimals),a}const n={};return t==="currency"?(typeof e=="string"&&e.length>0&&(n.currency=e),typeof r=="string"&&r.length>0&&(n.locale=r)):typeof e=="string"&&e.length>0&&(n.locale=e),n},fv=(t,e)=>{const n=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(n.length===0)return"";if(e==="snake")return n.join("_");if(e==="kebab")return n.join("-");const a=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?n.map(a).join(""):n[0]+n.slice(1).map(a).join("")},Sr={count:t=>oe(t).length,sum:t=>oe(t).reduce((e,r)=>e+H(r),0),avg:t=>{const e=oe(t);return e.length===0?0:e.reduce((r,n)=>r+H(n),0)/e.length},min:t=>{const e=oe(t).map(H);return e.length===0?0:Math.min(...e)},max:t=>{const e=oe(t).map(H);return e.length===0?0:Math.max(...e)},first:t=>oe(t)[0]??null,last:t=>{const e=oe(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",n)=>oe(t).filter(a=>_n(r,Ye(a,String(e)),n)),find:(t,e="",r="==",n)=>oe(t).find(a=>_n(r,Ye(a,String(e)),n))??null,sort:(t,e="",r="asc")=>{const n=[...oe(t)],a=String(r).toLowerCase()==="desc"?-1:1;return n.sort((i,o)=>{const s=Ye(i,String(e)),l=Ye(o,String(e));return typeof s=="number"&&typeof l=="number"?(s-l)*a:String(s??"").localeCompare(String(l??""))*a}),n},groupBy:(t,e="")=>{const r={};for(const n of oe(t)){const a=String(Ye(n,String(e))??"");(r[a]??(r[a]=[])).push(n)}return r},slice:(t,e,r)=>{const n=oe(t);return n.slice(e??0,r??n.length)},unique:(t,e)=>{const r=oe(t);if(!e)return Array.from(new Set(r));const n=new Set,a=[];for(const i of r){const o=Ye(i,e);n.has(o)||(n.add(o),a.push(i))}return a},reverse:t=>[...oe(t)].reverse(),range:(t,e,r)=>{const n=H(t),a=H(e),i=r===void 0?a>=n?1:-1:H(r);if(i===0)return[n];const o=Math.abs(a-n),s=Math.floor(o/Math.abs(i))+1;if(s>$r)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${$r}).`);const l=[];if(i>0)for(let u=n;u<=a;u+=i)l.push(u);else for(let u=n;u>=a;u+=i)l.push(u);return l},repeat:(t,e)=>{const r=Math.max(0,H(e));if(r>$r)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${$r}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!Ke(t))return{};const r=oe(e).map(a=>String(a??"")),n={};for(const a of r)a in t&&(n[a]=t[a]);return n},omit:(t,e)=>{if(!Ke(t))return{};const r=new Set(oe(e).map(a=>String(a??""))),n={};for(const a of Object.keys(t))r.has(a)||(n[a]=t[a]);return n},chunk:(t,e)=>{const r=oe(t),n=Math.max(1,Math.floor(H(e))),a=[];for(let i=0;i<r.length;i+=n)a.push(r.slice(i,i+n));return a},flatten:(t,e=1)=>{const r=(n,a)=>a<=0?n.slice():n.reduce((i,o)=>(Array.isArray(o)?i.push(...r(o,a-1)):i.push(o),i),[]);return r(oe(t),Math.max(0,Math.floor(H(e))))},zip:(...t)=>{const e=t.map(oe),r=e.reduce((a,i)=>Math.max(a,i.length),0),n=[];for(let a=0;a<r;a+=1)n.push(e.map(i=>i[a]??null));return n},partition:(t,e="",r="==",n)=>{const a=[],i=[];for(const o of oe(t))(_n(r,Ye(o,String(e)),n)?a:i).push(o);return[a,i]},keyBy:(t,e="")=>{const r={};for(const n of oe(t))r[String(Ye(n,String(e))??"")]=n;return r},cloneDeep:t=>Lt(t),merge:(t,...e)=>{const r=Ke(t)?Lt(t):{};for(const n of e)if(Ke(n))for(const a of Object.keys(n)){const i=n[a],o=r[a];r[a]=Ke(o)&&Ke(i)?Sr.merge(o,i):Ke(i)||Array.isArray(i)?Lt(i):i}return r},format:(t,e="number",r,n)=>{const a=H(t),i=String(e),o=mv(i,r,n),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(a)}catch{return i==="currency"?a.toFixed(o.decimals??2):String(a)}},formatDate:(t,e="MMM D")=>{const r=Xe(t),n=String(e);switch(n){case"relative":return pv(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 dv(r,n)}},plural:(t,e,r)=>{const n=H(t),a=String(e??""),i=r===void 0?a+"s":String(r??"");return`${n} ${n===1?a: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 fv(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=Xe(t),n=new Date(r.getTime());return n.setDate(n.getDate()+H(e)),n.toISOString()},addHours:(t,e)=>{const r=Xe(t);return new Date(r.getTime()+H(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=Xe(t),n=Xe(e);return Math.round((n.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=Xe(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=Xe(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>oe(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 n=String(t??"");return n.substring(H(e),r===void 0?n.length:H(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,H(e));return Math.round(H(t)*r)/r},floor:t=>Math.floor(H(t)),ceil:t=>Math.ceil(H(t)),abs:t=>Math.abs(H(t)),clamp:(t,e,r)=>Math.min(Math.max(H(t),H(e)),H(r)),pow:(t,e)=>Math.pow(H(t),H(e)),sqrt:t=>Math.sqrt(H(t)),random:()=>Math.random(),log:t=>Math.log(H(t)),slugify:t=>String(t??"").toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),truncate:(t,e=80,r="…")=>{const n=String(t??""),a=H(e);return n.length<=a?n:n.slice(0,Math.max(0,a-1)).trimEnd()+String(r)},initials:(t,e=2)=>String(t??"").split(/\s+/).filter(Boolean).slice(0,H(e)).map(r=>r.charAt(0).toUpperCase()).join(""),currency:(t,e="USD",r)=>{try{return new Intl.NumberFormat(r,{style:"currency",currency:String(e)}).format(H(t))}catch{return`${e} ${H(t).toFixed(2)}`}},percent:(t,e=0)=>`${(H(t)*100).toFixed(H(e))}%`,bytes:t=>{let e=H(t);const r=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<r.length-1;)e/=1024,n+=1;return`${n===0?e:e.toFixed(1)} ${r[n]}`},relativeTime:t=>{const e=Xe(t),r=e.getTime()-Date.now(),n=Math.abs(r),a=[["year",31536e6],["month",2592e6],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];try{const i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[o,s]of a)if(n>=s||o==="second")return i.format(Math.round(r/s),o)}catch{}return e.toLocaleString()},copy:t=>{try{const r=(typeof navigator<"u"?navigator:null)?.clipboard?.writeText?.(String(t??""));return r&&typeof r.then=="function"?r.then(()=>!0,()=>!1):Promise.resolve(!1)}catch{return Promise.resolve(!1)}},sleep:(t=0)=>{const e=H(t),r=Number.isFinite(e)?Math.max(0,Math.min(6e4,e)):0;return new Promise(n=>setTimeout(n,r))},uuid:()=>{try{const t=typeof crypto<"u"?crypto:null;if(t?.randomUUID)return t.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},debounceFn:(t,e=250)=>{const r=H(e),n=Number.isFinite(r)&&r>0?r:250;let a=null;return(...i)=>{typeof t=="function"&&(a&&clearTimeout(a),a=setTimeout(()=>{t(...i)},n))}},throttleFn:(t,e=250)=>{const r=H(e),n=Number.isFinite(r)&&r>0?r:250;let a=0,i=null,o=[];return(...s)=>{if(typeof t!="function")return;const l=Date.now();if(l-a>=n){a=l,t(...s);return}o=s,!i&&(i=setTimeout(()=>{i=null,a=Date.now(),t(...o)},n-(l-a)))}},vibrate:(t=10)=>{try{const e=typeof navigator<"u"?navigator:null;if(!e?.vibrate)return!1;const r=Array.isArray(t)?t.map(n=>Number(n)||0):Number(t)||0;return e.vibrate(r)}catch{return!1}},share:t=>{try{const e=typeof navigator<"u"?navigator:null;if(!e?.share)return Promise.resolve(!1);const r=t&&typeof t=="object"?t:{text:String(t??"")};return e.share(r).then(()=>!0).catch(()=>!1)}catch{return Promise.resolve(!1)}},readClipboard:()=>{try{const t=typeof navigator<"u"?navigator:null;return t?.clipboard?.readText?t.clipboard.readText().catch(()=>""):Promise.resolve("")}catch{return Promise.resolve("")}},geolocate:t=>new Promise(e=>{try{const r=typeof navigator<"u"?navigator:null;if(!r?.geolocation){e(null);return}r.geolocation.getCurrentPosition(n=>e({lat:n.coords.latitude,lng:n.coords.longitude,accuracy:n.coords.accuracy}),()=>e(null),t&&typeof t=="object"?t:void 0)}catch{e(null)}}),isOnline:()=>{try{return typeof navigator<"u"?navigator.onLine!==!1:!0}catch{return!0}},deviceType:()=>{try{const t=typeof navigator<"u"?navigator.userAgent:"";return/iPad|Tablet|PlayBook|Silk/.test(t)||/Android/.test(t)&&!/Mobile/.test(t)?"tablet":/Mobi|Android|iPhone|iPod|Windows Phone/.test(t)?"mobile":"desktop"}catch{return"desktop"}},worker:(t,...e)=>{if(typeof t!="function")return Promise.resolve(void 0);const r=()=>Promise.resolve().then(()=>t(...e));if(!(typeof Worker<"u"&&typeof Blob<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"))return r();try{const a=`self.onmessage=function(e){var fn=(${t.toString()});Promise.resolve().then(function(){return fn.apply(null,e.data);}).then(function(r){self.postMessage({ok:true,value:r});}).catch(function(err){self.postMessage({ok:false,error:String(err)});});};`,i=URL.createObjectURL(new Blob([a],{type:"application/javascript"})),o=new Worker(i);return new Promise((s,l)=>{o.onmessage=u=>{URL.revokeObjectURL(i),o.terminate();const d=u.data;d?.ok?s(d.value):l(new Error(d?.error||"worker error"))},o.onerror=u=>{URL.revokeObjectURL(i),o.terminate(),l(u)},o.postMessage(e)})}catch{return r()}},registerServiceWorker:(t,e)=>{try{const r=typeof navigator<"u"?navigator:null;if(!r?.serviceWorker||typeof t!="string"||!t)return Promise.resolve(!1);const n=typeof e=="string"&&e?{scope:e}:void 0;return r.serviceWorker.register(t,n).then(()=>!0).catch(()=>!1)}catch{return Promise.resolve(!1)}},webManifest:t=>{const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r={name:typeof e.name=="string"?e.name:"App",short_name:typeof e.shortName=="string"?e.shortName:typeof e.name=="string"?e.name:"App",start_url:typeof e.startUrl=="string"?e.startUrl:"/",display:typeof e.display=="string"?e.display:"standalone",background_color:typeof e.backgroundColor=="string"?e.backgroundColor:"#ffffff",theme_color:typeof e.themeColor=="string"?e.themeColor:"#000000"};return typeof e.description=="string"&&(r.description=e.description),Array.isArray(e.icons)&&(r.icons=e.icons.filter(n=>!!n&&typeof n=="object").map(n=>({src:String(n.src??""),sizes:String(n.sizes??"512x512"),type:String(n.type??"image/png")}))),r},nativeShell:()=>{try{const t=typeof window<"u"?window:{},e=typeof navigator<"u"?navigator:{userAgent:""};return t.__TAURI__||t.__TAURI_IPC__?"tauri":t.Capacitor?"capacitor":t.cordova||t.PhoneGap?"cordova":t.ReactNativeWebView?"react-native":/Electron\//.test(e.userAgent)?"electron":"web"}catch{return"web"}},isNativeApp:()=>Sr.nativeShell()!=="web"},$r=1e5,gv=/^[a-zA-Z0-9#%.,()\s+-]+$/,Ns={primary:"var(--rui-color-primary)",accent:"var(--rui-color-accent)",success:"var(--rui-color-success)",warning:"var(--rui-color-warning)",danger:"var(--rui-color-danger)",info:"var(--rui-color-info)",text:"var(--rui-color-text)",muted:"var(--rui-color-text-muted)",bg:"var(--rui-color-bg)",surface:"var(--rui-color-surface)",border:"var(--rui-color-border)"};function Is(t){const e=String(t??"").trim();return e in Ns?Ns[e]:!e||e.length>64||!gv.test(e)||/url\s*\(|expression\s*\(|javascript\s*:|@import/i.test(e)?"":e}function Un(t){const e=String(t??"").trim();return!e||e.length>64||!/^[a-zA-Z0-9.%+\-*/\s(),]+$/.test(e)?"0":e}const hv={cx:(...t)=>{const e=[],r=n=>{if(n){if(typeof n=="string"||typeof n=="number")for(const a of String(n).split(/\s+/))a&&/^[A-Za-z_-][\w-]*$/.test(a)&&!e.includes(a)&&e.push(a);else if(Array.isArray(n))n.forEach(r);else if(typeof n=="object")for(const[a,i]of Object.entries(n))i&&r(a)}};return t.forEach(r),e.join(" ")},gradient:(t,e)=>{const n=(Array.isArray(t)?t:[t]).map(Is).filter(Boolean);return n.length<2?"":`linear-gradient(${typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}deg`:"120deg"}, ${n.join(", ")})`},alpha:(t,e)=>{const r=Is(t);if(!r)return"";const n=Math.max(0,Math.min(1,Number(e))),a=Number.isFinite(n)?Math.round(n*100):100;return`color-mix(in srgb, ${r} ${a}%, transparent)`},clamp:(t,e,r)=>`clamp(${Un(t)}, ${Un(e)}, ${Un(r)})`,token:t=>{const e=String(t??"").trim();if(!/^[a-zA-Z0-9.]+$/.test(e))return"";const[r,...n]=e.split("."),a=n.join("-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return!r||!a?"":`var(--rui-${r==="colors"||r==="color"?"color":r==="spacing"?"spacing":r==="radius"?"radius":r==="shadows"||r==="shadow"?"shadow":r==="gradients"||r==="gradient"?"gradient":r}-${a})`},toStyle:t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const e=[];for(const[r,n]of Object.entries(t)){if(n==null||n===!1)continue;const a=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if(!/^[a-z-]+$/.test(a))continue;const i=String(n).trim();/[;{}<>]|expression\s*\(|javascript\s*:|@import/i.test(i)||e.push(`${a}:${i}`)}return e.join(";")}},Cr=t=>!!t&&typeof t.then=="function",Ve=t=>t==null||t===""||Array.isArray(t)&&t.length===0,bv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,vv=/^(https?:\/\/)[^\s/$.?#].[^\s]*$/i,Ar={required:(t="This field is required")=>e=>Ve(e)?t:null,email:(t="Enter a valid email")=>e=>Ve(e)||bv.test(String(e))?null:t,url:(t="Enter a valid URL")=>e=>Ve(e)||vv.test(String(e))?null:t,min:(t,e)=>r=>Ve(r)||Number(r)>=t?null:e??`Must be at least ${t}`,max:(t,e)=>r=>Ve(r)||Number(r)<=t?null:e??`Must be at most ${t}`,minLength:(t,e)=>r=>Ve(r)||String(r).length>=t?null:e??`Must be at least ${t} characters`,maxLength:(t,e)=>r=>Ve(r)||String(r).length<=t?null:e??`Must be at most ${t} characters`,pattern:(t,e="Invalid format")=>{let r=null;try{r=t instanceof RegExp?t:new RegExp(String(t))}catch{r=null}return n=>Ve(n)||!r||r.test(String(n))?null:e},oneOf:(t,e="Not an allowed value")=>r=>Ve(r)||Array.isArray(t)&&t.includes(r)?null:e,matches:(t,e="Values do not match")=>r=>r===t?null:e,custom:(t,e="Invalid")=>r=>{if(typeof t!="function")return null;try{const n=t(r);return Cr(n)?n.then(a=>a===!0||a==null?null:a===!1?e:String(a),()=>e):n===!0||n==null?null:n===!1?e:String(n)}catch{return e}},asyncCustom:(t,e="Invalid")=>r=>{if(typeof t!="function")return null;try{const n=t(r);return Cr(n)?n.then(a=>a===!0||a==null?null:a===!1?e:String(a),()=>e):n===!0||n==null?null:n===!1?e:String(n)}catch{return e}},validate:(t,e)=>{const r=Array.isArray(e)?e:[e],n=a=>{for(let i=a;i<r.length;i+=1){const o=r[i];if(typeof o!="function")continue;const s=o(t);if(Cr(s))return s.then(l=>l||n(i+1));if(s)return s}return null};return n(0)},validateAll:(t,e)=>{const r={},n=[];if(!e||typeof e!="object")return r;const a=t&&typeof t=="object"?t:{};for(const[i,o]of Object.entries(e)){const s=Ar.validate(a[i],o);Cr(s)?n.push(s.then(l=>{l&&(r[i]=l)})):s&&(r[i]=s)}return n.length>0?Promise.all(n).then(()=>r):r}},yv=/^[A-Za-z0-9 ]{1,48}$/,Hn=new Set;function xv(t){const e=typeof t=="string"?t.trim():"";if(!e)return null;const[r,n]=e.split(":"),a=(r??"").trim();if(!yv.test(a))return null;const i=[],o=[];if(n)for(const s of n.split(",")){const l=s.trim(),u=/i$/.test(l),d=Number(u?l.slice(0,-1):l);Number.isInteger(d)&&d>=100&&d<=900&&(u?o:i).push(d)}return{family:a,weights:i,italics:o}}function wv(t){const e=t.family.replace(/\s+/g,"+"),r=[];for(const n of t.weights.sort((a,i)=>a-i))r.push(`0,${n}`);for(const n of t.italics.sort((a,i)=>a-i))r.push(`1,${n}`);return r.length===0?`family=${e}`:t.italics.length>0?`family=${e}:ital,wght@${r.join(";")}`:`family=${e}:wght@${t.weights.sort((n,a)=>n-a).join(";")}`}function kv(t){const e=(Array.isArray(t)?t:[t]).map(xv).filter(n=>n!==null);return e.length===0?"":`https://fonts.googleapis.com/css2?${e.map(wv).join("&")}&display=swap`}function Ps(t){if(!t||typeof t!="object"||Array.isArray(t))return"";const e=t.import;if(e==null)return"";const r=kv(e);if(!r||Hn.has(r)||typeof document>"u")return r;if(typeof globalThis.happyDOM<"u")return Hn.add(r),r;try{const a=document.createElement("link");a.rel="stylesheet",a.href=r,a.setAttribute("data-rui-font",""),document.head.appendChild(a),Hn.add(r)}catch{}return r}const Te={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",spacing2xl:"48px",spacing3xl:"80px"},...{gradientBrand:"linear-gradient(120deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%)",gradientAccent:"linear-gradient(120deg, #22d3ee 0%, #6366f1 100%)",gradientWarm:"linear-gradient(120deg, #f59e0b 0%, #ec4899 100%)",gradientCool:"linear-gradient(120deg, #3b82f6 0%, #06b6d4 100%)",gradientSuccess:"linear-gradient(120deg, #10b981 0%, #22d3ee 100%)",gradientDanger:"linear-gradient(120deg, #f43f5e 0%, #ec4899 100%)"},...{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"}},Es={...Te,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)"},zs={...Te,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"},Rs={...Te,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"},Ls={...Te,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"},Ds={...Te,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"},js={...Te,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"},Dt={light:Te,dark:Es,neon:zs,pastel:Rs,glass:Ls,brutalist:Ds,skyline:js},Tr={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",spacing3xs:"--rui-spacing-3xs",spacing2xs:"--rui-spacing-2xs",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",spacing2xl:"--rui-spacing-2xl",spacing3xl:"--rui-spacing-3xl",gradientBrand:"--rui-gradient-brand",gradientAccent:"--rui-gradient-accent",gradientWarm:"--rui-gradient-warm",gradientCool:"--rui-gradient-cool",gradientSuccess:"--rui-gradient-success",gradientDanger:"--rui-gradient-danger",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",motionFast:"--rui-motion-fast",motionBase:"--rui-motion-base",motionSlow:"--rui-motion-slow",motionEase:"--rui-motion-ease",zBase:"--rui-z-base",zRaised:"--rui-z-raised",zDropdown:"--rui-z-dropdown",zSticky:"--rui-z-sticky",zBanner:"--rui-z-banner",zOverlay:"--rui-z-overlay",zModal:"--rui-z-modal",zPopover:"--rui-z-popover",zToast:"--rui-z-toast",zTooltip:"--rui-z-tooltip",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 qn(t){if(!t)return{name:"light",tokens:Te};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:_s(JSON.parse(t))}}catch{return{name:"light",tokens:Te}}const r=Dt[e];return r?{name:e,tokens:r}:{name:"light",tokens:Te}}return{name:"custom",tokens:_s(t)}}function Vn(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[n,a]of Object.entries(Tr)){const i=r.tokens[n];i==null?t.style.removeProperty(a):t.style.setProperty(a,i)}t.setAttribute("data-rui-theme",r.name)}function Bs(t,e){const r=[];for(const n of Object.keys(e)){const a=Tr[n];if(!a)continue;const i=e[n];typeof i!="string"||i===""||(t.style.setProperty(a,i),r.push(n))}return r}function Os(t,e){for(const r of e){const n=Tr[r];n&&t.style.removeProperty(n)}}function Fs(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t))if(r in Tr&&n!=null)if(typeof n=="string"){if(n.trim()==="")continue;e[r]=n}else typeof n=="number"&&(e[r]=String(n));return e}function _s(t){return{...Te,...t}}const Sv=8;function he(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 Wn(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=he(t),n=he(e),a=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/"),o={};let s=!1;for(let l=0;l<a.length;l+=1){const u=a[l];if(u==="*"){s=!0;const p=i.slice(l).join("/");return o._=p,{matched:!0,params:o,wildcard:s}}const d=i[l];if(d===void 0)return{matched:!1,params:{}};if(u.startsWith(":")){const p=u.slice(1);if(!p)return{matched:!1,params:{}};o[p]=decodeURIComponent(d);continue}if(u!==d)return{matched:!1,params:{}}}return!s&&i.length>a.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}function Gn(t,e){if(!t||t==="*")return{matched:!0,params:{},rest:he(e)};const r=he(t),n=he(e),a=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/");if(i.length<a.length)return{matched:!1,params:{},rest:"/"};const o={};for(let u=0;u<a.length;u+=1){const d=a[u],p=i[u];if(d.startsWith(":")){o[d.slice(1)]=decodeURIComponent(p);continue}if(d!==p)return{matched:!1,params:{},rest:"/"}}const s=i.slice(a.length),l=s.length===0?"/":"/"+s.join("/");return{matched:!0,params:o,rest:l}}class Kn{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,"mode");j(this,"basePath");j(this,"settingHash",!1);j(this,"guard",null);this.defaultPath=he(e.defaultPath??"/"),this.currentPath=this.defaultPath,this.mode=e.mode==="history"?"history":"hash",this.basePath=Us(e.basePath)}configure(e){this.enabled||(e.mode&&(this.mode=e.mode==="history"?"history":"hash"),e.basePath!==void 0&&(this.basePath=Us(e.basePath)))}getMode(){return this.mode}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=r=>{if(this.settingHash)return;const n=he(this.readLocation());if(n===this.currentPath)return;const a=this.runGuard(n);if(a===!1){this.restoreUrl();return}if(typeof a=="string"){this.restoreUrl(),this.navigateInternal(he(a),0);return}this.setPath(n,r)};if(this.mode==="history"){const r=()=>e("hashchange");window.addEventListener("popstate",r),this.hashListener=r}else{const r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r}e("init")}readLocation(){if(typeof window>"u")return this.currentPath;if(this.mode==="history"){let e=window.location.pathname||"/";return this.basePath&&e.startsWith(this.basePath)&&(e=e.slice(this.basePath.length)||"/"),he(e)}return he(window.location.hash)}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&(window.removeEventListener("hashchange",this.hashListener),window.removeEventListener("popstate",this.hashListener)),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,$v(this.currentParams,r)||(this.currentParams=r)}navigate(e){this.navigateInternal(he(e),0)}setGuard(e){this.guard=e}runGuard(e){if(!this.guard)return!0;try{return this.guard({to:e,from:this.currentPath})}catch(r){return console.error("[aktion] navigation guard threw",r),!0}}restoreUrl(){if(!(typeof window>"u")){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.replaceState=="function"?window.history.replaceState({},"",(this.basePath||"")+this.currentPath):window.location.hash="#"+this.currentPath}finally{queueMicrotask(()=>{this.settingHash=!1})}}}navigateInternal(e,r){const n=he(e);if(n===this.currentPath)return;const a=this.runGuard(n);if(a!==!1){if(typeof a=="string"&&r<Sv){this.navigateInternal(he(a),r+1);return}if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.pushState=="function"?window.history.pushState({},"",(this.basePath||"")+n):window.location.hash="#"+n}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(n,"navigate");return}this.setPath(n,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const n=he(e);if(n===this.currentPath)return;const a=this.currentPath;this.currentPath=n,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:n,previousPath:a,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function Us(t){if(!t)return"";let e=String(t).trim();return e===""||e==="/"?"":(e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e)}function $v(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(t[a]!==e[a])return!1;return!0}const Ze=(t,e)=>{try{return t()}catch{return e}},Hs=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)}},qs=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},Vs=t=>({set:(e,r)=>Ze(()=>{const n=t();return n?(n.setItem(String(e),Hs(r)),!0):!1},!1),get:e=>Ze(()=>{const r=t();return r?qs(r.getItem(String(e))):null},null),remove:e=>Ze(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>Ze(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),Cv=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,Av=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,Mr=()=>typeof globalThis>"u"?null:globalThis.document??null,Tv=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},Yn=(t={})=>{const e=[],r=Tv(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 n=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${n}`)}return e.length===0?"":`; ${e.join("; ")}`},Ws=()=>{const t=Mr();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const n of r.split(";")){const a=n.trim();if(!a)continue;const i=a.indexOf("=");if(i<0){e[decodeURIComponent(a)]="";continue}const o=decodeURIComponent(a.slice(0,i)),s=decodeURIComponent(a.slice(i+1));e[o]=s}return e},Mv={set:(t,e,r)=>Ze(()=>{const n=Mr();if(!n)return!1;const a=encodeURIComponent(String(t)),i=encodeURIComponent(Hs(e));return n.cookie=`${a}=${i}${Yn(r)}`,!0},!1),get:t=>Ze(()=>{const r=Ws()[String(t)];return r===void 0?null:qs(r)},null),remove:(t,e)=>Ze(()=>{const r=Mr();if(!r)return!1;const n=encodeURIComponent(String(t)),a={...e,expires:new Date(0),maxAge:0};return r.cookie=`${n}=${Yn(a)}`,!0},!1),clear:()=>Ze(()=>{const t=Mr();if(!t)return!1;const e=Ws();for(const r of Object.keys(e)){const n=encodeURIComponent(r);t.cookie=`${n}=${Yn({expires:new Date(0),maxAge:0})}`}return!0},!1)},jt=Vs(Cv),Nv=Vs(Av),Xn={set:jt.set,get:jt.get,remove:jt.remove,clear:jt.clear,local:jt,session:Nv,cookies:Mv},Iv=["log","error","warn","info","debug"],Pv=()=>typeof globalThis>"u"?null:globalThis.console??null,Ev=t=>(...e)=>{const r=Pv();if(!r)return;const n=r[t]??r.log;if(typeof n=="function")try{n(...e)}catch{}},Gs=Iv.reduce((t,e)=>(t[e]=Ev(e),t),{}),zv=4e3;function Zn(t){return t==null?"":typeof t=="string"?t:String(t)}function Ks(t){let e=[];const r=new Map;let n=0;const a=()=>t.notify?.(),i=p=>{const f=r.get(p);f!==void 0&&(clearTimeout(f),r.delete(p))},o=p=>{i(p);const f=e.filter(b=>b.id!==p);f.length!==e.length&&(e=f,d.items=e,a())},s=()=>{if(e.length!==0){for(const p of[...r.keys()])i(p);e=[],d.items=e,a()}},l=(p,f={})=>{const b=`toast-${n+=1}`,h=typeof f.duration=="number"?f.duration:zv,g={id:b,message:Zn(p),title:f.title!=null?Zn(f.title):void 0,tone:f.tone!=null?Zn(f.tone):"default",duration:h,createdAt:Date.now()};return e=[...e,g],d.items=e,h>0&&r.set(b,setTimeout(()=>{r.delete(b),o(b)},h)),a(),b},u=p=>(f,b={})=>l(f,{...b,tone:p}),d={items:e,show:l,success:u("success"),error:u("danger"),info:u("info"),warning:u("warning"),dismiss:o,clear:s};return t.disposers.push(()=>{for(const p of r.values())clearTimeout(p);r.clear(),e=[],d.items=e}),d}const Rv=[["xl",1280],["lg",1024],["md",768],["sm",640]];function Lv(t){for(const[e,r]of Rv)if(t>=r)return e;return"base"}function Dv(t){const e=typeof window<"u";let r=!1;const n=()=>{if(r)return;r=!0;const S=()=>{r=!1,t.notify?.()};e&&typeof requestAnimationFrame=="function"?requestAnimationFrame(S):setTimeout(S,16)};let a=e?window.innerWidth:1024,i=e?window.innerHeight:768,o=0,s=0,l=0,u="down",d=0,p=0,f=!1,b=!1,h=!1,g=!1;const y=()=>{if(f||!e)return;f=!0;let S=0;const $=()=>{S||(S=requestAnimationFrame(()=>{S=0;const C=window.innerWidth,M=window.innerHeight;(C!==a||M!==i)&&(a=C,i=M,n())}))};window.addEventListener("resize",$,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("resize",$),S&&cancelAnimationFrame(S)})},v=()=>{if(b||!e)return;b=!0,y();let S=0;const $=()=>{S=0;const M=document.documentElement,E=window.scrollY||M.scrollTop||0,R=window.scrollX||M.scrollLeft||0,_=M.scrollHeight-M.clientHeight||1,B=Math.round(Math.max(0,Math.min(1,E/_))*1e3)/1e3,U=E>s?"down":E<s?"up":u;(Math.round(E)!==Math.round(s)||Math.round(R)!==Math.round(o)||B!==l||U!==u)&&(s=E,o=R,l=B,u=U,n())},C=()=>{S||(S=requestAnimationFrame($))};$(),window.addEventListener("scroll",C,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("scroll",C),S&&cancelAnimationFrame(S)})},x=()=>{if(h||!e)return;h=!0;let S=0,$=0,C=0;const M=E=>{$=E.clientX,C=E.clientY,!S&&(S=requestAnimationFrame(()=>{S=0,($!==d||C!==p)&&(d=$,p=C,n())}))};window.addEventListener("mousemove",M,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("mousemove",M),S&&cancelAnimationFrame(S)})},w=[],k=()=>{if(g||!e||typeof window.matchMedia!="function")return;g=!0;const S=()=>n();for(const C of["(prefers-color-scheme: dark)","(prefers-reduced-motion: reduce)","(pointer: coarse)","(orientation: portrait)"])try{const M=window.matchMedia(C);typeof M.addEventListener=="function"?M.addEventListener("change",S):typeof M.addListener=="function"&&M.addListener(S),w.push(M)}catch{}const $=()=>n();window.addEventListener("online",$),window.addEventListener("offline",$),t.disposers.push(()=>{for(const C of w)typeof C.removeEventListener=="function"?C.removeEventListener("change",S):typeof C.removeListener=="function"&&C.removeListener(S);window.removeEventListener("online",$),window.removeEventListener("offline",$)})},A=S=>{if(!e||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(S).matches}catch{return!1}};return{get viewport(){return y(),{width:a,height:i}},get breakpoint(){y();const S=Lv(a);return{width:a,active:S,sm:a>=640,md:a>=768,lg:a>=1024,xl:a>=1280}},get scroll(){return v(),{x:Math.round(o),y:Math.round(s),progress:l,direction:u}},get media(){return k(),{prefersDark:A("(prefers-color-scheme: dark)"),prefersReducedMotion:A("(prefers-reduced-motion: reduce)"),online:e&&typeof navigator<"u"?navigator.onLine:!0,pointer:A("(pointer: coarse)")?"coarse":"fine",portrait:A("(orientation: portrait)")}},get mouse(){return x(),{x:d,y:p}}}}const Bt={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},Qn={util:Sr,console:Gs,storage:Xn},Ys=new Set(["toast"]);function jv(t){return t.toastManager||(t.toastManager=Ks(t)),t.toastManager}function Bv(t){return t.envManager||(t.envManager=Dv(t)),t.envManager}function Ov(t){if(t.utilFacade)return t.utilFacade;const e=Object.create(Sr),r=()=>Bv(t);return Object.defineProperties(e,{scroll:{get:()=>r().scroll,enumerable:!0},viewport:{get:()=>r().viewport,enumerable:!0},breakpoint:{get:()=>r().breakpoint,enumerable:!0},media:{get:()=>r().media,enumerable:!0},mouse:{get:()=>r().mouse,enumerable:!0},url:{get:()=>Fv(t),enumerable:!0},style:{value:hv,enumerable:!0},rules:{value:Ar,enumerable:!0},derived:{value:n=>typeof n=="function"?n():n,enumerable:!0},onError:{value:n=>{t.errorHook=typeof n=="function"?a=>{n(a)}:void 0},enumerable:!0},onNavigate:{value:n=>{t.router?.setGuard(typeof n=="function"?n:null)},enumerable:!0},onRequest:{value:n=>{typeof n=="function"&&t.http?.registerProgramInterceptors({onRequest:a=>{const i=n(a);if(i&&typeof i=="object"){const o=i;return{...a,...o,headers:{...a.headers,...o.headers??{}}}}return a}})},enumerable:!0},onResponse:{value:n=>{typeof n=="function"&&t.http?.registerProgramInterceptors({onResponse:async(a,i)=>{const o=await n(a,i);return o&&typeof o=="object"?o:a}})},enumerable:!0},invalidate:{value:n=>{Bn(t,n)},enumerable:!0}}),t.utilFacade=e,e}function Fv(t){t.trackedState.add("route");const e=t.router,r=ua(t),n=e?{...e.getParams()}:{},a={};let i="";if(typeof globalThis<"u"&&globalThis.location){const o=globalThis.location;let s=o.search??"";const l=o.hash?o.hash.replace(/^#/,""):"",u=l.indexOf("?");if(!s&&u>=0?s=l.slice(u):s&&(i=l),s){const d=new URLSearchParams(s.startsWith("?")?s.slice(1):s);for(const[p,f]of d)a[p]=f}}return{path:r,params:n,query:a,hash:i,navigate:o=>{typeof o=="string"&&o&&e?.navigate(o)},setQuery:(o,s)=>{const l={...a};if(o&&typeof o=="object"&&!Array.isArray(o))for(const[u,d]of Object.entries(o))d==null||d===""?delete l[u]:l[u]=String(d);else typeof o=="string"&&(s==null||s===""?delete l[o]:l[o]=String(s));Xs(t,l)},removeQuery:o=>{if(typeof o!="string")return;const s={...a};delete s[o],Xs(t,s)},toString(){return r}}}function Xs(t,e){if(typeof window>"u"||!window.location)return;const r=new URLSearchParams;for(const[i,o]of Object.entries(e))o==null||o===""||r.set(i,String(o));const n=r.toString();if((t.router?.getMode?t.router.getMode():"hash")==="history"&&typeof window.history?.replaceState=="function"){const i=window.location.pathname||"/",o=window.location.hash||"";window.history.replaceState({},"",i+(n?`?${n}`:"")+o)}else{const i=t.router?t.router.getPath():ua(t);window.location.hash=`#${i}${n?`?${n}`:""}`}t.notify?.()}function Zs(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 Nr={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class Qe extends Error{constructor(r,n,a){super(_v(r,n,a));j(this,"kind");j(this,"limit");j(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=n,this.source=a}}function _v(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 Qs(t={}){return{componentDepthLimit:t.componentDepthLimit??Nr.componentDepthLimit,iterationLimit:t.iterationLimit??Nr.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??Nr.arrayLengthLimit,componentDepth:0,iterations:0}}function Jn(t){t.iterations=0,t.componentDepth=0}function Ot(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new Qe("iterations",t.iterationLimit,r)}function ea(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new Qe("component-depth",r.componentDepthLimit,`component "${e}"`)}function ta(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}function Js(t,e){return e.activeComponentDecls.length>0&&e.activeComponentDecls.includes(t)&&!!(e.library&&Pe(e.library,t))}const el=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),tl=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),Ir=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function Pr(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,activeComponentDecls:[],effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,queryCache:new Map,notify:e.notify,onEmit:e.onEmit,strict:e.strict,strictWarned:new Set,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??Qs()};return r.disposers.push(()=>{for(const n of r.timers.timeouts)clearTimeout(n);for(const n of r.timers.intervals)clearInterval(n);r.timers.timeouts.clear(),r.timers.intervals.clear()}),e.http?.clearProgramInterceptors(),r.disposers.push(()=>e.http?.clearProgramInterceptors()),r}function ra(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(n){console.error("[aktion] context disposer threw",n)}}function rl(t){t.mutableBindings.clear()}function De(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const a=t.stateAliases[r].get(e);if(a!==void 0)return a}return e}function Er(t,e){const r=[];let n=t;for(;n.kind==="Member";){if(n.computed){if(n.computed.kind!=="Literal")return null;const a=n.computed.value;if(typeof a!="string"&&typeof a!="number")return null;r.unshift(String(a))}else if(n.property)r.unshift(n.property);else return null;n=n.object}return n.kind!=="StateRef"?null:{name:De(e,n.name),path:r}}function zr(t,e){if(t.kind==="StateRef")return De(e,t.name);if(t.kind==="Member"){const r=Er(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const n=fl(t,e);if(n)return n.path.length===0?n.atom:`${n.atom}.${n.path.join(".")}`}return null}function na(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const n=Lr(r.expression);e.state.declare(r.identifier,n)}for(const r of t.statements)aa(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!nl(r.expression))continue;const n=P(r.expression,e);e.state.set(r.identifier,n)}qv(t,e),Hv(t,e)}const Uv=8;function Hv(t,e){const r=[],n=o=>{const s=new Set,l=e.trackedState;e.trackedState=s;try{const u=P(o.expr,e);e.state.set(o.name,u)}finally{e.trackedState=l}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||Rr(o.expression)||nl(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),n(s)}if(r.length===0)return;let a=!1;const i=e.state.subscribe(o=>{if(!a){a=!0;try{const s=new Set(o);for(let l=0;l<Uv;l+=1){let u=!1;for(const d of r){if(!zt(s,d.deps))continue;const f=e.state.get(d.name);n(d),e.state.get(d.name)!==f&&(s.add(d.name),u=!0)}if(!u)break}}finally{a=!1}}});e.disposers.push(i)}function Rr(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&Rr(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&Rr(e.value));case"Template":return t.expressions.length===0;default:return!1}}function nl(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function al(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="theme"}function il(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="app"}function aa(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,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;il(r)?e.bindings.set("aktion",()=>P(r,e)):al(r)&&e.bindings.set("theme",()=>P(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,()=>P(r,e));return}}}function ol(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!il(t.expression)&&!al(t.expression);default:return!1}}function qv(t,e){let r=!1;for(const n of t.statements)if(ol(n)){r=!0;break}if(r){for(const n of t.statements)n.kind==="Assignment"&&n.isState&&Rr(n.expression)&&e.state.set(n.identifier,Lr(n.expression));for(const n of t.statements)if(ol(n))try{oa(n,e)}catch(a){if(a instanceof Me||a instanceof Ee||a instanceof ct)continue;if(a instanceof Qe)throw a;console.error("[aktion] top-level statement threw",a)}}}function Vv(t,e,r){const n=t[0];if(!n||n.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 a=ua(e);let i=null;for(const o of n.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const l=sl(o.value);if(l){const d=Gn(s,a);if(!d.matched)continue;return ll(s,l,d.params,d.rest,e)}const u=Wn(s,a);if(u.matched)return cl(s,o.value,u.params,e)}return i?cl(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function sl(t){if(t.kind!=="Object")return null;let e=null,r=null;for(const n of t.properties)n.spread||(n.key==="layout"?e=n.value:n.key==="routes"&&n.value.kind==="Object"&&(r=n.value));return e?{layout:e,routes:r}:null}function ll(t,e,r,n,a){let i=null,o=null,s={};if(e.routes){let u=null;for(const d of e.routes.properties){if(d.spread)continue;if(d.key==="default"||d.key==="*"){u=d;continue}const p=sl(d.value);if(p){const b=Gn(d.key,n);if(!b.matched)continue;o=d.key,s=b.params,i=ll(d.key,p,b.params,b.rest,a);break}const f=Wn(d.key,n);if(f.matched){o=d.key,s=f.params,i=ia(d.value,a,{params:f.params});break}}i===null&&o===null&&u&&(i=ia(u.value,a,{params:{}}))}const l={...r,...s};return a.router?.setActiveMatch(o?`${t}${o}`:t,l),ia(e.layout,a,{params:l,outlet:i})}function ia(t,e,r){const n=[];for(const[a,i]of Object.entries(r))n.push({name:a,had:e.loopVars.has(a),prev:e.loopVars.get(a)}),e.loopVars.set(a,i);try{return P(t,e)}finally{for(const a of n)a.had?e.loopVars.set(a.name,a.prev):e.loopVars.delete(a.name)}}function cl(t,e,r,n){const a=n.loopVars.get("params"),i=n.loopVars.has("params");n.loopVars.set("params",r);try{const o=P(e,n);return n.router?.setActiveMatch(t,r),o}finally{i?n.loopVars.set("params",a):n.loopVars.delete("params")}}function Lr(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Lr(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Lr(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function P(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?Ly(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const s=r();return e.mutableBindings.set(t.name,s),s}const n=Js(t.name,e),a=n?void 0:e.actionDecls.get(t.name);if(a)return Ty(a,e);const i=n?void 0:e.componentDecls.get(t.name);if(i)return My(i);if(Object.prototype.hasOwnProperty.call(Bt,t.name))return Bt[t.name];if(e.library&&Pe(e.library,t.name))return Ny(t.name);if(t.name==="cleanup"&&e.cleanupSink){const s=e.cleanupSink;return l=>{typeof l=="function"&&s(l)}}const o=Zs(t.name);if(o.found)return o.value;if(e.strict&&!e.strictWarned.has(t.name)){e.strictWarned.add(t.name);const s=t.loc?` (line ${t.loc.line}, col ${t.loc.column})`:"";console.warn(`[aktion] strict: unknown identifier "${t.name}" resolved to null${s}. Did you misspell a state atom, action, or component name?`)}return null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(Qn,t.name))return t.name==="util"?Ov(e):Qn[t.name];if(Ys.has(t.name)&&t.name==="toast")return jv(e);if(t.name==="emit"&&e.onEmit){const n=e.onEmit;return(a,i)=>{n(a==null?"":String(a),i)}}const r=De(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const n of t.elements){if(n.kind==="Spread"){const a=P(n.argument,e);if(Array.isArray(a))for(const i of a)r.push(i);else if(a!=null&&typeof a=="string")for(const i of a)r.push(i);continue}r.push(P(n,e))}return r}case"Object":{const r={};for(const n of t.properties){if(n.spread){const i=P(n.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const a=n.computedKey?String(P(n.computedKey,e)??""):n.key;r[a]=P(n.value,e)}return r}case"Member":{if(ey(t))return ty(t,e);const r=ry(t,e);if(r)return ny(t,e,r);const n=P(t.object,e);if(t.optional&&n==null)return;if(t.computed){const a=P(t.computed,e);return da(n,a)}return pa(n,t.property??"")}case"Unary":{if(t.operator==="delete"){const n=t.argument;if(n.kind==="Member"&&n.property){const a=P(n.object,e);if(a&&typeof a=="object")try{return delete a[n.property],!0}catch{return!1}}return!1}const r=P(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-q(r);case"+":return+q(r);case"~":return~pe(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return fy(t.operator,t.left,t.right,e);case"Ternary":{const r=P(t.test,e);return P(r?t.consequent:t.alternate,e)}case"Call":return hy(t.callee,t.arguments,e,t.loc);case"MethodCall":return gy(t,e);case"Invoke":return cy(t,e);case"New":return uy(t,e);case"BuiltinCall":return Iy(t.name,t.arguments,e);case"Template":return my(t.quasis,t.expressions,e);case"Spread":return P(t.argument,e);case"Block":return sa(t,e,{});case"Lambda":{const r=t.params,n=t.body,a=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),l=e.stateAliases.slice();e.loopVars.clear();for(const[p,f]of i)e.loopVars.set(p,f);e.stateAliases.length=0;for(const p of a)e.stateAliases.push(p);const u=[],d=(p,f)=>{u.push({name:p,had:e.loopVars.has(p),prev:e.loopVars.get(p)}),e.loopVars.set(p,f)};for(let p=0;p<r.length;p+=1){const f=r[p];let b=o[p];if(b===void 0&&f.defaultValue&&(b=P(f.defaultValue,e)),f.pattern){for(const h of Ft(f.pattern,b,e))d(h.name,h.value);continue}d(f.name,b)}try{return P(n,e)}finally{for(const p of u)p.had?e.loopVars.set(p.name,p.prev):e.loopVars.delete(p.name);e.loopVars.clear();for(const[p,f]of s)e.loopVars.set(p,f);e.stateAliases.length=0;for(const p of l)e.stateAliases.push(p)}}}default:return null}}class Me{constructor(){j(this,"kind","break")}}class Ee{constructor(){j(this,"kind","continue")}}class ct{constructor(e){j(this,"kind","return");this.value=e}}function ul(t,e){if(P(t.test,e)){ze(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){ul(t.alternate,e);return}t.alternate.kind==="Block"&&ze(t.alternate.body,e)}}function Wv(t,e){const r=P(t.discriminant,e);let n=!1;try{for(const a of t.cases)n||(a.test===null||P(a.test,e)===r)&&(n=!0),n&&ze(a.body,e)}catch(a){if(a instanceof Me)return;throw a}}function Gv(t,e){const r=P(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const n=e.loopVars.has(t.item),a=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,l=t.destructure??[],u=l.map(d=>({name:d,had:e.loopVars.has(d),value:e.loopVars.get(d)}));try{let d=0;const p=(Array.isArray(r),r);for(const f of p){Ot(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,d);for(const b of l){const h=f&&typeof f=="object"?f[b]:void 0;e.loopVars.set(b,h)}try{ze(t.body.body,e)}catch(b){if(b instanceof Ee){d+=1;continue}if(b instanceof Me)return;throw b}d+=1}}finally{n?e.loopVars.set(t.item,a):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const d of u)d.had?e.loopVars.set(d.name,d.value):e.loopVars.delete(d.name)}}function Kv(t,e){for(t.init&&Dr(t.init,e);!(t.test&&!P(t.test,e));){Ot(e.budget,1,"`for` loop");try{ze(t.body.body,e)}catch(r){if(!(r instanceof Ee)){if(r instanceof Me)return;throw r}}t.update&&P(t.update,e)}}function Yv(t,e){for(;P(t.test,e);){Ot(e.budget,1,"`while` loop");try{ze(t.body.body,e)}catch(r){if(r instanceof Ee)continue;if(r instanceof Me)return;throw r}}}function Xv(t,e){for(;;){Ot(e.budget,1,"`do…while` loop");try{ze(t.body.body,e)}catch(r){if(!(r instanceof Ee)){if(r instanceof Me)return;throw r}}if(!P(t.test,e))break}}function Zv(t,e){const r=P(t.expression,e),n=Ft({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:a,value:i}of n)e.loopVars.set(a,i)}function Ft(t,e,r){const n=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const l of t.bindings){if(l.rest){n.push({name:l.name,value:o.slice(s)}),s=o.length;continue}let u=o[s];u===void 0&&l.defaultValue&&(u=P(l.defaultValue,r)),l.name!==""&&n.push({name:l.name,value:u}),s+=1}return n}const a=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const u={};for(const[d,p]of Object.entries(a))i.has(d)||(u[d]=p);n.push({name:o.name,value:u});continue}const s=o.sourceKey??o.name;i.add(s);let l=a[s];l===void 0&&o.defaultValue&&(l=P(o.defaultValue,r)),n.push({name:o.name,value:l})}return n}function Qv(t,e){const r=P(t.iterable,e);if(r==null||typeof r!="object")return;const n=e.loopVars.has(t.item),a=e.loopVars.get(t.item);try{for(const i in r){Ot(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{ze(t.body.body,e)}catch(o){if(o instanceof Ee)continue;if(o instanceof Me)return;throw o}}}finally{n?e.loopVars.set(t.item,a):e.loopVars.delete(t.item)}}function Jv(t,e){try{ze(t.block.body,e)}catch(r){if(r instanceof Me||r instanceof Ee||r instanceof ct)throw r;if(t.catchBlock){const n=t.catchParam,a=n?e.loopVars.has(n):!1,i=n?e.loopVars.get(n):void 0;n&&e.loopVars.set(n,r);try{ze(t.catchBlock.body,e)}finally{n&&(a?e.loopVars.set(n,i):e.loopVars.delete(n))}}}finally{t.finallyBlock&&ze(t.finallyBlock.body,e)}}function ze(t,e){for(const r of t)Dr(r,e)}function oa(t,e){Dr(t,e)}function Dr(t,e){switch(t.kind){case"ExpressionStatement":P(t.expression,e);return;case"Assignment":{const r=P(t.expression,e);if(t.identifier)if(t.isState){const n=De(e,t.identifier);e.state.set(n,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":ul(t,e);return;case"SwitchStatement":Wv(t,e);return;case"ForOfStatement":Gv(t,e);return;case"ForClassicStatement":Kv(t,e);return;case"ForInStatement":Qv(t,e);return;case"WhileStatement":Yv(t,e);return;case"DoWhileStatement":Xv(t,e);return;case"DestructureStatement":Zv(t,e);return;case"TryStatement":Jv(t,e);return;case"BreakStatement":throw new Me;case"ContinueStatement":throw new Ee;case"ThrowStatement":throw P(t.argument,e);case"Return":{const r=t.argument?P(t.argument,e):void 0;throw new ct(r)}case"Await":P(t.argument,e);return;default:return}}function ey(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&(Object.prototype.hasOwnProperty.call(Qn,e.name)||Ys.has(e.name))?!1:e.kind==="StateRef"}function ty(t,e){const r=dl(t);let n=t;for(;n.kind==="Member";)n=n.object;const a=De(e,n.name);return pl(r,a,e)}function dl(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function pl(t,e,r){let n=r.state.get(e);const a=[e];let i=!0;for(const o of t){let s,l=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(l=String(s))):s=P(o.computed,r):(s=o.property??"",l=o.property??"");const u=n!=null&&typeof n=="object"&&!Array.isArray(n);i&&l!==null&&u?a.push(l):i=!1,n=o.computed?da(n,s):pa(n,o.property??"")}return r.trackedState.add(a.join(".")),n}function ry(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const n=P(r,e);return Ir(n)?n:null}function ny(t,e,r){const n=dl(t),a=n[0];if(a&&a.computed===void 0&&a.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,a.property)){let i=r.__methods[a.property];for(let o=1;o<n.length;o+=1){const s=n[o];s.computed?i=da(i,P(s.computed,e)):i=pa(i,s.property??"")}return i}return pl(n,r.__atom,e)}function ay(t,e,r){const n=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,a=e.stores.get(n);if(a)return a;const i=t[0]?P(t[0],e):{},o={},s={};let l=null,u="local",d=!1,p=50;if(i&&typeof i=="object"&&!Array.isArray(i))for(const[y,v]of Object.entries(i)){if(y==="persist"){v===!0?l=`aktion:store:${n}`:typeof v=="string"&&v&&(l=v);continue}if(y==="persistIn"){v==="session"&&(u="session");continue}if(y==="history"){v===!0?d=!0:typeof v=="number"&&v>0&&(d=!0,p=Math.floor(v));continue}typeof v=="function"?s[y]=v:o[y]=v}const f=Object.keys(o),b=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;if(l){const y=sy(l,u);if(y)for(const v of f)Object.prototype.hasOwnProperty.call(y,v)&&(o[v]=y[v])}d&&(o.canUndo=!1,o.canRedo=!1),e.state.declare(b,o);const h={},g={__kind:"Store",__atom:b,__methods:h};for(const[y,v]of Object.entries(s))h[y]=(...x)=>v(g,...x);if(l){const y=`${b}.`,v=e.state.subscribe(x=>{let w=!1;for(const k of x)if(k===b||k.startsWith(y)){w=!0;break}w&&ly(l,u,e.state.get(b))});e.disposers.push(v)}return d&&iy(e,b,f,p,h),e.stores.set(n,g),g}function iy(t,e,r,n,a){const i=`${e}.`,o=[],s=[];let l=!1;const u=()=>{const g=t.state.get(e),y={};for(const v of r)y[v]=g?g[v]:void 0;return y};let d=u();const p=g=>{for(const y of r)t.state.setPath(e,[y],g[y])},f=()=>{t.state.setPath(e,["canUndo"],o.length>0),t.state.setPath(e,["canRedo"],s.length>0)},b=g=>{for(const y of g){if(y===e)return!0;if(y.startsWith(i)){const v=y.slice(i.length).split(".")[0];if(v!=="canUndo"&&v!=="canRedo")return!0}}return!1},h=t.state.subscribe(g=>{if(b(g)){if(l){l=!1,d=u();return}o.push(d),o.length>n&&o.shift(),s.length=0,d=u(),f()}});t.disposers.push(h),a.undo=()=>{if(o.length===0)return;s.push(u());const g=o.pop();l=!0,p(g),d=g,f()},a.redo=()=>{if(s.length===0)return;o.push(u());const g=s.pop();l=!0,p(g),d=g,f()},a.clearHistory=()=>{o.length=0,s.length=0,f()}}function oy(t,e,r){const n=r?`${r.line}:${r.column}`:`form:${e.stores.size}`,a=e.stores.get(n);if(a)return a;const i=t[0]?P(t[0],e):{},o=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=o.values&&typeof o.values=="object"&&!Array.isArray(o.values)?{...o.values}:{},l=o.rules&&typeof o.rules=="object"&&!Array.isArray(o.rules)?o.rules:{},u=typeof o.onSubmit=="function"?o.onSubmit:null,d=r?`__form_${r.line}_${r.column}`:`__form_anon_${e.stores.size}`,p=()=>({values:{...s},errors:{},touched:{},dirty:!1,valid:!0,submitting:!1,validating:!1});e.state.declare(d,p());const f={},b={__kind:"Store",__atom:d,__methods:f},h=()=>e.state.get(d)??{},g=()=>{const M=h().values;return M&&typeof M=="object"?M:{}},y=M=>!!M&&typeof M.then=="function";let v=0;const x=()=>{v+=1,e.state.setPath(d,["validating"],!0)},w=()=>{v=Math.max(0,v-1),v===0&&e.state.setPath(d,["validating"],!1)};let k=JSON.stringify(s);const A=M=>{try{return JSON.stringify(M)??""}catch{return""}},S=`${d}.values`,$=e.state.subscribe(M=>{let E=!1;for(const _ of M)if(_===d||_===S||_.startsWith(`${S}.`)){E=!0;break}if(!E)return;const R=A(g())!==k;h().dirty!==R&&e.state.setPath(d,["dirty"],R)});e.disposers.push($),f.setField=(M,E)=>{const R=String(M);e.state.setPath(d,["values",R],E),e.state.setPath(d,["errors",R],void 0),e.state.setPath(d,["dirty"],!0)},f.setValues=M=>{const E={...g(),...M&&typeof M=="object"?M:{}};e.state.setPath(d,["values"],E),e.state.setPath(d,["dirty"],!0)},f.validateField=M=>{const E=String(M),R=g()[E],_=Ar.validate(R,l[E]);return y(_)?(x(),_.then(B=>(w(),g()[E]!==R||e.state.setPath(d,["errors",E],B??void 0),B??null))):(e.state.setPath(d,["errors",E],_??void 0),_??null)},f.touch=M=>{const E=String(M);e.state.setPath(d,["touched",E],!0),f.validateField(E)};const C=M=>{e.state.setPath(d,["errors"],M);const E=Object.keys(M).length===0;return e.state.setPath(d,["valid"],E),E};return f.validate=()=>{const M=Ar.validateAll(g(),l);return y(M)?(x(),M.then(E=>(w(),C(E)))):C(M)},f.handleSubmit=M=>{const E={};for(const U of Object.keys(l))E[U]=!0;const R=h().touched;e.state.setPath(d,["touched"],{...R&&typeof R=="object"?R:{},...E});const _=U=>{if(!U||!u)return U;e.state.setPath(d,["submitting"],!0);let O;try{O=u(g(),M)}catch(Q){throw e.state.setPath(d,["submitting"],!1),Q}return y(O)?O.finally(()=>e.state.setPath(d,["submitting"],!1)):(e.state.setPath(d,["submitting"],!1),U)},B=f.validate();return y(B)?B.then(_):_(B)},f.submit=M=>f.handleSubmit(M),f.reset=()=>{const M=p();k=A(M.values),e.state.setPath(d,["values"],M.values),e.state.setPath(d,["errors"],{}),e.state.setPath(d,["touched"],{}),e.state.setPath(d,["dirty"],!1),e.state.setPath(d,["valid"],!0),e.state.setPath(d,["submitting"],!1),e.state.setPath(d,["validating"],!1)},f.field=M=>{const E=String(M);e.trackedState.add(`${d}.values.${E}`),e.trackedState.add(`${d}.errors.${E}`),e.trackedState.add(`${d}.touched.${E}`);const R=h(),_=R.errors&&typeof R.errors=="object"?R.errors:{},B=R.touched&&typeof R.touched=="object"?R.touched:{};return{name:E,value:g()[E]??"",error:B[E]?_[E]:void 0,onChange:U=>f.setField(E,U),onBlur:()=>f.touch(E)}},e.stores.set(n,b),b}function ml(t){if(typeof globalThis>"u")return null;const e=globalThis;try{return(t==="session"?e.sessionStorage:e.localStorage)??null}catch{return null}}function sy(t,e){const r=ml(e);if(!r)return null;try{const n=r.getItem(t);if(!n)return null;const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}function ly(t,e,r){const n=ml(e);if(n)try{n.setItem(t,JSON.stringify(r))}catch{}}function fl(t,e){const r=[];let n=t;for(;n.kind==="Member";){if(n.computed){if(n.computed.kind!=="Literal")return null;const i=n.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(n.property)r.unshift(n.property);else return null;n=n.object}if(n.kind!=="Identifier")return null;const a=P(n,e);return Ir(a)?{atom:a.__atom,path:r}:null}function cy(t,e){if(t.callee.kind==="StateRef"){const a=t.callee.name;if(a==="state")return wy(t.arguments,e,t.loc);if(a==="memo")return ky(t.arguments,e,t.loc);if(a==="ref")return Sy(t.arguments,e,t.loc);if(a==="reducer")return $y(t.arguments,e,t.loc);if(a==="id")return Cy(t.arguments,e,t.loc);switch(a){case"store":return ay(t.arguments,e,t.loc);case"form":return oy(t.arguments,e,t.loc);case"router":return Vv(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Fn(o?P(o,e):{},e)}case"query":{const o=t.arguments[0];return Ss(o?P(o,e):{},e)}case"mutation":{const o=t.arguments[0];return $s(o?P(o,e):{},e)}case"socket":{const o=t.arguments[0];return Jb(o?P(o,e):{},e)}case"sse":{const o=t.arguments[0];return ev(o?P(o,e):{},e)}case"theme":{const o=t.arguments[0],s=o?P(o,e):null;if(s&&typeof s=="object"&&!Array.isArray(s)){const f=s;f.icons&&pi(f.icons),f.fonts&&Ps(f.fonts),f.font&&Ps(f.font)}const l=_y(s),u=Fy(s),d=u?Dt[u]:null;return{kind:"Theme",tokens:d?{...d,...l}:l}}case"app":{const o=t.arguments;return o.length===1?P(o[0],e):o.map(s=>P(s,e))}case"i18n":{const o=t.arguments[0],s=o?P(o,e):null,l=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return Ts(l)}case"emit":{const o=t.arguments[0]?String(P(t.arguments[0],e)):"",s=t.arguments[1]?P(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&P(t.arguments[0],e),Xn;case"optimistic":return yy(t.arguments[0],e)}const i=e.hookDecls.get(a);if(i)return Ay(i,t.arguments,e)}const r=P(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const n=[];for(const a of t.arguments){if(a.kind==="Spread"){const i=P(a.argument,e);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(P(a,e))}try{return r.apply(void 0,n)}catch(a){return console.error("[aktion] call expression threw",a),null}}function uy(t,e){const r=P(t.callee,e);if(typeof r!="function")return null;const n=[];for(const a of t.arguments){if(a.kind==="Spread"){const i=P(a.argument,e);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(P(a,e))}try{return Reflect.construct(r,n)}catch(a){return console.error("[aktion] `new` threw",a),null}}function dy(t,e,r){t.kind==="ComponentDeclaration"?r.push({kind:"component",name:t.name,had:e.componentDecls.has(t.name),prev:e.componentDecls.get(t.name)}):t.kind==="ActionDeclaration"?r.push({kind:"action",name:t.name,had:e.actionDecls.has(t.name),prev:e.actionDecls.get(t.name)}):r.push({kind:"hook",name:t.name,had:e.hookDecls.has(t.name),prev:e.hookDecls.get(t.name)})}function py(t,e){for(let r=e.length-1;r>=0;r-=1){const n=e[r],a=n.kind==="component"?t.componentDecls:n.kind==="action"?t.actionDecls:t.hookDecls;n.had?a.set(n.name,n.prev):a.delete(n.name)}}function sa(t,e,r){let n=null;const a=[],i=[];try{for(const o of t.body)switch(o.kind){case"ExpressionStatement":n=P(o.expression,e);continue;case"Assignment":{if(o.isState&&o.identifier){const l=De(e,o.identifier);if(r.stateAsDeclaration){if(e.state.has(l)){n=e.state.get(l);continue}const d=P(o.expression,e);e.state.declare(l,d),n=d;continue}const u=P(o.expression,e);e.state.set(l,u),n=u;continue}const s=P(o.expression,e);e.bindings.has(o.identifier)&&!e.loopVars.has(o.identifier)?e.mutableBindings.set(o.identifier,s):(e.loopVars.has(o.identifier)||a.push(o.identifier),e.loopVars.set(o.identifier,s)),n=s;continue}case"Return":return n=o.argument?P(o.argument,e):void 0,n;case"ThrowStatement":throw P(o.argument,e);case"EffectDeclaration":{const s=e.componentEffectStack[e.componentEffectStack.length-1];s?s.push({decl:o,capturedAliases:e.stateAliases.map(l=>new Map(l)),capturedLoopVars:new Map(e.loopVars)}):aa(o,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":dy(o,e,i),aa(o,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":Dr(o,e);continue}}catch(o){if(o instanceof ct)return o.value;throw o}finally{for(const o of a)e.loopVars.delete(o);py(e,i)}return n}function my(t,e,r){let n=t[0]??"";for(let a=0;a<e.length;a+=1)n+=ma(P(e[a],r)),n+=t[a+1]??"";return n}function fy(t,e,r,n){if(t==="&&"){const o=P(e,n);return o&&P(r,n)}if(t==="||"){const o=P(e,n);return o||P(r,n)}if(t==="??"){const o=P(e,n);return o??P(r,n)}const a=P(e,n),i=P(r,n);switch(t){case"+":return typeof a=="string"||typeof i=="string"?ma(a)+ma(i):q(a)+q(i);case"-":return q(a)-q(i);case"*":return q(a)*q(i);case"/":{const o=q(i);return o===0?0:q(a)/o}case"%":{const o=q(i);return o===0?0:q(a)%o}case"**":return q(a)**q(i);case"==":case"===":return a===i;case"!=":case"!==":return a!==i;case">":return q(a)>q(i);case"<":return q(a)<q(i);case">=":return q(a)>=q(i);case"<=":return q(a)<=q(i);case"&":return pe(a)&pe(i);case"|":return pe(a)|pe(i);case"^":return pe(a)^pe(i);case"<<":return pe(a)<<(Je(i)&31);case">>":return pe(a)>>(Je(i)&31);case">>>":return Je(a)>>>(Je(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return a instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(a)in i}catch{return!1}}default:return null}}function pe(t){return q(t)|0}function Je(t){return q(t)>>>0}function gy(t,e){const r=P(t.object,e);if(r==null)return t.optional?void 0:null;const n=Ir(r)?r.__methods[t.method]:r[t.method];if(typeof n!="function")return null;const a=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=P(o.argument,e);if(Array.isArray(s))for(const l of s)a.push(l);continue}a.push(P(o,e))}const i=a;try{return n.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof Qe)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function hy(t,e,r,n){const a=r.componentDecls.get(t),i=a!==void 0&&Js(t,r);if(a&&!i)return vy(a,e,r,n);const o=i?void 0:r.actionDecls.get(t);if(o){const g=e.map(y=>P(y,r));return hl(o,g,r)}if(t==="cleanup"&&r.cleanupSink){const g=e[0]?P(e[0],r):void 0;typeof g=="function"&&r.cleanupSink(g);return}if(t==="setTimeout"||t==="setInterval")return Py(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?P(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 s=r.loopVars.get(t);if(typeof s=="function"){const g=e.map(y=>P(y,r));return s(...g)}const l=r.bindings.get(t);if(l){const g=l();if(typeof g=="function"){const y=e.map(v=>P(v,r));return g(...y)}}if(Object.prototype.hasOwnProperty.call(Bt,t)&&typeof Bt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Pe(r.library,t))){const g=Bt[t],y=[];for(const v of e){if(v.kind==="Spread"){const x=P(v.argument,r);if(Array.isArray(x))for(const w of x)y.push(w);continue}y.push(P(v,r))}try{return g(...y)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}if(r.library&&!Pe(r.library,t)){const g=Zs(t);if(g.found&&typeof g.value=="function"){const y=g.value,v=[];for(const x of e){if(x.kind==="Spread"){const w=P(x.argument,r);if(Array.isArray(w))for(const k of w)v.push(k);continue}v.push(P(x,r))}try{return y(...v)}catch(x){return console.error(`[aktion] global "${t}" threw`,x),null}}return Pe(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:n}:null}let u;const d=[...e];if(d.length>0){const g=d[d.length-1];if(g.kind==="Object"){const y=g.properties.find(v=>!v.spread&&v.key==="key");if(y){u=P(y.value,r);const v=g.properties.filter(x=>x!==y);v.length>0?d[d.length-1]={...g,properties:v}:d.pop()}}}const{args:p,argMeta:f,universal:b}=by(r,t,d);return{__kind:"Component",name:t,args:p,argMeta:f,explicitKey:u,universal:b,source:n}}function by(t,e,r){const n=t.library?Pe(t.library,e):void 0;if(!n){const b=r.map(g=>P(g,t)),h=r.map(g=>{const y=zr(g,t);return y!==null?{stateRef:y}:{}});return{args:b,argMeta:h}}const a=new Map;n.props.forEach((b,h)=>{if(a.set(b.name,h),b.aliases)for(const g of b.aliases)a.has(g)||a.set(g,h)});const i=tr(n),o=n.props.map(()=>({value:void 0,meta:{},filled:!1}));let s;const l=[],u=an(on(r),n);for(let b=0;b<r.length;b+=1){if(b===u)continue;const h=r[b];l.push({expr:h,value:P(h,t)})}if(u>=0){const b=r[u];if(b.kind==="Object")for(const h of b.properties){if(h.spread)continue;const g=a.get(h.key);if(g===void 0){tn.has(h.key)&&(s||(s={}),s[h.key]=P(h.value,t));continue}const y=P(h.value,t);o[g].value=y,o[g].filled=!0;const v=zr(h.value,t);v!==null&&(o[g].meta={stateRef:v})}}if(l.length>0&&i>=0&&!o[i].filled){const{expr:b,value:h}=l.shift();o[i].value=h,o[i].filled=!0;const g=zr(b,t);g!==null&&(o[i].meta={stateRef:g})}let d=0;for(const{expr:b,value:h}of l){for(;d<n.props.length&&o[d].filled;)d+=1;if(d>=n.props.length)break;o[d].value=h,o[d].filled=!0;const g=zr(b,t);g!==null&&(o[d].meta={stateRef:g}),d+=1}const p=o.map(b=>b.value),f=o.map(b=>b.meta);for(;p.length>0&&p[p.length-1]===void 0;)p.pop(),f.pop();return{args:p,argMeta:f,universal:s}}function vy(t,e,r,n){const a=[],i={};let o,s=-1;for(let h=e.length-1;h>=0;h-=1)if(e[h].kind==="Object"){s=h;break}let l=s>=0?e[s]:null,u=!1;if(l&&l.kind==="Object"){const h=new Set(t.params.map(v=>v.name)),g=[];let y=!0;for(const v of l.properties)v.spread||(g.push(v.key),(v.key==="key"||h.has(v.key))&&(u=!0),/^[A-Za-z_$][\w$]*$/.test(v.key)||(y=!1));if(!u&&y&&g.length>0&&e.length-1>=t.params.length&&(u=!0),!u&&r.strict&&g.length>0&&t.params.length>0){const v=`trailing:${t.name}:${g.slice().sort().join(",")}`;if(!r.strictWarned.has(v)){r.strictWarned.add(v);const x=n?` (line ${n.line}, col ${n.column})`:"";console.warn(`[aktion] strict: object { ${g.join(", ")} } passed to <${t.name}>${x} is being forwarded as a positional argument because none of its keys match a parameter (${t.params.map(w=>w.name).join(", ")||"none"}). If you meant named props, check for a renamed/misspelled parameter.`)}}}u||(s=-1,l=null);for(let h=0;h<e.length;h+=1)h!==s&&a.push(e[h]);if(l&&l.kind==="Object")for(const h of l.properties)h.spread||(h.key==="key"?o=h.value:i[h.key]=h.value);const d=a.map(h=>h.kind==="Spread"?P(h.argument,r):P(h,r)),p=[];for(let h=0;h<a.length;h+=1){const g=a[h],y=d[h];if(g.kind==="Spread"&&Array.isArray(y))for(const v of y)p.push(v);else p.push(y)}const f={};for(const[h,g]of Object.entries(i))f[h]=P(g,r);const b=o?P(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:p,named:f,explicitKey:b,source:n}}function gl(t,e,r){const{decl:n,positional:a,named:i}=t,o=[],s=(h,g)=>{o.push({name:h,had:e.loopVars.has(h),prev:e.loopVars.get(h)}),e.loopVars.set(h,g)};for(let h=0;h<n.params.length;h+=1){const g=n.params[h];if(g.pattern){let v=a[h];v===void 0&&g.defaultValue&&(v=P(g.defaultValue,e));for(const x of Ft(g.pattern,v,e))s(x.name,x.value);continue}let y;i[g.name]!==void 0?y=i[g.name]:a[h]!==void 0?y=a[h]:g.defaultValue?y=P(g.defaultValue,e):y=void 0,s(g.name,y)}if(a.length>n.params.length){const h=a.slice(n.params.length),g=h.length===1?h[0]:h;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}const l=new Set;for(const h of n.params)h.name&&l.add(h.name);const u={};for(const h of n.slots)i[h]!==void 0&&(u[h]=i[h]);for(const[h,g]of Object.entries(i))l.has(h)||g===void 0||(u[h]=g,/^[A-Za-z_$][\w$]*$/.test(h)&&h!=="children"&&h!=="slots"&&!e.componentDecls.has(h)&&s(h,g));(Object.keys(u).length>0||n.slots.length>0)&&(o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",u));const d=new Map;for(const h of n.body.body)if(h.kind==="Assignment"&&h.isState){const g=`${r}:${h.identifier}`;d.set(h.identifier,g)}e.stateAliases.push(d);const p=[];e.componentEffectStack.push(p);const f=e.hookScope,b={instanceKey:r,cursor:0};e.hookScope=b,e.activeComponentDecls.push(n.name);try{return{value:sa(n.body,e,{stateAsDeclaration:!0}),effects:p,hooks:b.cursor}}finally{e.activeComponentDecls.pop(),e.hookScope=f,e.componentEffectStack.pop(),e.stateAliases.pop();for(const h of o)h.had?e.loopVars.set(h.name,h.prev):e.loopVars.delete(h.name)}}function hl(t,e,r){const n=!!(t.name&&r.componentDecls.has(t.name)&&r.library&&Pe(r.library,t.name));n&&r.activeComponentDecls.push(t.name);try{if(!r.errorHook)return la(t.params,t.body,e,r);try{return la(t.params,t.body,e,r)}catch(a){if(a instanceof ct||a instanceof Me||a instanceof Ee)throw a;try{r.errorHook({error:a,source:t.name??"action"})}catch{}throw a}}finally{n&&r.activeComponentDecls.pop()}}function yy(t,e){const r=t?P(t,e):void 0;if(typeof r!="function")return;const n=new Map;for(const[i,o]of e.state.entries())n.set(i,o);const a=()=>{for(const i of[...e.state.entries()].map(([o])=>o))n.has(i)||e.state.set(i,void 0);for(const[i,o]of n)e.state.set(i,o);e.notify?.()};try{const i=r();return i&&typeof i.then=="function"?i.catch(o=>{throw a(),o}):i}catch(i){throw i instanceof ct||i instanceof Me||i instanceof Ee||a(),i}}function la(t,e,r,n){const a=[],i=(o,s)=>{a.push({name:o,had:n.loopVars.has(o),prev:n.loopVars.get(o)}),n.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let l=r[o];if(l===void 0&&s.defaultValue&&(l=P(s.defaultValue,n)),s.pattern){for(const u of Ft(s.pattern,l,n))i(u.name,u.value);continue}i(s.name,l)}try{return sa(e,n,{stateAsDeclaration:n.state.isRendering()})}finally{for(const o of a)o.had?n.loopVars.set(o.name,o.prev):n.loopVars.delete(o.name)}}function _t(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 xy(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 wy(t,e,r){const n=_t(e);if(!n)return Ut("state",r),[t[0]?P(t[0],e):void 0,()=>{}];const a=e.hookScope.cursor++;let i=n[a];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?P(t[0],e):void 0},n[a]=i);const o=i,s=l=>{const u=typeof l=="function"?l(o.value):l;Object.is(u,o.value)||(o.value=u,e.notify?.())};return[o.value,s]}function ky(t,e,r){const n=t[0],a=t[1],i=()=>{const f=n?P(n,e):void 0;return typeof f=="function"?f():f},o=_t(e);if(!o)return Ut("memo",r),i();const s=e.hookScope.cursor++,l=a?P(a,e):void 0,u=Array.isArray(l)?l:void 0,d=o[s];if(d&&d.kind==="memo"&&u&&d.deps&&xy(d.deps,u))return d.value;const p=i();return o[s]={kind:"memo",deps:u,value:p},p}function Sy(t,e,r){const n=_t(e);if(!n)return Ut("ref",r),{current:t[0]?P(t[0],e):void 0};const a=e.hookScope.cursor++;let i=n[a];return(!i||i.kind!=="ref")&&(i={kind:"ref",box:{current:t[0]?P(t[0],e):void 0}},n[a]=i),i.box}function $y(t,e,r){const n=t[0]?P(t[0],e):void 0,a=_t(e),i=t[1]?P(t[1],e):void 0;if(!a)return Ut("reducer",r),[i,()=>{}];const o=e.hookScope.cursor++;let s=a[o];(!s||s.kind!=="reducer")&&(s={kind:"reducer",value:i},a[o]=s);const l=s,u=d=>{if(typeof n!="function")return;const p=n(l.value,d);Object.is(p,l.value)||(l.value=p,e.notify?.())};return[l.value,u]}let bl=0;function Cy(t,e,r){const n=t[0]?String(P(t[0],e)):"rui",a=_t(e);if(!a)return Ut("id",r),`${n}-${bl+=1}`;const i=e.hookScope.cursor++;let o=a[i];return(!o||o.kind!=="id")&&(o={kind:"id",value:`${n}-${bl+=1}`},a[i]=o),o.value}function Ay(t,e,r){const n=[];for(const a of e){if(a.kind==="Spread"){const i=P(a.argument,r);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(P(a,r))}return la(t.params,t.body,n,r)}let vl=!1;function Ut(t,e){vl||(vl=!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 yl(t,e){t.hookStore.delete(e)}function Ty(t,e){const r=e.stateAliases.map(a=>new Map(a)),n=new Map(e.loopVars);return(...a)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,l]of n)e.loopVars.set(s,l);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return hl(t,a,e)}finally{e.loopVars.clear();for(const[s,l]of i)e.loopVars.set(s,l);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function My(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function Ny(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function Iy(t,e,r){return t==="__rui_assign__"?Ey(e,r):t==="__rui_postfix__"?zy(e,r):t==="__rui_prefix__"?Ry(e,r):t==="__rui_await__"?e[0]?P(e[0],r):void 0:null}function et(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:q(e)+q(r);case"-=":return q(e)-q(r);case"*=":return q(e)*q(r);case"/=":{const n=q(r);return n===0?0:q(e)/n}case"%=":{const n=q(r);return n===0?0:q(e)%n}case"**=":return q(e)**q(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return pe(e)&pe(r);case"|=":return pe(e)|pe(r);case"^=":return pe(e)^pe(r);case"<<=":return pe(e)<<(Je(r)&31);case">>=":return pe(e)>>(Je(r)&31);case">>>=":return Je(e)>>>(Je(r)&31);default:return r}}function Py(t,e,r){const n=e[0]?P(e[0],r):null;if(typeof n!="function")return null;const a=n,i=e[1]?q(P(e[1],r)):0,o=[];for(let u=2;u<e.length;u+=1)o.push(P(e[u],r));const s=()=>{try{a(...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 l=setInterval(s,i);return r.timers.intervals.add(l),l}function Ey(t,e){const[r,n,a]=t;if(!r||!n)return null;const i=a&&a.kind==="Literal"?String(a.value??"="):"=",o=P(n,e);if(r.kind==="StateRef"){const s=De(e,r.name),l=e.state.get(s),u=et(i,l,o);return e.state.set(s,u),u}if(r.kind==="Member"){const s=Er(r,e);if(s){const p=e.state.get(s.name);if(s.path.length>=1&&xs(p)){let h=p;for(let g=0;g<s.path.length-1;g+=1)h=h?.[s.path[g]];if(h&&typeof h=="object"){const g=s.path[s.path.length-1],y=h[g],v=et(i,y,o);return h[g]=v,e.notify?.(),v}}const f=ca(p,s.path),b=et(i,f,o);return e.state.setPath(s.name,s.path,b),b}const l=fl(r,e);if(l){const p=ca(e.state.get(l.atom),l.path),f=et(i,p,o);return e.state.setPath(l.atom,l.path,f),f}const u=P(r.object,e),d=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(u&&typeof u=="object"&&d!=null){const p=u[String(d)],f=et(i,p,o);return u[String(d)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const d=e.loopVars.get(s),p=et(i,d,o);return e.loopVars.set(s,p),p}if(e.bindings.has(s)||e.mutableBindings.has(s)){const d=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),p=et(i,d,o);return e.mutableBindings.set(s,p),p}const l=e.loopVars.get(s),u=et(i,l,o);return e.loopVars.set(s,u),u}return o}function ca(t,e){let r=t;for(const n of e){if(r==null)return;if(Array.isArray(r)){const a=Number(n);r=Number.isNaN(a)?void 0:r[a];continue}if(typeof r=="object"){r=r[n];continue}return}return r}function xl(t,e,r){const[n,a]=t;if(!n)return null;const o=(a&&a.kind==="Literal"?String(a.value??"++"):"++")==="--"?-1:1;if(n.kind==="StateRef"){const s=De(e,n.name),l=q(e.state.get(s)),u=l+o;return e.state.set(s,u),r==="prefix"?u:l}if(n.kind==="Member"){const s=Er(n,e);if(s){const l=q(ca(e.state.get(s.name),s.path)),u=l+o;return e.state.setPath(s.name,s.path,u),r==="prefix"?u:l}}if(n.kind==="Identifier"){const s=n.name;if(e.loopVars.has(s)){const d=q(e.loopVars.get(s)),p=d+o;return e.loopVars.set(s,p),r==="prefix"?p:d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const d=q(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),p=d+o;return e.mutableBindings.set(s,p),r==="prefix"?p:d}const l=q(e.loopVars.get(s)),u=l+o;return e.loopVars.set(s,u),r==="prefix"?u:l}return null}function zy(t,e){return xl(t,e,"postfix")}function Ry(t,e){return xl(t,e,"prefix")}function ua(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 Ly(t){const e=t.getPath(),r={...t.getParams()},n=t.getActivePattern(),a={};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,l]of o)a[s]=l}}return{path:e,params:r,pattern:n,query:a,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function da(t,e){if(t!=null){if(Array.isArray(t)){const r=wl(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=wl(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function wl(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 pa(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 q(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 Dy=new Set(["colors","radius","font","fonts","spacing","shadows","gradients","zIndex","motion"]),jy=new Set(["name","direction"]),By={sm:"s",md:"m",lg:"l"},Oy={colors:"color",radius:"radius",font:"font",spacing:"spacing",shadows:"shadow",gradients:"gradient",zIndex:"z",motion:"motion"};function Fy(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t.name;if(typeof e!="string")return null;const r=e.trim().toLowerCase();return r in Dt?r:null}function _y(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[n,a]of Object.entries(r))if(a!=null&&!jy.has(n)&&Dy.has(n)&&a&&typeof a=="object"&&!Array.isArray(a)){const i=Oy[n]??n,o=n==="gradients";for(const[s,l]of Object.entries(a)){if(l==null)continue;const u=n==="spacing"?By[s]??s:s,d=i+Hy(u),p=o?Uy(l):qy(l);p&&(e[d]=p)}}return e}function Uy(t){const e=r=>{const n=typeof r=="string"?r.trim():"";return!n||n.length>64||!/^[a-zA-Z0-9#%.,()\s+-]+$/.test(n)||/url\s*\(|expression\s*\(|javascript\s*:|@import/i.test(n)?"":n};if(Array.isArray(t)){const r=t.map(e).filter(Boolean);return r.length<2?"":`linear-gradient(120deg, ${r.join(", ")})`}if(t&&typeof t=="object"){const r=t,n=Array.isArray(r.stops)?r.stops.map(e).filter(Boolean):[];return n.length<2?"":`linear-gradient(${typeof r.angle=="number"&&Number.isFinite(r.angle)?`${Math.round(r.angle)}deg`:"120deg"}, ${n.join(", ")})`}if(typeof t=="string"){const r=t.trim();if(/^(linear|radial|conic)-gradient\(/.test(r)&&!/expression\s*\(|javascript\s*:|@import|<\/?\w/i.test(r)&&r.length<=256)return r}return""}function Hy(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function qy(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function ma(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 Vy="__AKTION_DEVTOOLS_HOOK__";function Wy(){return globalThis}function jr(){return Wy()[Vy]}function fa(){const t=jr();return t!==void 0&&t.active}function ga(t){jr()?.emit(t)}function Gy(t){jr()?.unregisterApp(t)}function ve(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}const Ky="$";function kl(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 Sl(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(!Object.prototype.hasOwnProperty.call(e,a)||!Object.is(t[a],e[a]))return!1;return!0}class ha{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);j(this,"profiling",!1);j(this,"profilerRecords",[]);j(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 n=0;n<e.length;n+=1)e[n]==="#"&&(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 n=r.lastIndexOf("::"),a=n===-1?r:r.slice(0,n);e.has(a)||this.instanceStates.delete(r)}for(const[r,n]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const a of n.values())this.safeDispose(a);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(n){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,n)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(n){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,n)}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,n,a,i,o,s){this.profilerRecords.push({instanceKey:e,name:r,kind:n,phase:a,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 n=e.indexOf(".");if(n<0){this.options.state.set(e,r);return}const a=e.slice(0,n),i=e.slice(n+1).split(".");this.options.state.setPath(a,i,r)}render(e){return this.renderAt(e,Ky)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const n=document.createDocumentFragment();return e.forEach((a,i)=>{n.append(this.renderAt(a,`${r}/${i}`))}),n}return tl(e)?this.renderUserComponent(e,r):el(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const n=this.options.evaluationContext;if(!n){const p=document.createElement("div");return p.className="rui-unknown-component",p.textContent=`[unknown component: ${e.decl.name}]`,p}const a=n(),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&&kl(e.positional,s.positional)&&Sl(e.named,s.named)&&!zt(this.changedPaths,s.deps)){const p=a.trackedState;for(const f of s.deps)p.add(f);this.profiling&&this.profile(o,e.decl.name,"user","memo",0,"memoized (args + deps unchanged)",s.deps),ea(a,e.decl.name);try{return this.renderAt(s.value,o)}finally{ta(a)}}const l=this.profiledInstances.has(o)?"update":"mount",u=s?kl(e.positional,s.positional)?Sl(e.named,s.named)?zt(this.changedPaths,s.deps)?"state dependency changed":"full render":"named args changed":"positional args changed":l==="mount"?"initial mount":"no memo (full render)",d=this.profiling?ve():0;ea(a,e.decl.name);try{const p=a.trackedState,f=new Set;a.trackedState=f;let b;try{b=gl(e,a,o)}finally{a.trackedState=p;for(const x of f)p.add(x)}const{value:h,effects:g,hooks:y}=b;this.profiling&&this.profile(o,e.decl.name,"user",l,ve()-d,u,f),this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,g,n),g.length>0&&this.instancesWithEffects.add(o)),y>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:f,value:h});const v=this.renderAt(h,o);return e.explicitKey!=null&&v instanceof Element&&!v.hasAttribute("data-rui-key")&&v.setAttribute("data-rui-key",String(e.explicitKey)),v}finally{ta(a)}}renderComponent(e,r){const n=Pe(this.options.library,e.name);if(!n){const p=document.createElement("div");return p.className="rui-unknown-component",p.textContent=`[unknown component: ${e.name}]`,p}const a=rr(n,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 l={renderNode:p=>this.renderAt(p,`${o}>${s++}`),invoke:(p,...f)=>{if(typeof p=="function")try{const b=p(...f);b&&typeof b.then=="function"&&b.catch(h=>{console.error("[aktion] handler rejected",h)})}catch(b){console.error("[aktion] handler threw",b)}},setState:(p,f)=>{this.writeState(p,f)},resetState:(...p)=>{this.options.state.reset(...p)},sendToAssistant:p=>{this.options.onAssistantMessage?.(p)},openUrl:p=>{const f=Fe(p,"#"),b=this.options.onOpenUrl;b?b(f):f!=="#"&&typeof window<"u"&&window.open(f,"_blank","noopener,noreferrer")},bindState:(p,f,b)=>{const g=`on${b?.event??this.eventFor(p)}`,y=b?.getValue??this.defaultValueGetter(p);p[g]=v=>{const x=v.currentTarget??v.target??p;this.writeState(f,y(x))}},useInstanceState:(p,f)=>{const b=`${o}::${p}`;return this.instanceStates.has(b)||this.instanceStates.set(b,f),{get:()=>this.instanceStates.get(b),set:h=>{this.instanceStates.set(b,h)}}},registerDisposer:(p,f)=>{let b=this.instanceDisposers.get(o);b||(b=new Map,this.instanceDisposers.set(o,b));const h=f??`__anon::${b.size}`,g=b.get(h);g&&g!==p&&this.safeDispose(g),b.set(h,p)},router:this.options.router},u=this.profiledInstances.has(o)?"update":"mount",d=this.profiling?ve():0;try{const p=n.render(e,a,l);return e.universal&&$u(p,e.universal),e.explicitKey!=null&&p instanceof Element&&!p.hasAttribute("data-rui-key")&&p.setAttribute("data-rui-key",String(e.explicitKey)),this.profiling&&this.profile(o,e.name,"library",u,ve()-d,u==="mount"?"mounted":"re-rendered"),p}catch(p){this.profiling&&this.profile(o,e.name,"library",u,ve()-d,"render threw"),console.error(`[aktion] failed to render ${n.name}`,p);const f=document.createElement("div");return f.className="rui-render-error",f.textContent=`[render error in ${n.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 n=r.value;if(n==="")return null;const a=Number(n);return Number.isFinite(a)?a:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}function Yy(){return typeof document<"u"&&typeof document.createElement=="function"}function $l(t,e={}){if(!Yy())throw new Error("[aktion] renderToString requires a DOM. In Node, register happy-dom or jsdom globals before calling it.");const r=e.library??kt,n=new Dn;e.initialState&&typeof e.initialState=="object"&&n.hydrate(e.initialState);const a=new Kn({defaultPath:e.path??"/"}),i=new jn,o=Pr(n,{library:r,router:a,http:i,notify:()=>{}});let s;try{s=xe(t)}catch(g){return console.error("[aktion] renderToString parse error",g),{html:e.container===!1?"":'<div class="rui-root"></div>',state:n.snapshot()}}na(s,o);const l=new ha({library:r,state:n,router:a,evaluationContext:()=>o}),u=o.bindings.get("aktion");let d=null;if(u)try{d=u()}catch(g){console.error("[aktion] renderToString entry-point error",g)}l.beginRender({changedPaths:new Set,memoize:!1});let p;try{p=l.render(d)}finally{l.endRender()}const f=document.createElement("div");f.className="rui-root",f.append(p);const b=f.innerHTML;return{html:e.container===!1?b:f.outerHTML,state:n.snapshot()}}function Xy(t,e={}){return $l(t,e).html}function Zy(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const Br="::",Qy=new Map;class Cl{constructor(e){j(this,"mounted",new Map);j(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const n=new Set(e.map(a=>a.name));for(const a of[...this.mounted.keys()])a.includes(Br)||n.has(a)||this.unmount(a);for(const a of e)this.mounted.has(a.name)||this.mount(a.name,a,r,[],Qy)}syncInstanceEffects(e,r,n){const a=`${e}${Br}`,i=new Set(r.map(o=>`${a}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(a)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${a}${o.decl.name}`,l=this.mounted.get(s);if(l){l.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,n,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${Br}`;for(const n of[...this.mounted.keys()])n.startsWith(r)&&this.unmount(n)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,n,a,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:n,capturedAliases:a,capturedLoopVars:i};this.mounted.set(e,o),this.emitEffect(e,r,"mount","mount");const l=Jy(f=>{const b=o.cleanups.splice(0);if(b.length>0){for(const g of b)try{g()}catch(y){Tl(e,y)}this.emitEffect(e,r,"cleanup",f,{cleanups:b.length})}const h=ve();try{Al(r,n(),o,this.options),this.emitEffect(e,r,"run",f,{duration:ve()-h})}catch(g){this.emitEffect(e,r,"error",f,{duration:ve()-h,error:g instanceof Error?g.message:String(g)}),console.error(`[aktion] effect "${e}" failed`,g)}finally{this.options.notify()}},r.rateLimit,o);let u=!1,d=!1,p=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(u=!0),f.name==="unmount"&&(d=!0);break;case"every":{p=!0;const b=`every(${f.intervalMs})`,h=setInterval(()=>l(b),f.intervalMs);o.intervals.push(h);break}case"state":{const b=nx(f.name,a),h=`state:${f.name}`,g=this.options.state.subscribe(y=>{Ln(y,b)&&l(h)});o.unsubscribers.push(g);break}}(r.triggers.length===0||u||!p&&!d&&r.triggers.every(f=>f.kind==="state"))&&l("mount")}emitEffect(e,r,n,a,i={}){const o=this.options.onEffectEvent;if(!o||!fa())return;const s=e.lastIndexOf(Br);o({effectKey:e,label:tx(r.name),instanceKey:s>=0?e.slice(0,s):null,phase:n,reason:a,triggers:rx(r),...i})}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const a of r.intervals)clearInterval(a);for(const a of r.unsubscribers)try{a()}catch{}if(r.cleanups.length>0){const a=r.cleanups.length;for(const i of r.cleanups)try{i()}catch(o){Tl(e,o)}this.emitEffect(e,r.decl,"cleanup","unmount",{cleanups:a})}if(r.decl.triggers.some(a=>a.kind==="lifecycle"&&a.name==="unmount")){const a=ve();try{Al(r.decl,r.ctxRef(),r,this.options),this.emitEffect(e,r.decl,"run","unmount",{duration:ve()-a})}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 Jy(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),l=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(l)},e.ms)}}let n=0,a=null,i="";return r.cleanups.push(()=>{a&&(clearTimeout(a),a=null)}),o=>{const s=Date.now(),l=s-n;l>=e.ms?(n=s,t(o)):a?i=o:(i=o,a=setTimeout(()=>{a=null,n=Date.now(),t(i)},e.ms-l))}}function Al(t,e,r,n){const a=r.capturedAliases.length>0?e.stateAliases.slice():null;if(a){e.stateAliases.length=0;for(const s of r.capturedAliases)e.stateAliases.push(new Map(s))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[s,l]of r.capturedLoopVars)e.loopVars.set(s,l)}const o=e.cleanupSink;e.cleanupSink=s=>{r.cleanups.push(s)};try{for(const s of t.body.body)ex(s,e,r,n)}finally{if(e.cleanupSink=o,a){e.stateAliases.length=0;for(const s of a)e.stateAliases.push(s)}if(i){e.loopVars.clear();for(const[s,l]of i)e.loopVars.set(s,l)}}}function ex(t,e,r,n){switch(t.kind){case"ExpressionStatement":{const a=t.expression;if(a.kind==="Call"&&a.callee==="cleanup"){const i=a.arguments[0]?P(a.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(Zy(a)){const i=a.arguments,o=i[0]?String(P(i[0],e)):"",s=i[1]?P(i[1],e):void 0;n.onEmit?.(o,s);return}return P(a,e)}case"Assignment":{const a=P(t.expression,e);if(t.identifier&&t.identifier!==""){const i=De(e,t.identifier);e.state.set(i,a)}return 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":oa(t,e);return;default:return}}function Tl(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function tx(t){const e=/^__effect_L(\d+)_C(\d+)$/.exec(t);return e?`effect @ L${e[1]}:C${e[2]}`:t}function rx(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 nx(t,e){const r=t.indexOf("."),n=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(n);if(o!==void 0)return o+a}return t}const ax=["onclick","ondblclick","oncontextmenu","onmousedown","onmouseup","onmousemove","onmouseenter","onmouseleave","onmouseover","onmouseout","onpointerdown","onpointerup","onpointermove","onpointerenter","onpointerleave","onpointercancel","onscroll","onwheel","ondrag","ondragstart","ondragend","ondragenter","ondragleave","ondragover","ondrop","ontouchstart","ontouchmove","ontouchend","ontouchcancel","oninput","onchange","onsubmit","onreset","oninvalid","ontoggle","onkeydown","onkeyup","onkeypress","onfocus","onblur","onanimationend","ontransitionend","onerror"];function ix(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];Pl(t,r)}function Ml(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return Nl(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,n=e;return r.tagName!==n.tagName?Nl(r,n):(ox(r,n),r)}function Nl(t,e){return t.parentNode?.replaceChild(e,t),e}function ox(t,e){sx(t,e),lx(t,e),Pl(t,Array.from(e.childNodes)),cx(t,e)}function sx(t,e){const r=t.attributes;for(let a=r.length-1;a>=0;a-=1){const i=r[a];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.tagName==="CANVAS"&&(i.name==="width"||i.name==="height")||t.removeAttribute(i.name)}const n=e.attributes;for(let a=0;a<n.length;a+=1){const i=n[a];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function lx(t,e){for(const r of ax){const n=e[r],a=t[r];n!==a&&(t[r]=n??null)}}function cx(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){ux(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){dx(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){t.value!==e.value&&(t.value=e.value);return}}function ux(t,e){if(t.type==="checkbox"||t.type==="radio"){const n=e.hasAttribute("checked")||e.checked;t.checked!==n&&(t.checked=n);return}const r=e.getAttribute("value")??e.value??"";t.value!==r&&Il(t,r)}function dx(t,e){const r=e.value??e.textContent??"";t.value!==r&&Il(t,r)}function Il(t,e){if(!px(t)){t.value=e;return}let r=null,n=null;try{r=t.selectionStart,n=t.selectionEnd}catch{}const a=t.value.length;if(t.value=e,r==null||n==null)return;const i=r>=a&&n>=a,o=i?e.length:Math.min(r,e.length),s=i?e.length:Math.min(n,e.length);try{t.setSelectionRange(o,s)}catch{}}function px(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function Pl(t,e){const r=new Map;for(const a of Array.from(t.childNodes)){const i=ba(a);i&&r.set(i,a)}let n=0;for(const a of e){const i=t.childNodes[n]??null,o=ba(a);if(o&&r.has(o)){const l=r.get(o);r.delete(o),l!==i&&t.insertBefore(l,i),Ml(l,a),n+=1;continue}if(!i){t.appendChild(a),n+=1;continue}const s=ba(i);if(s&&(!o||s!==o)){t.insertBefore(a,i),n+=1;continue}Ml(i,a),n+=1}for(;t.childNodes.length>e.length;){const a=t.childNodes[t.childNodes.length-1];t.removeChild(a)}}function ba(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 va(t,e={}){return e.mode==="chat"?gx(t,e):fx(t,e)}function mx(t){return Or(t)}function fx(t,e){const r=e.bindings??!0,n=e.toolCalls??!0,a=[];a.push(hx(e.preamble)),a.push(bx()),a.push(vx()),r&&a.push(yx()),a.push(xx()),a.push(wx()),n&&a.push(kx()),a.push(Sx()),a.push($x()),a.push(Cx()),a.push(Ax()),a.push(Mx()),a.push(Tx()),a.push(Nx()),a.push(Ix()),a.push(Px(t)),e.inlineMode&&a.push(Ex()),e.editMode&&a.push(zx()),e.tools&&e.tools.length>0&&a.push(Wx(e.tools)),e.toolExamples&&e.toolExamples.length>0&&a.push(ya("Endpoint examples",e.toolExamples));const i=e.examples??Lx();return i.length>0&&a.push(ya("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&a.push(El(e.additionalRules)),a.push(Rx()),a.join(`
|
|
101
|
+
`),a=Math.max(r.length,n.length),i=[];for(let o=0;o<a;o++){const s=r[o],l=n[o];s===l?s!==void 0&&i.push({type:"same",text:s}):(s!==void 0&&i.push({type:"remove",text:s}),l!==void 0&&i.push({type:"add",text:l}))}return i}function ns(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function as(t,e,r,n){for(const[a,i]of e){const o=u("div",{class:"rui-json-tree-row"});o.append(u("span",{class:"rui-json-tree-key"},[`${a}: `])),i!==null&&typeof i=="object"?o.append(is(i,r,n+1)):o.append(u("span",{class:"rui-json-tree-leaf"},[ns(i)])),t.append(o)}}function is(t,e,r=0){const n=u("div",{class:"rui-json-tree-node","data-depth":String(r)});if(t===null||typeof t!="object")return n.append(u("span",{class:"rui-json-tree-leaf"},[ns(t)])),n;const a=Array.isArray(t),i=a?t.map((c,d)=>[String(d),c]):Object.entries(t),o=e||r<1,s=u("button",{type:"button",class:"rui-json-tree-toggle","aria-expanded":o?"true":"false"},[o?"▼":"▶",a?` Array(${i.length})`:" Object"]),l=u("div",{class:"rui-json-tree-children","data-open":o?"true":"false"});return o&&as(l,i,e,r),s.onclick=c=>{const d=c.currentTarget,p=d.nextElementSibling;if(!p)return;const f=p.getAttribute("data-open")!=="true";p.setAttribute("data-open",f?"true":"false"),d.setAttribute("aria-expanded",f?"true":"false"),d.firstChild&&(d.firstChild.textContent=f?"▼":"▶"),f&&p.childElementCount===0?as(p,i,e,r):f||p.replaceChildren()},n.append(s,l),n}const zh={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:Mh},{name:"size",type:"string",optional:!0,enum:Nh},{name:"disabled",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=u("button",{class:"rui-icon-button",type:"button","data-variant":m(e.variant,"ghost"),"data-size":Ih(e.size),"aria-label":m(e.label),title:m(e.label),disabled:I(e.disabled)?"":null}),a=j(e.icon,{className:"rui-icon-button-icon"});return a&&n.append(a),n.onclick=()=>r.invoke(e.onClick),n}},jh={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 n=Rh(e.items),a=e.open!==void 0,i=a?I(e.open):!0,o=r.useInstanceState("open",i);a&&o.get()!==i&&o.set(i);const s=r.useInstanceState("filter",""),l=a?i:o.get(),c=u("div",{class:"rui-command-palette","data-open":l?"true":"false"});if(!l)return c;const d=u("div",{class:"rui-command-palette-backdrop"}),p=u("div",{class:"rui-command-palette-panel",role:"dialog","aria-modal":"true"}),f=u("div",{class:"rui-command-palette-header"}),b=u("input",{type:"text",class:"rui-command-palette-input",placeholder:m(e.placeholder,"Search commands…"),value:s.get(),autocomplete:"off"});f.append(b);const h=m(e.shortcut);h&&f.append(u("span",{class:"rui-command-palette-shortcut"},[h])),p.append(f);const g=u("div",{class:"rui-command-palette-list",role:"listbox"}),y=(v,x)=>{v.replaceChildren();const w=x.trim().toLowerCase(),k=w===""?n:n.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,v.append(u("div",{class:"rui-command-palette-group"},[A])));const $=u("button",{type:"button",class:"rui-command-palette-item",role:"option","data-value":S.value},[S.label]);S.shortcut&&$.append(u("span",{class:"rui-command-palette-item-kbd"},[S.shortcut])),$.onclick=C=>{C.stopPropagation(),r.invoke(S.action),o.set(!1),s.set("");const M=C.currentTarget.closest(".rui-command-palette"),L=M?.querySelector(".rui-command-palette-panel");M?.setAttribute("data-open","false"),We(L??null)},v.append($)}k.length===0&&v.append(u("div",{class:"rui-command-palette-empty"},["No commands found"]))};return y(g,s.get()),p.append(g),d.onclick=v=>{const x=v.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),We(w??null)},c.append(d,p),b.oninput=v=>{const x=v.currentTarget,w=x.closest(".rui-command-palette-panel")?.querySelector(".rui-command-palette-list");s.set(x.value),w&&y(w,x.value)},b.onkeydown=v=>{if(v.key==="Escape"){const x=v.currentTarget.closest(".rui-command-palette"),w=x?.querySelector(".rui-command-palette-panel");o.set(!1),x?.setAttribute("data-open","false"),We(w??null)}},setTimeout(()=>b.focus(),0),$t({liveRoot:p,onDismiss:()=>{o.set(!1),c.setAttribute("data-open","false")}}),c}},Dh={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 n=Ph(e.chips),a=u("div",{class:"rui-filter-chips"}),i=u("div",{class:"rui-filter-chips-row"});for(const o of n){const s=u("span",{class:"rui-filter-chip","data-value":o.value});s.append(u("span",{class:"rui-filter-chip-label"},[o.label]));const l=u("button",{type:"button",class:"rui-filter-chip-remove","aria-label":`Remove ${o.label}`}),c=j("xmark",{className:"rui-filter-chip-remove-icon"});c&&l.append(c),l.onclick=()=>r.invoke(e.onRemove,o.value),s.append(l),i.append(s)}if(a.append(i),n.length>0&&typeof e.onClear=="function"){const o=u("button",{type:"button",class:"rui-filter-chips-clear"},["Clear all"]);o.onclick=()=>r.invoke(e.onClear),a.append(o)}return a}},Oh={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 n=$r(e.items),a=rs(e.fields),i=u("div",{class:"rui-field-repeater"});if(n.forEach((o,s)=>{const l=u("div",{class:"rui-field-repeater-row","data-index":String(s)}),c=u("div",{class:"rui-field-repeater-grid"});for(const d of a){const p=u("label",{class:"rui-field-repeater-field"});p.append(u("span",{class:"rui-field-repeater-label"},[d.label]));const f=u("input",{class:"rui-input",type:d.type==="number"?"number":"text",name:`${d.name}-${s}`,value:m(o[d.name]),readonly:""});p.append(f),c.append(p)}if(l.append(c),typeof e.onRemove=="function"){const d=u("button",{type:"button",class:"rui-field-repeater-remove","aria-label":"Remove row"},["Remove"]);d.onclick=()=>r.invoke(e.onRemove,s),l.append(d)}i.append(l)}),typeof e.onAdd=="function"){const o=u("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}},Bh={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 n=Math.max(24,P(e.itemHeight,40)),a=T(e.items),i=u("div",{class:"rui-virtual-list"}),o=u("div",{class:"rui-virtual-list-scroller"}),s=u("div",{class:"rui-virtual-list-spacer"}),l=u("div",{class:"rui-virtual-list-window"}),c=a.length;s.style.height=`${c*n}px`,s.style.position="relative",l.style.position="absolute",l.style.top="0",l.style.left="0",l.style.right="0",o.style.maxHeight=`${Math.min(Math.max(c,1),12)*n}px`,o.style.overflow="auto";const d=(p,f)=>{p.replaceChildren();const b=f.clientHeight||n*12,h=Math.ceil(b/n)+2,g=Number.isFinite(f.scrollTop)?f.scrollTop:0,y=Math.max(0,Math.floor(g/n)),v=Math.min(c,y+h);p.style.transform=`translateY(${y*n}px)`;for(let x=y;x<v;x++){const w=a[x];if(e.renderItem)p.append(r.renderNode(w??e.renderItem));else if(w&&typeof w=="object"&&w.__kind)p.append(r.renderNode(w));else{const k=u("div",{class:"rui-virtual-list-item",style:`height:${n}px`});k.append(u("span",{},[m(w)])),p.append(k)}}};return o.onscroll=p=>{const f=p?.currentTarget??p?.target??o,b=f.querySelector(".rui-virtual-list-window");b&&d(b,f)},d(l,o),o.append(s,l),i.append(o),i}},Fh={name:"VirtualGrid",description:"Windowed 2-D grid for very large collections (galleries, tiles, thumbnails). Only the visible rows of cells are mounted. Pass pre-rendered nodes (or plain values) as `items`; set `columns`, `itemHeight`, and `gap`. Virtualizes by row so thousands of items scroll smoothly (XI.3).",props:[{name:"items",type:"any[]"},{name:"columns",type:"number",optional:!0,description:"Cells per row (default 4)"},{name:"itemHeight",type:"number",optional:!0,description:"Row height in px (default 120)"},{name:"gap",type:"number",optional:!0,description:"Gap between cells in px (default 8)"},{name:"height",type:"number",optional:!0,description:"Viewport height in px (default 480)"}],render:(t,e,r)=>{const n=Math.max(1,Math.min(12,Math.floor(P(e.columns,4)))),a=Math.max(24,P(e.itemHeight,120)),i=Math.max(0,P(e.gap,8)),o=Math.max(120,P(e.height,480)),s=T(e.items),l=s.length,c=Math.ceil(l/n),d=a+i,p=u("div",{class:"rui-virtual-grid"}),f=u("div",{class:"rui-virtual-grid-scroller",style:`max-height:${o}px;overflow:auto`}),b=u("div",{class:"rui-virtual-grid-spacer",style:`position:relative;height:${c*d}px`}),h=u("div",{class:"rui-virtual-grid-window",style:`position:absolute;left:0;right:0;top:0;display:grid;grid-template-columns:repeat(${n},minmax(0,1fr));gap:${i}px`}),g=(y,v)=>{y.replaceChildren();const x=Math.max(0,Math.floor((Number.isFinite(v)?v:0)/d)-1),w=Math.ceil(o/d)+2,k=Math.min(c,x+w);y.style.transform=`translateY(${x*d}px)`;for(let A=x;A<k;A+=1)for(let S=0;S<n;S+=1){const $=A*n+S;if($>=l)break;const C=s[$],M=u("div",{class:"rui-virtual-grid-cell",style:`height:${a}px`});C&&typeof C=="object"&&C.__kind?M.append(r.renderNode(C)):M.append(u("span",{},[m(C)])),y.append(M)}};return f.onscroll=y=>{const v=y?.currentTarget??y?.target??f,x=v.querySelector(".rui-virtual-grid-window");x&&g(x,v.scrollTop)},g(h,0),f.append(b,h),p.append(f),p}},_h={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 n=rs(e.fields),a=$r(e.value),i=t.argMeta?.[1]?.stateRef,o=u("div",{class:"rui-query-builder"}),s=l=>{o.replaceChildren(),l.forEach((d,p)=>{const f=u("div",{class:"rui-query-builder-row","data-index":String(p)}),b=u("select",{class:"rui-select rui-query-builder-field"});for(const v of n)b.append(u("option",{value:v.name},[v.label]));b.value=m(d.field??n[0]?.name);const h=u("select",{class:"rui-select rui-query-builder-op"},[]);for(const v of["equals","contains","gt","lt"])h.append(u("option",{value:v},[v]));h.value=m(d.op,"equals");const g=u("input",{class:"rui-input rui-query-builder-value",value:m(d.value)});f.append(b,h,g);const y=u("button",{type:"button",class:"rui-query-builder-remove"},["×"]);y.onclick=()=>{const v=l.filter((x,w)=>w!==p);i?r.setState(i,v):r.invoke(e.onChange,v),s(v)},f.append(y),o.append(f)});const c=u("button",{type:"button",class:"rui-query-builder-add"},["Add rule"]);c.onclick=()=>{const d=[...l,{field:n[0]?.name??"",op:"equals",value:""}];i?r.setState(i,d):r.invoke(e.onChange,d),s(d)},o.append(c)};return s(a.length>0?a:[{field:n[0]?.name??"",op:"equals",value:""}]),o}},Uh={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),n=m(e.right),a=m(e.mode,"split"),i=u("div",{class:"rui-diff-viewer","data-mode":a});if(a==="unified"){const c=u("pre",{class:"rui-diff-viewer-unified"});for(const d of Lh(r,n))c.append(u("div",{class:`rui-diff-line rui-diff-line-${d.type}`},[(d.type==="add"?"+ ":d.type==="remove"?"- ":" ")+d.text]));return i.append(c),i}const o=u("div",{class:"rui-diff-viewer-panes"}),s=u("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-left"},[r]),l=u("pre",{class:"rui-diff-viewer-pane rui-diff-viewer-right"},[n]);return o.append(s,l),i.append(o),i}},Hh={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=u("div",{class:"rui-json-tree"});return r.append(is(e.data,I(e.expanded))),r}},qh={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=Eh(e.tasks),n=r.map(d=>dt(d.start)),a=r.map(d=>dt(d.end)),i=e.startDate?dt(m(e.startDate)):n.length?Math.min(...n):Date.now(),o=e.endDate?dt(m(e.endDate)):a.length?Math.max(...a):i+864e5,s=Math.max(o-i,1),l=u("div",{class:"rui-gantt"}),c=u("div",{class:"rui-gantt-track"});for(const d of r){const p=u("div",{class:"rui-gantt-row"});p.append(u("div",{class:"rui-gantt-label"},[d.label]));const f=u("div",{class:"rui-gantt-bars"}),b=(dt(d.start)-i)/s*100,h=Math.max((dt(d.end)-dt(d.start))/s*100,2),g=u("div",{class:"rui-gantt-bar",style:`left:${b}%;width:${h}%`,title:`${d.start} → ${d.end}`});d.progress!=null&&g.append(u("div",{class:"rui-gantt-bar-progress",style:`width:${Math.min(100,Math.max(0,d.progress))}%`})),f.append(g),p.append(f),c.append(p)}return l.append(c),l}},Vh={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 n=Math.max(1,Math.floor(P(e.maxLines,3))),a=r.useInstanceState("expanded",!1),i=`display:-webkit-box;-webkit-line-clamp:${n};-webkit-box-orient:vertical;overflow:hidden`,o=u("div",{class:"rui-truncate","data-expanded":a.get()?"true":"false"}),s=u("p",{class:"rui-truncate-text",style:a.get()?"":i},[m(e.text)]),l=u("button",{type:"button",class:"rui-truncate-toggle"},[a.get()?"Show less":m(e.expandLabel,"Show more")]);return l.onclick=c=>{const d=c.currentTarget,p=d.closest(".rui-truncate"),f=p?.querySelector(".rui-truncate-text");if(!p||!f)return;const b=!a.get();a.set(b),f.style.cssText=b?"":i,d.textContent=b?"Show less":m(e.expandLabel,"Show more"),p.setAttribute("data-expanded",b?"true":"false")},o.append(s,l),o}},Wh={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 n=r.useInstanceState("editing",!1),a=r.useInstanceState("draft",m(e.value)),i=t.argMeta?.[0]?.stateRef,o=u("div",{class:"rui-inline-edit","data-editing":n.get()?"true":"false"}),s=m(e.label);s&&o.append(u("span",{class:"rui-inline-edit-label"},[s]));const l=u("button",{type:"button",class:"rui-inline-edit-display"},[m(e.value)]),c=u("input",{class:"rui-inline-edit-input rui-input",value:a.get()}),d=f=>{const b=f.closest(".rui-inline-edit"),h=b?.querySelector(".rui-inline-edit-input");return!b||!h?null:{root:b,input:h}},p=f=>{const b=d(f);n.set(!1),b?.root.setAttribute("data-editing","false");const h=a.get();i&&r.setState(i,h),r.invoke(e.onSave,h)};return l.onclick=f=>{const b=d(f.currentTarget);a.set(m(e.value)),n.set(!0),b&&(b.root.setAttribute("data-editing","true"),b.input.value=a.get(),setTimeout(()=>b.input.focus(),0))},c.oninput=f=>a.set(f.currentTarget.value),c.onkeydown=f=>{const b=f;if(b.key==="Enter"&&p(f.currentTarget),b.key==="Escape"){const h=d(f.currentTarget);n.set(!1),h?.root.setAttribute("data-editing","false")}},c.onblur=f=>p(f.currentTarget),o.append(l,c),o}},Gh={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 n=Math.max(0,Math.floor(P(e.count,0))),a=$r(e.items),i=r.useInstanceState("open",!1),o=i.get(),s=u("div",{class:"rui-notification-bell","data-open":o?"true":"false"}),l=u("button",{type:"button",class:"rui-notification-bell-trigger","aria-expanded":o?"true":"false","aria-haspopup":"true"}),c=j("bell",{className:"rui-notification-bell-icon"});c&&l.append(c),n>0&&l.append(u("span",{class:"rui-notification-bell-badge"},[n>99?"99+":String(n)])),s.append(l);const d=u("div",{class:"rui-notification-bell-panel",role:"menu"});if(a.length===0)d.append(u("div",{class:"rui-notification-bell-empty"},["No notifications"]));else for(const p of a){const f=u("div",{class:"rui-notification-bell-item"});f.append(u("div",{class:"rui-notification-bell-item-title"},[m(p.title)]));const b=m(p.message);b&&f.append(u("div",{class:"rui-notification-bell-item-message"},[b]));const h=m(p.time);h&&f.append(u("div",{class:"rui-notification-bell-item-time"},[h])),d.append(f)}return s.append(d),l.onclick=p=>{p.stopPropagation();const f=p.currentTarget,b=f.closest(".rui-notification-bell");if(!b)return;const h=!i.get();i.set(h),b.setAttribute("data-open",h?"true":"false"),f.setAttribute("aria-expanded",h?"true":"false"),h?(r.invoke(e.onOpen),$t({liveRoot:b,onDismiss:()=>{i.set(!1),b.setAttribute("data-open","false"),f.setAttribute("aria-expanded","false")}})):We(b)},s}},Ge=(t,e)=>e==null?document.createDocumentFragment():t.renderNode(e),Kh=t=>!!(t&&typeof t=="object"),Yh={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 n=e.resource,a={loading:e.loading,error:e.error,empty:e.empty,data:e.data};if(!Kh(n))return Ge(r,a.empty??a.data??null);const i=n.state;if(i==="loading"||n.loading)return Ge(r,a.loading??null);if(i==="error"||n.error)return Ge(r,a.error??null);const o=n.data;return o==null||Array.isArray(o)&&o.length===0?Ge(r,a.empty??a.data??null):Ge(r,a.data??null)}},Xh={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?Ge(r,e.children??null):Ge(r,e.fallback??null)},Jh={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 n=m(e.target);let a=null;if(n)try{a=document.querySelector(n)}catch{a=null}a||(a=document.body);const i=u("div",{class:"rui-portal"});for(const o of T(e.children))i.append(r.renderNode(o));return a&&(a.append(i),r.registerDisposer(()=>{i.parentNode&&i.parentNode.removeChild(i)},"rui-portal-container")),u("span",{class:"rui-portal-anchor","data-portal":n??"body"})}},Qh={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 n=m(e.path);if(n)try{r.router.navigate(n)}catch{}return u("span",{class:"rui-redirect","data-path":n,hidden:"true"})}},Zh={name:"Lazy",description:"Defer rendering until an async `loader` resolves: show `fallback` while pending, then render the resolved value (or `children`). A synchronous loader value renders immediately.",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 n=e.loader,a=r.useInstanceState("rui-lazy",{status:"init"}),i=u("span",{class:"rui-lazy",style:"display: contents;"}),o=p=>{i.replaceChildren(Ge(r,p))},s=()=>e.fallback??null,l=p=>p??e.children??null,c=a.get();if(c.status==="resolved")return o(l(c.value)),i;if(c.status==="pending"||c.status==="error")return o(s()),i;let d;try{d=typeof n=="function"?n():n}catch{return a.set({status:"error"}),o(s()),i}if(d&&typeof d.then=="function"){a.set({status:"pending"}),o(s());let p=!1;return r.registerDisposer(()=>{p=!0},"rui-lazy-cancel"),d.then(f=>{p||(a.set({status:"resolved",value:f}),o(l(f)))},()=>{p||(a.set({status:"error"}),o(s()))}),i}return a.set({status:"resolved",value:d}),o(l(d)),i}},eb={name:"ErrorBoundary",description:"Render a fallback subtree when rendering children throws. Pass a `fallback` node (or omit it for a built-in friendly error card showing the message + a Retry button); `onError(err)` fires with the error. Set `showDetails=true` to reveal the message inline (great in dev).",props:[{name:"fallback",type:"Node",optional:!0},{name:"onError",type:"callable",optional:!0},{name:"showDetails",type:"boolean",optional:!0,description:"Show the error message inline (default false)"},{name:"children",type:"Node[]",positional:!0}],render:(t,e,r)=>{const n=u("div",{class:"rui-error-boundary"});try{for(const a of T(e.children))n.append(r.renderNode(a));return n}catch(a){try{r.invoke(e.onError,a)}catch{}const i=a instanceof Error?a.message:String(a),o=u("div",{class:"rui-error-boundary rui-error-boundary--fallback"});if(o.setAttribute("role","alert"),e.fallback!=null)o.append(Ge(r,e.fallback));else{const s=u("div",{class:"rui-error-card"}),l=j("triangle-exclamation",{className:"rui-error-card-icon"});l&&s.append(l),s.append(u("div",{class:"rui-error-card-title"},["Something went wrong"])),(e.showDetails===!0||e.showDetails==="true")&&s.append(u("div",{class:"rui-error-card-message"},[i])),o.append(s)}return o.setAttribute("data-error",i),o}}},tb=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"]),rb=/^[a-zA-Z][a-zA-Z0-9_:-]*$/,nb=new Set(["href","ping","action","formaction"]),ab=new Set(["src","poster"]);function ib(t){const e=m(t).trim();return!e||/[<>]/.test(e)||/\bexpression\s*\(|\bjavascript\s*:|\bbehavior\s*:|@import\b/i.test(e)?"":e}function ob(t){const e=m(t).trim().toLowerCase();return!e||!tb.has(e)?"div":e}function sb(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t)){const a=r.trim();if(!a||!rb.test(a))continue;const i=a.toLowerCase();if(!i.startsWith("on")&&!(n==null||n===!1)){if(i==="style"){const o=ib(n);o&&(e.style=o);continue}if(nb.has(i)){const o=qe(n,"");o&&(e[a]=o);continue}if(ab.has(i)){const o=ie(n);o&&(e[a]=o);continue}e[a]=n===!0?"":m(n)}}return e}const lb={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 n=ob(e.tag),a=sb(e.attributes),i=u(n,a);for(const o of T(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}},cb=/<\/style|<script|expression\s*\(|javascript\s*:|behavior\s*:|@import\b/i,ub=64*1024;function db(t){const e=m(t);return!e||e.length>ub||cb.test(e)?"":e}function pb(t){return t.replace(/\{\s*([a-zA-Z]+)\.([a-zA-Z0-9-]+)\s*\}/g,(e,r,n)=>{const a=n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r==="colors"||r==="color"?"color":r==="spacing"?"spacing":r==="radius"?"radius":r==="shadows"||r==="shadow"?"shadow":r==="gradients"||r==="gradient"?"gradient":r==="font"||r==="fonts"?"font":null;return i?`var(--rui-${i}-${a})`:e})}function os(t,e){const r=[];let n=0;const a=t.length;for(;n<a;){const i=t.indexOf("{",n);if(i===-1){r.push(t.slice(n));break}const o=t.slice(n,i).trim();let s=1,l=i+1;for(;l<a&&s>0;l+=1)t[l]==="{"?s+=1:t[l]==="}"&&(s-=1);const c=t.slice(i+1,l-1);if(o.startsWith("@media")||o.startsWith("@supports"))r.push(`${o} { ${os(c,e)} }`);else if(o.startsWith("@"))r.push(`${o} { ${c} }`);else{const d=o.split(",").map(p=>{const f=p.trim();return f&&(f.startsWith(":root")?f:`${e} ${f}`)}).join(", ");r.push(`${d} { ${c} }`)}n=l}return r.join(`
|
|
102
|
+
`)}const mb={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; }"`).'},{name:"scope",type:"string",optional:!0,description:'Selector to scope every rule under, e.g. `".my-widget"` (I.6)'},{name:"tokens",type:"boolean",optional:!0,description:"Interpolate `{group.key}` token refs to CSS vars (default true)"}],render:(t,e)=>{let r=db(e.css);r&&(e.tokens===void 0||e.tokens===!0||e.tokens==="true")&&(r=pb(r));const n=m(e.scope).trim();r&&n&&(r=os(r,n));const a=document.createElement("style");return a.setAttribute("class","rui-styles"),r&&(a.textContent=r),a}};function At(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function fb(t,e){if(t===null)return!1;const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(!Object.is(t[a],e[a]))return!1;return!0}function Cr(t){typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t)}const gb=new Set(["div","span","section","article","aside","figure","canvas","p","pre","form"]);function hb(t){const e=m(t).trim().toLowerCase();return gb.has(e)?e:"div"}const bb={name:"Mount",description:"First-class host for an imperative / third-party widget that owns its own DOM (chart, map, editor, payment element, captcha, video SDK). Aktion creates the host element; `setup(node, props)` runs once after it attaches and returns an instance handle, `update(instance, props)` runs when `props` change (shallow-compared), and `cleanup(instance)` runs on unmount. The host is preserved across re-renders so the widget is never rebuilt. Apply layout with `sx`.",props:[{name:"setup",type:"callable",required:!0,description:"`(node, props) => instance` — runs once after the host attaches; return value is the instance handle passed to `update`/`cleanup`."},{name:"update",type:"callable",optional:!0,description:"`(instance, props) => void` — runs when `props` change (shallow-compared)."},{name:"cleanup",type:"callable",optional:!0,description:"`(instance) => void` — runs when the component leaves the tree (destroy/teardown)."},{name:"props",type:"object",optional:!0,description:"Reactive prop bag handed to `setup`/`update`. Bind `$state` here to drive the widget."},{name:"tag",type:"string",optional:!0,enum:["div","span","section","article","aside","figure","canvas","p","pre","form"],description:'Host element tag (default "div").'}],render:(t,e,r)=>{const n=u(hb(e.tag),{class:"rui-mount","data-rui-preserve":""}),a=At(e.props),o=r.useInstanceState("rui-mount",{started:!1,instance:void 0,props:a,prevProps:null}).get();if(o.prevProps=o.props,o.props=a,!o.started)return o.started=!0,Cr(()=>{try{o.instance=typeof e.setup=="function"?e.setup(n,o.props):void 0}catch(s){console.error("[aktion] Mount setup threw",s)}e.cleanup!=null&&r.registerDisposer(()=>{Cr(()=>{try{typeof e.cleanup=="function"&&e.cleanup(o.instance)}catch(s){console.error("[aktion] Mount cleanup threw",s)}})},"rui-mount-cleanup")}),n;if(o.instance!==void 0&&typeof e.update=="function"&&!fb(o.prevProps,a)){const s=e.update,l=o.instance;Cr(()=>{try{s(l,a)}catch(c){console.error("[aktion] Mount update threw",c)}})}return n}},vb=/^[a-z][a-z0-9]*(-[a-z0-9]+)+$/;function yb(t){const e=m(t).trim().toLowerCase();return vb.test(e)?e:"div"}function ss(t,e){for(const[r,n]of Object.entries(e))if(!/^on/i.test(r)){if(n==null||n===!1){t.removeAttribute(r);continue}t.setAttribute(r,n===!0?"":String(n))}}function ls(t,e){const r=t;for(const[n,a]of Object.entries(e))try{r[n]=a}catch{}}const xb={name:"WebComponent",description:"Render and hydrate any native custom element / web component with reactive `attributes`, JS `properties`, and `on` event hooks. Use to drop a third-party web component (`<stripe-pricing-table>`, `<model-viewer>`, a design-system element) into an Aktion app. The element is preserved across re-renders; attribute changes flow through reactively and listeners stay current. Invalid (hyphen-less) tag names fall back to a `div`.",props:[{name:"tag",type:"string",positional:!0,required:!0,description:'Custom-element tag name (must contain a hyphen, e.g. "stripe-pricing-table").'},{name:"attributes",type:"object",optional:!0,aliases:["attrs"],description:"Reactive attribute map. `$state` values update the element on change; `on*` keys are ignored."},{name:"properties",type:"object",optional:!0,aliases:["props"],description:"JS properties assigned on the element (for components that take rich, non-string props)."},{name:"on",type:"object",optional:!0,aliases:["events"],description:"Event map `{ eventName: handler }` bound once to the live element (handlers stay current across re-renders)."},{name:"children",type:"Node[]",optional:!0,description:"Light-DOM child nodes / text to slot inside the element."}],render:(t,e,r)=>{const n=yb(e.tag),a=u(n,{class:"rui-web-component","data-rui-preserve":""});ss(a,At(e.attributes)),ls(a,At(e.properties));const i=Array.isArray(e.children)?e.children:e.children!=null?[e.children]:[];for(const c of i)c!=null&&a.append(typeof c=="string"?document.createTextNode(c):r.renderNode(c));const o=At(e.on),l=r.useInstanceState("rui-web-component",{bound:!1,handlers:o,node:null}).get();return l.handlers=o,l.bound?l.node&&(ss(l.node,At(e.attributes)),ls(l.node,At(e.properties))):(l.bound=!0,Cr(()=>{l.node=a;for(const c of Object.keys(o))a.addEventListener(c,d=>{const p=l.handlers[c];typeof p=="function"&&r.invoke(p,d)})})),a}},wb={name:"GradientText",description:'Inline text painted with a brand gradient. Use inside a Display/Heading title to emphasise a phrase: `Display(["Build in ", GradientText("record time")])`. `gradient` selects a named theme gradient (brand|accent|warm|cool|success|danger).',props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["children","label"]},{name:"gradient",type:"string",optional:!0,enum:["brand","accent","warm","cool","success","danger"]}],render:(t,e)=>{const r=u("span",{class:"rui-gradient-text","data-gradient":m(e.gradient,"brand")});return r.append(document.createTextNode(m(e.text))),r}};function Un(t,e,r){for(const n of T(e))n!=null&&(typeof n=="string"||typeof n=="number"?t.append(document.createTextNode(String(n))):t.append(r.renderNode(n)))}const kb={name:"Display",description:"Oversized display headline with built-in responsive `clamp()` sizing. The positional argument may be a plain string OR an array mixing strings and `GradientText(...)` runs. `size`: hero|xl|lg. `balance` wraps for even line lengths.",props:[{name:"content",type:"string | Node[]",positional:!0,required:!0,aliases:["children","title"]},{name:"size",type:"string",optional:!0,enum:["hero","xl","lg"]},{name:"align",type:"string",optional:!0,enum:["left","center","right"]},{name:"balance",type:"boolean",optional:!0},{name:"weight",type:"number",optional:!0}],render:(t,e,r)=>{const n=u("h1",{class:"rui-display","data-size":m(e.size,"hero"),"data-align":m(e.align)||null,"data-balance":I(e.balance)?"true":null,style:e.weight!=null?`font-weight:${P(e.weight,900)}`:null});return Un(n,e.content,r),n}},Sb={name:"Heading",description:"Section/subsection heading with token-driven sizing. `level` sets the semantic tag (1–6); `size`: section|lg|md|sm. Accepts string or mixed string/GradientText array like Display.",props:[{name:"content",type:"string | Node[]",positional:!0,required:!0,aliases:["children","title"]},{name:"level",type:"number",optional:!0,description:"Heading level 1–6 (default 2)"},{name:"size",type:"string",optional:!0,enum:["section","lg","md","sm"]},{name:"align",type:"string",optional:!0,enum:["left","center","right"]}],render:(t,e,r)=>{const n=Math.min(6,Math.max(1,Math.round(P(e.level,2)))),a=u(`h${n}`,{class:"rui-heading","data-size":m(e.size,"section"),"data-align":m(e.align)||null});return Un(a,e.content,r),a}},$b={name:"Eyebrow",description:"Small uppercase, letter-spaced, primary-toned label above a heading.",props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["label","children"]}],render:(t,e)=>u("span",{class:"rui-eyebrow"},[m(e.text)])},Cb={name:"Section",description:"Full-bleed page band → centered max-width container → optional tinted background → optional eyebrow/title/subtitle header. The single most useful primitive for marketing, docs, and settings pages. Children render below the header.",props:[{name:"children",type:"Node[]",positional:!0,required:!0},{name:"background",type:"string",optional:!0,enum:["base","soft","surface","muted","brand"],aliases:["bg"]},{name:"width",type:"string",optional:!0,enum:["sm","md","lg","xl","full"]},{name:"padding",type:"string",optional:!0,enum:["none","xs","sm","md","lg","xl"],description:"Band padding preset (default md)"},{name:"align",type:"string",optional:!0,enum:["left","center"]},{name:"eyebrow",type:"string",optional:!0},{name:"title",type:"string | Node[]",optional:!0},{name:"subtitle",type:"string",optional:!0,aliases:["description"]},{name:"id",type:"string",optional:!0}],render:(t,e,r)=>{const n=m(e.background,"base"),a=u("section",{class:"rui-section","data-bg":n!=="base"?n:null,"data-pad":ve(e.padding,m(e.padding))||null,"data-align":m(e.align)||null,id:m(e.id)||null}),i=u("div",{class:"rui-section-inner","data-w":m(e.width,"lg")}),o=m(e.eyebrow),s=e.title!=null&&(typeof e.title!="string"||e.title!==""),l=m(e.subtitle);if(o||s||l){const c=u("div",{class:"rui-section-head"});if(o&&c.append(u("span",{class:"rui-eyebrow"},[o])),s){const d=u("h2",{class:"rui-section-title"});Un(d,e.title,r),c.append(d)}l&&c.append(u("p",{class:"rui-section-sub"},[l])),i.append(c)}for(const c of T(e.children))i.append(r.renderNode(c));return a.append(i),a}},Ab={name:"OverlayItem",description:"A child positioned over an Overlay's base. `anchor` picks a corner/edge/center.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"anchor",type:"string",optional:!0,enum:["top-left","top-right","bottom-left","bottom-right","top","bottom","left","right","center"]},{name:"offset",type:"string",optional:!0,description:"Inset distance (CSS length, e.g. 8px or 1rem)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-overlay-item","data-anchor":m(e.anchor,"top-right"),style:e.offset?`--ak-ov-off:${m(e.offset)}`:null});return e.child!=null&&n.append(r.renderNode(e.child)),n}},Tb={name:"Overlay",description:"Layers OverlayItem children on top of a base node — corner badges, play buttons over thumbnails, sale ribbons, floating actions. Pass the base as the positional argument and `items` as OverlayItem entries.",props:[{name:"base",type:"Node",positional:!0,required:!0},{name:"items",type:"OverlayItem[]",aliases:["overlays"]}],render:(t,e,r)=>{const n=u("div",{class:"rui-overlay"});if(e.base!=null){const a=u("div",{class:"rui-overlay-base"});a.append(r.renderNode(e.base)),n.append(a)}for(const a of T(e.items))n.append(r.renderNode(a));return n}},Mb={name:"Brand",description:"Logo + product name (+ optional version pill), linking home. Use in NavBar/Footer.",props:[{name:"name",type:"string",positional:!0,required:!0,aliases:["label"]},{name:"logo",type:"string",optional:!0,description:"Logo image src URL, e.g. https://example.com/logo.png"},{name:"version",type:"string",optional:!0},{name:"href",type:"string",optional:!0}],render:(t,e)=>{const r=u("a",{class:"rui-brand",href:qe(e.href,"#")}),n=ie(e.logo);n&&r.append(u("img",{class:"rui-brand-logo",src:n,alt:""})),r.append(u("span",{},[m(e.name)]));const a=m(e.version);return a&&r.append(u("span",{class:"rui-brand-version"},[a])),r}},Nb={name:"NavBar",description:"Marketing top navigation: brand on the left, links in the middle, actions (buttons/toggles) on the right. `sticky` pins it; `blur` adds a frosted-glass backdrop. On narrow viewports the links collapse behind a burger toggle. Distinct from the app-shell Navbar/TopBar.",props:[{name:"brand",type:"Node",optional:!0},{name:"links",type:"Node[]",optional:!0,description:"NavLink / Link nodes"},{name:"actions",type:"Node[]",optional:!0,description:"Buttons, ThemeToggle, IconButton, etc."},{name:"sticky",type:"boolean",optional:!0},{name:"blur",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=u("header",{class:"rui-navbar2","data-sticky":I(e.sticky)?"true":null,"data-blur":I(e.blur)?"true":null});e.brand!=null&&n.append(r.renderNode(e.brand));const a=T(e.links);if(a.length>0){const o=u("nav",{class:"rui-navbar2-links",id:"rui-navbar2-menu","aria-label":"Primary"});for(const c of a)o.append(r.renderNode(c));n.append(o);const s=u("button",{class:"rui-navbar2-burger",type:"button","aria-label":"Menu","aria-expanded":"false","aria-controls":"rui-navbar2-menu"}),l=j("bars");l?s.append(l):s.textContent="≡",s.onclick=c=>{const d=c.currentTarget??c.target,p=d?.closest(".rui-navbar2");if(!p)return;const f=p.getAttribute("data-menu-open")==="true";p.setAttribute("data-menu-open",f?"false":"true"),d?.setAttribute("aria-expanded",f?"false":"true")},n.append(s)}const i=u("div",{class:"rui-navbar2-actions"});for(const o of T(e.actions))i.append(r.renderNode(o));return n.append(i),n}},Ib={name:"FooterColumn",description:"A titled column of links inside a Footer.",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"links",type:"Node[]",aliases:["children","items"]}],render:(t,e,r)=>{const n=u("div",{class:"rui-footer-col"});n.append(u("h5",{},[m(e.title)]));const a=u("div",{class:"rui-footer-col-links"});for(const i of T(e.links))a.append(r.renderNode(i));return n.append(a),n}},Pb={name:"Footer",description:"Site footer: brand + tagline in a wide first column, then link columns, and a legal/copyright line. Pass `columns` as FooterColumn nodes.",props:[{name:"brand",type:"Node",optional:!0},{name:"tagline",type:"string",optional:!0},{name:"columns",type:"FooterColumn[]",optional:!0},{name:"legal",type:"string",optional:!0,aliases:["copyright"]}],render:(t,e,r)=>{const n=u("footer",{class:"rui-footer"}),a=T(e.columns),i=u("div",{class:"rui-footer-grid",style:`--ak-foot-cols:${Math.max(1,a.length)}`}),o=u("div",{class:"rui-footer-brand"});e.brand!=null&&o.append(r.renderNode(e.brand));const s=m(e.tagline);s&&o.append(u("p",{class:"rui-footer-tagline"},[s])),i.append(o);for(const c of a)i.append(r.renderNode(c));n.append(i);const l=m(e.legal);return l&&n.append(u("div",{class:"rui-footer-legal"},[l])),n}},Rb={name:"LogoChip",description:"A single labelled chip (icon + name) for a LogoCloud.",props:[{name:"label",type:"string",positional:!0,required:!0},{name:"icon",type:"string",optional:!0,description:"Font Awesome name (e.g. brands:react)"}],render:(t,e)=>{const r=u("span",{class:"rui-logochip"}),n=j(e.icon);return n&&r.append(n),r.append(document.createTextNode(m(e.label))),r}},Eb={name:"LogoCloud",description:"A centered, wrapping row of LogoChip items with an optional label — 'works with' / 'trusted by' bands.",props:[{name:"items",type:"LogoChip[]",positional:!0,required:!0,aliases:["children","chips"]},{name:"label",type:"string",optional:!0}],render:(t,e,r)=>{const n=u("div",{class:"rui-logocloud"}),a=m(e.label);a&&n.append(u("p",{class:"rui-logocloud-label"},[a]));const i=u("div",{class:"rui-logocloud-row"});for(const o of T(e.items))i.append(r.renderNode(o));return n.append(i),n}};function cs(t,e,r,n,a,i){const o=c=>{t.textContent=`${n}${Math.round(c)}${r}`};o(0);let s=!1;const l=()=>{if(s)return;s=!0;const c=performance.now(),d=p=>{const f=Math.min(1,(p-c)/a),b=1-Math.pow(1-f,3);o(e*b),f<1&&t.isConnected&&requestAnimationFrame(d)};requestAnimationFrame(d)};setTimeout(()=>{if(typeof IntersectionObserver>"u"){l();return}const c=new IntersectionObserver(d=>{for(const p of d)p.isIntersecting&&(l(),c.disconnect())},{threshold:.4});c.observe(t),i?.registerDisposer(()=>c.disconnect(),"rui-countup-io")},0)}const Lb={name:"CountUp",description:"A number that animates from 0 to `value` when scrolled into view. `prefix`/`suffix` wrap it (e.g. `$`, `+`, `%`). Respects reduced motion.",props:[{name:"value",type:"number",positional:!0,required:!0},{name:"suffix",type:"string",optional:!0},{name:"prefix",type:"string",optional:!0},{name:"duration",type:"number",optional:!0,description:"Animation ms (default 1000)"}],render:(t,e,r)=>{const n=u("span",{class:"rui-countup"}),a=P(e.value,0);return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches?n.textContent=`${m(e.prefix)}${a}${m(e.suffix)}`:cs(n,a,m(e.suffix),m(e.prefix),Math.max(200,P(e.duration,1e3)),r),n}},zb={name:"Metric",description:"A single big-number metric tile with a gradient accent bar and label. Use inside MetricStrip. Set `countUp` to animate.",props:[{name:"value",type:"string | number",positional:!0,required:!0},{name:"label",type:"string",optional:!0},{name:"gradient",type:"boolean",optional:!0,description:"Paint the number with the brand gradient"},{name:"countUp",type:"boolean",optional:!0,description:"Animate numeric value from 0 on scroll-in"}],render:(t,e,r)=>{const n=u("div",{class:"rui-metric"}),a=e.gradient===void 0?!0:I(e.gradient),i=u("div",{class:"rui-metric-value","data-gradient":a?"true":null}),o=m(e.value),s=Number(o.replace(/[^0-9.]/g,"")),l=o.replace(/[0-9.,\s]/g,""),c=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;I(e.countUp)&&Number.isFinite(s)&&s>0&&!c?cs(i,s,l,"",1e3,r):i.textContent=o,n.append(i);const d=m(e.label);return d&&n.append(u("div",{class:"rui-metric-label"},[d])),n}},jb={name:"MetricStrip",description:"A responsive row/grid of Metric tiles. `columns` sets the preferred count.",props:[{name:"items",type:"Metric[]",positional:!0,required:!0,aliases:["children","metrics"]},{name:"columns",type:"number",optional:!0}],render:(t,e,r)=>{const n=Math.max(1,Math.min(6,Math.round(P(e.columns,4)))),a=u("div",{class:"rui-metricstrip",style:`--ak-metric-cols:${n}`});for(const i of T(e.items))a.append(r.renderNode(i));return a}};function us(t,e,r){const n=u("div",{class:"rui-window-bar"}),a=u("span",{class:"rui-window-dots"});if(a.append(u("i"),u("i"),u("i")),n.append(a),t&&n.append(u("span",{class:"rui-window-file"},[t])),e!=null){const i=u("span",{class:"rui-window-status"});i.append(e instanceof Node?e:r.renderNode(e)),n.append(i)}return n}function Db(t){if(typeof t=="string")return t;if(t==null||typeof t!="object")return"";const e=t;return e.__kind!=="Component"||!Array.isArray(e.args)?"":e.name==="CodeBlock"?m(lr(fr,e.args).codeString):m(e.args.find(r=>typeof r=="string"))}const Ob={aktion:"aktion",js:"js",mjs:"js",cjs:"js",jsx:"jsx",ts:"ts",tsx:"tsx",py:"py",css:"css",scss:"scss",less:"less",json:"json",html:"html",xml:"xml",svg:"svg",vue:"vue",sh:"bash",bash:"bash",zsh:"bash",md:"md",yml:"yaml",yaml:"yaml",sql:"sql"};function Bb(t){const e=/\.([a-z0-9]+)$/i.exec(t.trim())?.[1]?.toLowerCase();return e?Ob[e]??"":""}const ds=new WeakSet,Fb={name:"CodeWindow",description:"An editor/IDE window chrome (traffic-light dots + filename + status area) around source code. Pass the code as a plain STRING — it renders through a chromeless CodeBlock that fills the pane (no inner border, language label, or copy button), syntax-highlighted via `language` (default: inferred from the `file` extension, else aktion). Set `preview: true` to run the source as a LIVE app beside the code (split view with a pulsing 'Live render' badge); a custom node is also accepted for non-Aktion previews. The canonical way to show code in docs/marketing.",props:[{name:"code",type:"string",positional:!0,required:!0,aliases:["codeString"],description:"Source text (a legacy CodeBlock(...) node is also accepted)"},{name:"file",type:"string",optional:!0,description:"Filename shown in the title bar"},{name:"language",type:"string",optional:!0,description:"Highlight language (default: from the file extension, else aktion)"},{name:"status",type:"Node",optional:!0,description:"A Badge shown at the right of the bar"},{name:"preview",type:"boolean | Node",optional:!0,description:"true → run the source as a live Aktion preview; or a custom node"}],render:(t,e,r)=>{const n=m(e.file),a=e.code!=null&&typeof e.code=="object"?e.code:null,i=Db(e.code);let o=m(e.language);!o&&a?.name==="CodeBlock"&&Array.isArray(a.args)&&(o=m(lr(fr,a.args).language)),o||(o=Bb(n)||"aktion");const s=e.preview===!0||e.preview==="true",l=!s&&e.preview!=null&&e.preview!==!1&&e.preview!=="false"?e.preview:null,c=s||l!=null,d=u("div",{class:"rui-codewindow"}),p=c&&e.status==null?u("span",{class:"rui-window-live"},[u("span",{class:"rui-window-live-dot"}),"Live render"]):e.status;d.append(us(n,p,r));const f=u("div",{class:"rui-codewindow-body","data-split":c?"true":null}),b=u("div",{class:"rui-codewindow-code"});if(i||a==null?b.append(fr.render({__kind:"Component",name:"CodeBlock",args:[],argMeta:[]},{codeString:i,language:o,header:!1},r)):b.append(r.renderNode(a)),f.append(b),c){const h=u("div",{class:"rui-codewindow-preview"});s?h.append(_b(i,d,r)):h.append(r.renderNode(l)),f.append(h)}return d.append(f),d}};function _b(t,e,r){const n=document.createElement("aktion-app");n.setAttribute("response",t);const a=r.useInstanceState("rui-codewindow-theme","");return a.get()&&n.setAttribute("theme",a.get()),setTimeout(()=>{if(!n.isConnected||ds.has(n))return;ds.add(n);const i=e.getRootNode(),o=i instanceof ShadowRoot?i.host:null;if(!o)return;const s=()=>{const c=o.getAttribute("theme")??"";a.set(c),c?n.setAttribute("theme",c):n.removeAttribute("theme")};s();const l=new MutationObserver(s);l.observe(o,{attributes:!0,attributeFilter:["theme"]}),r.registerDisposer(()=>l.disconnect(),"rui-codewindow-theme-sync")},0),n}const Ub={name:"BrowserFrame",description:"A browser-window chrome (dots + URL bar) wrapping a child — for screenshots/demos of web UIs.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children","content"]},{name:"url",type:"string",optional:!0}],render:(t,e,r)=>{const n=u("div",{class:"rui-browserframe"}),a=u("div",{class:"rui-browserframe-bar"}),i=u("span",{class:"rui-window-dots"});i.append(u("i"),u("i"),u("i")),a.append(i),a.append(u("span",{class:"rui-browserframe-url"},[m(e.url,"example.com")])),n.append(a);const o=u("div",{class:"rui-browserframe-body"});return e.child!=null&&o.append(r.renderNode(e.child)),n.append(o),n}},Hb={name:"Terminal",description:"A terminal window rendering monospace lines. Pass `lines` as an array of strings.",props:[{name:"lines",type:"string[]",positional:!0,required:!0,aliases:["children","content"]},{name:"file",type:"string",optional:!0,description:"Title-bar label (default 'bash')"}],render:(t,e,r)=>{const n=u("div",{class:"rui-terminal"});n.append(us(m(e.file,"bash"),null,r));const a=u("div",{class:"rui-terminal-body"}),i=T(e.lines);return a.textContent=i.map(o=>m(o)).join(`
|
|
103
|
+
`),n.append(a),n}},qb=[{t:"-160px",l:"-120px",d:"0s"},{t:"-80px",r:"-120px",d:"-6s"},{t:"46%",l:"34%",d:"-12s"}],Hn=["network","drift","snow","stars","bubbles"],ps=["#6366f1","#8b5cf6","#ec4899","#22d3ee"],ms=(t,e)=>/^[#a-zA-Z0-9(),.%\s-]+$/.test(t)&&t.length<=64&&t.trim()!==""?t.trim():e,Ar=new WeakSet;function Vb(t,e){if(!t.isConnected||Ar.has(t))return;const r=t.getContext("2d");if(!r)return;Ar.add(t);const n=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;let a=[],i=0,o=0,s=1,l="",c=0,d=0;const p=()=>{const v=Math.max(0,Math.min(120,Math.round(Number(t.dataset.count)||0))),x=t.dataset.type??"network",w=Hn.includes(x)?x:"network",k=Math.max(.1,Math.min(4,Number(t.dataset.speed)||1)),A=Math.max(40,Math.min(240,Number(t.dataset.link)||130)),S=Math.max(.5,Math.min(6,Number(t.dataset.size)||2.2)),$=(t.dataset.colors??"").split(",").map(C=>C.trim()).filter(Boolean);return{count:v,type:w,speed:k,link:A,size:S,colors:$.length>0?$:ps}},f=()=>{const v=p();a=Array.from({length:v.count},(x,w)=>({x:Math.random()*i,y:Math.random()*o,vx:(Math.random()-.5)*.5*s,vy:(Math.random()-.5)*.5*s,r:(Math.random()*(v.size-.5)+.5)*s,c:v.colors[w%v.colors.length],phase:Math.random()*Math.PI*2}))},b=()=>{const x=(t.parentElement??t).getBoundingClientRect();s=Math.min((typeof window<"u"?window.devicePixelRatio:1)||1,2),i=Math.max(1,Math.round(x.width*s)),o=Math.max(1,Math.round(x.height*s)),t.width=i,t.height=o,f()},h=()=>{const v=p(),x=`${v.count}|${v.type}|${v.colors.join(",")}`;x!==l&&(l=x,f()),t.width!==i&&(t.width=i),t.height!==o&&(t.height=o),r.clearRect(0,0,i,o),d+=1;const w=v.speed;for(const k of a){switch(v.type){case"drift":k.x+=k.vx*.5*w,k.y+=k.vy*.5*w,k.x<-10&&(k.x=i+10),k.x>i+10&&(k.x=-10),k.y<-10&&(k.y=o+10),k.y>o+10&&(k.y=-10),r.globalAlpha=.35+.3*Math.abs(Math.sin(d/60+k.phase));break;case"snow":k.y+=(.4+Math.abs(k.vy))*w,k.x+=Math.sin(d/50+k.phase)*.4*s,k.y>o+6&&(k.y=-6,k.x=Math.random()*i),r.globalAlpha=.8;break;case"stars":r.globalAlpha=.15+.65*Math.abs(Math.sin(d/40*w+k.phase));break;case"bubbles":k.y-=(.5+Math.abs(k.vy))*w,k.x+=Math.sin(d/40+k.phase)*.5*s,k.y<-10&&(k.y=o+10,k.x=Math.random()*i),r.globalAlpha=.5;break;default:k.x+=k.vx*w,k.y+=k.vy*w,(k.x<0||k.x>i)&&(k.vx*=-1),(k.y<0||k.y>o)&&(k.vy*=-1),r.globalAlpha=.7}r.beginPath(),r.arc(k.x,k.y,k.r,0,Math.PI*2),v.type==="bubbles"?(r.strokeStyle=k.c,r.lineWidth=s,r.stroke(),r.globalAlpha=.08,r.fillStyle=k.c,r.fill()):(r.fillStyle=k.c,r.fill())}if(v.type==="network"){const k=v.link*s;for(let A=0;A<a.length;A+=1)for(let S=A+1;S<a.length;S+=1){const $=a[A],C=a[S],M=Math.hypot($.x-C.x,$.y-C.y);M<k&&(r.beginPath(),r.moveTo($.x,$.y),r.lineTo(C.x,C.y),r.strokeStyle=$.c,r.globalAlpha=(1-M/k)*.18,r.lineWidth=s*.6,r.stroke())}}r.globalAlpha=1},g=()=>{if(c=0,!t.isConnected){Ar.delete(t);return}h(),c=requestAnimationFrame(g)};b(),n?h():c=requestAnimationFrame(g);const y=typeof ResizeObserver<"u"?new ResizeObserver(b):null;y?.observe(t.parentElement??t),e.registerDisposer(()=>{c&&cancelAnimationFrame(c),y?.disconnect(),Ar.delete(t)},"rui-backdrop-engine")}const Wb={name:"Backdrop",description:"Decorative background layer for hero/marketing sections: a masked grid, floating blurred color 'blobs', and an animated canvas particle field. `type` picks the particle behaviour — `network` (drifting dots joined by constellation lines, the default), `drift`, `snow`, `stars`, or `bubbles` — tuned via `particleColors`, `speed`, `linkDistance`, and `particleSize`. All theme-aware and motion-safe. Place as the first child of a Section (which is `position: relative`).",props:[{name:"grid",type:"boolean",optional:!0,description:"Show the masked line grid"},{name:"blobs",type:"string[]",optional:!0,description:"Colors for floating blur orbs (CSS colors)"},{name:"particles",type:"number",optional:!0,description:"Particle count (0 = none, max 120)"},{name:"type",type:"string",optional:!0,enum:[...Hn],aliases:["particleType"],description:"Particle behaviour (default network)"},{name:"particleColors",type:"string[]",optional:!0,aliases:["colors"],description:"Particle palette (CSS colors; defaults to the brand palette)"},{name:"speed",type:"number",optional:!0,description:"Animation speed multiplier 0.1–4 (default 1)"},{name:"linkDistance",type:"number",optional:!0,description:"Max px between linked network particles (default 130)"},{name:"particleSize",type:"number",optional:!0,description:"Max particle radius in px (default 2.2)"},{name:"fixed",type:"boolean",optional:!0,description:"Pin to the viewport instead of the section"}],render:(t,e,r)=>{const n=u("div",{class:"rui-backdrop","data-fixed":I(e.fixed)?"true":null,"aria-hidden":"true"});I(e.grid)&&n.append(u("div",{class:"rui-backdrop-grid"})),T(e.blobs).slice(0,3).forEach((o,s)=>{const l=m(o),c=qb[s],d=460-s*40,p=[`width:${d}px`,`height:${d}px`,c.t?`top:${c.t}`:"",c.l?`left:${c.l}`:"",c.r?`right:${c.r}`:"",`background:radial-gradient(circle, ${ms(l,"#6366f1")}, transparent 70%)`,`animation-delay:${c.d}`].filter(Boolean).join(";");n.append(u("div",{class:"rui-backdrop-blob",style:p}))});const i=Math.max(0,Math.min(120,Math.round(P(e.particles,0))));if(i>0){const o=m(e.type,"network"),s=T(e.particleColors).map(c=>ms(m(c),"")).filter(Boolean).slice(0,8),l=u("canvas",{class:"rui-backdrop-canvas","data-count":String(i),"data-type":Hn.includes(o)?o:"network","data-speed":String(Math.max(.1,Math.min(4,P(e.speed,1)))),"data-link":String(Math.max(40,Math.min(240,P(e.linkDistance,130)))),"data-size":String(Math.max(.5,Math.min(6,P(e.particleSize,2.2)))),"data-colors":(s.length>0?s:ps).join(",")});n.append(l),setTimeout(()=>Vb(l,r),0)}return n}},Gb={name:"ThemeToggle",description:"A sun/moon button that toggles the host between light and dark themes — no host glue required. It flips the <aktion-app> `theme` attribute and dispatches a `theme-change` event the host can listen for.",props:[{name:"light",type:"string",optional:!0,description:"Theme name when toggled to light (default 'light')"},{name:"dark",type:"string",optional:!0,description:"Theme name when toggled to dark (default 'dark')"}],render:(t,e)=>{const r=m(e.light,"light"),n=m(e.dark,"dark"),a=u("button",{class:"rui-theme-toggle",type:"button","aria-label":"Toggle dark mode",title:"Toggle theme"}),i=j("moon");i&&a.append(i);const o=l=>{const c=l?.getRootNode?.();return c&&c.host?c.host:void 0},s=l=>{const c=o(l),d=c?(c.getAttribute("theme")||"").toLowerCase().includes("dark"):!1;(l??a).replaceChildren(j(d?"sun":"moon")??document.createTextNode(""))};return setTimeout(()=>s(a),0),a.onclick=l=>{const c=l.currentTarget??l.target,d=o(c);if(!d)return;const f=(d.getAttribute("theme")||r).toLowerCase().includes("dark")?r:n;d.setAttribute("theme",f),d.dispatchEvent(new CustomEvent("theme-change",{detail:{theme:f},bubbles:!0,composed:!0})),setTimeout(()=>s(c),0)},a}},Kb={name:"Swatch",description:"A theme/palette preview tile — color dots over a named background. For theming galleries.",props:[{name:"name",type:"string",positional:!0,required:!0},{name:"background",type:"string",optional:!0,description:"Tile background CSS color"},{name:"foreground",type:"string",optional:!0,description:"Tile text CSS color"},{name:"colors",type:"string[]",optional:!0,description:"Accent dot colors"}],render:(t,e)=>{const r=(s,l)=>/^[#a-zA-Z0-9(),.%\s-]+$/.test(s)&&s.length<=64?s:l,n=r(m(e.background,"#ffffff"),"#ffffff"),a=r(m(e.foreground,"#0f172a"),"#0f172a"),i=u("div",{class:"rui-swatch",style:`background:${n};color:${a}`}),o=u("div",{class:"rui-swatch-dots"});for(const s of T(e.colors).slice(0,5))o.append(u("i",{style:`background:${r(m(s),"#6366f1")}`}));return i.append(o),i.append(u("div",{class:"rui-swatch-name"},[m(e.name)])),i}},qn=new WeakMap,Yb={name:"CopyButton",description:"A button that copies `text` to the clipboard and confirms it — the label flips to `copiedLabel` (default 'Copied!') with a check icon for a couple of seconds, then reverts. Bounded, no host glue.",props:[{name:"text",type:"string",positional:!0,required:!0,aliases:["value"]},{name:"label",type:"string",optional:!0,description:"Button label (default 'Copy')"},{name:"copiedLabel",type:"string",optional:!0,description:"Confirmation label (default 'Copied!')"}],render:(t,e)=>{const r=m(e.label,"Copy"),n=m(e.copiedLabel,"Copied!"),a=u("button",{class:"rui-copy-button",type:"button"}),i=j("copy",{className:"rui-copy-button-icon"});return i&&a.append(i),a.append(u("span",{class:"rui-copy-button-label"},[r])),a.onclick=o=>{const s=o.currentTarget??o.target??a,l=m(e.text),c=()=>{try{const f=document.createElement("textarea");f.value=l,f.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none",document.body.append(f),f.select(),document.execCommand("copy"),f.remove()}catch{}};try{const f=navigator.clipboard?.writeText(l);f&&typeof f.catch=="function"?f.catch(c):navigator.clipboard||c()}catch{c()}const d=f=>{f?s.setAttribute("data-copied","true"):s.removeAttribute("data-copied");const b=s.querySelector(".rui-copy-button-label");b&&(b.textContent=f?n:r);const h=s.querySelector(".rui-copy-button-icon");if(h){const g=j(f?"check":"copy",{className:"rui-copy-button-icon"});g&&h.replaceWith(g)}};d(!0);const p=qn.get(s);p&&clearTimeout(p),qn.set(s,setTimeout(()=>{qn.delete(s),d(!1)},2e3))},a}},Xb={name:"SegmentedControl",description:"A compact segmented toggle (iOS-style). `options` is an array of strings or {label, value}. Bind `value` to a $variable; `onChange(value)` fires on select.",props:[{name:"options",type:"any[]",positional:!0,required:!0,aliases:["items"]},{name:"value",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=u("div",{class:"rui-segmented",role:"tablist"}),a=m(e.value);for(const i of T(e.options)){const o=i&&typeof i=="object"?i:{label:i,value:i},s=m(o.value??o.label),l=m(o.label??o.value),c=u("button",{type:"button",role:"tab","aria-pressed":s===a?"true":"false"},[l]);c.onclick=()=>{const d=t.argMeta?.[1];d?.stateRef&&r.setState(d.stateRef,s),r.invoke(e.onChange,s)},n.append(c)}return n}},Jb={name:"FloatingActionButton",description:"A fixed circular action button (FAB) anchored bottom-right. `icon` + `onClick`.",props:[{name:"icon",type:"string",positional:!0,required:!0},{name:"label",type:"string",optional:!0,description:"Accessible label"},{name:"onClick",type:"callable",optional:!0,aliases:["action","onclick"]}],render:(t,e,r)=>{const n=u("button",{class:"rui-fab",type:"button","aria-label":m(e.label,"Action")}),a=j(e.icon,{size:"lg"});return a&&n.append(a),n.onclick=()=>r.invoke(e.onClick),n}},Qb={name:"Prose",description:"A styled long-form reading container — applies typographic defaults to headings, lists, blockquotes, code, links inside. Wrap Markdown(...) or raw nodes for blog posts, docs bodies, product descriptions.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]}],render:(t,e,r)=>{const n=u("div",{class:"rui-prose","data-size":m(e.size,"md")});for(const a of T(e.children))typeof a=="string"?n.append(document.createTextNode(a)):n.append(r.renderNode(a));return n}},Zb={name:"RelativeTime",description:"Renders a human relative time ('3m ago', 'in 2 days') from an ISO date/timestamp, localized via Intl.",props:[{name:"value",type:"string | number",positional:!0,required:!0,aliases:["date","time"]}],render:(t,e)=>{const r=e.value,n=typeof r=="number"?new Date(r):new Date(m(r)),a=u("span",{class:"rui-relative-time"});if(Number.isNaN(n.getTime()))return a.textContent=m(r),a;const i=n.getTime()-Date.now(),o=Math.abs(i),s=[["year",31536e6],["month",2592e6],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];let l="just now";try{const c=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[d,p]of s)if(o>=p||d==="second"){l=c.format(Math.round(i/p),d);break}}catch{l=n.toLocaleString()}return a.textContent=l,a.setAttribute("title",n.toLocaleString()),a}},fs={name:"PriceTag",description:"A formatted price with an optional struck-through compare-at price and a discount badge.",props:[{name:"price",type:"string | number",positional:!0,required:!0},{name:"compareAt",type:"string | number",optional:!0,aliases:["was","original"]},{name:"currency",type:"string",optional:!0,description:"Currency symbol/prefix (default '$')"},{name:"size",type:"string",optional:!0,enum:["sm","md","lg"]}],render:(t,e)=>{const r=m(e.currency,"$"),n=i=>`${r}${m(i)}`,a=u("span",{class:"rui-pricetag","data-size":m(e.size,"md")});if(a.append(u("span",{class:"rui-pricetag-now"},[n(e.price)])),e.compareAt!=null&&m(e.compareAt)!==""){a.append(u("span",{class:"rui-pricetag-was"},[n(e.compareAt)]));const i=Number(m(e.price).replace(/[^0-9.]/g,"")),o=Number(m(e.compareAt).replace(/[^0-9.]/g,""));if(Number.isFinite(i)&&Number.isFinite(o)&&o>i&&o>0){const s=Math.round((1-i/o)*100);a.append(u("span",{class:"rui-pricetag-off"},[`-${s}%`]))}}return a}},ev={name:"QuantityStepper",description:"A −/value/+ numeric stepper. Bind `value` to a $variable; `onChange(value)` fires on change. Respects min/max.",props:[{name:"value",type:"number",positional:!0,required:!0},{name:"min",type:"number",optional:!0},{name:"max",type:"number",optional:!0},{name:"step",type:"number",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=e.min!=null?P(e.min):-1/0,a=e.max!=null?P(e.max):1/0,i=P(e.step,1),o=P(e.value,0),s=t.argMeta?.[0]?.stateRef,l=u("div",{class:"rui-qty"}),c=b=>{const h=Math.min(a,Math.max(n,b));s&&r.setState(s,h),r.invoke(e.onChange,h)},d=u("button",{type:"button","aria-label":"Decrease",disabled:o<=n?"":null},["−"]);d.onclick=()=>c(o-i);const p=u("span",{class:"rui-qty-value"},[String(o)]),f=u("button",{type:"button","aria-label":"Increase",disabled:o>=a?"":null},["+"]);return f.onclick=()=>c(o+i),l.append(d,p,f),l}},tv={name:"ProductCard",description:"An e-commerce product card: image, title, optional rating, a PriceTag, and an add-to-cart action. Pass `price`/`compareAt` directly or a custom `price` node.",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"image",type:"string",optional:!0,aliases:["src"]},{name:"price",type:"string | number",optional:!0},{name:"compareAt",type:"string | number",optional:!0},{name:"currency",type:"string",optional:!0},{name:"rating",type:"number",optional:!0,description:"0–5 stars"},{name:"badge",type:"string",optional:!0,description:"Corner ribbon label (e.g. 'Sale')"},{name:"action",type:"Node",optional:!0,description:"Add-to-cart Button (defaults to one)"},{name:"onAdd",type:"callable",optional:!0,description:"Fired by the default add button"}],render:(t,e,r)=>{const n=u("div",{class:"rui-product-card"}),a=u("div",{class:"rui-product-media"}),i=ie(e.image);i&&a.append(u("img",{src:i,alt:m(e.title),loading:"lazy"}));const o=m(e.badge);o&&a.append(u("span",{class:"rui-product-badge"},[o])),n.append(a);const s=u("div",{class:"rui-product-body"});s.append(u("h3",{class:"rui-product-title"},[m(e.title)]));const l=Math.max(0,Math.min(5,Math.round(P(e.rating,0))));if(l>0){const d=u("div",{class:"rui-product-rating"});for(let p=0;p<5;p+=1){const f=j(p<l?"star":"regular:star");f&&d.append(f)}s.append(d)}const c=u("div",{class:"rui-product-foot"});if(e.price!=null&&c.append(fs.render({__kind:"Component",name:"PriceTag",args:[],argMeta:[]},{price:e.price,compareAt:e.compareAt,currency:e.currency},r)),e.action!=null)c.append(r.renderNode(e.action));else if(typeof e.onAdd=="function"){const d=u("button",{class:"rui-product-add",type:"button","aria-label":"Add to cart"}),p=j("cart-plus");p&&d.append(p),d.onclick=()=>r.invoke(e.onAdd),c.append(d)}return s.append(c),n.append(s),n}},rv={name:"TableOfContents",description:"A navigable table of contents. `items` is an array of {label, href, level?}.",props:[{name:"items",type:"object[]",positional:!0,required:!0,aliases:["children"]},{name:"title",type:"string",optional:!0}],render:(t,e)=>{const r=u("nav",{class:"rui-toc","aria-label":"Table of contents"}),n=m(e.title);n&&r.append(u("div",{class:"rui-toc-title"},[n]));const a=u("ul",{class:"rui-toc-list"});for(const i of T(e.items)){const o=i??{},s=u("li",{class:"rui-toc-item","data-level":String(Math.max(1,Math.min(4,Math.round(P(o.level,1)))))});s.append(u("a",{href:qe(o.href,"#")},[m(o.label)])),a.append(s)}return r.append(a),r}},nv={name:"TypingIndicator",description:"Three animated bouncing dots — a chat 'is typing…' affordance. Optional `name` prefix.",props:[{name:"name",type:"string",optional:!0,positional:!0}],render:(t,e)=>{const r=u("div",{class:"rui-typing",role:"status"}),n=m(e.name);n&&r.append(u("span",{class:"rui-typing-name"},[`${n} is typing`]));const a=u("span",{class:"rui-typing-dots","aria-label":"typing"});return a.append(u("i"),u("i"),u("i")),r.append(a),r}},av={name:"CountdownTimer",description:"Live countdown to a target date/time (ISO string or timestamp). Ticks every second, then shows `endLabel`.",props:[{name:"to",type:"string | number",positional:!0,required:!0,aliases:["target","date"]},{name:"endLabel",type:"string",optional:!0,description:"Shown when the countdown finishes (default 'Done')"}],render:(t,e,r)=>{const n=typeof e.to=="number"?e.to:new Date(m(e.to)).getTime(),a=u("div",{class:"rui-countdown",role:"timer"}),i=f=>{const b=u("div",{class:"rui-countdown-unit"}),h=u("div",{class:"rui-countdown-value"},["00"]);return b.append(h,u("div",{class:"rui-countdown-label"},[f])),{u:b,v:h}},o=i("days"),s=i("hrs"),l=i("min"),c=i("sec");a.append(o.u,s.u,l.u,c.u);const d=f=>String(Math.max(0,f)).padStart(2,"0"),p=()=>{const f=n-Date.now();if(!Number.isFinite(n)||f<=0)return a.replaceChildren(u("div",{class:"rui-countdown-done"},[m(e.endLabel,"Done")])),!1;const b=Math.floor(f/1e3);return o.v.textContent=d(Math.floor(b/86400)),s.v.textContent=d(Math.floor(b%86400/3600)),l.v.textContent=d(Math.floor(b%3600/60)),c.v.textContent=d(b%60),!0};if(p()){const f=setInterval(()=>{p()||clearInterval(f)},1e3);r.registerDisposer(()=>clearInterval(f),"countdown")}return a}},iv={name:"BackToTop",description:"A floating button that smoothly scrolls the page (and the host) back to the top.",props:[{name:"label",type:"string",optional:!0}],render:(t,e)=>{const r=u("button",{class:"rui-fab rui-backtotop",type:"button","aria-label":m(e.label,"Back to top")}),n=j("arrow-up",{size:"lg"});return n&&r.append(n),r.onclick=()=>{try{window.scrollTo({top:0,behavior:"smooth"})}catch{window.scrollTo(0,0)}r.getRootNode()?.host?.scrollIntoView?.({behavior:"smooth",block:"start"})},r}};function Ne(t,e){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const r=document.createDocumentFragment();for(const n of e)n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}return typeof e=="string"?document.createTextNode(e):t.renderNode(e)}const ov={"1/1":"1fr 1fr","1/2":"1fr 2fr","2/1":"2fr 1fr","2/3":"2fr 3fr","3/2":"3fr 2fr","1/3":"1fr 3fr","3/1":"3fr 1fr","2/5":"2fr 5fr","5/2":"5fr 2fr"},sv={name:"Split",description:"Two-pane layout: a left/primary node and a right/secondary node, with a controllable `ratio` (1/1, 3/2, 2/3…), optional `divider`, an optional `sticky` pane that pins on scroll, and a `stackAt` breakpoint where it collapses to a single column. The canonical 'text + media' / 'code + preview' / 'content + sidebar' section.",props:[{name:"left",type:"Node",positional:!0,required:!0,aliases:["primary"]},{name:"right",type:"Node",required:!0,aliases:["secondary"]},{name:"ratio",type:"string",optional:!0,description:"Column ratio: 1/1, 3/2, 2/3, 1/3, 2/1, etc."},{name:"gap",type:"string",optional:!0,enum:me},{name:"divider",type:"boolean",optional:!0},{name:"sticky",type:"string",optional:!0,enum:["left","right"],description:"Pin one pane while the other scrolls"},{name:"stackAt",type:"string",optional:!0,enum:["sm","md","lg"],description:"Breakpoint below which it stacks (default md)"},{name:"align",type:"string",optional:!0,enum:["start","center","stretch"]}],render:(t,e,r)=>{const n=ov[m(e.ratio,"1/1")]??"1fr 1fr",a=Ii(m(e.gap,"lg"))||"var(--rui-spacing-l)",i=u("div",{class:"rui-split","data-divider":I(e.divider)?"true":null,"data-stack":m(e.stackAt,"md"),"data-align":m(e.align)||null,style:`grid-template-columns:${n};gap:${a}`}),o=u("div",{class:"rui-split-pane","data-sticky":m(e.sticky)==="left"?"true":null});o.append(Ne(r,e.left));const s=u("div",{class:"rui-split-pane","data-sticky":m(e.sticky)==="right"?"true":null});return s.append(Ne(r,e.right)),i.append(o,s),i}},gs={tile:{col:1,row:1},wide:{col:2,row:1},tall:{col:1,row:2},hero:{col:2,row:2}};function lv(t){const e=n=>Math.max(1,Math.min(8,Math.round(n))),r=n=>Math.max(1,Math.min(4,Math.round(n)));if(typeof t=="number")return{col:e(t),row:1,name:null};if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="full")return{col:1,row:1,name:"full"};if(gs[n])return{...gs[n],name:n};const a=/^(\d+)\s*[x×]\s*(\d+)$/.exec(n);if(a)return{col:e(Number(a[1])),row:r(Number(a[2])),name:null};const i=Number(n);return Number.isFinite(i)&&i>0?{col:e(i),row:1,name:null}:{col:1,row:1,name:null}}if(t&&typeof t=="object"){const n=t;return{col:e(P(n.col,1)),row:r(P(n.row,1)),name:null}}return{col:1,row:1,name:null}}const cv={name:"BentoCell",description:'A single cell in a Bento grid. `span` names a size — `tile` 1×1, `wide` 2×1 (2 columns), `tall` 1×2 (2 rows), `hero` 2×2, `full` (a whole row) — or use a "CxR" string ("2x1"), a bare column-span number, or `{ col, row }`; `rowSpan` adds rows to a named/numeric span. The child stretches to fill the cell, so images/cards crop to the cell\'s shape. Pick spans that tile the parent Bento with no leftover tracks.',props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"span",type:"string | number | object",optional:!0,description:'tile (1×1) | wide (2×1) | tall (1×2) | hero (2×2) | full (whole row), "2x1", 2, or { col, row }'},{name:"rowSpan",type:"number",optional:!0,description:"Rows to span (combines with a numeric/named span)"}],render:(t,e,r)=>{let{col:n,row:a,name:i}=lv(e.span);e.rowSpan!==void 0&&(a=Math.max(1,Math.min(4,Math.round(P(e.rowSpan,a)))));const o=u("div",{class:"rui-bento-cell","data-span":i,style:`--rui-cell-col:${n};--rui-cell-row:${a}`});return o.append(Ne(r,e.child)),o}},uv={name:"Bento",description:"Asymmetric 'bento box' grid — the marquee feature-section layout. Children must be BentoCell nodes (a plain node becomes a 1×1 tile). Two rules make it look right: (1) spans must tile the grid exactly — each row's column spans sum to `columns` and row-spans pair up with neighbouring cells, never leaving a dangling track (e.g. `columns: 3` with 4 cells: hero 2×2 + tall 1×2 fill rows 1–2, wide 2×1 + tile fill row 3); (2) set a fixed `rowHeight` (e.g. \"180px\") whenever cells hold images or cards — the default auto row stretches to the tallest cell and makes the mosaic ragged. Give 1–2 standout cells a big span (hero/wide/tall) and keep the rest 1×1 tiles. `dense` (default true) backfills gaps. Collapses to 2 columns below 920px and 1 below 640px.",props:[{name:"items",type:"BentoCell[]",positional:!0,required:!0,aliases:["children","cells"]},{name:"columns",type:"number",optional:!0,description:"Track count 1–8 (default 6) — pick it so the cell spans in every row can sum to it"},{name:"gap",type:"string",optional:!0,enum:me},{name:"rowHeight",type:"string",optional:!0,description:'Fixed row track size, e.g. "180px" — set it whenever any cell spans rows or holds images (default minmax(110px, auto) stretches rows to content)'},{name:"dense",type:"boolean",optional:!0,description:"Backfill holes with later cells (default true)"}],render:(t,e,r)=>{const n=Math.max(1,Math.min(8,Math.round(P(e.columns,6)))),a=ve(e.gap,"md"),i=Z(e.rowHeight,""),o=e.dense===void 0?!0:I(e.dense),s=u("div",{class:"rui-bento","data-cols":String(n),"data-gap":a,"data-dense":o?"true":null,style:i?`--rui-bento-row:${i}`:null});for(const l of T(e.items)){const c=r.renderNode(l);if(c instanceof HTMLElement&&c.classList.contains("rui-bento-cell")){const d=Number.parseInt(c.style.getPropertyValue("--rui-cell-col"),10);Number.isFinite(d)&&d>n&&c.style.setProperty("--rui-cell-col",String(n))}s.append(c)}return s}},hs=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","slide-up"]),dv={name:"Reveal",description:"Animates its child in the first time it scrolls into view (scroll choreography). `animation` is a preset (fade-up|fade|zoom|…), `delay` staggers it (ms), `once` (default true) plays a single time. Honours prefers-reduced-motion (renders immediately).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"animation",type:"string",optional:!0,enum:[...hs]},{name:"delay",type:"number",optional:!0,description:"Stagger delay in ms"},{name:"once",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=m(e.animation,"fade-up"),a=hs.has(n)?n:"fade-up",i=Math.max(0,Math.min(5e3,P(e.delay,0))),o=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,s=r.useInstanceState("rui-reveal-shown",!1),l=s.get()||o||typeof IntersectionObserver>"u",c=u("div",{class:l?"rui-reveal is-revealed":"rui-reveal","data-anim":a,style:i?`transition-delay:${i}ms`:null});if(c.append(Ne(r,e.child)),l&&(e.once===void 0||I(e.once))||o||typeof IntersectionObserver>"u")return c;const d=e.once===void 0?!0:I(e.once);return setTimeout(()=>{if(!c.isConnected)return;const p=new IntersectionObserver(f=>{for(const b of f)if(b.isIntersecting){if(s.set(!0),b.target.classList.add("is-revealed"),d){p.disconnect();return}}else d||(s.set(!1),b.target.classList.remove("is-revealed"))},{threshold:.15,rootMargin:"0px 0px -8% 0px"});p.observe(c),r.registerDisposer(()=>p.disconnect(),"rui-reveal-io")},0),c}},bs=new WeakMap;function Tr(t){let e=bs.get(t);return e||(e={x:0,y:0,lastTap:0,longTimer:null,longFired:!1},bs.set(t,e)),e}function Mr(t){t.longTimer&&(clearTimeout(t.longTimer),t.longTimer=null)}const pv={name:"OnGesture",description:"Attach high-level pointer gestures to any component without raw DOM: `swipe(dir)` (left/right/up/down), `longPress()`, `doubleTap()`, and `pan({dx, dy})`. Powers swipe-to-dismiss, pull-to-refresh, carousels, and drag affordances on touch + mouse.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"swipe",type:"callable",optional:!0,aliases:["onSwipe"],description:"(dir) => … — fired on a swipe; dir is left|right|up|down"},{name:"longPress",type:"callable",optional:!0,aliases:["onLongPress"]},{name:"doubleTap",type:"callable",optional:!0,aliases:["onDoubleTap"]},{name:"pan",type:"callable",optional:!0,aliases:["onPan"],description:"({dx, dy}) => … — fired during a drag"},{name:"threshold",type:"number",optional:!0,description:"Swipe distance in px (default 40)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-gesture",style:`touch-action:${e.pan!=null?"none":"pan-y"}`});n.append(Ne(r,e.child));const a=Math.max(8,P(e.threshold,40)),i=o=>o.currentTarget??n;return n.onpointerdown=o=>{const s=i(o),l=Tr(s);l.x=o.clientX,l.y=o.clientY,l.longFired=!1,Mr(l);try{s.setPointerCapture(o.pointerId)}catch{}e.longPress!=null&&(l.longTimer=setTimeout(()=>{l.longTimer=null,s.isConnected&&(l.longFired=!0,r.invoke(e.longPress))},500))},n.onpointermove=o=>{const s=Tr(i(o)),l=o.clientX-s.x,c=o.clientY-s.y;(Math.abs(l)>6||Math.abs(c)>6)&&Mr(s),e.pan!=null&&o.buttons&1&&r.invoke(e.pan,{dx:l,dy:c})},n.onpointerup=o=>{const s=Tr(i(o));if(Mr(s),s.longFired){s.longFired=!1,s.lastTap=0;return}const l=o.clientX-s.x,c=o.clientY-s.y,d=Math.abs(l),p=Math.abs(c);if(e.swipe!=null&&(d>a||p>a)){const f=d>p?l>0?"right":"left":c>0?"down":"up";s.lastTap=0,r.invoke(e.swipe,f);return}if(e.doubleTap!=null&&d<8&&p<8){const f=Date.now();f-s.lastTap<300?(s.lastTap=0,r.invoke(e.doubleTap)):s.lastTap=f}},n.onpointercancel=o=>{const s=Tr(i(o));Mr(s),s.longFired=!1},n}},mv={name:"Sortable",description:"A vertical list whose items can be drag-reordered. Pass already-rendered `items`; `onReorder(fromIndex, toIndex)` fires after a drop so you can reorder the backing reactive array. Works with mouse + touch.",props:[{name:"items",type:"Node[]",positional:!0,required:!0,aliases:["children"]},{name:"onReorder",type:"callable",optional:!0,description:"(fromIndex, toIndex) => …"},{name:"handle",type:"boolean",optional:!0,description:"Show a drag handle on each row (default true)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-sortable"}),a=e.handle===void 0?!0:I(e.handle),i=s=>(s.currentTarget??s.target)?.closest?.(".rui-sortable-item")??null,o=s=>{const l=Number(s?.getAttribute("data-index"));return Number.isFinite(l)?l:-1};return T(e.items).forEach((s,l)=>{const c=u("div",{class:"rui-sortable-item",draggable:"true","data-index":String(l)});if(a){const p=u("span",{class:"rui-sortable-handle","aria-hidden":"true"});p.append(u("i",{class:"rui-icon fa-solid fa-grip-vertical"})),c.append(p)}const d=u("div",{class:"rui-sortable-body"});d.append(r.renderNode(s)),c.append(d),c.ondragstart=p=>{const f=i(p);f?.classList.add("is-dragging"),f?.closest(".rui-sortable")?.setAttribute("data-drag-from",String(o(f)))},c.ondragend=p=>{const f=i(p);f?.classList.remove("is-dragging"),f?.closest(".rui-sortable")?.removeAttribute("data-drag-from")},c.ondragover=p=>{p.preventDefault(),i(p)?.classList.add("is-over")},c.ondragleave=p=>i(p)?.classList.remove("is-over"),c.ondrop=p=>{p.preventDefault();const f=i(p);f?.classList.remove("is-over");const b=f?.closest(".rui-sortable"),h=Number(b?.getAttribute("data-drag-from")),g=o(f);b?.removeAttribute("data-drag-from"),Number.isFinite(h)&&h>=0&&g>=0&&h!==g&&r.invoke(e.onReorder,h,g)},n.append(c)}),n}},fv={name:"Draggable",description:"Makes its child draggable, carrying a `data` payload picked up by a DropZone. `onDragStart`/`onDragEnd` optional.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"data",type:"any",optional:!0,description:"Payload (stringified) handed to the DropZone"},{name:"onDragStart",type:"callable",optional:!0},{name:"onDragEnd",type:"callable",optional:!0}],render:(t,e,r)=>{const n=u("div",{class:"rui-draggable",draggable:"true"});return n.append(Ne(r,e.child)),n.ondragstart=a=>{try{a.dataTransfer?.setData("text/plain",typeof e.data=="string"?e.data:JSON.stringify(e.data??null))}catch{}(a.currentTarget??a.target)?.classList.add("is-dragging"),r.invoke(e.onDragStart,e.data)},n.ondragend=a=>{(a.currentTarget??a.target)?.classList.remove("is-dragging"),r.invoke(e.onDragEnd)},n}},gv={name:"DropZone",description:"A target that accepts a Draggable. `onDrop(data)` receives the dropped payload (parsed JSON when possible).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"onDrop",type:"callable",optional:!0},{name:"label",type:"string",optional:!0}],render:(t,e,r)=>{const n=u("div",{class:"rui-dropzone"});e.child!=null?n.append(Ne(r,e.child)):m(e.label)&&n.append(u("span",{class:"rui-dropzone-label"},[m(e.label)]));const a=i=>(i.currentTarget??i.target)?.closest?.(".rui-dropzone")??null;return n.ondragover=i=>{i.preventDefault(),a(i)?.classList.add("is-over")},n.ondragleave=i=>a(i)?.classList.remove("is-over"),n.ondrop=i=>{i.preventDefault(),a(i)?.classList.remove("is-over");const o=i.dataTransfer?.getData("text/plain")??"";let s=o;try{s=JSON.parse(o)}catch{}r.invoke(e.onDrop,s)},n}},hv={name:"Parallax",description:"Translates its child vertically as the page scrolls for a depth effect. `speed` (−1…1) sets intensity/direction. Honours prefers-reduced-motion.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"speed",type:"number",optional:!0,description:"−1…1 (default 0.3)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-parallax",style:"will-change:transform"});if(n.append(Ne(r,e.child)),typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches||typeof window>"u")return n;const i=Math.max(-1,Math.min(1,P(e.speed,.3)));let o=0;const s=()=>{o=0;const c=n.getBoundingClientRect(),d=window.innerHeight||800,p=c.top+c.height/2-d/2;n.style.transform=`translateY(${(-p*i).toFixed(1)}px)`},l=()=>{o||(o=requestAnimationFrame(s))};return setTimeout(s,0),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0}),r.registerDisposer(()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),o&&cancelAnimationFrame(o)},"rui-parallax"),n}},bv={name:"ReadingProgress",description:"A thin progress bar that fills as the page scrolls — article/docs reading affordance. Optional gradient fill.",props:[{name:"gradient",type:"boolean",optional:!0},{name:"height",type:"string",optional:!0,description:"Bar thickness (CSS length, default 3px)"}],render:(t,e,r)=>{const n=u("div",{class:"rui-reading-progress",style:`height:${Z(e.height,"3px")}`}),a=u("div",{class:"rui-reading-progress-bar","data-gradient":I(e.gradient)?"true":null});if(n.append(a),typeof window>"u")return n;let i=0;const o=()=>{i=0;const l=document.documentElement,c=l.scrollHeight-l.clientHeight||1,d=Math.max(0,Math.min(100,l.scrollTop/c*100));a.style.width=`${d}%`},s=()=>{i||(i=requestAnimationFrame(o))};return setTimeout(o,0),window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s,{passive:!0}),r.registerDisposer(()=>{window.removeEventListener("scroll",s),window.removeEventListener("resize",s),i&&cancelAnimationFrame(i)},"rui-reading-progress"),n}},vs=new Set(["fade","scale","slide-up","slide-down","slide-left","slide-right"]),vv={name:"Transition",description:"Animates its child IN when `show` becomes true and OUT when it becomes false (mount/unmount choreography) — modals, toasts, dropdowns, list rows. `preset` is fade|scale|slide-up|slide-down|slide-left|slide-right, `duration` is ms. The child stays mounted through the exit animation, then is removed. Honours prefers-reduced-motion (instant swap).",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"show",type:"boolean",description:"Whether the child is visible"},{name:"preset",type:"string",optional:!0,enum:[...vs]},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 280)"}],render:(t,e,r)=>{const n=I(e.show),a=m(e.preset,"fade"),i=vs.has(a)?a:"fade",o=Math.max(0,Math.min(5e3,P(e.duration,280))),s=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,l=r.useInstanceState("rui-transition",{mounted:!1}),c=l.get().mounted,d=u("div",{class:"rui-transition","data-preset":i,style:`--rui-transition-ms:${o}ms`}),p=b=>d.setAttribute("data-state",b),f=b=>{if(s||typeof requestAnimationFrame>"u"){p(b);return}requestAnimationFrame(()=>requestAnimationFrame(()=>p(b)))};if(n)return d.append(Ne(r,e.child)),p(c?"enter":"exit"),c||f("enter"),l.set({mounted:!0}),d;if(c&&o>0&&!s){d.append(Ne(r,e.child)),p("enter"),f("exit");const b=setTimeout(()=>d.replaceChildren(),o);r.registerDisposer(()=>clearTimeout(b),"rui-transition-exit")}else p("exit");return l.set({mounted:!1}),d}},yv={name:"FlipList",description:"Smoothly animates its children when they reorder, are added, or removed (the FLIP technique — First/Last/Invert/Play). Wrap a keyed list whose order changes (drag-sort, filter, sort toggle) so items glide to their new positions instead of jumping. `duration` is ms. Honours prefers-reduced-motion (no animation). Use stable `key:`s on the items so their DOM nodes persist across the reorder.",props:[{name:"children",type:"Node[]",description:"The list items (use stable keys)"},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 300)"}],render:(t,e,r)=>{const n=Math.max(0,Math.min(2e3,P(e.duration,300))),a=u("div",{class:"rui-flip-list"});for(const f of T(e.children))a.append(Ne(r,f));if(typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches||typeof requestAnimationFrame>"u"||typeof MutationObserver>"u")return a;const o=r.useInstanceState("rui-flip-setup",{done:!1});if(o.get().done)return a;o.set({done:!0});const s=new WeakMap,l=()=>{for(const f of Array.from(a.children)){const b=f.getBoundingClientRect();s.set(f,{left:b.left,top:b.top})}},c=()=>{const f=Array.from(a.children),b=f.map(h=>h.getBoundingClientRect());f.forEach((h,g)=>{const y=s.get(h),v=b[g];if(y){const x=y.left-v.left,w=y.top-v.top;(x!==0||w!==0)&&(h.style.transition="none",h.style.transform=`translate(${x}px, ${w}px)`,requestAnimationFrame(()=>{h.style.transition=`transform ${n}ms cubic-bezier(.22,1,.36,1)`,h.style.transform=""}))}}),f.forEach((h,g)=>s.set(h,{left:b[g].left,top:b[g].top}))};let d=0;const p=new MutationObserver(()=>{d||(d=requestAnimationFrame(()=>{d=0,c()}))});return setTimeout(()=>{l(),p.observe(a,{childList:!0})},0),r.registerDisposer(()=>{p.disconnect(),d&&cancelAnimationFrame(d)},"rui-flip-list"),a}},ys=new Set(["fade","fade-up","fade-down","fade-left","fade-right","zoom","slide-up"]),xv={name:"RouteView",description:"Wraps a router's output so the page animates whenever the route changes. Pass `routeKey: route.path` so it knows when to replay the entrance animation; `animation` is fade|fade-up|zoom|… and `duration` is ms. Works by swapping a keyed inner wrapper, so the fresh page element plays its CSS entrance on mount. Honours prefers-reduced-motion.",props:[{name:"children",type:"Node",positional:!0,required:!0,description:"The $router(...) result"},{name:"routeKey",type:"string",description:"Pass route.path so the view animates on change"},{name:"animation",type:"string",optional:!0,enum:[...ys]},{name:"duration",type:"number",optional:!0,description:"Animation duration in ms (default 300)"}],render:(t,e,r)=>{const n=m(e.animation,"fade"),a=ys.has(n)?n:"fade",i=Math.max(0,Math.min(2e3,P(e.duration,300))),o=m(e.routeKey,"page")||"page",s=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,l=u("div",{class:"rui-route-view"}),c=u("div",{class:"rui-route-page","data-rui-key":o,"data-anim":s?null:a,style:s?null:`--rui-route-ms:${i}ms`});return c.append(Ne(r,e.children)),l.append(c),l}};function Vn(t,e){const r=document.createDocumentFragment();for(const n of T(e))n!=null&&r.append(typeof n=="string"?document.createTextNode(n):t.renderNode(n));return r}const wv={name:"VisuallyHidden",description:"Renders content that is invisible on screen but available to screen readers (the `sr-only` pattern). Use for icon-button labels, form hints, and context that sighted users get from layout but assistive tech needs.",props:[{name:"children",type:"Node[]",description:"Content exposed only to assistive tech"}],render:(t,e,r)=>{const n=u("span",{class:"rui-visually-hidden"});return n.append(Vn(r,e.children)),n}},kv={name:"SkipLink",description:"A keyboard-only 'skip to content' link that is hidden until focused, then jumps to the element with the given id. Place it as the first node in a page so keyboard users can bypass the nav.",props:[{name:"to",type:"string",positional:!0,required:!0,description:"Target element id (with or without #)"},{name:"label",type:"string",optional:!0,description:"Link text (default 'Skip to content')"}],render:(t,e)=>{const n=m(e.to,"main").replace(/^#/,""),a=u("a",{class:"rui-skip-link",href:`#${n}`});return a.textContent=m(e.label,"Skip to content"),a.onclick=i=>{const s=(i.currentTarget??i.target??a).getRootNode();let l=null;try{l=s.getElementById?.(n)??document.getElementById(n)}catch{l=null}if(l){i.preventDefault(),l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{l.focus()}try{l.scrollIntoView?.({behavior:"smooth",block:"start"})}catch{}}},a}},Sv={name:"LiveRegion",description:"An aria-live region that announces its text to screen readers whenever it changes — toasts, validation summaries, async status. `politeness` is `polite` (default) or `assertive`. Visually hidden by default; set `visible` to also show it.",props:[{name:"text",type:"string",positional:!0,aliases:["children"]},{name:"politeness",type:"string",optional:!0,enum:["polite","assertive"]},{name:"visible",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=m(e.politeness,"polite")==="assertive"?"assertive":"polite",a=e.visible===!0||e.visible==="true",i=u("div",{class:a?"rui-live-region":"rui-live-region rui-visually-hidden",role:"status","aria-live":n,"aria-atomic":"true"});return e.text!=null&&typeof e.text!="object"?i.textContent=String(e.text):i.append(Vn(r,e.text??e.children)),i}},xs=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(","),$v={name:"FocusTrap",description:"Confines keyboard focus to its subtree while `active` (default true) — Tab from the last focusable wraps to the first and vice-versa. Use inside modals, drawers, and command palettes. Auto-focuses the first focusable on mount.",props:[{name:"child",type:"Node",positional:!0,required:!0,aliases:["children"]},{name:"active",type:"boolean",optional:!0}],render:(t,e,r)=>{const n=e.active===void 0?!0:e.active===!0||e.active==="true",a=u("div",{class:"rui-focus-trap"});if(a.append(Vn(r,e.child??e.children)),!n)return a;const i=o=>{if(o.key!=="Tab")return;const s=Array.from(a.querySelectorAll(xs)).filter(p=>p.offsetParent!==null||p===document.activeElement);if(s.length===0)return;const l=s[0],c=s[s.length-1],d=a.getRootNode().activeElement;o.shiftKey&&d===l?(o.preventDefault(),c.focus()):!o.shiftKey&&d===c&&(o.preventDefault(),l.focus())};return a.addEventListener("keydown",i),setTimeout(()=>{const o=a.querySelector(xs);o&&typeof o.focus=="function"&&o.focus()},0),r.registerDisposer(()=>a.removeEventListener("keydown",i),"rui-focus-trap"),a}},ws={L:[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],M:[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],Q:[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],H:[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},ks={L:[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],M:[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Q:[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],H:[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},Cv=(()=>{const t=[[]];for(let e=1;e<=40;e+=1){if(e===1){t.push([]);continue}const r=Math.floor(e/7)+2,n=e===32?26:Math.ceil((e*4+4)/(r*2-2))*2,a=[6];for(let i=e*4+10;a.length<r;i-=n)a.splice(1,0,i);t.push(a)}return t})(),Nr=new Uint8Array(512),Wn=new Uint8Array(256);(()=>{let t=1;for(let e=0;e<255;e+=1)Nr[e]=t,Wn[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e+=1)Nr[e]=Nr[e-255]})();function Gn(t,e){return t===0||e===0?0:Nr[Wn[t]+Wn[e]]}function Av(t){const e=new Uint8Array(t);e[t-1]=1;let r=1;for(let n=0;n<t;n+=1){for(let a=0;a<t;a+=1)e[a]=Gn(e[a],r),a+1<t&&(e[a]=e[a]^e[a+1]);r=Gn(r,2)}return e}function Tv(t,e){const r=new Uint8Array(e.length);for(const n of t){const a=n^r[0];r.copyWithin(0,1),r[r.length-1]=0;for(let i=0;i<r.length;i+=1)r[i]=r[i]^Gn(e[i],a)}return r}function Ss(t,e){const r=$s(t)>>>3,n=ks[e][t],a=ws[e][t];return r-a*n}function $s(t){let e=(16*t+128)*t+64;if(t>=2){const r=Math.floor(t/7)+2;e-=(25*r-10)*r-55,t>=7&&(e-=36)}return e}const Mv={L:1,M:0,Q:3,H:2};function Nv(t,e="M"){const r=zv(t);let n=1;for(;n<=40;n+=1){const c=Ss(n,e)*8;if(4+(n<=9?8:16)+r.length*8<=c)break}if(n>40)throw new Error("Data too long for QR code");const a=[],i=(c,d)=>{for(let p=d-1;p>=0;p-=1)a.push(c>>>p&1)};i(4,4),i(r.length,n<=9?8:16);for(const c of r)i(c,8);const o=Ss(n,e)*8;for(i(0,Math.min(4,o-a.length));a.length%8!==0;)a.push(0);for(let c=236;a.length<o;c^=253)i(c,8);const s=new Uint8Array(a.length>>>3);for(let c=0;c<a.length;c+=1)s[c>>>3]=s[c>>>3]|a[c]<<7-(c&7);const l=Iv(s,n,e);return Pv(n,e,l)}function Iv(t,e,r){const n=ks[r][e],a=ws[r][e],i=$s(e)>>>3,o=n-i%n,s=Math.floor(i/n),l=[],c=Av(a);let d=0;for(let b=0;b<n;b+=1){const h=s-a+(b<o?0:1),g=t.slice(d,d+h);d+=h;const y=Tv(g,c),v=new Uint8Array(s+1);v.set(g,0),v.set(y,v.length-a),l.push(v)}const p=new Uint8Array(i);let f=0;for(let b=0;b<l[0].length;b+=1)for(let h=0;h<l.length;h+=1)(b!==s-a||h>=o)&&(p[f++]=l[h][b]);return p}function Pv(t,e,r){const n=t*4+17,a=Array.from({length:n},()=>new Array(n).fill(!1)),i=Array.from({length:n},()=>new Array(n).fill(!1)),o=(h,g,y)=>{a[g][h]=y,i[g][h]=!0},s=(h,g)=>{for(let y=-4;y<=4;y+=1)for(let v=-4;v<=4;v+=1){const x=Math.max(Math.abs(v),Math.abs(y)),w=h+v,k=g+y;w>=0&&w<n&&k>=0&&k<n&&o(w,k,x!==2&&x!==4)}};for(let h=0;h<n;h+=1)o(6,h,h%2===0),o(h,6,h%2===0);s(3,3),s(n-4,3),s(3,n-4);const l=Cv[t];for(const h of l)for(const g of l)if(!(g===6&&h===6||g===6&&h===n-7||g===n-7&&h===6))for(let y=-2;y<=2;y+=1)for(let v=-2;v<=2;v+=1)o(g+v,h+y,Math.max(Math.abs(v),Math.abs(y))!==1);if((()=>{for(let h=0;h<9;h+=1)i[h][8]||o(8,h,!1),i[8][h]||o(h,8,!1);for(let h=0;h<8;h+=1)o(n-1-h,8,!1),o(8,n-1-h,!1);o(8,n-8,!0)})(),t>=7)for(let h=0;h<18;h+=1){const g=h%3,y=Math.floor(h/3);o(n-11+g,y,!1),o(y,n-11+g,!1)}let d=0;const p=r.length*8;for(let h=n-1;h>=1;h-=2){const g=h===6?5:h;for(let y=0;y<n;y+=1)for(let v=0;v<2;v+=1){const x=g-v,k=(g+1&2)===0?n-1-y:y;if(i[k][x])continue;let A=!1;d<p&&(A=(r[d>>>3]>>>7-(d&7)&1)!==0,d+=1),a[k][x]=A}}let f=1/0,b=a;for(let h=0;h<8;h+=1){const g=a.map(v=>v.slice());Rv(g,i,h),Ev(g,i,e,h,n);const y=Lv(g,n);y<f&&(f=y,b=g)}return b}function Rv(t,e,r){const n=t.length;for(let a=0;a<n;a+=1)for(let i=0;i<n;i+=1){if(e[a][i])continue;let o=!1;switch(r){case 0:o=(i+a)%2===0;break;case 1:o=a%2===0;break;case 2:o=i%3===0;break;case 3:o=(i+a)%3===0;break;case 4:o=(Math.floor(i/3)+Math.floor(a/2))%2===0;break;case 5:o=i*a%2+i*a%3===0;break;case 6:o=(i*a%2+i*a%3)%2===0;break;case 7:o=((i+a)%2+i*a%3)%2===0;break}o&&(t[a][i]=!t[a][i])}}function Ev(t,e,r,n,a){const i=Mv[r]<<3|n;let o=i;for(let c=0;c<10;c+=1)o=o<<1^(o>>>9)*1335;const s=(i<<10|o)^21522,l=c=>(s>>>c&1)!==0;for(let c=0;c<=5;c+=1)t[c][8]=l(c);t[7][8]=l(6),t[8][8]=l(7),t[8][7]=l(8);for(let c=9;c<15;c+=1)t[8][14-c]=l(c);for(let c=0;c<8;c+=1)t[8][a-1-c]=l(c);for(let c=8;c<15;c+=1)t[a-15+c][8]=l(c);t[a-8][8]=!0}function Lv(t,e){let r=0;for(let n=0;n<e;n+=1){let a=t[n][0],i=1;for(let o=1;o<e;o+=1)t[n][o]===a?(i+=1,i===5?r+=3:i>5&&(r+=1)):(a=t[n][o],i=1)}for(let n=0;n<e;n+=1){let a=t[0][n],i=1;for(let o=1;o<e;o+=1)t[o][n]===a?(i+=1,i===5?r+=3:i>5&&(r+=1)):(a=t[o][n],i=1)}for(let n=0;n<e-1;n+=1)for(let a=0;a<e-1;a+=1){const i=t[n][a];i===t[n][a+1]&&i===t[n+1][a]&&i===t[n+1][a+1]&&(r+=3)}return r}function zv(t){if(typeof TextEncoder<"u")return new TextEncoder().encode(t);const e=[];for(const r of t){const n=r.codePointAt(0);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):e.push(224|n>>12,128|n>>6&63,128|n&63)}return new Uint8Array(e)}const jv="http://www.w3.org/2000/svg";function Ot(t,e){const r=document.createElementNS(jv,t);for(const[n,a]of Object.entries(e))a!=null&&r.setAttribute(n,a);return r}const Dv={name:"QRCode",description:"Renders an offline QR code as crisp SVG from `data` (a URL or text). `size` is the pixel side length, `ecc` the error-correction level (L|M|Q|H, default M), `color`/`background` override the modules. No network — encodes fully in the browser.",props:[{name:"data",type:"string",positional:!0,required:!0,aliases:["value","text"],description:"URL or text to encode"},{name:"size",type:"number",optional:!0,description:"Side length in px (default 160)"},{name:"ecc",type:"string",optional:!0,enum:["L","M","Q","H"]},{name:"color",type:"string",optional:!0,description:"Module (dark) color"},{name:"background",type:"string",optional:!0,description:"Background color (default transparent-white)"},{name:"margin",type:"number",optional:!0,description:"Quiet-zone modules (default 2)"}],render:(t,e)=>{const r=m(e.data),n=Math.max(48,Math.min(1024,P(e.size,160))),a=m(e.ecc,"M").toUpperCase(),i=["L","M","Q","H"].includes(a)?a:"M",o=He(e.color)||"#000000",s=He(e.background)||"#ffffff",l=Math.max(0,Math.min(8,P(e.margin,2))),c=u("div",{class:"rui-qrcode"});let d;try{d=Nv(r||" ",i)}catch{return c.append(u("div",{class:"rui-qrcode-error"},["Data too long for QR"])),c}const p=d.length,f=p+l*2,b=Ot("svg",{viewBox:`0 0 ${f} ${f}`,width:String(n),height:String(n),role:"img","aria-label":`QR code for ${r}`,"shape-rendering":"crispEdges"});b.append(Ot("rect",{x:"0",y:"0",width:String(f),height:String(f),fill:s}));let h="";for(let g=0;g<p;g+=1)for(let y=0;y<p;y+=1)d[g][y]&&(h+=`M${y+l},${g+l}h1v1h-1z`);return b.append(Ot("path",{d:h,fill:o})),c.append(b),c}},Ov={name:"ReactionPicker",description:"A row of emoji reactions with counts. `reactions` is a list of { emoji, count?, active? }; `onReact(emoji)` fires on click. Use under messages, comments, and posts.",props:[{name:"reactions",type:"object[]",positional:!0,required:!0,description:"[{ emoji, count?, active? }]"},{name:"onReact",type:"callable",optional:!0,description:"(emoji) => …"}],render:(t,e)=>{const r=T(e.reactions),n=typeof e.onReact=="function"?e.onReact:null,a=u("div",{class:"rui-reaction-picker",role:"group","aria-label":"Reactions"});for(const i of r){const o=i&&typeof i=="object"?i:{},s=m(o.emoji,"👍"),l=P(o.count,0),c=I(o.active),d=u("button",{type:"button",class:"rui-reaction","data-active":c?"true":null,"aria-pressed":c?"true":"false"});d.append(u("span",{class:"rui-reaction-emoji"},[s])),l>0&&d.append(u("span",{class:"rui-reaction-count"},[String(l)])),n&&(d.onclick=()=>n(s)),a.append(d)}return a}},Bv={name:"LiveCursor",description:"A floating collaborator cursor positioned at `x`/`y` (px) with a name label — drive it from presence/`$socket` state for multiplayer UIs. Pointer-events are disabled so it never blocks interaction.",props:[{name:"x",type:"number",description:"X position in px"},{name:"y",type:"number",description:"Y position in px"},{name:"label",type:"string",optional:!0,description:"Collaborator name"},{name:"color",type:"string",optional:!0}],render:(t,e)=>{const r=P(e.x,0),n=P(e.y,0),a=He(e.color)||"var(--rui-color-primary)",i=u("div",{class:"rui-live-cursor",style:`transform:translate(${r}px,${n}px);--rui-cursor-color:${a}`}),o=Ot("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"});o.append(Ot("path",{d:"M3 3l14 6-6 2-2 6z",fill:a,stroke:"#fff","stroke-width":"1"})),i.append(o);const s=m(e.label);return s&&i.append(u("span",{class:"rui-live-cursor-label",style:`background:${a}`},[s])),i}},Fv={name:"TabBar",description:"Bottom navigation bar for mobile layouts — a row of icon+label tabs. `items` is [{ id, label, icon?, badge? }]; `active` is the current id; `onChange(id)` fires on tap. Pins to the bottom with safe-area padding.",props:[{name:"items",type:"object[]",positional:!0,required:!0,description:"[{ id, label, icon?, badge? }]"},{name:"active",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"(id) => …"}],render:(t,e)=>{const r=T(e.items),n=m(e.active),a=typeof e.onChange=="function"?e.onChange:null,i=u("nav",{class:"rui-tabbar",role:"tablist","aria-label":"Primary"});for(const o of r){const s=o&&typeof o=="object"?o:{},l=m(s.id??s.label),c=l===n&&l!=="",d=u("button",{type:"button",class:"rui-tabbar-item",role:"tab","data-active":c?"true":null,"aria-selected":c?"true":"false","aria-current":c?"page":null}),p=m(s.icon);if(p){const b=j(p,{className:"rui-tabbar-icon"});if(b){const h=u("span",{class:"rui-tabbar-icon-wrap"});h.append(b);const g=m(s.badge);g&&h.append(u("span",{class:"rui-tabbar-badge"},[g])),d.append(h)}}const f=m(s.label);f&&d.append(u("span",{class:"rui-tabbar-label"},[f])),a&&l&&(d.onclick=()=>a(l)),i.append(d)}return i}};function _v(t,e){return e==null?null:typeof e=="string"?document.createTextNode(e):t.renderNode(e)}const Uv={name:"Cart",description:"A shopping-cart line list: each item shows image, name, unit price, a quantity stepper, and a remove button, with a running subtotal. `items` is [{ id, name, price, qty, image? }]; `onQty(id, qty)` and `onRemove(id)` fire on interaction. `currency` is an ISO code (default USD).",props:[{name:"items",type:"object[]",positional:!0,required:!0,description:"[{ id, name, price, qty, image? }]"},{name:"onQty",type:"callable",optional:!0,description:"(id, qty) => …"},{name:"onRemove",type:"callable",optional:!0,description:"(id) => …"},{name:"currency",type:"string",optional:!0},{name:"footer",type:"Node",optional:!0,description:"Custom footer (e.g. a checkout button)"}],render:(t,e,r)=>{const n=T(e.items),a=m(e.currency,"USD")||"USD",i=typeof e.onQty=="function"?e.onQty:null,o=typeof e.onRemove=="function"?e.onRemove:null,s=f=>{try{return new Intl.NumberFormat(void 0,{style:"currency",currency:a}).format(f)}catch{return`${f.toFixed(2)} ${a}`}},l=u("div",{class:"rui-cart"});let c=0;n.length===0&&l.append(u("div",{class:"rui-cart-empty"},["Your cart is empty"]));for(const f of n){const b=f&&typeof f=="object"?f:{},h=m(b.id??b.name),g=m(b.name),y=P(b.price,0),v=Math.max(0,P(b.qty,1));c+=y*v;const x=u("div",{class:"rui-cart-line"}),w=ie(b.image);w&&x.append(u("img",{class:"rui-cart-thumb",src:w,alt:g,loading:"lazy"}));const k=u("div",{class:"rui-cart-body"});k.append(u("div",{class:"rui-cart-name"},[g])),k.append(u("div",{class:"rui-cart-price"},[s(y)])),x.append(k);const A=u("div",{class:"rui-cart-qty"}),S=u("button",{type:"button",class:"rui-cart-qty-btn","aria-label":"Decrease quantity"},["−"]),$=u("button",{type:"button",class:"rui-cart-qty-btn","aria-label":"Increase quantity"},["+"]);if(i&&h&&(S.onclick=()=>i(h,Math.max(0,v-1)),$.onclick=()=>i(h,v+1)),A.append(S,u("span",{class:"rui-cart-qty-value"},[String(v)]),$),x.append(A),x.append(u("div",{class:"rui-cart-line-total"},[s(y*v)])),o&&h){const C=u("button",{type:"button",class:"rui-cart-remove","aria-label":`Remove ${g}`}),M=j("xmark",{className:"rui-cart-remove-icon"});M?C.append(M):C.append(document.createTextNode("×")),C.onclick=()=>o(h),x.append(C)}l.append(x)}const d=u("div",{class:"rui-cart-foot"});d.append(u("span",{class:"rui-cart-subtotal-label"},["Subtotal"])),d.append(u("span",{class:"rui-cart-subtotal-value"},[s(c)])),l.append(d);const p=_v(r,e.footer);return p&&l.append(p),l}},Hv=["SUN","MON","TUE","WED","THU","FRI","SAT"],Cs=["January","February","March","April","May","June","July","August","September","October","November","December"],As={primary:"var(--rui-color-primary)",success:"var(--rui-color-success, #10b981)",warning:"var(--rui-color-warning, #f59e0b)",danger:"var(--rui-color-danger, #ef4444)",info:"var(--rui-color-info, #06b6d4)"},Ts=t=>String(t).padStart(2,"0"),Ms=(t,e,r)=>`${t}-${Ts(e+1)}-${Ts(r)}`;function qv(t){const e=new Map,r=new Map;for(const n of T(t)){if(n==null)continue;if(typeof n=="string"){const d=n.slice(0,10);d&&r.set(d,(r.get(d)??0)+1);continue}if(typeof n!="object")continue;const a=n,i=m(a.date).slice(0,10);if(!i)continue;const o=m(a.label??a.title);if(!o){r.set(i,(r.get(i)??0)+1);continue}const s=m(a.color??a.tone,"primary"),l=As[s]??He(s)??As.primary,c=e.get(i)??[];c.push({label:o,color:l,time:m(a.time)}),e.set(i,c)}return{chips:e,dots:r}}function Ns(t,e,r,n){const a=h=>(h.currentTarget??h.target)?.closest(".rui-gcal")??t,i=(h,g,y)=>{const v=a(h),x=n.viewSlot.get();n.viewSlot.set({propsYear:x?.propsYear??g,propsMonth:x?.propsMonth??y,year:g,month:y}),Ns(v,g,y,n),n.helpers.invoke(n.onNavigate,g,y)},o=(h,g)=>{const y=n.viewSlot.get(),v=y?.year??e,x=y?.month??r,w=new Date(v,x+g,1);i(h,w.getFullYear(),w.getMonth())},s=u("div",{class:"rui-gcal-toolbar"});if(n.navigable){const h=u("button",{type:"button",class:"rui-gcal-today"},["Today"]);h.onclick=w=>{const k=new Date;i(w,k.getFullYear(),k.getMonth())};const g=u("button",{type:"button",class:"rui-gcal-nav","data-dir":"prev","aria-label":"Previous month"}),y=j("chevron-left");y?g.append(y):g.textContent="‹",g.onclick=w=>o(w,-1);const v=u("button",{type:"button",class:"rui-gcal-nav","data-dir":"next","aria-label":"Next month"}),x=j("chevron-right");x?v.append(x):v.textContent="›",v.onclick=w=>o(w,1),s.append(h,g,v)}s.append(u("span",{class:"rui-gcal-title"},[`${Cs[r]} ${e}`]));const l=u("div",{class:"rui-gcal-grid",role:"grid"});for(let h=0;h<7;h+=1)l.append(u("div",{class:"rui-gcal-weekday",role:"columnheader"},[Hv[(n.firstDay+h)%7]]));l.onkeydown=h=>{const g=h.key;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(g))return;const y=a(h),v=Array.from(y.querySelectorAll(".rui-gcal-day")),x=y.getRootNode(),w=v.indexOf(x.activeElement);if(w<0)return;let k=w;g==="ArrowLeft"?k=w-1:g==="ArrowRight"?k=w+1:g==="ArrowUp"?k=w-7:g==="ArrowDown"?k=w+7:g==="Home"?k=w-w%7:g==="End"&&(k=w-w%7+6),!(k<0||k>=v.length)&&(h.preventDefault(),v[k]?.focus())};const c=new Date(e,r,1),d=new Date(e,r+1,0).getDate(),p=(c.getDay()-n.firstDay+7)%7,f=Math.ceil((p+d)/7)*7,b=new Date(e,r,1-p);for(let h=0;h<f;h+=1){const g=new Date(b.getFullYear(),b.getMonth(),b.getDate()+h),y=Ms(g.getFullYear(),g.getMonth(),g.getDate()),v=g.getMonth()===r,x=u("button",{type:"button",class:"rui-gcal-day",role:"gridcell","data-in-month":v?"true":"false","data-today":y===n.todayIso?"true":null,"data-selected":n.selected&&y===n.selected?"true":null,"data-iso":y,"aria-label":`${Cs[g.getMonth()]} ${g.getDate()}, ${g.getFullYear()}`,"aria-pressed":n.selected&&y===n.selected?"true":"false"});x.append(u("span",{class:"rui-gcal-daynum"},[String(g.getDate())]));const w=n.chips.get(y)??[],k=n.dots.get(y)??0;if(w.length>0||k>0){const A=u("div",{class:"rui-gcal-events"}),S=w.slice(0,2);for(const C of S)A.append(u("span",{class:"rui-gcal-chip",style:`--rui-gcal-chip:${C.color}`,title:C.time?`${C.time} — ${C.label}`:C.label},[C.time?`${C.time} ${C.label}`:C.label]));if(k>0){const C=u("div",{class:"rui-gcal-dots"});for(let M=0;M<Math.min(3,k);M+=1)C.append(u("span",{class:"rui-gcal-dot"}));A.append(C)}const $=w.length-S.length;$>0&&A.append(u("span",{class:"rui-gcal-more"},[`+${$} more`])),x.append(A)}x.onclick=A=>{const S=a(A);for(const M of S.querySelectorAll('.rui-gcal-day[data-selected="true"]'))M.removeAttribute("data-selected"),M.setAttribute("aria-pressed","false");const C=(A.currentTarget??A.target)?.closest?.(".rui-gcal-day");C?.setAttribute("data-selected","true"),C?.setAttribute("aria-pressed","true"),n.selRef&&n.helpers.setState(n.selRef,y),n.helpers.invoke(n.onSelect,y)},l.append(x)}t.replaceChildren(s,l)}const Vv={name:"Calendar",description:"A Google Calendar-style month grid with Today/prev/next navigation. `month` (0–11) and `year` set the view (default current month); `selected` is an ISO date (YYYY-MM-DD) to highlight — bind a $variable for two-way selection; `onSelect(iso)` fires on a day click. `events` mixes bare ISO strings (rendered as dots) and `{date, label, color?, time?}` objects (rendered as colored chips with a '+N more' overflow; `color` is a tone name or CSS color). `onNavigate(year, month)` fires when the user pages months; `navigable=false` hides the toolbar buttons. Use for schedules, bookings, and availability calendars.",props:[{name:"month",type:"number",optional:!0,description:"0–11 (default current month)"},{name:"year",type:"number",optional:!0,description:"Full year (default current)"},{name:"selected",type:"string",optional:!0,description:"ISO date to highlight; bind a $variable"},{name:"onSelect",type:"callable",optional:!0,description:"(isoDate) => …"},{name:"events",type:"any[]",optional:!0,description:"ISO strings (dots) and/or {date, label, color?, time?} chips"},{name:"firstDay",type:"number",optional:!0,description:"0=Sunday (default), 1=Monday"},{name:"navigable",type:"boolean",optional:!0,description:"Show Today/prev/next controls (default true)"},{name:"onNavigate",type:"callable",optional:!0,description:"(year, month) => … after paging"}],render:(t,e,r)=>{const n=new Date,a=e.month!==void 0&&Number.isFinite(Number(e.month)),i=e.year!==void 0&&Number.isFinite(Number(e.year)),o=a?Math.max(0,Math.min(11,Math.floor(P(e.month,n.getMonth())))):n.getMonth(),s=i?Math.floor(P(e.year,n.getFullYear())):n.getFullYear(),l=r.useInstanceState("rui-gcal-view",null),c=l.get(),p=!c||c.propsYear!==s||c.propsMonth!==o?{propsYear:s,propsMonth:o,year:s,month:o}:c;l.set(p);const{chips:f,dots:b}=qv(e.events),h={todayIso:Ms(n.getFullYear(),n.getMonth(),n.getDate()),selected:m(e.selected),chips:f,dots:b,firstDay:(Math.round(P(e.firstDay,0))%7+7)%7,navigable:e.navigable===void 0?!0:I(e.navigable),onSelect:e.onSelect,onNavigate:e.onNavigate,selRef:t.argMeta?.[2]?.stateRef,helpers:r,viewSlot:l},g=u("div",{class:"rui-gcal"});return Ns(g,p.year,p.month,h),g}},pt=new WeakMap;function Wv(t,e,r){const n=typeof window<"u"&&window.devicePixelRatio||1;t.width=Math.round(e*n),t.height=Math.round(r*n),t.style.width=`${e}px`,t.style.height=`${r}px`;const a=t.getContext("2d");return a&&(a.scale(n,n),a.lineCap="round",a.lineJoin="round"),a}function Is(t){let e=t.dataset.stroke??"";if(!e)try{e=getComputedStyle(t).color||"#1a1a1a"}catch{e="#1a1a1a"}return{stroke:e,lineWidth:Math.max(1,Math.min(40,Number(t.dataset.lineWidth)||2)),background:t.dataset.bg??"transparent"}}function Ps(t,e){if(!e.ctx)return;const{background:r}=Is(t);r&&r!=="transparent"&&(e.ctx.fillStyle=r,e.ctx.fillRect(0,0,e.width,e.height))}function Rs(t){const e=pt.get(t);if(!e?.ctx)return;const{stroke:r,lineWidth:n}=Is(t);e.ctx.clearRect(0,0,e.width,e.height),Ps(t,e),e.ctx.strokeStyle=r,e.ctx.lineWidth=n;for(const a of e.strokes)if(!(a.length<1)){e.ctx.beginPath(),e.ctx.moveTo(a[0].x,a[0].y);for(let i=1;i<a.length;i+=1)e.ctx.lineTo(a[i].x,a[i].y);e.ctx.stroke()}}function Es(t){const e=pt.get(t);e&&(e.strokes=[],e.current=[],Rs(t))}function Ls(t){const{width:e,height:r,stroke:n,lineWidth:a,background:i,rootClass:o,helpers:s}=t,l=u("div",{class:o,style:`width:${e}px`}),c=u("canvas",{class:"rui-canvas-surface",style:"touch-action:none","data-stroke":n||null,"data-line-width":String(a),"data-bg":i});l.append(c);const d=Wv(c,e,r);pt.set(c,{strokes:[],current:[],drawing:!1,ctx:d,width:e,height:r}),Ps(c,pt.get(c));const p=h=>h.currentTarget??c,f=(h,g)=>{const y=h.getBoundingClientRect();return{x:g.clientX-y.left,y:g.clientY-y.top}};c.onpointerdown=h=>{const g=p(h),y=pt.get(g);if(y){y.drawing=!0;try{g.setPointerCapture(h.pointerId)}catch{}y.current=[f(g,h)],y.strokes.push(y.current)}},c.onpointermove=h=>{const g=p(h),y=pt.get(g);y?.drawing&&(y.current.push(f(g,h)),Rs(g),s.invoke(t.onChange,y.strokes.length))};const b=h=>{const g=p(h),y=pt.get(g);if(!y?.drawing)return;y.drawing=!1;let v="";try{v=g.toDataURL("image/png")}catch{}s.invoke(t.onEnd,v)};return c.onpointerup=b,c.onpointercancel=b,{root:l,canvas:c}}function zs(t,e,r){return(t.currentTarget??t.target)?.closest?.(`.${e}`)?.querySelector("canvas.rui-canvas-surface")??r}const Gv={name:"DrawingCanvas",description:"A freehand drawing surface (pointer / touch / stylus). `onChange(count)` fires while drawing; `onEnd(dataUrl)` fires when a stroke finishes with a PNG data URL. `color`/`lineWidth`/`background` style the ink. Includes a Clear button unless `clearable=false`.",props:[{name:"width",type:"number",optional:!0,description:"px (default 360)"},{name:"height",type:"number",optional:!0,description:"px (default 220)"},{name:"color",type:"string",optional:!0,description:"Ink color"},{name:"lineWidth",type:"number",optional:!0},{name:"background",type:"string",optional:!0},{name:"clearable",type:"boolean",optional:!0},{name:"onChange",type:"callable",optional:!0,description:"(strokeCount) => …"},{name:"onEnd",type:"callable",optional:!0,description:"(pngDataUrl) => …"}],render:(t,e,r)=>{const n=Math.max(80,Math.min(2e3,P(e.width,360))),a=Math.max(80,Math.min(2e3,P(e.height,220))),i=He(e.color)||"",o=Math.max(1,Math.min(40,P(e.lineWidth,2))),s=He(e.background)||"transparent",l=Ls({width:n,height:a,stroke:i,lineWidth:o,background:s,rootClass:"rui-drawing-canvas",onChange:e.onChange,onEnd:e.onEnd,helpers:r});if(e.clearable===void 0||I(e.clearable)){const c=u("div",{class:"rui-canvas-toolbar"}),d=u("button",{type:"button",class:"rui-canvas-clear"},["Clear"]);d.onclick=p=>{Es(zs(p,"rui-drawing-canvas",l.canvas)),r.invoke(e.onChange,0)},c.append(d),l.root.append(c)}return l.root}},Kv={name:"SignaturePad",description:"A signature capture pad — a DrawingCanvas tuned for signing, with a baseline and a Clear button. `onChange(pngDataUrl)` fires when the signature changes (empty string when cleared). Use in contracts, delivery confirmation, and consent flows.",props:[{name:"width",type:"number",optional:!0,description:"px (default 400)"},{name:"height",type:"number",optional:!0,description:"px (default 160)"},{name:"color",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,description:'(pngDataUrl|"") => …'}],render:(t,e,r)=>{const n=Math.max(120,Math.min(1200,P(e.width,400))),a=Math.max(80,Math.min(600,P(e.height,160))),i=He(e.color)||"#1a1a1a",o=Ls({width:n,height:a,stroke:i,lineWidth:2.5,background:"#ffffff",rootClass:"rui-signature-pad",onEnd:d=>r.invoke(e.onChange,d),helpers:r}),s=u("div",{class:"rui-signature-baseline"});o.root.append(s);const l=u("div",{class:"rui-canvas-toolbar"}),c=u("button",{type:"button",class:"rui-canvas-clear"},["Clear"]);return c.onclick=d=>{Es(zs(d,"rui-signature-pad",o.canvas)),r.invoke(e.onChange,"")},l.append(c),o.root.append(l),o.root}},Yv=/<script|<foreignObject|on\w+\s*=|javascript\s*:|<!ENTITY|<iframe|<embed|<object/i;function Xv(t){return!t||t.length>32768||Yv.test(t)?"":t}const Jv=/^[\d.\s-]+$/,js=[Wd,Gd,Yd,Kd,qd,mo,sp,lp,cp,Xd,Jd,Qd,Zd,rp,tp,ip,ap,gp,ep,up,pp,Dp,Op,$p,Cp,Ap,No,Mp,Np,Ip,fr,Ep,jp,Fp,wp,Bp,wm,xm,pm,mm,gm,fm,hm,vm,bm,ym,um,dm,Io,km,Sm,$m,Cm,Po,Am,Tm,pf,df,ff,mf,gf,hf,vf,bf,kf,Sf,$f,wf,Nf,If,Pf,Lf,zf,Yf,Fo,Of,Bf,Kf,Ff,_f,Hf,qf,Jf,Zf,eg,Xf,Vf,rg,qo,ag,sg,og,dg,pg,mg,fg,Em,Lm,lf,cf,zm,Dm,jm,Bm,Om,Fm,_m,uf,Um,Hm,Ro,of,Wm,Vm,qm,Gm,Km,Jm,Xm,Ym,Qm,Zm,tf,ef,rf,af,nf,yg,wg,$g,Cg,Ag,Mg,Ng,Pg,Rg,Eg,zg,Dg,Og,Fg,Ug,qg,Wg,Gg,Yg,Xg,Zg,th,rh,ah,ih,oh,sh,lh,ch,uh,ph,fh,hh,bh,vh,yh,xh,wh,kh,Sh,$h,Ch,Ah,Th,zh,jh,Dh,Oh,Bh,Fh,_h,Uh,Hh,qh,Vh,Wh,Gh,Yh,Xh,Jh,Qh,Zh,eb,Yp,Jp,Zp,em,tm,rm,am,No,wb,kb,Sb,$b,Cb,Tb,Ab,Mb,Nb,Pb,Ib,Eb,Rb,Lb,zb,jb,Fb,Ub,Hb,Wb,Gb,Kb,Yb,Xb,Jb,Qb,Zb,fs,ev,tv,rv,nv,av,iv,sv,uv,cv,dv,pv,mv,fv,gv,hv,bv,vv,yv,xv,{name:"Svg",description:"Render inline SVG markup safely (paths, shapes, gradients) — for brand illustrations, custom icons, and data-viz overlays without the HTMLTag escape hatch. Pass the inner markup (everything inside <svg>) plus a `viewBox`. Script/event-handler payloads are stripped.",props:[{name:"content",type:"string",positional:!0,required:!0,aliases:["paths","markup"]},{name:"viewBox",type:"string",optional:!0,description:'e.g. "0 0 24 24" (default)'},{name:"width",type:"string",optional:!0},{name:"height",type:"string",optional:!0},{name:"fill",type:"string",optional:!0,description:"currentColor (default), none, or a token color"}],render:(t,e)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","rui-svg");const a=m(e.viewBox,"0 0 24 24");n.setAttribute("viewBox",Jv.test(a)?a:"0 0 24 24");const i=m(e.fill,"currentColor");return n.setAttribute("fill",/^[a-zA-Z#()0-9,.\s-]+$/.test(i)?i:"currentColor"),e.width&&n.setAttribute("width",m(e.width).replace(/[^0-9a-z%.]/gi,"")),e.height&&n.setAttribute("height",m(e.height).replace(/[^0-9a-z%.]/gi,"")),n.setAttribute("aria-hidden","true"),n.innerHTML=Xv(m(e.content)),n}},{name:"Sheet",description:"A panel that slides in from an edge over a dimmed backdrop. `side` is left|right|top|bottom. Bind `open` to a $variable; `onClose` fires on backdrop click / Escape. Use BottomSheet for the mobile bottom variant.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"open",type:"boolean",optional:!0},{name:"side",type:"string",optional:!0,enum:["left","right","top","bottom"]},{name:"title",type:"string",optional:!0},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"]}],render:(t,e,r)=>{const n=I(e.open),a=u("div",{class:"rui-sheet-root","data-open":n?"true":"false","data-side":m(e.side,"right")}),i=t.argMeta?.find(p=>p?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1),r.invoke(e.onClose)},s=u("div",{class:"rui-sheet-backdrop"});s.onclick=o;const l=u("div",{class:"rui-sheet-panel",role:"dialog","aria-modal":"true",tabindex:"-1"}),c=m(e.title);if(c){const p=u("div",{class:"rui-sheet-head"});p.append(u("h3",{class:"rui-sheet-title",id:"rui-sheet-label"},[c])),l.setAttribute("aria-labelledby","rui-sheet-label");const f=u("button",{class:"rui-sheet-close",type:"button","aria-label":"Close"}),b=j("xmark");b&&f.append(b),f.onclick=o,p.append(f),l.append(p)}const d=u("div",{class:"rui-sheet-body"});for(const p of T(e.children))d.append(r.renderNode(p));return l.append(d),a.append(s,l),a.onkeydown=Pn(".rui-sheet-panel",()=>o()),Rn(a,".rui-sheet-panel",r),a}},{name:"BottomSheet",description:"A mobile bottom sheet — Sheet pinned to the bottom edge with a drag handle. Bind `open`; `onClose` on dismiss.",props:[{name:"children",type:"Node[]",positional:!0,required:!0,aliases:["content"]},{name:"open",type:"boolean",optional:!0},{name:"title",type:"string",optional:!0},{name:"onClose",type:"callable",optional:!0,aliases:["onclose"]}],render:(t,e,r)=>{const n=I(e.open),a=u("div",{class:"rui-sheet-root rui-bottomsheet","data-open":n?"true":"false","data-side":"bottom"}),i=t.argMeta?.find(p=>p?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1),r.invoke(e.onClose)},s=u("div",{class:"rui-sheet-backdrop"});s.onclick=o;const l=u("div",{class:"rui-sheet-panel",role:"dialog","aria-modal":"true",tabindex:"-1"});l.append(u("div",{class:"rui-bottomsheet-grip","aria-hidden":"true"}));const c=m(e.title);c&&l.append(u("h3",{class:"rui-sheet-title"},[c]));const d=u("div",{class:"rui-sheet-body"});for(const p of T(e.children))d.append(r.renderNode(p));return l.append(d),a.append(s,l),a.onkeydown=Pn(".rui-sheet-panel",()=>o()),Rn(a,".rui-sheet-panel",r),a}},{name:"ConfirmDialog",description:"A confirm/cancel modal dialog. Bind `open` to a $variable; `onConfirm` fires on accept, `onCancel`/backdrop on dismiss. `tone` colors the confirm button (danger for destructive actions).",props:[{name:"title",type:"string",positional:!0,required:!0},{name:"open",type:"boolean",optional:!0},{name:"message",type:"string",optional:!0,aliases:["body"]},{name:"confirmLabel",type:"string",optional:!0},{name:"cancelLabel",type:"string",optional:!0},{name:"tone",type:"string",optional:!0,enum:["primary","danger","warning"]},{name:"onConfirm",type:"callable",optional:!0},{name:"onCancel",type:"callable",optional:!0}],render:(t,e,r)=>{const n=I(e.open),a=u("div",{class:"rui-confirm-root","data-open":n?"true":"false"}),i=t.argMeta?.find(b=>b?.stateRef)?.stateRef,o=()=>{i&&r.setState(i,!1)},s=u("div",{class:"rui-confirm-backdrop"});s.onclick=()=>{r.invoke(e.onCancel),o()};const l=u("div",{class:"rui-confirm-card",role:"alertdialog","aria-modal":"true","aria-labelledby":"rui-confirm-label",tabindex:"-1"});l.append(u("h3",{class:"rui-confirm-title",id:"rui-confirm-label"},[m(e.title)]));const c=m(e.message);c&&l.append(u("p",{class:"rui-confirm-message"},[c]));const d=u("div",{class:"rui-confirm-actions"}),p=u("button",{class:"rui-confirm-cancel",type:"button"},[m(e.cancelLabel,"Cancel")]);p.onclick=()=>{r.invoke(e.onCancel),o()};const f=u("button",{class:"rui-confirm-ok",type:"button","data-tone":m(e.tone,"primary")},[m(e.confirmLabel,"Confirm")]);return f.onclick=()=>{r.invoke(e.onConfirm),o()},d.append(p,f),l.append(d),a.append(s,l),a.onkeydown=Pn(".rui-confirm-card",()=>{r.invoke(e.onCancel),o()}),Rn(a,".rui-confirm-card",r),a}},{name:"PresenceAvatars",description:"An overlapping stack of avatars with online status dots — 'who's here' for collab/social. Pass `people` as {name, src?, online?}.",props:[{name:"people",type:"object[]",positional:!0,required:!0,aliases:["users","children"]},{name:"max",type:"number",optional:!0,description:"Max avatars before a +N chip (default 5)"}],render:(t,e)=>{const r=T(e.people),n=Math.max(1,Math.round(P(e.max,5))),a=u("div",{class:"rui-presence"});return r.slice(0,n).forEach(i=>{const o=i??{},s=u("div",{class:"rui-presence-avatar","data-online":I(o.online)?"true":null,title:m(o.name)}),l=ie(o.src);l?s.append(u("img",{src:l,alt:m(o.name)})):s.append(u("span",{class:"rui-presence-initials"},[m(o.name).split(/\s+/).filter(Boolean).slice(0,2).map(c=>c[0].toUpperCase()).join("")])),a.append(s)}),r.length>n&&a.append(u("div",{class:"rui-presence-more"},[`+${r.length-n}`])),a}},{name:"ShareButtons",description:"A row of social share buttons (twitter|facebook|linkedin|reddit|email) plus a copy-link button, for the given `url`/`title`.",props:[{name:"url",type:"string",positional:!0,required:!0},{name:"title",type:"string",optional:!0},{name:"networks",type:"string[]",optional:!0,description:"Which to show (default twitter, facebook, linkedin, copy)"}],render:(t,e)=>{const r=qe(e.url,""),n=m(e.title),a=encodeURIComponent(r),i=encodeURIComponent(n),o=T(e.networks).map(d=>m(d)),s=o.length>0?o:["twitter","facebook","linkedin","copy"],l={twitter:{icon:"brands:x-twitter",href:`https://twitter.com/intent/tweet?url=${a}&text=${i}`},facebook:{icon:"brands:facebook",href:`https://www.facebook.com/sharer/sharer.php?u=${a}`},linkedin:{icon:"brands:linkedin",href:`https://www.linkedin.com/sharing/share-offsite/?url=${a}`},reddit:{icon:"brands:reddit",href:`https://www.reddit.com/submit?url=${a}&title=${i}`},email:{icon:"envelope",href:`mailto:?subject=${i}&body=${a}`}},c=u("div",{class:"rui-share"});for(const d of s){if(d==="copy"){const h=u("button",{class:"rui-share-btn",type:"button","aria-label":"Copy link",title:"Copy link"}),g=j("link");g&&h.append(g),h.onclick=()=>{try{navigator.clipboard?.writeText(r)}catch{}},c.append(h);continue}const p=l[d];if(!p)continue;const f=u("a",{class:"rui-share-btn",href:p.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Share on ${d}`}),b=j(p.icon);b&&f.append(b),c.append(f)}return c}},{name:"AuthorByline",description:"An author byline: avatar, name, optional role and date — for articles/blog posts.",props:[{name:"name",type:"string",positional:!0,required:!0},{name:"avatar",type:"string",optional:!0,aliases:["src"]},{name:"role",type:"string",optional:!0},{name:"date",type:"string",optional:!0}],render:(t,e)=>{const r=u("div",{class:"rui-byline"}),n=ie(e.avatar),a=u("div",{class:"rui-byline-avatar"});n?a.append(u("img",{src:n,alt:m(e.name)})):a.append(u("span",{},[m(e.name).split(/\s+/).filter(Boolean).slice(0,2).map(s=>s[0].toUpperCase()).join("")])),r.append(a);const i=u("div",{class:"rui-byline-meta"});i.append(u("div",{class:"rui-byline-name"},[m(e.name)]));const o=[m(e.role),m(e.date)].filter(Boolean).join(" · ");return o&&i.append(u("div",{class:"rui-byline-sub"},[o])),r.append(i),r}},{name:"VariantSelector",description:"Product variant picker — color swatches or size pills. `options` is an array of strings or {label, value, color?}. Bind `value` to a $variable; `onChange(value)` fires on select.",props:[{name:"options",type:"any[]",positional:!0,required:!0,aliases:["items"]},{name:"value",type:"string",optional:!0},{name:"kind",type:"string",optional:!0,enum:["pill","swatch"]},{name:"label",type:"string",optional:!0},{name:"onChange",type:"callable",optional:!0,aliases:["onchange"]}],render:(t,e,r)=>{const n=m(e.kind,"pill"),a=u("div",{class:"rui-variants","data-kind":n}),i=m(e.label);i&&a.append(u("div",{class:"rui-variants-label"},[i]));const o=u("div",{class:"rui-variants-row"}),s=m(e.value),l=t.argMeta?.find(c=>c?.stateRef)?.stateRef;for(const c of T(e.options)){const d=c&&typeof c=="object"?c:{label:c,value:c},p=m(d.value??d.label),f=p===s,b=u("button",{class:"rui-variant",type:"button","aria-pressed":f?"true":"false","data-selected":f?"true":null});if(n==="swatch"){const h=m(d.color??d.value);b.style.background=/^[a-zA-Z#()0-9,.\s-]+$/.test(h)?h:"var(--rui-color-surface-muted)",b.title=m(d.label??d.value)}else b.textContent=m(d.label??d.value);b.onclick=()=>{l&&r.setState(l,p),r.invoke(e.onChange,p)},o.append(b)}return a.append(o),a}},{name:"OrderSummary",description:"An order/cart summary: line items, subtotal, shipping, tax, and a bold total. Pass `items` as {label, amount} and the named totals; `currency` prefixes amounts.",props:[{name:"items",type:"object[]",positional:!0,required:!0,aliases:["lines"]},{name:"subtotal",type:"string | number",optional:!0},{name:"shipping",type:"string | number",optional:!0},{name:"tax",type:"string | number",optional:!0},{name:"total",type:"string | number",optional:!0},{name:"currency",type:"string",optional:!0}],render:(t,e)=>{const r=m(e.currency,"$"),n=s=>s==null||m(s)===""?"":`${r}${m(s)}`,a=u("div",{class:"rui-order-summary"}),i=u("div",{class:"rui-order-lines"});for(const s of T(e.items)){const l=s??{},c=u("div",{class:"rui-order-line"});c.append(u("span",{},[m(l.label)]),u("span",{},[n(l.amount)])),i.append(c)}a.append(i);const o=(s,l,c=!1)=>{if(l==null||m(l)==="")return;const d=u("div",{class:c?"rui-order-total":"rui-order-sub"});d.append(u("span",{},[s]),u("span",{},[n(l)])),a.append(d)};return o("Subtotal",e.subtotal),o("Shipping",e.shipping),o("Tax",e.tax),o("Total",e.total,!0),a}},{name:"ScrollSpy",description:"A sticky in-page nav that highlights the section currently in view. `sections` is an array of {label, id} matching element ids on the page (set via the universal `id` prop). Clicking smooth-scrolls to a section.",props:[{name:"sections",type:"object[]",positional:!0,required:!0,aliases:["items"]},{name:"title",type:"string",optional:!0}],render:(t,e,r)=>{const n=u("nav",{class:"rui-scrollspy","aria-label":"On this page"}),a=m(e.title);a&&n.append(u("div",{class:"rui-scrollspy-title"},[a]));const i=u("ul",{class:"rui-scrollspy-list"}),o=T(e.sections).map(l=>{const c=l??{};return{label:m(c.label),id:m(c.id).replace(/[^A-Za-z0-9_-]/g,"")}}).filter(l=>l.id),s=new Map;for(const l of o){const c=u("li",{class:"rui-scrollspy-item"}),d=u("a",{href:`#${l.id}`},[l.label]);d.onclick=p=>{p.preventDefault(),(d.getRootNode()?.getElementById?.(l.id)??document.getElementById(l.id))?.scrollIntoView({behavior:"smooth",block:"start"})},c.append(d),i.append(c),s.set(l.id,d)}return n.append(i),typeof IntersectionObserver<"u"&&setTimeout(()=>{const l=n.getRootNode(),c=new IntersectionObserver(d=>{for(const p of d)if(p.isIntersecting){s.forEach(b=>b.classList.remove("is-active"));const f=p.target.id;s.get(f)?.classList.add("is-active")}},{rootMargin:"0px 0px -70% 0px",threshold:0});for(const d of o){const p=l.getElementById?.(d.id)??document.getElementById(d.id);p&&c.observe(p)}r.registerDisposer(()=>c.disconnect(),"rui-scrollspy-io")},0),n}},{name:"SpeedDial",description:"A floating action button that expands a stack of mini-actions on click. Pass `actions` as {icon, label, onClick}.",props:[{name:"actions",type:"object[]",positional:!0,required:!0,aliases:["items"]},{name:"icon",type:"string",optional:!0,description:"Main FAB icon (default 'plus')"}],render:(t,e,r)=>{const n=u("div",{class:"rui-speeddial"}),a=u("div",{class:"rui-speeddial-menu"});for(const s of T(e.actions)){const l=s??{},c=u("button",{class:"rui-speeddial-action",type:"button",title:m(l.label),"aria-label":m(l.label)}),d=j(l.icon??"circle");d&&c.append(d),c.onclick=p=>{r.invoke(l.onClick??l.action),((p.currentTarget??p.target)?.closest(".rui-speeddial")??n).classList.remove("is-open")},a.append(c)}n.append(a);const i=u("button",{class:"rui-speeddial-fab",type:"button","aria-label":"Actions","aria-expanded":"false"}),o=j(e.icon??"plus",{size:"lg"});return o&&i.append(o),i.onclick=s=>{const l=s.currentTarget??s.target??i,d=(l.closest(".rui-speeddial")??n).classList.toggle("is-open");l.setAttribute("aria-expanded",d?"true":"false")},n.append(i),n}},{name:"Confetti",description:"A one-shot confetti burst — celebration affordance after a success (checkout, completion). Renders a short CSS particle animation when `fire` is true. Honours prefers-reduced-motion.",props:[{name:"fire",type:"boolean",optional:!0,description:"Trigger the burst (default true)"},{name:"count",type:"number",optional:!0,description:"Particle count (default 40, max 120)"}],render:(t,e)=>{const r=u("div",{class:"rui-confetti","aria-hidden":"true"}),n=e.fire===void 0?!0:I(e.fire),a=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(!n||a)return r;const i=Math.max(1,Math.min(120,Math.round(P(e.count,40)))),o=["#6366f1","#8b5cf6","#ec4899","#22d3ee","#10b981","#f59e0b"];for(let s=0;s<i;s+=1){const l=Math.round((s*53+7)%100),c=s*17%50/100,d=1+s*7%10/10,p=o[s%o.length],f=s*47%360,b=u("span",{class:"rui-confetti-piece",style:`left:${l}%;background:${p};animation-delay:${c}s;animation-duration:${d}s;transform:rotate(${f}deg)`});b.onanimationend=h=>{(h.currentTarget??h.target)?.remove()},r.append(b)}return r}},{name:"KbdShortcut",description:'Render a keyboard shortcut as styled key caps. Pass `keys` as an array (e.g. ["Cmd", "K"]) or a \'+\'-joined string.',props:[{name:"keys",type:"string | string[]",positional:!0,required:!0}],render:(t,e)=>{const r=e.keys,n=Array.isArray(r)?r.map(i=>m(i)):m(r).split("+").map(i=>i.trim()).filter(Boolean),a=u("span",{class:"rui-kbd-shortcut"});return n.forEach((i,o)=>{o>0&&a.append(u("span",{class:"rui-kbd-plus"},["+"])),a.append(u("kbd",{class:"rui-kbd-key"},[i]))}),a}},{name:"Lottie",description:"Plays a Lottie/Bodymovin vector animation from `src` (a .json URL) or inline `data`. Uses the `lottie-web` library when it is present on the page (`window.lottie`); otherwise shows the `fallback` (or a poster image) so the layout never breaks. `loop`/`autoplay` default true; `speed` scales playback. No dependency is bundled.",props:[{name:"src",type:"string",optional:!0,description:"URL to a Lottie JSON file"},{name:"data",type:"object",optional:!0,description:"Inline Lottie animation data"},{name:"loop",type:"boolean",optional:!0},{name:"autoplay",type:"boolean",optional:!0},{name:"speed",type:"number",optional:!0},{name:"width",type:"string",optional:!0},{name:"height",type:"string",optional:!0},{name:"poster",type:"string",optional:!0,description:"Image shown when lottie-web is unavailable"},{name:"fallback",type:"Node",optional:!0,description:"Node shown when lottie-web is unavailable and no poster"}],render:(t,e,r)=>{const n=m(e.width,"200px"),a=m(e.height,"200px"),i=u("div",{class:"rui-lottie",style:`width:${n};height:${a}`}),o=typeof window<"u"?window.lottie:null,s=e.data&&typeof e.data=="object"?e.data:null,l=ie(e.src);if(!o||!s&&!l){const c=ie(e.poster);return c?i.append(u("img",{src:c,alt:"animation",class:"rui-lottie-poster",style:"width:100%;height:100%;object-fit:contain"})):e.fallback!=null?i.append(r.renderNode(e.fallback)):i.classList.add("rui-lottie-empty"),i}return setTimeout(()=>{try{const c=o.loadAnimation({container:i,renderer:"svg",loop:e.loop===void 0?!0:I(e.loop),autoplay:e.autoplay===void 0?!0:I(e.autoplay),...s?{animationData:s}:{path:l}}),d=P(e.speed,1);d!==1&&typeof c.setSpeed=="function"&&c.setSpeed(d),r.registerDisposer(()=>{try{c.destroy?.()}catch{}},"rui-lottie")}catch{i.classList.add("rui-lottie-empty")}},0),i}},wv,kv,Sv,$v,Dv,Ov,Bv,Fv,Uv,Vv,Gv,Kv,lb,mb,bb,xb],Qv=[{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 `none|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl` (`none` = 0); `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","Toasts","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. Use `Banner` for top-of-page announcements and `Notification` for permanent inbox entries.","- `Toasts(children, position?)` stacks toasts in a viewport corner. Pair it with the `$toast` namespace: `Toasts($toast.items.map(t => Toast({ title: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))`.","- `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 rendering until the async `loader` resolves, showing `fallback` while pending (a synchronous loader value renders immediately).","- `ErrorBoundary(fallback?, onError?, children)` catches rendering errors thrown by descendants."]},{name:"Behaviour wrappers",components:["OnClick","OnMouse","OnKeyboard","OnFocus","OnIntersect","OnMount","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.","- `OnMount(child, { onMount?, onUnmount? })` is the DOM-ref / lifecycle wrapper. `onMount(node)` fires once after the wrapped element attaches; `onUnmount(node)` fires when it leaves the tree. Use it to measure or focus an element, or to hand a node to an imperative library (chart / map / editor). Stash the node in a `$ref(...)`.","- `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:"Interop",components:["Mount","WebComponent"],notes:["- Interop primitives are the bridge to imperative / third-party libraries that own their own DOM. Reach for them ONLY when a real widget (chart, map, editor, payment element, captcha) cannot be expressed with built-in components.",'- `Mount({ setup, update?, cleanup?, props?, tag?, sx? })` is the managed imperative-component host. `setup(node, props)` runs once after the host attaches and returns an instance handle; `update(instance, props)` runs when the (shallow-compared) `props` bag changes; `cleanup(instance)` runs on unmount. Aktion owns + preserves the host element so the widget is never rebuilt mid-session. Example: `Mount({ sx: { h: "320px" }, setup: (node, p) => new Chart(node, p.config), update: (c, p) => { c.data = p.data; c.update() }, cleanup: c => c.destroy(), props: { config: $cfg, data: $series } })`.','- `WebComponent(tag, { attributes?, properties?, on?, children? })` renders + hydrates a native custom element. `attributes` is reactive (re-applies on `$state` change); `properties` assigns rich JS props; `on` binds event listeners that stay current across renders. Example: `WebComponent("stripe-pricing-table", { attributes: { "pricing-table-id": $id, "publishable-key": $pk }, on: { checkout: e => route.navigate("/thanks") } })`.',"- Pair these with the `$script({ src, global? })` loader (gate a widget on its SDK being ready) and the `$dom` observer namespace (`$dom.onResize`/`onIntersect`/`measure`) for layout-aware widgets."]},{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."]}];Ji(js);const Tt={root:"Column",components:js,componentGroups:Qv},Zv=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},ey=t=>{const e=t.props.map(r=>r.optional?`${r.name}?`:r.name);return`${t.name}(${e.join(", ")})`},ty=t=>{const e=new Map;for(const r of t.componentGroups??[])for(const n of r.components)e.set(n,r.name);return e};function Ds(t=Tt){const e=ty(t);return t.components.map(r=>({name:r.name,group:e.get(r.name)??"Other",description:r.description,params:r.props.map(Zv),signature:ey(r)}))}function Os(t){const e={};for(const r of t)e[r.name]=r;return e}[...kn].join("|"),[...kn].join("|");const Bs=t=>!!(t&&typeof t=="object"&&t.kind==="Theme");function Fs(t,e){return e.length===0?t:`${t}.${e.join(".")}`}function _s(t,e){return!!(t===e||e.startsWith(t+".")||t.startsWith(e+"."))}function Kn(t,e){if(t.has(e))return!0;for(const r of t)if(_s(r,e))return!0;return!1}function Bt(t,e){for(const r of e)if(Kn(t,r))return!0;return!1}class Yn{constructor(){O(this,"values",new Map);O(this,"defaults",new Map);O(this,"subscribers",new Set);O(this,"pendingChanges",new Set);O(this,"flushScheduled",!1);O(this,"rendering",!1);O(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,n){if(r.length===0){this.set(e,n);return}const a=this.values.get(e),i=Ft(a,r,0,n);this.values.set(e,i),this.enqueueChange(Fs(e,r))}entries(){return this.values.entries()}snapshot(){const e={};return this.values.forEach((r,n)=>{e[n]=r}),e}hydrate(e){for(const[r,n]of Object.entries(e))this.values.set(r,n)}reset(...e){for(const r of e){if(!this.defaults.has(r))continue;const n=this.defaults.get(r);this.values.get(r)!==n&&(this.values.set(r,n),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,n]of e)this.defaults.set(r,n),this.values.set(r,n)}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 Ft(t,e,r,n){if(r>=e.length)return n;const a=e[r],i=a!==""&&!Number.isNaN(Number(a))?Number(a):null;if(Array.isArray(t)&&i!==null){const s=t.slice();return s[i]=Ft(t[i],e,r+1,n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){const s={...t};return s[a]=Ft(t[a],e,r+1,n),s}if(i!==null){const s=[];return s[i]=Ft(void 0,e,r+1,n),s}const o={};return o[a]=Ft(void 0,e,r+1,n),o}const Ir=Symbol("aktion.httpResource");function Us(t){return typeof t=="object"&&t!==null&&t[Ir]===!0}class Xn{constructor(){O(this,"interceptors",{});O(this,"programInterceptors",{})}registerInterceptors(e){this.interceptors={...this.interceptors,...e}}registerProgramInterceptors(e){this.programInterceptors={...this.programInterceptors,...e}}clearProgramInterceptors(){this.programInterceptors={}}fireError(e,r){this.interceptors.onError?.(e,r),this.programInterceptors.onError?.(e,r)}resolveUrl(e){return e}async request(e){let r={...e,headers:{...e.headers}};const n=[this.interceptors.onRequest,this.programInterceptors.onRequest];for(const i of n)if(i)try{r=await i(r)}catch(o){throw this.fireError(o,r),o}const a=async()=>{const i=new AbortController,o=typeof fetch=="function"?fetch:null;if(!o)throw new Error("`fetch` is not available in this environment");const s={...r.init,method:r.method,headers:r.headers,signal:r.signal??i.signal};r.body!==void 0&&r.method!=="GET"&&r.method!=="HEAD"&&(s.body=ry(r.body,r.headers));const l=await o(r.url,s),c={};l.headers.forEach((f,b)=>{c[b]=f});const d=c["content-type"]??"";let p;return l.status===204||r.method==="HEAD"?p=null:d.includes("application/json")?p=await l.json().catch(()=>null):p=await l.text().catch(()=>""),{status:l.status,headers:c,body:p}};try{let i=await a();const o=[this.programInterceptors.onResponse,this.interceptors.onResponse];for(const s of o){if(!s)continue;let l=!1;i=await s(i,async()=>l?i:(l=!0,a()))}return i}catch(i){throw this.fireError(i,r),i}}}function ry(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 ny=new Set(["url","method","headers","body","query","signal","gql","variables","optimistic","invalidates"]);function Jn(t,e){const n=(Array.isArray(e)?e:e!=null?[e]:[]).map(a=>String(a)).filter(Boolean);if(n.length!==0)for(const[a,i]of t.queryCache)n.some(o=>a.includes(o))&&(i.loading||i.refetch())}function Qn(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=typeof e.url=="string"?e.url:"",n=typeof e.gql=="string"&&e.gql.trim().length>0,a=n?"POST":typeof e.method=="string"?e.method.toUpperCase():"GET",i={};if(e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers))for(const[c,d]of Object.entries(e.headers))d!=null&&(i[c]=String(d));let o=r;if(e.query&&typeof e.query=="object"&&!Array.isArray(e.query)){const c=new URLSearchParams;for(const[p,f]of Object.entries(e.query))f!=null&&c.append(p,String(f));const d=c.toString();d&&(o+=(o.includes("?")?"&":"?")+d)}const s={};for(const[c,d]of Object.entries(e))ny.has(c)||(s[c]=d);const l={url:o,method:a,headers:i,body:n?{query:e.gql,variables:Ke(e.variables)}:e.body};return Object.keys(s).length>0&&(l.init=s),e.signal instanceof AbortSignal&&(l.signal=e.signal),l}function Zn(t,e){const r={state:"loading",data:void 0,error:void 0,loading:!0,refetch:async()=>{await o()},cancel:()=>{a+=1,n&&n.abort(),n=null,r.loading&&(r.loading=!1,r.state=r.data===void 0?"idle":"data",i())}};Object.defineProperty(r,Ir,{value:!0,enumerable:!1,writable:!1});let n=null,a=0;const i=()=>e.notify?.(),o=async()=>{const s=a+=1;n&&n.abort(),n=new AbortController;const l=n;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=Qn(t);c.url=e.http.resolveUrl(c.url),c.signal=l.signal;const d=await e.http.request(c);if(s!==a)return;const p=d.status>=200&&d.status<300,f=typeof Ke(t).gql=="string",b=f?Ke(d.body):null,h=b&&Array.isArray(b.errors)&&b.errors.length>0?b.errors:null;p&&!h?(r.data=f?b.data:d.body,r.state="data",r.error=void 0):(r.error=h?{graphqlErrors:h}:{status:d.status,body:d.body},r.state="error"),r.status=d.status,r.headers=d.headers,r.lastUpdated=Date.now()}catch(c){if(s!==a||c?.name==="AbortError")return;r.error=c,r.state="error"}finally{if(s===a&&(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 Ke(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Hs(t){return t===!0||t==="true"}function qs(t){const e=typeof t.method=="string"?t.method.toUpperCase():"GET",r=typeof t.url=="string"?t.url:"";let n="null",a="null";try{n=JSON.stringify(t.query??null)}catch{}try{a=JSON.stringify(t.body??null)}catch{}let i="null";if(typeof t.gql=="string"){let o="null";try{o=JSON.stringify(t.variables??null)}catch{}i=`${t.gql}|${o}`}return`${e} ${r} ${n} ${a} ${i}`}function Vs(t,e){const r=Ke(t);if(r.infinite&&typeof r.infinite=="object"){const d=r.key!=null?String(r.key):qs(r),p=e.queryCache.get(d);if(p)return p;const f=ay(r,e);return e.queryCache.set(d,f),f}const n=typeof r.ttl=="number"?r.ttl:0,a=r.key!=null?String(r.key):qs(r),i=e.queryCache,o=i.get(a);if(o)return n>0&&o.lastUpdated!=null&&Date.now()-o.lastUpdated>n&&!o.loading&&o.refetch(),o;const s={};for(const[d,p]of Object.entries(r))d==="key"||d==="ttl"||d==="refetchInterval"||d==="refetchOnFocus"||d==="refetchOnReconnect"||(s[d]=p);const l=Zn(s,e);i.set(a,l);const c=typeof r.refetchInterval=="number"?r.refetchInterval:0;if(c>0){const d=setInterval(()=>{l.loading||l.refetch()},Math.max(250,c));e.disposers.push(()=>clearInterval(d))}if(Hs(r.refetchOnFocus)&&typeof window<"u"){const d=()=>{l.loading||l.refetch()};window.addEventListener("focus",d),e.disposers.push(()=>window.removeEventListener("focus",d))}if(Hs(r.refetchOnReconnect)&&typeof window<"u"){const d=()=>{l.loading||l.refetch()};window.addEventListener("online",d),e.disposers.push(()=>window.removeEventListener("online",d))}return l}function ay(t,e){const r=Ke(t.infinite),n=typeof r.param=="string"?r.param:"page",a=typeof r.limit=="number"&&r.limit>0?r.limit:20,i=typeof r.start=="number"?r.start:r.mode==="offset"?0:1,o=r.mode==="offset"?"offset":"page",s=typeof r.select=="function"?r.select:null,l=()=>e.notify?.(),c=[];let d=i,p=!1;const f={};for(const[v,x]of Object.entries(t))v==="key"||v==="ttl"||v==="infinite"||(f[v]=x);const b=v=>{const x=s?s(v):v;return Array.isArray(x)?x:[]},h=()=>{const v=[];for(const x of c)for(const w of b(x))v.push(w);return v},g={state:"loading",data:[],error:void 0,loading:!0,hasMore:!0,loadingMore:!1,page:i,pages:c,refetch:async()=>{p||(c.length=0,d=i,g.hasMore=!0,await y(!0))},cancel:()=>{},loadMore:async()=>{p||!g.hasMore||await y(!1)}};Object.defineProperty(g,Ir,{value:!0,enumerable:!1,writable:!1});const y=async v=>{if(!e.http){g.error={message:"http runtime not available"},g.state="error",g.loading=!1,l();return}p=!0,v||c.length===0?(g.loading=!0,g.state=c.length?"stale":"loading"):g.loadingMore=!0,l();try{const x=d,w={...f,query:{...Ke(f.query),[n]:x,limit:a}},k=Qn(w);k.url=e.http.resolveUrl(k.url);const A=await e.http.request(k);if(!(A.status>=200&&A.status<300)){g.error={status:A.status,body:A.body},g.state="error";return}const $=b(A.body);c.push(A.body),g.hasMore=$.length>=a,d=o==="offset"?d+a:d+1,g.page=o==="offset"?c.length:d-1,g.data=h(),g.error=void 0,g.state="data",g.lastUpdated=Date.now()}catch(x){if(x?.name==="AbortError")return;g.error=x,g.state="error"}finally{p=!1,g.loading=!1,g.loadingMore=!1,l()}};return y(!0),g}function Ws(t,e){const r=Ke(t);let n=0,a=null;const i=()=>e.notify?.(),o={data:void 0,error:void 0,loading:!1,reset:()=>{n+=1,a&&a.abort(),a=null,o.data=void 0,o.error=void 0,o.status=void 0,o.loading=!1,i()},mutate:async s=>{const l=n+=1;a&&a.abort(),a=new AbortController;const c=a;o.loading=!0,o.error=void 0;const d=r.optimistic;let p=null;if(typeof d=="function"){const f=new Map;for(const[b,h]of e.state.entries())f.set(b,h);p=()=>{for(const[b]of e.state.entries())f.has(b)||e.state.set(b,void 0);for(const[b,h]of f)e.state.set(b,h);e.notify?.()};try{d(Ke(s))}catch{}}if(i(),!e.http){o.error={message:"http runtime not available"},o.loading=!1,p&&p(),i();return}try{const f={method:"POST",...r,...Ke(s)},b=Qn(f);b.url=e.http.resolveUrl(b.url),b.signal=c.signal;const h=await e.http.request(b);if(l!==n)return;const g=h.status>=200&&h.status<300;return g?(o.data=h.body,o.error=void 0,r.invalidates!=null&&Jn(e,r.invalidates)):(o.error={status:h.status,body:h.body},p&&p()),o.status=h.status,g?h.body:void 0}catch(f){if(l!==n||f?.name==="AbortError")return;o.error=f,p&&p();return}finally{if(l===n&&(o.loading=!1,i(),typeof o.onDone=="function"))try{o.onDone(o)}catch(f){console.error("[aktion] $mutation onDone callback threw",f)}}}};return Object.defineProperty(o,Ir,{value:!0,enumerable:!1,writable:!1}),o}function Gs(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Ks(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}const iy=100,oy=500,sy=15e3;function ly(t,e){const r=Gs(t),n=typeof r.url=="string"?r.url:"",a=typeof r.bufferSize=="number"&&r.bufferSize>0?Math.floor(r.bufferSize):50,i=typeof r.onMessage=="function"?r.onMessage:null,o=r.reconnect===!0?1/0:typeof r.reconnect=="number"&&r.reconnect>0?Math.floor(r.reconnect):0,s=()=>e.notify?.(),l={connected:!1,status:"closed",messages:[],last:null,error:void 0,attempts:0,send:()=>{},close:()=>{}},c=v=>{l.status!==v&&(l.status=v,l.connected=v==="open",s())};if(!n||typeof WebSocket>"u")return l.error={message:"WebSocket not available"},l;let d=null,p=!1,f=null;const b=[],h=()=>{for(;b.length>0&&d&&d.readyState===WebSocket.OPEN;)d.send(b.shift())},g=()=>{if(p||l.attempts>=o){c("closed");return}l.attempts+=1;const v=Math.min(sy,oy*2**(l.attempts-1));c("connecting"),f=setTimeout(()=>{f=null,y()},v)},y=()=>{let v;try{v=r.protocols!=null?new WebSocket(n,r.protocols):new WebSocket(n)}catch(x){l.error=x,c("closed");return}d=v,c("connecting"),v.addEventListener("open",()=>{d===v&&(l.error=void 0,l.attempts=0,c("open"),h())}),v.addEventListener("close",()=>{d===v&&(!p&&o>0?g():c("closed"))}),v.addEventListener("error",x=>{d===v&&(l.error=x,s())}),v.addEventListener("message",x=>{if(d!==v)return;const w=Ks(x.data);if(l.last=w,l.messages=[...l.messages,w].slice(-a),i)try{i(w)}catch{}s()})};return l.send=v=>{const x=typeof v=="string"?v:JSON.stringify(v);if(d&&d.readyState===WebSocket.OPEN){d.send(x);return}l.status==="connecting"&&b.length<iy&&b.push(x)},l.close=()=>{p=!0,f!=null&&(clearTimeout(f),f=null),b.length=0;try{d?.close()}catch{}c("closed")},y(),e.disposers.push(()=>{p=!0,f!=null&&(clearTimeout(f),f=null);try{d?.close()}catch{}}),l}function cy(t,e){const r=Gs(t),n=typeof r.url=="string"?r.url:"",a=typeof r.bufferSize=="number"&&r.bufferSize>0?Math.floor(r.bufferSize):50,i=typeof r.event=="string"&&r.event?r.event:"message",o=typeof r.onMessage=="function"?r.onMessage:null,s=()=>e.notify?.(),l={connected:!1,status:"closed",messages:[],last:null,error:void 0,close:()=>{}};if(!n||typeof EventSource>"u")return l.error={message:"EventSource not available"},l;let c=null;try{c=new EventSource(n,{withCredentials:r.withCredentials===!0})}catch(p){return l.error=p,l}const d=c;return l.status="connecting",l.close=()=>{try{d.close()}catch{}l.connected=!1,l.status="closed",s()},d.addEventListener("open",()=>{l.connected=!0,l.status="open",l.error=void 0,s()}),d.addEventListener("error",p=>{l.error=p,l.connected=!1,l.status=d.readyState===2?"closed":"connecting",s()}),d.addEventListener(i,p=>{const f=Ks(p.data);if(l.last=f,l.messages=[...l.messages,f].slice(-a),o)try{o(f)}catch{}s()}),e.disposers.push(()=>{try{d.close()}catch{}}),l}function Pr(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}const Ys=new Map;function uy(t,e){return e==="style"||e==="stylesheet"||e==="css"?!0:/\.css(\?|#|$)/i.test(t)}function dy(t,e){return new Promise((r,n)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=t;for(const[i,o]of Object.entries(e))o==null||/^on/i.test(i)||a.setAttribute(i,o===!0?"":String(o));a.addEventListener("load",()=>r(!0)),a.addEventListener("error",()=>n(new Error(`[aktion] $script failed to load stylesheet: ${t}`))),document.head.appendChild(a)})}function py(t,e){return new Promise((r,n)=>{const a=()=>e.global?globalThis[e.global]??!0:!0,i=document.createElement("script");i.src=t,i.async=!0,e.type&&(i.type=e.type);for(const[o,s]of Object.entries(e.attributes))s==null||/^on/i.test(o)||i.setAttribute(o,s===!0?"":String(s));i.addEventListener("load",()=>r(a())),i.addEventListener("error",()=>n(new Error(`[aktion] $script failed to load: ${t}`))),document.head.appendChild(i)})}function my(t,e){const r=Pr(t),n=typeof r.src=="string"?r.src:"",a=typeof r.global=="string"?r.global:void 0,i=typeof r.type=="string"?r.type:void 0,o=typeof r.as=="string"?r.as.toLowerCase():"",s=Pr(r.attributes),l=()=>e.notify?.(),c={ready:!1,loading:!1,error:null,value:null};if(!n)return c.error=new Error("[aktion] $script requires a `src`."),c;if(typeof document>"u"||typeof document.createElement!="function")return c;let d=Ys.get(n);if(!d){const f=uy(n,o)?dy(n,s):py(n,{global:a,type:i,attributes:s});d={promise:f,settled:!1,value:null,error:null},f.then(b=>{d.settled=!0,d.value=b},b=>{d.settled=!0,d.error=b}),Ys.set(n,d)}if(d.settled)return d.error!=null?c.error=d.error:(c.ready=!0,c.value=a?globalThis[a]??d.value:d.value),c;c.loading=!0;let p=!0;return d.promise.then(f=>{p&&(c.loading=!1,c.ready=!0,c.value=a?globalThis[a]??f:f,l())},f=>{p&&(c.loading=!1,c.error=f,l())}),e.disposers.push(()=>{p=!1}),c}const ea=()=>{};function Rr(t){return t instanceof Element?t:null}function ta(t){return typeof t=="function"?t:null}function fy(t){const e=()=>t.notify?.(),r=n=>{let a=!1;const i=()=>{if(!a){a=!0;try{n()}catch{}}};return t.disposers.push(i),i};return{onResize(n,a){const i=Rr(n),o=ta(a);if(!i||!o||typeof ResizeObserver>"u")return ea;const s=new ResizeObserver(l=>{for(const c of l){const d=c.contentRect;try{o({width:d.width,height:d.height,entry:c})}catch{}}e()});return s.observe(i),r(()=>s.disconnect())},onIntersect(n,a,i){const o=Rr(n),s=ta(a);if(!o||!s||typeof IntersectionObserver>"u")return ea;const l=new IntersectionObserver(c=>{for(const d of c)try{s(d)}catch{}e()},Pr(i));return l.observe(o),r(()=>l.disconnect())},onMutation(n,a,i){const o=Rr(n),s=ta(a);if(!o||!s||typeof MutationObserver>"u")return ea;const l=Pr(i),c=new MutationObserver(d=>{try{s(d)}catch{}e()});return c.observe(o,{childList:l.childList!==!1,attributes:l.attributes!==!1,subtree:l.subtree===!0,characterData:l.characterData===!0}),r(()=>c.disconnect())},measure(n){const a=Rr(n);if(!a)return null;const i=typeof a.getBoundingClientRect=="function"?a.getBoundingClientRect():{width:0,height:0,top:0,left:0,right:0,bottom:0},o=a;return{rect:i,scroll:{top:o.scrollTop??0,left:o.scrollLeft??0,width:o.scrollWidth??0,height:o.scrollHeight??0},viewport:{width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}}}}}function Mt(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Be(t){return String(t??"").replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function gy(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function hy(t){const e=Mt(t),r={meta:{},og:{},twitter:{},link:[],jsonLd:[],htmlAttrs:{}};if(typeof e.title=="string"){const l=typeof e.titleTemplate=="string"?e.titleTemplate:"";r.title=l?l.replace("%s",e.title):e.title}const n=Mt(e.meta);for(const[l,c]of Object.entries(n))c!=null&&(r.meta[l]=String(c));const a=Mt(e.og);for(const[l,c]of Object.entries(a))c!=null&&(r.og[l]=String(c));const i=Mt(e.twitter);for(const[l,c]of Object.entries(i))c!=null&&(r.twitter[l]=String(c));const o=Array.isArray(e.link)?e.link:e.link!=null?[e.link]:[];for(const l of o){const c=Mt(l),d={};for(const[p,f]of Object.entries(c))f!=null&&(d[p]=String(f));Object.keys(d).length>0&&r.link.push(d)}if(e.jsonLd!=null){const l=Array.isArray(e.jsonLd)?e.jsonLd:[e.jsonLd];for(const c of l)if(c&&typeof c=="object"){const d=c;r.jsonLd.push("@context"in d?d:{"@context":"https://schema.org",...d})}}if(typeof e.base=="string")r.base=e.base;else if(e.base&&typeof e.base=="object"){const l=e.base.href;typeof l=="string"&&(r.base=l)}const s=Mt(e.htmlAttrs);for(const[l,c]of Object.entries(s))c!=null&&(r.htmlAttrs[l]=String(c));return r}function by(t){const e={meta:{},og:{},twitter:{},link:[],jsonLd:[],htmlAttrs:{}},r=new Set;for(const n of t){n.title!=null&&(e.title=n.title),Object.assign(e.meta,n.meta),Object.assign(e.og,n.og),Object.assign(e.twitter,n.twitter),Object.assign(e.htmlAttrs,n.htmlAttrs),n.base!=null&&(e.base=n.base);for(const a of n.link){const i=`${a.rel??""}|${a.href??""}|${a.hreflang??""}`;r.has(i)||(r.add(i),e.link.push(a))}for(const a of n.jsonLd)e.jsonLd.push(a)}return e}function vy(t){const e=[];t.title!=null&&e.push(`<title>${gy(t.title)}</title>`);for(const[r,n]of Object.entries(t.meta))r.toLowerCase()==="charset"?e.push(`<meta charset="${Be(n)}">`):e.push(`<meta name="${Be(r)}" content="${Be(n)}">`);for(const[r,n]of Object.entries(t.og)){const a=r.startsWith("og:")?r:`og:${r}`;e.push(`<meta property="${Be(a)}" content="${Be(n)}">`)}for(const[r,n]of Object.entries(t.twitter)){const a=r.startsWith("twitter:")?r:`twitter:${r}`;e.push(`<meta name="${Be(a)}" content="${Be(n)}">`)}t.base&&e.push(`<base href="${Be(t.base)}">`);for(const r of t.link){const n=Object.entries(r).map(([a,i])=>`${Be(a)}="${Be(i)}"`).join(" ");e.push(`<link ${n}>`)}for(const r of t.jsonLd){let n="";try{n=JSON.stringify(r)}catch{n=""}n&&e.push(`<script type="application/ld+json">${n.replace(/</g,"\\u003c")}<\/script>`)}return e.join(`
|
|
104
|
+
`)}const ra="data-rui-head";function yy(t){if(typeof document>"u")return;t.title!=null&&(document.title=t.title);const e=document.documentElement;if(e)for(const[a,i]of Object.entries(t.htmlAttrs))/^on/i.test(a)||e.setAttribute(a,i);const r=document.head;if(!r)return;r.querySelectorAll(`[${ra}]`).forEach(a=>a.remove());const n=a=>{a.setAttribute(ra,""),r.appendChild(a)};for(const[a,i]of Object.entries(t.meta)){const o=document.createElement("meta");a.toLowerCase()==="charset"?o.setAttribute("charset",i):(o.setAttribute("name",a),o.setAttribute("content",i)),n(o)}for(const[a,i]of Object.entries(t.og)){const o=document.createElement("meta");o.setAttribute("property",a.startsWith("og:")?a:`og:${a}`),o.setAttribute("content",i),n(o)}for(const[a,i]of Object.entries(t.twitter)){const o=document.createElement("meta");o.setAttribute("name",a.startsWith("twitter:")?a:`twitter:${a}`),o.setAttribute("content",i),n(o)}if(t.base){const a=document.createElement("base");a.setAttribute("href",t.base),n(a)}for(const a of t.link){const i=document.createElement("link");for(const[o,s]of Object.entries(a))/^on/i.test(o)||i.setAttribute(o,s);n(i)}for(const a of t.jsonLd){const i=document.createElement("script");i.setAttribute("type","application/ld+json");try{i.textContent=JSON.stringify(a)}catch{}n(i)}}function xy(t){let e=[],r=!1,n={meta:{},og:{},twitter:{},link:[],jsonLd:[],htmlAttrs:{}};const a=()=>{r=!1,e.length!==0&&(n=by(e),e=[],yy(n))};return t.disposers.push(()=>{typeof document>"u"||!document.head||document.head.querySelectorAll(`[${ra}]`).forEach(i=>i.remove())}),{apply(i){e.push(hy(i)),!r&&(r=!0,typeof queueMicrotask=="function"?queueMicrotask(a):Promise.resolve().then(a))},flush(){a()},serialize(){return e.length>0&&a(),vy(n)},htmlAttrs(){return e.length>0&&a(),n.htmlAttrs}}}function Xs(t={}){const e=wy(t.translations),r=typeof t.defaultLanguage=="string"?t.defaultLanguage:"";let n=typeof t.currentLanguage=="string"&&t.currentLanguage?t.currentLanguage:r;function a(s,l){if(typeof s!="string"||!s)return"";const c=e[s];let d;return c&&(n&&typeof c[n]=="string"?d=c[n]:r&&typeof c[r]=="string"&&(d=c[r])),d===void 0?s:ky(d,l,n||r||"en")}function i(s){typeof s!="string"||!s||(n=s)}function o(){return n}return{t:a,setCurrentLanguage:i,getCurrentLanguage:o}}function wy(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const a={};for(const[i,o]of Object.entries(n))typeof o=="string"&&(a[i]=o);e[r]=a}return e}function ky(t,e,r="en"){return Sy(t,e??{},r).replace(/\{([^{}]+)\}/g,(a,i)=>{const o=(e??{})[i.trim()];return o==null?"":String(o)})}function Sy(t,e,r){let n="",a=0;for(;a<t.length;){const i=t.indexOf("{",a);if(i===-1){n+=t.slice(a);break}const o=Js(t,i);if(o===-1){n+=t.slice(a);break}const s=t.slice(i+1,o),l=$y(s,e,r);l!==null?n+=t.slice(a,i)+l:n+=t.slice(a,o+1),a=o+1}return n}function Js(t,e){let r=0;for(let n=e;n<t.length;n+=1)if(t[n]==="{")r+=1;else if(t[n]==="}"&&(r-=1,r===0))return n;return-1}function $y(t,e,r){const n=t.indexOf(",");if(n===-1)return null;const a=t.slice(0,n).trim(),i=t.indexOf(",",n+1);if(i===-1)return null;const o=t.slice(n+1,i).trim(),s=t.slice(i+1);if(o!=="plural"&&o!=="select")return null;const l=Cy(s);if(!l)return null;const c=e[a];if(o==="select")return l[String(c)]??l.other??"";const d=typeof c=="number"?c:Number(c);if(Number.isFinite(d)){let f=l[`=${d}`];if(f===void 0){let h="other";try{h=new Intl.PluralRules(r).select(d)}catch{}f=l[h]??l.other}const b=Ay(d,r);return(f??"").replace(/#/g,b)}return l.other??""}function Cy(t){const e={};let r=0,n=!1;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r+=1;if(r>=t.length)break;const a=t.indexOf("{",r);if(a===-1)break;const i=t.slice(r,a).trim(),o=Js(t,a);if(o===-1)break;e[i]=t.slice(a+1,o),n=!0,r=o+1}return n?e:null}function Ay(t,e){try{return new Intl.NumberFormat(e).format(t)}catch{return String(t)}}const W=t=>typeof t=="number"?t:typeof t=="string"&&t.trim()!==""&&!Number.isNaN(Number(t))?Number(t):0,ce=t=>Array.isArray(t)?t:[],Qe=t=>!!t&&typeof t=="object"&&!Array.isArray(t),na=(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 n=String(e??"").toLowerCase(),a=String(r??"").toLowerCase();return n.includes(a)}case"startsWith":return String(e??"").toLowerCase().startsWith(String(r??"").toLowerCase());case"endsWith":return String(e??"").toLowerCase().endsWith(String(r??"").toLowerCase());default:return!1}},_t=t=>{if(Array.isArray(t))return t.map(e=>_t(e));if(t instanceof Date)return new Date(t.getTime());if(t&&typeof t=="object"){const e={};for(const r of Object.keys(t))e[r]=_t(t[r]);return e}return t},Ze=(t,e)=>{if(e==="")return t;if(t&&typeof t=="object"){if(e.includes(".")){let r=t;for(const n of e.split("."))if(r&&typeof r=="object")r=r[n];else return;return r}return t[e]}},et=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},Ty=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],My=["January","February","March","April","May","June","July","August","September","October","November","December"],Ny=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Iy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Py=(t,e)=>{const r=(s,l=2)=>String(s).padStart(l,"0"),n=t.getHours(),a=(n+11)%12+1,i=[[/YYYY/g,String(t.getFullYear())],[/YY/g,String(t.getFullYear()).slice(-2)],[/MMMM/g,My[t.getMonth()]],[/MMM/g,Ty[t.getMonth()]],[/MM/g,r(t.getMonth()+1)],[/dddd/g,Iy[t.getDay()]],[/ddd/g,Ny[t.getDay()]],[/DD/g,r(t.getDate())],[/HH/g,r(n)],[/hh/g,r(a)],[/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(n)],[/\bh\b/g,String(a)],[/\bm\b/g,String(t.getMinutes())],[/\bs\b/g,String(t.getSeconds())],[/A/g,n>=12?"PM":"AM"],[/a/g,n>=12?"pm":"am"]];let o=e;for(const[s,l]of i)o=o.replace(s,l);return o},Ry=(t,e=Date.now())=>{const r=e-t.getTime(),n=Math.abs(r),a=r<0,i=6e4,o=60*i,s=24*o,l=7*s,c=30*s,d=365*s;let p,f;return n<i?a?"in a moment":"just now":(n<o?(p=Math.round(n/i),f="m"):n<s?(p=Math.round(n/o),f="h"):n<l?(p=Math.round(n/s),f="d"):n<c?(p=Math.round(n/l),f="w"):n<d?(p=Math.round(n/c),f="mo"):(p=Math.round(n/d),f="y"),a?`in ${p}${f}`:`${p}${f} ago`)},Ey=(t,e,r)=>{if(Qe(e)){const a={};return typeof e.currency=="string"&&(a.currency=e.currency),typeof e.locale=="string"&&(a.locale=e.locale),typeof e.decimals=="number"&&(a.decimals=e.decimals),a}const n={};return t==="currency"?(typeof e=="string"&&e.length>0&&(n.currency=e),typeof r=="string"&&r.length>0&&(n.locale=r)):typeof e=="string"&&e.length>0&&(n.locale=e),n},Ly=(t,e)=>{const n=String(t??"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(i=>i.toLowerCase());if(n.length===0)return"";if(e==="snake")return n.join("_");if(e==="kebab")return n.join("-");const a=i=>i.charAt(0).toUpperCase()+i.slice(1);return e==="pascal"?n.map(a).join(""):n[0]+n.slice(1).map(a).join("")},Er={count:t=>ce(t).length,sum:t=>ce(t).reduce((e,r)=>e+W(r),0),avg:t=>{const e=ce(t);return e.length===0?0:e.reduce((r,n)=>r+W(n),0)/e.length},min:t=>{const e=ce(t).map(W);return e.length===0?0:Math.min(...e)},max:t=>{const e=ce(t).map(W);return e.length===0?0:Math.max(...e)},first:t=>ce(t)[0]??null,last:t=>{const e=ce(t);return e.length===0?null:e[e.length-1]},filter:(t,e="",r="==",n)=>ce(t).filter(a=>na(r,Ze(a,String(e)),n)),find:(t,e="",r="==",n)=>ce(t).find(a=>na(r,Ze(a,String(e)),n))??null,sort:(t,e="",r="asc")=>{const n=[...ce(t)],a=String(r).toLowerCase()==="desc"?-1:1;return n.sort((i,o)=>{const s=Ze(i,String(e)),l=Ze(o,String(e));return typeof s=="number"&&typeof l=="number"?(s-l)*a:String(s??"").localeCompare(String(l??""))*a}),n},groupBy:(t,e="")=>{const r={};for(const n of ce(t)){const a=String(Ze(n,String(e))??"");(r[a]??(r[a]=[])).push(n)}return r},slice:(t,e,r)=>{const n=ce(t);return n.slice(e??0,r??n.length)},unique:(t,e)=>{const r=ce(t);if(!e)return Array.from(new Set(r));const n=new Set,a=[];for(const i of r){const o=Ze(i,e);n.has(o)||(n.add(o),a.push(i))}return a},reverse:t=>[...ce(t)].reverse(),range:(t,e,r)=>{const n=W(t),a=W(e),i=r===void 0?a>=n?1:-1:W(r);if(i===0)return[n];const o=Math.abs(a-n),s=Math.floor(o/Math.abs(i))+1;if(s>Lr)throw new RangeError(`$util.range refusing to allocate ${s} entries (limit ${Lr}).`);const l=[];if(i>0)for(let c=n;c<=a;c+=i)l.push(c);else for(let c=n;c>=a;c+=i)l.push(c);return l},repeat:(t,e)=>{const r=Math.max(0,W(e));if(r>Lr)throw new RangeError(`$util.repeat refusing to allocate ${r} entries (limit ${Lr}).`);return Array.from({length:r},()=>t)},pick:(t,e)=>{if(!Qe(t))return{};const r=ce(e).map(a=>String(a??"")),n={};for(const a of r)a in t&&(n[a]=t[a]);return n},omit:(t,e)=>{if(!Qe(t))return{};const r=new Set(ce(e).map(a=>String(a??""))),n={};for(const a of Object.keys(t))r.has(a)||(n[a]=t[a]);return n},chunk:(t,e)=>{const r=ce(t),n=Math.max(1,Math.floor(W(e))),a=[];for(let i=0;i<r.length;i+=n)a.push(r.slice(i,i+n));return a},flatten:(t,e=1)=>{const r=(n,a)=>a<=0?n.slice():n.reduce((i,o)=>(Array.isArray(o)?i.push(...r(o,a-1)):i.push(o),i),[]);return r(ce(t),Math.max(0,Math.floor(W(e))))},zip:(...t)=>{const e=t.map(ce),r=e.reduce((a,i)=>Math.max(a,i.length),0),n=[];for(let a=0;a<r;a+=1)n.push(e.map(i=>i[a]??null));return n},partition:(t,e="",r="==",n)=>{const a=[],i=[];for(const o of ce(t))(na(r,Ze(o,String(e)),n)?a:i).push(o);return[a,i]},keyBy:(t,e="")=>{const r={};for(const n of ce(t))r[String(Ze(n,String(e))??"")]=n;return r},cloneDeep:t=>_t(t),merge:(t,...e)=>{const r=Qe(t)?_t(t):{};for(const n of e)if(Qe(n))for(const a of Object.keys(n)){const i=n[a],o=r[a];r[a]=Qe(o)&&Qe(i)?Er.merge(o,i):Qe(i)||Array.isArray(i)?_t(i):i}return r},format:(t,e="number",r,n)=>{const a=W(t),i=String(e),o=Ey(i,r,n),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(a)}catch{return i==="currency"?a.toFixed(o.decimals??2):String(a)}},formatDate:(t,e="MMM D")=>{const r=et(t),n=String(e);switch(n){case"relative":return Ry(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 Py(r,n)}},plural:(t,e,r)=>{const n=W(t),a=String(e??""),i=r===void 0?a+"s":String(r??"");return`${n} ${n===1?a: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 Ly(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=et(t),n=new Date(r.getTime());return n.setDate(n.getDate()+W(e)),n.toISOString()},addHours:(t,e)=>{const r=et(t);return new Date(r.getTime()+W(e)*36e5).toISOString()},diffDays:(t,e)=>{const r=et(t),n=et(e);return Math.round((n.getTime()-r.getTime())/864e5)},startOfWeek:t=>{const e=et(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=et(t);return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999).toISOString()},join:(t,e=",")=>ce(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 n=String(t??"");return n.substring(W(e),r===void 0?n.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)),slugify:t=>String(t??"").toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),truncate:(t,e=80,r="…")=>{const n=String(t??""),a=W(e);return n.length<=a?n:n.slice(0,Math.max(0,a-1)).trimEnd()+String(r)},initials:(t,e=2)=>String(t??"").split(/\s+/).filter(Boolean).slice(0,W(e)).map(r=>r.charAt(0).toUpperCase()).join(""),currency:(t,e="USD",r)=>{try{return new Intl.NumberFormat(r,{style:"currency",currency:String(e)}).format(W(t))}catch{return`${e} ${W(t).toFixed(2)}`}},percent:(t,e=0)=>`${(W(t)*100).toFixed(W(e))}%`,bytes:t=>{let e=W(t);const r=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<r.length-1;)e/=1024,n+=1;return`${n===0?e:e.toFixed(1)} ${r[n]}`},relativeTime:t=>{const e=et(t),r=e.getTime()-Date.now(),n=Math.abs(r),a=[["year",31536e6],["month",2592e6],["week",6048e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];try{const i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});for(const[o,s]of a)if(n>=s||o==="second")return i.format(Math.round(r/s),o)}catch{}return e.toLocaleString()},copy:t=>{try{const r=(typeof navigator<"u"?navigator:null)?.clipboard?.writeText?.(String(t??""));return r&&typeof r.then=="function"?r.then(()=>!0,()=>!1):Promise.resolve(!1)}catch{return Promise.resolve(!1)}},sleep:(t=0)=>{const e=W(t),r=Number.isFinite(e)?Math.max(0,Math.min(6e4,e)):0;return new Promise(n=>setTimeout(n,r))},uuid:()=>{try{const t=typeof crypto<"u"?crypto:null;if(t?.randomUUID)return t.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},debounceFn:(t,e=250)=>{const r=W(e),n=Number.isFinite(r)&&r>0?r:250;let a=null;return(...i)=>{typeof t=="function"&&(a&&clearTimeout(a),a=setTimeout(()=>{t(...i)},n))}},throttleFn:(t,e=250)=>{const r=W(e),n=Number.isFinite(r)&&r>0?r:250;let a=0,i=null,o=[];return(...s)=>{if(typeof t!="function")return;const l=Date.now();if(l-a>=n){a=l,t(...s);return}o=s,!i&&(i=setTimeout(()=>{i=null,a=Date.now(),t(...o)},n-(l-a)))}},vibrate:(t=10)=>{try{const e=typeof navigator<"u"?navigator:null;if(!e?.vibrate)return!1;const r=Array.isArray(t)?t.map(n=>Number(n)||0):Number(t)||0;return e.vibrate(r)}catch{return!1}},share:t=>{try{const e=typeof navigator<"u"?navigator:null;if(!e?.share)return Promise.resolve(!1);const r=t&&typeof t=="object"?t:{text:String(t??"")};return e.share(r).then(()=>!0).catch(()=>!1)}catch{return Promise.resolve(!1)}},readClipboard:()=>{try{const t=typeof navigator<"u"?navigator:null;return t?.clipboard?.readText?t.clipboard.readText().catch(()=>""):Promise.resolve("")}catch{return Promise.resolve("")}},geolocate:t=>new Promise(e=>{try{const r=typeof navigator<"u"?navigator:null;if(!r?.geolocation){e(null);return}r.geolocation.getCurrentPosition(n=>e({lat:n.coords.latitude,lng:n.coords.longitude,accuracy:n.coords.accuracy}),()=>e(null),t&&typeof t=="object"?t:void 0)}catch{e(null)}}),isOnline:()=>{try{return typeof navigator<"u"?navigator.onLine!==!1:!0}catch{return!0}},deviceType:()=>{try{const t=typeof navigator<"u"?navigator.userAgent:"";return/iPad|Tablet|PlayBook|Silk/.test(t)||/Android/.test(t)&&!/Mobile/.test(t)?"tablet":/Mobi|Android|iPhone|iPod|Windows Phone/.test(t)?"mobile":"desktop"}catch{return"desktop"}},worker:(t,...e)=>{if(typeof t!="function")return Promise.resolve(void 0);const r=()=>Promise.resolve().then(()=>t(...e));if(!(typeof Worker<"u"&&typeof Blob<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"))return r();try{const a=`self.onmessage=function(e){var fn=(${t.toString()});Promise.resolve().then(function(){return fn.apply(null,e.data);}).then(function(r){self.postMessage({ok:true,value:r});}).catch(function(err){self.postMessage({ok:false,error:String(err)});});};`,i=URL.createObjectURL(new Blob([a],{type:"application/javascript"})),o=new Worker(i);return new Promise((s,l)=>{o.onmessage=c=>{URL.revokeObjectURL(i),o.terminate();const d=c.data;d?.ok?s(d.value):l(new Error(d?.error||"worker error"))},o.onerror=c=>{URL.revokeObjectURL(i),o.terminate(),l(c)},o.postMessage(e)})}catch{return r()}},registerServiceWorker:(t,e)=>{try{const r=typeof navigator<"u"?navigator:null;if(!r?.serviceWorker||typeof t!="string"||!t)return Promise.resolve(!1);const n=typeof e=="string"&&e?{scope:e}:void 0;return r.serviceWorker.register(t,n).then(()=>!0).catch(()=>!1)}catch{return Promise.resolve(!1)}},webManifest:t=>{const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r={name:typeof e.name=="string"?e.name:"App",short_name:typeof e.shortName=="string"?e.shortName:typeof e.name=="string"?e.name:"App",start_url:typeof e.startUrl=="string"?e.startUrl:"/",display:typeof e.display=="string"?e.display:"standalone",background_color:typeof e.backgroundColor=="string"?e.backgroundColor:"#ffffff",theme_color:typeof e.themeColor=="string"?e.themeColor:"#000000"};return typeof e.description=="string"&&(r.description=e.description),Array.isArray(e.icons)&&(r.icons=e.icons.filter(n=>!!n&&typeof n=="object").map(n=>({src:String(n.src??""),sizes:String(n.sizes??"512x512"),type:String(n.type??"image/png")}))),r},nativeShell:()=>{try{const t=typeof window<"u"?window:{},e=typeof navigator<"u"?navigator:{userAgent:""};return t.__TAURI__||t.__TAURI_IPC__?"tauri":t.Capacitor?"capacitor":t.cordova||t.PhoneGap?"cordova":t.ReactNativeWebView?"react-native":/Electron\//.test(e.userAgent)?"electron":"web"}catch{return"web"}},isNativeApp:()=>Er.nativeShell()!=="web"},Lr=1e5,zy=/^[a-zA-Z0-9#%.,()\s+-]+$/,Qs={primary:"var(--rui-color-primary)",accent:"var(--rui-color-accent)",success:"var(--rui-color-success)",warning:"var(--rui-color-warning)",danger:"var(--rui-color-danger)",info:"var(--rui-color-info)",text:"var(--rui-color-text)",muted:"var(--rui-color-text-muted)",bg:"var(--rui-color-bg)",surface:"var(--rui-color-surface)",border:"var(--rui-color-border)"};function Zs(t){const e=String(t??"").trim();return e in Qs?Qs[e]:!e||e.length>64||!zy.test(e)||/url\s*\(|expression\s*\(|javascript\s*:|@import/i.test(e)?"":e}function aa(t){const e=String(t??"").trim();return!e||e.length>64||!/^[a-zA-Z0-9.%+\-*/\s(),]+$/.test(e)?"0":e}const jy={cx:(...t)=>{const e=[],r=n=>{if(n){if(typeof n=="string"||typeof n=="number")for(const a of String(n).split(/\s+/))a&&/^[A-Za-z_-][\w-]*$/.test(a)&&!e.includes(a)&&e.push(a);else if(Array.isArray(n))n.forEach(r);else if(typeof n=="object")for(const[a,i]of Object.entries(n))i&&r(a)}};return t.forEach(r),e.join(" ")},gradient:(t,e)=>{const n=(Array.isArray(t)?t:[t]).map(Zs).filter(Boolean);return n.length<2?"":`linear-gradient(${typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}deg`:"120deg"}, ${n.join(", ")})`},alpha:(t,e)=>{const r=Zs(t);if(!r)return"";const n=Math.max(0,Math.min(1,Number(e))),a=Number.isFinite(n)?Math.round(n*100):100;return`color-mix(in srgb, ${r} ${a}%, transparent)`},clamp:(t,e,r)=>`clamp(${aa(t)}, ${aa(e)}, ${aa(r)})`,token:t=>{const e=String(t??"").trim();if(!/^[a-zA-Z0-9.]+$/.test(e))return"";const[r,...n]=e.split("."),a=n.join("-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return!r||!a?"":`var(--rui-${r==="colors"||r==="color"?"color":r==="spacing"?"spacing":r==="radius"?"radius":r==="shadows"||r==="shadow"?"shadow":r==="gradients"||r==="gradient"?"gradient":r}-${a})`},toStyle:t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const e=[];for(const[r,n]of Object.entries(t)){if(n==null||n===!1)continue;const a=r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if(!/^[a-z-]+$/.test(a))continue;const i=String(n).trim();/[;{}<>]|expression\s*\(|javascript\s*:|@import/i.test(i)||e.push(`${a}:${i}`)}return e.join(";")}},zr=t=>!!t&&typeof t.then=="function",Ye=t=>t==null||t===""||Array.isArray(t)&&t.length===0,Dy=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Oy=/^(https?:\/\/)[^\s/$.?#].[^\s]*$/i,jr={required:(t="This field is required")=>e=>Ye(e)?t:null,email:(t="Enter a valid email")=>e=>Ye(e)||Dy.test(String(e))?null:t,url:(t="Enter a valid URL")=>e=>Ye(e)||Oy.test(String(e))?null:t,min:(t,e)=>r=>Ye(r)||Number(r)>=t?null:e??`Must be at least ${t}`,max:(t,e)=>r=>Ye(r)||Number(r)<=t?null:e??`Must be at most ${t}`,minLength:(t,e)=>r=>Ye(r)||String(r).length>=t?null:e??`Must be at least ${t} characters`,maxLength:(t,e)=>r=>Ye(r)||String(r).length<=t?null:e??`Must be at most ${t} characters`,pattern:(t,e="Invalid format")=>{let r=null;try{r=t instanceof RegExp?t:new RegExp(String(t))}catch{r=null}return n=>Ye(n)||!r||r.test(String(n))?null:e},oneOf:(t,e="Not an allowed value")=>r=>Ye(r)||Array.isArray(t)&&t.includes(r)?null:e,matches:(t,e="Values do not match")=>r=>r===t?null:e,custom:(t,e="Invalid")=>r=>{if(typeof t!="function")return null;try{const n=t(r);return zr(n)?n.then(a=>a===!0||a==null?null:a===!1?e:String(a),()=>e):n===!0||n==null?null:n===!1?e:String(n)}catch{return e}},asyncCustom:(t,e="Invalid")=>r=>{if(typeof t!="function")return null;try{const n=t(r);return zr(n)?n.then(a=>a===!0||a==null?null:a===!1?e:String(a),()=>e):n===!0||n==null?null:n===!1?e:String(n)}catch{return e}},validate:(t,e)=>{const r=Array.isArray(e)?e:[e],n=a=>{for(let i=a;i<r.length;i+=1){const o=r[i];if(typeof o!="function")continue;const s=o(t);if(zr(s))return s.then(l=>l||n(i+1));if(s)return s}return null};return n(0)},validateAll:(t,e)=>{const r={},n=[];if(!e||typeof e!="object")return r;const a=t&&typeof t=="object"?t:{};for(const[i,o]of Object.entries(e)){const s=jr.validate(a[i],o);zr(s)?n.push(s.then(l=>{l&&(r[i]=l)})):s&&(r[i]=s)}return n.length>0?Promise.all(n).then(()=>r):r}},By=/^[A-Za-z0-9 ]{1,48}$/,ia=new Set;function Fy(t){const e=typeof t=="string"?t.trim():"";if(!e)return null;const[r,n]=e.split(":"),a=(r??"").trim();if(!By.test(a))return null;const i=[],o=[];if(n)for(const s of n.split(",")){const l=s.trim(),c=/i$/.test(l),d=Number(c?l.slice(0,-1):l);Number.isInteger(d)&&d>=100&&d<=900&&(c?o:i).push(d)}return{family:a,weights:i,italics:o}}function _y(t){const e=t.family.replace(/\s+/g,"+"),r=[];for(const n of t.weights.sort((a,i)=>a-i))r.push(`0,${n}`);for(const n of t.italics.sort((a,i)=>a-i))r.push(`1,${n}`);return r.length===0?`family=${e}`:t.italics.length>0?`family=${e}:ital,wght@${r.join(";")}`:`family=${e}:wght@${t.weights.sort((n,a)=>n-a).join(";")}`}function Uy(t){const e=(Array.isArray(t)?t:[t]).map(Fy).filter(n=>n!==null);return e.length===0?"":`https://fonts.googleapis.com/css2?${e.map(_y).join("&")}&display=swap`}function el(t){if(!t||typeof t!="object"||Array.isArray(t))return"";const e=t.import;if(e==null)return"";const r=Uy(e);if(!r||ia.has(r)||typeof document>"u")return r;if(typeof globalThis.happyDOM<"u")return ia.add(r),r;try{const a=document.createElement("link");a.rel="stylesheet",a.href=r,a.setAttribute("data-rui-font",""),document.head.appendChild(a),ia.add(r)}catch{}return r}const Ie={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",spacing2xl:"48px",spacing3xl:"80px"},...{gradientBrand:"linear-gradient(120deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%)",gradientAccent:"linear-gradient(120deg, #22d3ee 0%, #6366f1 100%)",gradientWarm:"linear-gradient(120deg, #f59e0b 0%, #ec4899 100%)",gradientCool:"linear-gradient(120deg, #3b82f6 0%, #06b6d4 100%)",gradientSuccess:"linear-gradient(120deg, #10b981 0%, #22d3ee 100%)",gradientDanger:"linear-gradient(120deg, #f43f5e 0%, #ec4899 100%)"},...{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"}},tl={...Ie,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)"},rl={...Ie,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"},nl={...Ie,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"},al={...Ie,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"},il={...Ie,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"},ol={...Ie,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"},Ut={light:Ie,dark:tl,neon:rl,pastel:nl,glass:al,brutalist:il,skyline:ol},Dr={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",spacing3xs:"--rui-spacing-3xs",spacing2xs:"--rui-spacing-2xs",spacingXs:"--rui-spacing-xs",spacingS:"--rui-spacing-s",spacingM:"--rui-spacing-m",spacingL:"--rui-spacing-l",spacingXl:"--rui-spacing-xl",spacing2xl:"--rui-spacing-2xl",spacing3xl:"--rui-spacing-3xl",gradientBrand:"--rui-gradient-brand",gradientAccent:"--rui-gradient-accent",gradientWarm:"--rui-gradient-warm",gradientCool:"--rui-gradient-cool",gradientSuccess:"--rui-gradient-success",gradientDanger:"--rui-gradient-danger",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",motionFast:"--rui-motion-fast",motionBase:"--rui-motion-base",motionSlow:"--rui-motion-slow",motionEase:"--rui-motion-ease",zBase:"--rui-z-base",zRaised:"--rui-z-raised",zDropdown:"--rui-z-dropdown",zSticky:"--rui-z-sticky",zBanner:"--rui-z-banner",zOverlay:"--rui-z-overlay",zModal:"--rui-z-modal",zPopover:"--rui-z-popover",zToast:"--rui-z-toast",zTooltip:"--rui-z-tooltip",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 oa(t){if(!t)return{name:"light",tokens:Ie};if(typeof t=="string"){const e=t.trim().toLowerCase();if(e.startsWith("{"))try{return{name:"custom",tokens:ul(JSON.parse(t))}}catch{return{name:"light",tokens:Ie}}const r=Ut[e];return r?{name:e,tokens:r}:{name:"light",tokens:Ie}}return{name:"custom",tokens:ul(t)}}function sa(t,e){const r="tokens"in e?e:{name:"custom",tokens:e};for(const[n,a]of Object.entries(Dr)){const i=r.tokens[n];i==null?t.style.removeProperty(a):t.style.setProperty(a,i)}t.setAttribute("data-rui-theme",r.name)}function sl(t,e){const r=[];for(const n of Object.keys(e)){const a=Dr[n];if(!a)continue;const i=e[n];typeof i!="string"||i===""||(t.style.setProperty(a,i),r.push(n))}return r}function ll(t,e){for(const r of e){const n=Dr[r];n&&t.style.removeProperty(n)}}function cl(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[r,n]of Object.entries(t))if(r in Dr&&n!=null)if(typeof n=="string"){if(n.trim()==="")continue;e[r]=n}else typeof n=="number"&&(e[r]=String(n));return e}function ul(t){return{...Ie,...t}}const Hy=8;function ye(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 la(t,e){if(!t)return{matched:!1,params:{}};if(t==="*")return{matched:!0,params:{},wildcard:!0};const r=ye(t),n=ye(e),a=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/"),o={};let s=!1;for(let l=0;l<a.length;l+=1){const c=a[l];if(c==="*"){s=!0;const p=i.slice(l).join("/");return o._=p,{matched:!0,params:o,wildcard:s}}const d=i[l];if(d===void 0)return{matched:!1,params:{}};if(c.startsWith(":")){const p=c.slice(1);if(!p)return{matched:!1,params:{}};o[p]=decodeURIComponent(d);continue}if(c!==d)return{matched:!1,params:{}}}return!s&&i.length>a.length?{matched:!1,params:{}}:s?{matched:!0,params:o,wildcard:!0}:{matched:!0,params:o}}function ca(t,e){if(!t||t==="*")return{matched:!0,params:{},rest:ye(e)};const r=ye(t),n=ye(e),a=r==="/"?[]:r.slice(1).split("/"),i=n==="/"?[]:n.slice(1).split("/");if(i.length<a.length)return{matched:!1,params:{},rest:"/"};const o={};for(let c=0;c<a.length;c+=1){const d=a[c],p=i[c];if(d.startsWith(":")){o[d.slice(1)]=decodeURIComponent(p);continue}if(d!==p)return{matched:!1,params:{},rest:"/"}}const s=i.slice(a.length),l=s.length===0?"/":"/"+s.join("/");return{matched:!0,params:o,rest:l}}class ua{constructor(e={}){O(this,"currentPath");O(this,"currentParams",{});O(this,"currentPattern",null);O(this,"enabled",!1);O(this,"hashListener",null);O(this,"listeners",new Set);O(this,"defaultPath");O(this,"mode");O(this,"basePath");O(this,"settingHash",!1);O(this,"guard",null);this.defaultPath=ye(e.defaultPath??"/"),this.currentPath=this.defaultPath,this.mode=e.mode==="history"?"history":"hash",this.basePath=dl(e.basePath)}configure(e){this.enabled||(e.mode&&(this.mode=e.mode==="history"?"history":"hash"),e.basePath!==void 0&&(this.basePath=dl(e.basePath)))}getMode(){return this.mode}start(){if(this.enabled||(this.enabled=!0,typeof window>"u"))return;const e=r=>{if(this.settingHash)return;const n=ye(this.readLocation());if(n===this.currentPath)return;const a=this.runGuard(n);if(a===!1){this.restoreUrl();return}if(typeof a=="string"){this.restoreUrl(),this.navigateInternal(ye(a),0);return}this.setPath(n,r)};if(this.mode==="history"){const r=()=>e("hashchange");window.addEventListener("popstate",r),this.hashListener=r}else{const r=()=>e("hashchange");window.addEventListener("hashchange",r),this.hashListener=r}e("init")}readLocation(){if(typeof window>"u")return this.currentPath;if(this.mode==="history"){let e=window.location.pathname||"/";return this.basePath&&e.startsWith(this.basePath)&&(e=e.slice(this.basePath.length)||"/"),ye(e)}return ye(window.location.hash)}stop(){this.enabled&&(this.enabled=!1,typeof window<"u"&&this.hashListener&&(window.removeEventListener("hashchange",this.hashListener),window.removeEventListener("popstate",this.hashListener)),this.hashListener=null)}getPath(){return this.currentPath}getParams(){return this.currentParams}getActivePattern(){return this.currentPattern}setActiveMatch(e,r){this.currentPattern=e,qy(this.currentParams,r)||(this.currentParams=r)}navigate(e){this.navigateInternal(ye(e),0)}setGuard(e){this.guard=e}runGuard(e){if(!this.guard)return!0;try{return this.guard({to:e,from:this.currentPath})}catch(r){return console.error("[aktion] navigation guard threw",r),!0}}restoreUrl(){if(!(typeof window>"u")){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.replaceState=="function"?window.history.replaceState({},"",(this.basePath||"")+this.currentPath):window.location.hash="#"+this.currentPath}finally{queueMicrotask(()=>{this.settingHash=!1})}}}navigateInternal(e,r){const n=ye(e);if(n===this.currentPath)return;const a=this.runGuard(n);if(a!==!1){if(typeof a=="string"&&r<Hy){this.navigateInternal(ye(a),r+1);return}if(this.enabled&&typeof window<"u"){this.settingHash=!0;try{this.mode==="history"&&typeof window.history?.pushState=="function"?window.history.pushState({},"",(this.basePath||"")+n):window.location.hash="#"+n}finally{queueMicrotask(()=>{this.settingHash=!1})}this.setPath(n,"navigate");return}this.setPath(n,"navigate")}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}setPath(e,r){const n=ye(e);if(n===this.currentPath)return;const a=this.currentPath;this.currentPath=n,this.currentParams={},this.currentPattern=null;for(const i of[...this.listeners])try{i({path:n,previousPath:a,source:r})}catch(o){console.error("[aktion] router listener failed",o)}}}function dl(t){if(!t)return"";let e=String(t).trim();return e===""||e==="/"?"":(e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e)}function qy(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(t[a]!==e[a])return!1;return!0}const tt=(t,e)=>{try{return t()}catch{return e}},pl=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)}},ml=t=>{if(t===null||t==="")return t;try{return JSON.parse(t)}catch{return t}},fl=t=>({set:(e,r)=>tt(()=>{const n=t();return n?(n.setItem(String(e),pl(r)),!0):!1},!1),get:e=>tt(()=>{const r=t();return r?ml(r.getItem(String(e))):null},null),remove:e=>tt(()=>{const r=t();return r?(r.removeItem(String(e)),!0):!1},!1),clear:()=>tt(()=>{const e=t();return e?(e.clear(),!0):!1},!1)}),Vy=()=>typeof globalThis>"u"?null:globalThis.localStorage??null,Wy=()=>typeof globalThis>"u"?null:globalThis.sessionStorage??null,Or=()=>typeof globalThis>"u"?null:globalThis.document??null,Gy=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},da=(t={})=>{const e=[],r=Gy(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 n=t.sameSite.charAt(0).toUpperCase()+t.sameSite.slice(1).toLowerCase();e.push(`samesite=${n}`)}return e.length===0?"":`; ${e.join("; ")}`},gl=()=>{const t=Or();if(!t)return{};const e={},r=t.cookie??"";if(!r)return e;for(const n of r.split(";")){const a=n.trim();if(!a)continue;const i=a.indexOf("=");if(i<0){e[decodeURIComponent(a)]="";continue}const o=decodeURIComponent(a.slice(0,i)),s=decodeURIComponent(a.slice(i+1));e[o]=s}return e},Ky={set:(t,e,r)=>tt(()=>{const n=Or();if(!n)return!1;const a=encodeURIComponent(String(t)),i=encodeURIComponent(pl(e));return n.cookie=`${a}=${i}${da(r)}`,!0},!1),get:t=>tt(()=>{const r=gl()[String(t)];return r===void 0?null:ml(r)},null),remove:(t,e)=>tt(()=>{const r=Or();if(!r)return!1;const n=encodeURIComponent(String(t)),a={...e,expires:new Date(0),maxAge:0};return r.cookie=`${n}=${da(a)}`,!0},!1),clear:()=>tt(()=>{const t=Or();if(!t)return!1;const e=gl();for(const r of Object.keys(e)){const n=encodeURIComponent(r);t.cookie=`${n}=${da({expires:new Date(0),maxAge:0})}`}return!0},!1)},Ht=fl(Vy),Yy=fl(Wy),pa={set:Ht.set,get:Ht.get,remove:Ht.remove,clear:Ht.clear,local:Ht,session:Yy,cookies:Ky},Xy=["log","error","warn","info","debug"],Jy=()=>typeof globalThis>"u"?null:globalThis.console??null,Qy=t=>(...e)=>{const r=Jy();if(!r)return;const n=r[t]??r.log;if(typeof n=="function")try{n(...e)}catch{}},hl=Xy.reduce((t,e)=>(t[e]=Qy(e),t),{}),Zy=4e3;function ma(t){return t==null?"":typeof t=="string"?t:String(t)}function bl(t){let e=[];const r=new Map;let n=0;const a=()=>t.notify?.(),i=p=>{const f=r.get(p);f!==void 0&&(clearTimeout(f),r.delete(p))},o=p=>{i(p);const f=e.filter(b=>b.id!==p);f.length!==e.length&&(e=f,d.items=e,a())},s=()=>{if(e.length!==0){for(const p of[...r.keys()])i(p);e=[],d.items=e,a()}},l=(p,f={})=>{const b=`toast-${n+=1}`,h=typeof f.duration=="number"?f.duration:Zy,g={id:b,message:ma(p),title:f.title!=null?ma(f.title):void 0,tone:f.tone!=null?ma(f.tone):"default",duration:h,createdAt:Date.now()};return e=[...e,g],d.items=e,h>0&&r.set(b,setTimeout(()=>{r.delete(b),o(b)},h)),a(),b},c=p=>(f,b={})=>l(f,{...b,tone:p}),d={items:e,show:l,success:c("success"),error:c("danger"),info:c("info"),warning:c("warning"),dismiss:o,clear:s};return t.disposers.push(()=>{for(const p of r.values())clearTimeout(p);r.clear(),e=[],d.items=e}),d}const ex=[["xl",1280],["lg",1024],["md",768],["sm",640]];function tx(t){for(const[e,r]of ex)if(t>=r)return e;return"base"}function rx(t){const e=typeof window<"u";let r=!1;const n=()=>{if(r)return;r=!0;const S=()=>{r=!1,t.notify?.()};e&&typeof requestAnimationFrame=="function"?requestAnimationFrame(S):setTimeout(S,16)};let a=e?window.innerWidth:1024,i=e?window.innerHeight:768,o=0,s=0,l=0,c="down",d=0,p=0,f=!1,b=!1,h=!1,g=!1;const y=()=>{if(f||!e)return;f=!0;let S=0;const $=()=>{S||(S=requestAnimationFrame(()=>{S=0;const C=window.innerWidth,M=window.innerHeight;(C!==a||M!==i)&&(a=C,i=M,n())}))};window.addEventListener("resize",$,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("resize",$),S&&cancelAnimationFrame(S)})},v=()=>{if(b||!e)return;b=!0,y();let S=0;const $=()=>{S=0;const M=document.documentElement,L=window.scrollY||M.scrollTop||0,z=window.scrollX||M.scrollLeft||0,H=M.scrollHeight-M.clientHeight||1,F=Math.round(Math.max(0,Math.min(1,L/H))*1e3)/1e3,V=L>s?"down":L<s?"up":c;(Math.round(L)!==Math.round(s)||Math.round(z)!==Math.round(o)||F!==l||V!==c)&&(s=L,o=z,l=F,c=V,n())},C=()=>{S||(S=requestAnimationFrame($))};$(),window.addEventListener("scroll",C,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("scroll",C),S&&cancelAnimationFrame(S)})},x=()=>{if(h||!e)return;h=!0;let S=0,$=0,C=0;const M=L=>{$=L.clientX,C=L.clientY,!S&&(S=requestAnimationFrame(()=>{S=0,($!==d||C!==p)&&(d=$,p=C,n())}))};window.addEventListener("mousemove",M,{passive:!0}),t.disposers.push(()=>{window.removeEventListener("mousemove",M),S&&cancelAnimationFrame(S)})},w=[],k=()=>{if(g||!e||typeof window.matchMedia!="function")return;g=!0;const S=()=>n();for(const C of["(prefers-color-scheme: dark)","(prefers-reduced-motion: reduce)","(pointer: coarse)","(orientation: portrait)"])try{const M=window.matchMedia(C);typeof M.addEventListener=="function"?M.addEventListener("change",S):typeof M.addListener=="function"&&M.addListener(S),w.push(M)}catch{}const $=()=>n();window.addEventListener("online",$),window.addEventListener("offline",$),t.disposers.push(()=>{for(const C of w)typeof C.removeEventListener=="function"?C.removeEventListener("change",S):typeof C.removeListener=="function"&&C.removeListener(S);window.removeEventListener("online",$),window.removeEventListener("offline",$)})},A=S=>{if(!e||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(S).matches}catch{return!1}};return{get viewport(){return y(),{width:a,height:i}},get breakpoint(){y();const S=tx(a);return{width:a,active:S,sm:a>=640,md:a>=768,lg:a>=1024,xl:a>=1280}},get scroll(){return v(),{x:Math.round(o),y:Math.round(s),progress:l,direction:c}},get media(){return k(),{prefersDark:A("(prefers-color-scheme: dark)"),prefersReducedMotion:A("(prefers-reduced-motion: reduce)"),online:e&&typeof navigator<"u"?navigator.onLine:!0,pointer:A("(pointer: coarse)")?"coarse":"fine",portrait:A("(orientation: portrait)")}},get mouse(){return x(),{x:d,y:p}}}}const qt={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},fa={util:Er,console:hl,storage:pa},vl=new Set(["toast","dom"]);function nx(t){return t.toastManager||(t.toastManager=bl(t)),t.toastManager}function ax(t){return t.domManager||(t.domManager=fy(t)),t.domManager}function ga(t){return t.headManager||(t.headManager=xy(t)),t.headManager}function ix(t){return t.envManager||(t.envManager=rx(t)),t.envManager}function ox(t){if(t.utilFacade)return t.utilFacade;const e=Object.create(Er),r=()=>ix(t);return Object.defineProperties(e,{scroll:{get:()=>r().scroll,enumerable:!0},viewport:{get:()=>r().viewport,enumerable:!0},breakpoint:{get:()=>r().breakpoint,enumerable:!0},media:{get:()=>r().media,enumerable:!0},mouse:{get:()=>r().mouse,enumerable:!0},url:{get:()=>sx(t),enumerable:!0},style:{value:jy,enumerable:!0},rules:{value:jr,enumerable:!0},derived:{value:n=>typeof n=="function"?n():n,enumerable:!0},onError:{value:n=>{t.errorHook=typeof n=="function"?a=>{n(a)}:void 0},enumerable:!0},onNavigate:{value:n=>{t.router?.setGuard(typeof n=="function"?n:null)},enumerable:!0},onRequest:{value:n=>{typeof n=="function"&&t.http?.registerProgramInterceptors({onRequest:a=>{const i=n(a);if(i&&typeof i=="object"){const o=i;return{...a,...o,headers:{...a.headers,...o.headers??{}}}}return a}})},enumerable:!0},onResponse:{value:n=>{typeof n=="function"&&t.http?.registerProgramInterceptors({onResponse:async(a,i)=>{const o=await n(a,i);return o&&typeof o=="object"?o:a}})},enumerable:!0},invalidate:{value:n=>{Jn(t,n)},enumerable:!0}}),t.utilFacade=e,e}function sx(t){t.trackedState.add("route");const e=t.router,r=Ta(t),n=e?{...e.getParams()}:{},a={};let i="";if(typeof globalThis<"u"&&globalThis.location){const o=globalThis.location;let s=o.search??"";const l=o.hash?o.hash.replace(/^#/,""):"",c=l.indexOf("?");if(!s&&c>=0?s=l.slice(c):s&&(i=l),s){const d=new URLSearchParams(s.startsWith("?")?s.slice(1):s);for(const[p,f]of d)a[p]=f}}return{path:r,params:n,query:a,hash:i,navigate:o=>{typeof o=="string"&&o&&e?.navigate(o)},setQuery:(o,s)=>{const l={...a};if(o&&typeof o=="object"&&!Array.isArray(o))for(const[c,d]of Object.entries(o))d==null||d===""?delete l[c]:l[c]=String(d);else typeof o=="string"&&(s==null||s===""?delete l[o]:l[o]=String(s));yl(t,l)},removeQuery:o=>{if(typeof o!="string")return;const s={...a};delete s[o],yl(t,s)},toString(){return r}}}function yl(t,e){if(typeof window>"u"||!window.location)return;const r=new URLSearchParams;for(const[i,o]of Object.entries(e))o==null||o===""||r.set(i,String(o));const n=r.toString();if((t.router?.getMode?t.router.getMode():"hash")==="history"&&typeof window.history?.replaceState=="function"){const i=window.location.pathname||"/",o=window.location.hash||"";window.history.replaceState({},"",i+(n?`?${n}`:"")+o)}else{const i=t.router?t.router.getPath():Ta(t);window.location.hash=`#${i}${n?`?${n}`:""}`}t.notify?.()}function xl(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 Br={componentDepthLimit:150,iterationLimit:25e4,arrayLengthLimit:1e5};class rt extends Error{constructor(r,n,a){super(lx(r,n,a));O(this,"kind");O(this,"limit");O(this,"source");this.name="RuntimeBudgetError",this.kind=r,this.limit=n,this.source=a}}function lx(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 wl(t={}){return{componentDepthLimit:t.componentDepthLimit??Br.componentDepthLimit,iterationLimit:t.iterationLimit??Br.iterationLimit,arrayLengthLimit:t.arrayLengthLimit??Br.arrayLengthLimit,componentDepth:0,iterations:0}}function ha(t){t.iterations=0,t.componentDepth=0}function Vt(t,e,r){if(t&&(t.iterations+=e,t.iterations>t.iterationLimit))throw new rt("iterations",t.iterationLimit,r)}function ba(t,e){const r=t.budget;if(r&&(r.componentDepth+=1,r.componentDepth>r.componentDepthLimit))throw r.componentDepth-=1,new rt("component-depth",r.componentDepthLimit,`component "${e}"`)}function va(t){const e=t.budget;e&&e.componentDepth>0&&(e.componentDepth-=1)}function kl(t,e){return e.activeComponentDecls.length>0&&e.activeComponentDecls.includes(t)&&!!(e.library&&Le(e.library,t))}const Sl=t=>!!(t&&typeof t=="object"&&t.__kind==="Component"),$l=t=>!!(t&&typeof t=="object"&&t.__kind==="UserComponent"),Fr=t=>!!(t&&typeof t=="object"&&t.__kind==="Store");function _r(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,activeComponentDecls:[],effectDecls:new Map,componentEffectStack:[],actionDecls:new Map,hookDecls:new Map,hookScope:null,hookStore:new Map,stores:new Map,http:e.http,queryCache:new Map,notify:e.notify,onEmit:e.onEmit,strict:e.strict,strictWarned:new Set,disposers:[],timers:{timeouts:new Set,intervals:new Set},budget:e.budget===null?void 0:e.budget??wl()};return r.disposers.push(()=>{for(const n of r.timers.timeouts)clearTimeout(n);for(const n of r.timers.intervals)clearInterval(n);r.timers.timeouts.clear(),r.timers.intervals.clear()}),e.http?.clearProgramInterceptors(),r.disposers.push(()=>e.http?.clearProgramInterceptors()),r}function ya(t){const e=t.disposers;t.disposers=[];for(const r of e)try{r()}catch(n){console.error("[aktion] context disposer threw",n)}}function Cl(t){t.mutableBindings.clear()}function Fe(t,e){for(let r=t.stateAliases.length-1;r>=0;r-=1){const a=t.stateAliases[r].get(e);if(a!==void 0)return a}return e}function Ur(t,e){const r=[];let n=t;for(;n.kind==="Member";){if(n.computed){if(n.computed.kind!=="Literal")return null;const a=n.computed.value;if(typeof a!="string"&&typeof a!="number")return null;r.unshift(String(a))}else if(n.property)r.unshift(n.property);else return null;n=n.object}return n.kind!=="StateRef"?null:{name:Fe(e,n.name),path:r}}function Hr(t,e){if(t.kind==="StateRef")return Fe(e,t.name);if(t.kind==="Member"){const r=Ur(t,e);if(r)return r.path.length===0?r.name:`${r.name}.${r.path.join(".")}`;const n=Dl(t,e);if(n)return n.path.length===0?n.atom:`${n.atom}.${n.path.join(".")}`}return null}function xa(t,e){for(const r of t.statements)if(r.kind==="Assignment"&&r.isState){const n=Vr(r.expression);e.state.declare(r.identifier,n)}for(const r of t.statements)wa(r,e);for(const r of t.statements){if(r.kind!=="Assignment"||!r.isState||!Al(r.expression))continue;const n=R(r.expression,e);e.state.set(r.identifier,n)}dx(t,e),ux(t,e)}const cx=8;function ux(t,e){const r=[],n=o=>{const s=new Set,l=e.trackedState;e.trackedState=s;try{const c=R(o.expr,e);e.state.set(o.name,c)}finally{e.trackedState=l}o.deps=s};for(const o of t.statements){if(o.kind!=="Assignment"||!o.isState||qr(o.expression)||Al(o.expression))continue;const s={name:o.identifier,expr:o.expression,deps:new Set};r.push(s),n(s)}if(r.length===0)return;let a=!1;const i=e.state.subscribe(o=>{if(!a){a=!0;try{const s=new Set(o);for(let l=0;l<cx;l+=1){let c=!1;for(const d of r){if(!Bt(s,d.deps))continue;const f=e.state.get(d.name);n(d),e.state.get(d.name)!==f&&(s.add(d.name),c=!0)}if(!c)break}}finally{a=!1}}});e.disposers.push(i)}function qr(t){switch(t.kind){case"Literal":return!0;case"Array":return t.elements.every(e=>e.kind!=="Spread"&&qr(e));case"Object":return t.properties.every(e=>!e.spread&&!e.computedKey&&qr(e.value));case"Template":return t.expressions.length===0;default:return!1}}function Al(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="http"}function Tl(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="theme"}function Ml(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="app"}function wa(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,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;Ml(r)?e.bindings.set("aktion",()=>R(r,e)):Tl(r)&&e.bindings.set("theme",()=>R(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,()=>R(r,e));return}}}function Nl(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!Ml(t.expression)&&!Tl(t.expression);default:return!1}}function dx(t,e){let r=!1;for(const n of t.statements)if(Nl(n)){r=!0;break}if(r){for(const n of t.statements)n.kind==="Assignment"&&n.isState&&qr(n.expression)&&e.state.set(n.identifier,Vr(n.expression));for(const n of t.statements)if(Nl(n))try{Sa(n,e)}catch(a){if(a instanceof Pe||a instanceof ze||a instanceof mt)continue;if(a instanceof rt)throw a;console.error("[aktion] top-level statement threw",a)}}}function px(t,e,r){const n=t[0];if(!n||n.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 a=Ta(e);let i=null;for(const o of n.properties){if(o.spread)continue;const s=o.key;if(s==="default"||s==="*"){i=o;continue}const l=Il(o.value);if(l){const d=ca(s,a);if(!d.matched)continue;return Pl(s,l,d.params,d.rest,e)}const c=la(s,a);if(c.matched)return Rl(s,o.value,c.params,e)}return i?Rl(null,i.value,{},e):(e.router?.setActiveMatch(null,{}),null)}function Il(t){if(t.kind!=="Object")return null;let e=null,r=null;for(const n of t.properties)n.spread||(n.key==="layout"?e=n.value:n.key==="routes"&&n.value.kind==="Object"&&(r=n.value));return e?{layout:e,routes:r}:null}function Pl(t,e,r,n,a){let i=null,o=null,s={};if(e.routes){let c=null;for(const d of e.routes.properties){if(d.spread)continue;if(d.key==="default"||d.key==="*"){c=d;continue}const p=Il(d.value);if(p){const b=ca(d.key,n);if(!b.matched)continue;o=d.key,s=b.params,i=Pl(d.key,p,b.params,b.rest,a);break}const f=la(d.key,n);if(f.matched){o=d.key,s=f.params,i=ka(d.value,a,{params:f.params});break}}i===null&&o===null&&c&&(i=ka(c.value,a,{params:{}}))}const l={...r,...s};return a.router?.setActiveMatch(o?`${t}${o}`:t,l),ka(e.layout,a,{params:l,outlet:i})}function ka(t,e,r){const n=[];for(const[a,i]of Object.entries(r))n.push({name:a,had:e.loopVars.has(a),prev:e.loopVars.get(a)}),e.loopVars.set(a,i);try{return R(t,e)}finally{for(const a of n)a.had?e.loopVars.set(a.name,a.prev):e.loopVars.delete(a.name)}}function Rl(t,e,r,n){const a=n.loopVars.get("params"),i=n.loopVars.has("params");n.loopVars.set("params",r);try{const o=R(e,n);return n.router?.setActiveMatch(t,r),o}finally{i?n.loopVars.set("params",a):n.loopVars.delete("params")}}function Vr(t){switch(t.kind){case"Literal":return t.value;case"Array":{const e=[];for(const r of t.elements)r.kind!=="Spread"&&e.push(Vr(r));return e}case"Object":{const e={};for(const r of t.properties)r.spread||(e[r.key]=Vr(r.value));return e}case"Template":return t.expressions.length===0?t.quasis[0]??"":null;default:return null}}function R(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?rw(e.router):{path:"/",params:{},pattern:null,query:{},navigate(){},toString(){return"/"}};const r=e.bindings.get(t.name);if(r){const s=r();return e.mutableBindings.set(t.name,s),s}const n=kl(t.name,e),a=n?void 0:e.actionDecls.get(t.name);if(a)return Kx(a,e);const i=n?void 0:e.componentDecls.get(t.name);if(i)return Yx(i);if(Object.prototype.hasOwnProperty.call(qt,t.name))return qt[t.name];if(e.library&&Le(e.library,t.name))return Xx(t.name);if(t.name==="cleanup"&&e.cleanupSink){const s=e.cleanupSink;return l=>{typeof l=="function"&&s(l)}}const o=xl(t.name);if(o.found)return o.value;if(e.strict&&!e.strictWarned.has(t.name)){e.strictWarned.add(t.name);const s=t.loc?` (line ${t.loc.line}, col ${t.loc.column})`:"";console.warn(`[aktion] strict: unknown identifier "${t.name}" resolved to null${s}. Did you misspell a state atom, action, or component name?`)}return null}case"StateRef":{if(Object.prototype.hasOwnProperty.call(fa,t.name))return t.name==="util"?ox(e):fa[t.name];if(vl.has(t.name)){if(t.name==="toast")return nx(e);if(t.name==="dom")return ax(e)}if(t.name==="emit"&&e.onEmit){const n=e.onEmit;return(a,i)=>{n(a==null?"":String(a),i)}}const r=Fe(e,t.name);return e.trackedState.add(r),e.state.get(r)}case"Array":{const r=[];for(const n of t.elements){if(n.kind==="Spread"){const a=R(n.argument,e);if(Array.isArray(a))for(const i of a)r.push(i);else if(a!=null&&typeof a=="string")for(const i of a)r.push(i);continue}r.push(R(n,e))}return r}case"Object":{const r={};for(const n of t.properties){if(n.spread){const i=R(n.value,e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const[o,s]of Object.entries(i))r[o]=s;continue}const a=n.computedKey?String(R(n.computedKey,e)??""):n.key;r[a]=R(n.value,e)}return r}case"Member":{if(wx(t))return kx(t,e);const r=Sx(t,e);if(r)return $x(t,e,r);const n=R(t.object,e);if(t.optional&&n==null)return;if(t.computed){const a=R(t.computed,e);return Ma(n,a)}return Na(n,t.property??"")}case"Unary":{if(t.operator==="delete"){const n=t.argument;if(n.kind==="Member"&&n.property){const a=R(n.object,e);if(a&&typeof a=="object")try{return delete a[n.property],!0}catch{return!1}}return!1}const r=R(t.argument,e);switch(t.operator){case"!":return!r;case"-":return-G(r);case"+":return+G(r);case"~":return~ge(r);case"typeof":return typeof r;case"void":return;default:return r}}case"Binary":return zx(t.operator,t.left,t.right,e);case"Ternary":{const r=R(t.test,e);return R(r?t.consequent:t.alternate,e)}case"Call":return Dx(t.callee,t.arguments,e,t.loc);case"MethodCall":return jx(t,e);case"Invoke":return Ix(t,e);case"New":return Px(t,e);case"BuiltinCall":return Jx(t.name,t.arguments,e);case"Template":return Lx(t.quasis,t.expressions,e);case"Spread":return R(t.argument,e);case"Block":return $a(t,e,{});case"Lambda":{const r=t.params,n=t.body,a=e.stateAliases.map(o=>new Map(o)),i=new Map(e.loopVars);return(...o)=>{const s=new Map(e.loopVars),l=e.stateAliases.slice();e.loopVars.clear();for(const[p,f]of i)e.loopVars.set(p,f);e.stateAliases.length=0;for(const p of a)e.stateAliases.push(p);const c=[],d=(p,f)=>{c.push({name:p,had:e.loopVars.has(p),prev:e.loopVars.get(p)}),e.loopVars.set(p,f)};for(let p=0;p<r.length;p+=1){const f=r[p];let b=o[p];if(b===void 0&&f.defaultValue&&(b=R(f.defaultValue,e)),f.pattern){for(const h of Wt(f.pattern,b,e))d(h.name,h.value);continue}d(f.name,b)}try{return R(n,e)}finally{for(const p of c)p.had?e.loopVars.set(p.name,p.prev):e.loopVars.delete(p.name);e.loopVars.clear();for(const[p,f]of s)e.loopVars.set(p,f);e.stateAliases.length=0;for(const p of l)e.stateAliases.push(p)}}}default:return null}}class Pe{constructor(){O(this,"kind","break")}}class ze{constructor(){O(this,"kind","continue")}}class mt{constructor(e){O(this,"kind","return");this.value=e}}function El(t,e){if(R(t.test,e)){je(t.consequent.body,e);return}if(t.alternate){if(t.alternate.kind==="IfStatement"){El(t.alternate,e);return}t.alternate.kind==="Block"&&je(t.alternate.body,e)}}function mx(t,e){const r=R(t.discriminant,e);let n=!1;try{for(const a of t.cases)n||(a.test===null||R(a.test,e)===r)&&(n=!0),n&&je(a.body,e)}catch(a){if(a instanceof Pe)return;throw a}}function fx(t,e){const r=R(t.iterable,e);if(!Array.isArray(r)&&(r==null||typeof r!="object"||!(Symbol.iterator in r)))return;const n=e.loopVars.has(t.item),a=e.loopVars.get(t.item),i=t.index,o=i?e.loopVars.has(i):!1,s=i?e.loopVars.get(i):void 0,l=t.destructure??[],c=l.map(d=>({name:d,had:e.loopVars.has(d),value:e.loopVars.get(d)}));try{let d=0;const p=(Array.isArray(r),r);for(const f of p){Vt(e.budget,1,"`for…of` loop"),e.loopVars.set(t.item,f),i&&e.loopVars.set(i,d);for(const b of l){const h=f&&typeof f=="object"?f[b]:void 0;e.loopVars.set(b,h)}try{je(t.body.body,e)}catch(b){if(b instanceof ze){d+=1;continue}if(b instanceof Pe)return;throw b}d+=1}}finally{n?e.loopVars.set(t.item,a):e.loopVars.delete(t.item),i&&(o?e.loopVars.set(i,s):e.loopVars.delete(i));for(const d of c)d.had?e.loopVars.set(d.name,d.value):e.loopVars.delete(d.name)}}function gx(t,e){for(t.init&&Wr(t.init,e);!(t.test&&!R(t.test,e));){Vt(e.budget,1,"`for` loop");try{je(t.body.body,e)}catch(r){if(!(r instanceof ze)){if(r instanceof Pe)return;throw r}}t.update&&R(t.update,e)}}function hx(t,e){for(;R(t.test,e);){Vt(e.budget,1,"`while` loop");try{je(t.body.body,e)}catch(r){if(r instanceof ze)continue;if(r instanceof Pe)return;throw r}}}function bx(t,e){for(;;){Vt(e.budget,1,"`do…while` loop");try{je(t.body.body,e)}catch(r){if(!(r instanceof ze)){if(r instanceof Pe)return;throw r}}if(!R(t.test,e))break}}function vx(t,e){const r=R(t.expression,e),n=Wt({kind:t.patternKind,bindings:t.bindings},r,e);for(const{name:a,value:i}of n)e.loopVars.set(a,i)}function Wt(t,e,r){const n=[];if(t.kind==="array"){const o=Array.isArray(e)?e:[];let s=0;for(const l of t.bindings){if(l.rest){n.push({name:l.name,value:o.slice(s)}),s=o.length;continue}let c=o[s];c===void 0&&l.defaultValue&&(c=R(l.defaultValue,r)),l.name!==""&&n.push({name:l.name,value:c}),s+=1}return n}const a=e&&typeof e=="object"&&!Array.isArray(e)?e:{},i=new Set;for(const o of t.bindings){if(o.rest){const c={};for(const[d,p]of Object.entries(a))i.has(d)||(c[d]=p);n.push({name:o.name,value:c});continue}const s=o.sourceKey??o.name;i.add(s);let l=a[s];l===void 0&&o.defaultValue&&(l=R(o.defaultValue,r)),n.push({name:o.name,value:l})}return n}function yx(t,e){const r=R(t.iterable,e);if(r==null||typeof r!="object")return;const n=e.loopVars.has(t.item),a=e.loopVars.get(t.item);try{for(const i in r){Vt(e.budget,1,"`for…in` loop"),e.loopVars.set(t.item,i);try{je(t.body.body,e)}catch(o){if(o instanceof ze)continue;if(o instanceof Pe)return;throw o}}}finally{n?e.loopVars.set(t.item,a):e.loopVars.delete(t.item)}}function xx(t,e){try{je(t.block.body,e)}catch(r){if(r instanceof Pe||r instanceof ze||r instanceof mt)throw r;if(t.catchBlock){const n=t.catchParam,a=n?e.loopVars.has(n):!1,i=n?e.loopVars.get(n):void 0;n&&e.loopVars.set(n,r);try{je(t.catchBlock.body,e)}finally{n&&(a?e.loopVars.set(n,i):e.loopVars.delete(n))}}}finally{t.finallyBlock&&je(t.finallyBlock.body,e)}}function je(t,e){for(const r of t)Wr(r,e)}function Sa(t,e){Wr(t,e)}function Wr(t,e){switch(t.kind){case"ExpressionStatement":R(t.expression,e);return;case"Assignment":{const r=R(t.expression,e);if(t.identifier)if(t.isState){const n=Fe(e,t.identifier);e.state.set(n,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":El(t,e);return;case"SwitchStatement":mx(t,e);return;case"ForOfStatement":fx(t,e);return;case"ForClassicStatement":gx(t,e);return;case"ForInStatement":yx(t,e);return;case"WhileStatement":hx(t,e);return;case"DoWhileStatement":bx(t,e);return;case"DestructureStatement":vx(t,e);return;case"TryStatement":xx(t,e);return;case"BreakStatement":throw new Pe;case"ContinueStatement":throw new ze;case"ThrowStatement":throw R(t.argument,e);case"Return":{const r=t.argument?R(t.argument,e):void 0;throw new mt(r)}case"Await":R(t.argument,e);return;default:return}}function wx(t){let e=t;for(;e.kind==="Member";)e=e.object;return e.kind==="StateRef"&&(Object.prototype.hasOwnProperty.call(fa,e.name)||vl.has(e.name))?!1:e.kind==="StateRef"}function kx(t,e){const r=Ll(t);let n=t;for(;n.kind==="Member";)n=n.object;const a=Fe(e,n.name);return zl(r,a,e)}function Ll(t){const e=[];let r=t;for(;r.kind==="Member";)e.unshift({property:r.property,computed:r.computed}),r=r.object;return e}function zl(t,e,r){let n=r.state.get(e);const a=[e];let i=!0;for(const o of t){let s,l=null;o.computed?o.computed.kind==="Literal"?(s=o.computed.value,(typeof s=="string"||typeof s=="number")&&(l=String(s))):s=R(o.computed,r):(s=o.property??"",l=o.property??"");const c=n!=null&&typeof n=="object"&&!Array.isArray(n);i&&l!==null&&c?a.push(l):i=!1,n=o.computed?Ma(n,s):Na(n,o.property??"")}return r.trackedState.add(a.join(".")),n}function Sx(t,e){let r=t;for(;r.kind==="Member";)r=r.object;if(r.kind!=="Identifier")return null;const n=R(r,e);return Fr(n)?n:null}function $x(t,e,r){const n=Ll(t),a=n[0];if(a&&a.computed===void 0&&a.property!==void 0&&Object.prototype.hasOwnProperty.call(r.__methods,a.property)){let i=r.__methods[a.property];for(let o=1;o<n.length;o+=1){const s=n[o];s.computed?i=Ma(i,R(s.computed,e)):i=Na(i,s.property??"")}return i}return zl(n,r.__atom,e)}function Cx(t,e,r){const n=r?`${r.line}:${r.column}`:`anon:${e.stores.size}`,a=e.stores.get(n);if(a)return a;const i=t[0]?R(t[0],e):{},o={},s={};let l=null,c="local",d=!1,p=50;if(i&&typeof i=="object"&&!Array.isArray(i))for(const[y,v]of Object.entries(i)){if(y==="persist"){v===!0?l=`aktion:store:${n}`:typeof v=="string"&&v&&(l=v);continue}if(y==="persistIn"){v==="session"&&(c="session");continue}if(y==="history"){v===!0?d=!0:typeof v=="number"&&v>0&&(d=!0,p=Math.floor(v));continue}typeof v=="function"?s[y]=v:o[y]=v}const f=Object.keys(o),b=r?`__store_${r.line}_${r.column}`:`__store_anon_${e.stores.size}`;if(l){const y=Mx(l,c);if(y)for(const v of f)Object.prototype.hasOwnProperty.call(y,v)&&(o[v]=y[v])}d&&(o.canUndo=!1,o.canRedo=!1),e.state.declare(b,o);const h={},g={__kind:"Store",__atom:b,__methods:h};for(const[y,v]of Object.entries(s))h[y]=(...x)=>v(g,...x);if(l){const y=`${b}.`,v=e.state.subscribe(x=>{let w=!1;for(const k of x)if(k===b||k.startsWith(y)){w=!0;break}w&&Nx(l,c,e.state.get(b))});e.disposers.push(v)}return d&&Ax(e,b,f,p,h),e.stores.set(n,g),g}function Ax(t,e,r,n,a){const i=`${e}.`,o=[],s=[];let l=!1;const c=()=>{const g=t.state.get(e),y={};for(const v of r)y[v]=g?g[v]:void 0;return y};let d=c();const p=g=>{for(const y of r)t.state.setPath(e,[y],g[y])},f=()=>{t.state.setPath(e,["canUndo"],o.length>0),t.state.setPath(e,["canRedo"],s.length>0)},b=g=>{for(const y of g){if(y===e)return!0;if(y.startsWith(i)){const v=y.slice(i.length).split(".")[0];if(v!=="canUndo"&&v!=="canRedo")return!0}}return!1},h=t.state.subscribe(g=>{if(b(g)){if(l){l=!1,d=c();return}o.push(d),o.length>n&&o.shift(),s.length=0,d=c(),f()}});t.disposers.push(h),a.undo=()=>{if(o.length===0)return;s.push(c());const g=o.pop();l=!0,p(g),d=g,f()},a.redo=()=>{if(s.length===0)return;o.push(c());const g=s.pop();l=!0,p(g),d=g,f()},a.clearHistory=()=>{o.length=0,s.length=0,f()}}function Tx(t,e,r){const n=r?`${r.line}:${r.column}`:`form:${e.stores.size}`,a=e.stores.get(n);if(a)return a;const i=t[0]?R(t[0],e):{},o=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=o.values&&typeof o.values=="object"&&!Array.isArray(o.values)?{...o.values}:{},l=o.rules&&typeof o.rules=="object"&&!Array.isArray(o.rules)?o.rules:{},c=typeof o.onSubmit=="function"?o.onSubmit:null,d=r?`__form_${r.line}_${r.column}`:`__form_anon_${e.stores.size}`,p=()=>({values:{...s},errors:{},touched:{},dirty:!1,valid:!0,submitting:!1,validating:!1});e.state.declare(d,p());const f={},b={__kind:"Store",__atom:d,__methods:f},h=()=>e.state.get(d)??{},g=()=>{const M=h().values;return M&&typeof M=="object"?M:{}},y=M=>!!M&&typeof M.then=="function";let v=0;const x=()=>{v+=1,e.state.setPath(d,["validating"],!0)},w=()=>{v=Math.max(0,v-1),v===0&&e.state.setPath(d,["validating"],!1)};let k=JSON.stringify(s);const A=M=>{try{return JSON.stringify(M)??""}catch{return""}},S=`${d}.values`,$=e.state.subscribe(M=>{let L=!1;for(const H of M)if(H===d||H===S||H.startsWith(`${S}.`)){L=!0;break}if(!L)return;const z=A(g())!==k;h().dirty!==z&&e.state.setPath(d,["dirty"],z)});e.disposers.push($),f.setField=(M,L)=>{const z=String(M);e.state.setPath(d,["values",z],L),e.state.setPath(d,["errors",z],void 0),e.state.setPath(d,["dirty"],!0)},f.setValues=M=>{const L={...g(),...M&&typeof M=="object"?M:{}};e.state.setPath(d,["values"],L),e.state.setPath(d,["dirty"],!0)},f.validateField=M=>{const L=String(M),z=g()[L],H=jr.validate(z,l[L]);return y(H)?(x(),H.then(F=>(w(),g()[L]!==z||e.state.setPath(d,["errors",L],F??void 0),F??null))):(e.state.setPath(d,["errors",L],H??void 0),H??null)},f.touch=M=>{const L=String(M);e.state.setPath(d,["touched",L],!0),f.validateField(L)};const C=M=>{e.state.setPath(d,["errors"],M);const L=Object.keys(M).length===0;return e.state.setPath(d,["valid"],L),L};return f.validate=()=>{const M=jr.validateAll(g(),l);return y(M)?(x(),M.then(L=>(w(),C(L)))):C(M)},f.handleSubmit=M=>{const L={};for(const V of Object.keys(l))L[V]=!0;const z=h().touched;e.state.setPath(d,["touched"],{...z&&typeof z=="object"?z:{},...L});const H=V=>{if(!V||!c)return V;e.state.setPath(d,["submitting"],!0);let _;try{_=c(g(),M)}catch(te){throw e.state.setPath(d,["submitting"],!1),te}return y(_)?_.finally(()=>e.state.setPath(d,["submitting"],!1)):(e.state.setPath(d,["submitting"],!1),V)},F=f.validate();return y(F)?F.then(H):H(F)},f.submit=M=>f.handleSubmit(M),f.reset=()=>{const M=p();k=A(M.values),e.state.setPath(d,["values"],M.values),e.state.setPath(d,["errors"],{}),e.state.setPath(d,["touched"],{}),e.state.setPath(d,["dirty"],!1),e.state.setPath(d,["valid"],!0),e.state.setPath(d,["submitting"],!1),e.state.setPath(d,["validating"],!1)},f.field=M=>{const L=String(M);e.trackedState.add(`${d}.values.${L}`),e.trackedState.add(`${d}.errors.${L}`),e.trackedState.add(`${d}.touched.${L}`);const z=h(),H=z.errors&&typeof z.errors=="object"?z.errors:{},F=z.touched&&typeof z.touched=="object"?z.touched:{};return{name:L,value:g()[L]??"",error:F[L]?H[L]:void 0,onChange:V=>f.setField(L,V),onBlur:()=>f.touch(L)}},e.stores.set(n,b),b}function jl(t){if(typeof globalThis>"u")return null;const e=globalThis;try{return(t==="session"?e.sessionStorage:e.localStorage)??null}catch{return null}}function Mx(t,e){const r=jl(e);if(!r)return null;try{const n=r.getItem(t);if(!n)return null;const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}function Nx(t,e,r){const n=jl(e);if(n)try{n.setItem(t,JSON.stringify(r))}catch{}}function Dl(t,e){const r=[];let n=t;for(;n.kind==="Member";){if(n.computed){if(n.computed.kind!=="Literal")return null;const i=n.computed.value;if(typeof i!="string"&&typeof i!="number")return null;r.unshift(String(i))}else if(n.property)r.unshift(n.property);else return null;n=n.object}if(n.kind!=="Identifier")return null;const a=R(n,e);return Fr(a)?{atom:a.__atom,path:r}:null}function Ix(t,e){if(t.callee.kind==="StateRef"){const a=t.callee.name;if(a==="state")return Ux(t.arguments,e,t.loc);if(a==="memo")return Hx(t.arguments,e,t.loc);if(a==="ref")return qx(t.arguments,e,t.loc);if(a==="reducer")return Vx(t.arguments,e,t.loc);if(a==="id")return Wx(t.arguments,e,t.loc);switch(a){case"store":return Cx(t.arguments,e,t.loc);case"form":return Tx(t.arguments,e,t.loc);case"router":return px(t.arguments,e,t.loc);case"http":{const o=t.arguments[0];return Zn(o?R(o,e):{},e)}case"query":{const o=t.arguments[0];return Vs(o?R(o,e):{},e)}case"mutation":{const o=t.arguments[0];return Ws(o?R(o,e):{},e)}case"socket":{const o=t.arguments[0];return ly(o?R(o,e):{},e)}case"sse":{const o=t.arguments[0];return cy(o?R(o,e):{},e)}case"script":{const o=t.arguments[0];return my(o?R(o,e):{},e)}case"head":{const o=t.arguments[0];return ga(e).apply(o?R(o,e):{}),null}case"theme":{const o=t.arguments[0],s=o?R(o,e):null;if(s&&typeof s=="object"&&!Array.isArray(s)){const f=s;f.icons&&Ni(f.icons),f.fonts&&el(f.fonts),f.font&&el(f.font)}const l=lw(s),c=sw(s),d=c?Ut[c]:null;return{kind:"Theme",tokens:d?{...d,...l}:l}}case"app":{const o=t.arguments;return o.length===1?R(o[0],e):o.map(s=>R(s,e))}case"i18n":{const o=t.arguments[0],s=o?R(o,e):null,l=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return Xs(l)}case"emit":{const o=t.arguments[0]?String(R(t.arguments[0],e)):"",s=t.arguments[1]?R(t.arguments[1],e):void 0;e.onEmit?.(o,s);return}case"storage":return t.arguments[0]&&R(t.arguments[0],e),pa;case"optimistic":return Fx(t.arguments[0],e)}const i=e.hookDecls.get(a);if(i)return Gx(i,t.arguments,e)}const r=R(t.callee,e);if(r==null)return t.optional?void 0:null;if(typeof r!="function")return null;const n=[];for(const a of t.arguments){if(a.kind==="Spread"){const i=R(a.argument,e);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(R(a,e))}try{return r.apply(void 0,n)}catch(a){return console.error("[aktion] call expression threw",a),null}}function Px(t,e){const r=R(t.callee,e);if(typeof r!="function")return null;const n=[];for(const a of t.arguments){if(a.kind==="Spread"){const i=R(a.argument,e);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(R(a,e))}try{return Reflect.construct(r,n)}catch(a){return console.error("[aktion] `new` threw",a),null}}function Rx(t,e,r){t.kind==="ComponentDeclaration"?r.push({kind:"component",name:t.name,had:e.componentDecls.has(t.name),prev:e.componentDecls.get(t.name)}):t.kind==="ActionDeclaration"?r.push({kind:"action",name:t.name,had:e.actionDecls.has(t.name),prev:e.actionDecls.get(t.name)}):r.push({kind:"hook",name:t.name,had:e.hookDecls.has(t.name),prev:e.hookDecls.get(t.name)})}function Ex(t,e){for(let r=e.length-1;r>=0;r-=1){const n=e[r],a=n.kind==="component"?t.componentDecls:n.kind==="action"?t.actionDecls:t.hookDecls;n.had?a.set(n.name,n.prev):a.delete(n.name)}}function $a(t,e,r){let n=null;const a=[],i=[];try{for(const o of t.body)switch(o.kind){case"ExpressionStatement":n=R(o.expression,e);continue;case"Assignment":{if(o.isState&&o.identifier){const l=Fe(e,o.identifier);if(r.stateAsDeclaration){if(e.state.has(l)){n=e.state.get(l);continue}const d=R(o.expression,e);e.state.declare(l,d),n=d;continue}const c=R(o.expression,e);e.state.set(l,c),n=c;continue}const s=R(o.expression,e);e.bindings.has(o.identifier)&&!e.loopVars.has(o.identifier)?e.mutableBindings.set(o.identifier,s):(e.loopVars.has(o.identifier)||a.push(o.identifier),e.loopVars.set(o.identifier,s)),n=s;continue}case"Return":return n=o.argument?R(o.argument,e):void 0,n;case"ThrowStatement":throw R(o.argument,e);case"EffectDeclaration":{const s=e.componentEffectStack[e.componentEffectStack.length-1];s?s.push({decl:o,capturedAliases:e.stateAliases.map(l=>new Map(l)),capturedLoopVars:new Map(e.loopVars)}):wa(o,e);continue}case"ComponentDeclaration":case"ActionDeclaration":case"HookDeclaration":Rx(o,e,i),wa(o,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":Wr(o,e);continue}}catch(o){if(o instanceof mt)return o.value;throw o}finally{for(const o of a)e.loopVars.delete(o);Ex(e,i)}return n}function Lx(t,e,r){let n=t[0]??"";for(let a=0;a<e.length;a+=1)n+=Ia(R(e[a],r)),n+=t[a+1]??"";return n}function zx(t,e,r,n){if(t==="&&"){const o=R(e,n);return o&&R(r,n)}if(t==="||"){const o=R(e,n);return o||R(r,n)}if(t==="??"){const o=R(e,n);return o??R(r,n)}const a=R(e,n),i=R(r,n);switch(t){case"+":return typeof a=="string"||typeof i=="string"?Ia(a)+Ia(i):G(a)+G(i);case"-":return G(a)-G(i);case"*":return G(a)*G(i);case"/":{const o=G(i);return o===0?0:G(a)/o}case"%":{const o=G(i);return o===0?0:G(a)%o}case"**":return G(a)**G(i);case"==":case"===":return a===i;case"!=":case"!==":return a!==i;case">":return G(a)>G(i);case"<":return G(a)<G(i);case">=":return G(a)>=G(i);case"<=":return G(a)<=G(i);case"&":return ge(a)&ge(i);case"|":return ge(a)|ge(i);case"^":return ge(a)^ge(i);case"<<":return ge(a)<<(nt(i)&31);case">>":return ge(a)>>(nt(i)&31);case">>>":return nt(a)>>>(nt(i)&31);case"instanceof":{if(typeof i!="function")return!1;try{return a instanceof i}catch{return!1}}case"in":{if(i==null||typeof i!="object"&&typeof i!="function")return!1;try{return String(a)in i}catch{return!1}}default:return null}}function ge(t){return G(t)|0}function nt(t){return G(t)>>>0}function jx(t,e){const r=R(t.object,e);if(r==null)return t.optional?void 0:null;const n=Fr(r)?r.__methods[t.method]:r[t.method];if(typeof n!="function")return null;const a=[];for(const o of t.arguments){if(o.kind==="Spread"){const s=R(o.argument,e);if(Array.isArray(s))for(const l of s)a.push(l);continue}a.push(R(o,e))}const i=a;try{return n.apply(r,i)}catch(o){if(o instanceof RangeError||o instanceof rt)throw o;return console.error(`[aktion] method "${t.method}" threw`,o),null}}function Dx(t,e,r,n){const a=r.componentDecls.get(t),i=a!==void 0&&kl(t,r);if(a&&!i)return Bx(a,e,r,n);const o=i?void 0:r.actionDecls.get(t);if(o){const g=e.map(y=>R(y,r));return Bl(o,g,r)}if(t==="cleanup"&&r.cleanupSink){const g=e[0]?R(e[0],r):void 0;typeof g=="function"&&r.cleanupSink(g);return}if(t==="setTimeout"||t==="setInterval")return Qx(t,e,r);if(t==="clearTimeout"||t==="clearInterval"){const g=e[0]?R(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 s=r.loopVars.get(t);if(typeof s=="function"){const g=e.map(y=>R(y,r));return s(...g)}const l=r.bindings.get(t);if(l){const g=l();if(typeof g=="function"){const y=e.map(v=>R(v,r));return g(...y)}}if(Object.prototype.hasOwnProperty.call(qt,t)&&typeof qt[t]=="function"&&!r.componentDecls.has(t)&&!(r.library&&Le(r.library,t))){const g=qt[t],y=[];for(const v of e){if(v.kind==="Spread"){const x=R(v.argument,r);if(Array.isArray(x))for(const w of x)y.push(w);continue}y.push(R(v,r))}try{return g(...y)}catch(v){return console.error(`[aktion] global "${t}" threw`,v),null}}if(r.library&&!Le(r.library,t)){const g=xl(t);if(g.found&&typeof g.value=="function"){const y=g.value,v=[];for(const x of e){if(x.kind==="Spread"){const w=R(x.argument,r);if(Array.isArray(w))for(const k of w)v.push(k);continue}v.push(R(x,r))}try{return y(...v)}catch(x){return console.error(`[aktion] global "${t}" threw`,x),null}}return Le(r.library,"Skeleton")?{__kind:"Component",name:"Skeleton",args:[],argMeta:[],source:n}:null}let c;const d=[...e];if(d.length>0){const g=d[d.length-1];if(g.kind==="Object"){const y=g.properties.find(v=>!v.spread&&v.key==="key");if(y){c=R(y.value,r);const v=g.properties.filter(x=>x!==y);v.length>0?d[d.length-1]={...g,properties:v}:d.pop()}}}const{args:p,argMeta:f,universal:b}=Ox(r,t,d);return{__kind:"Component",name:t,args:p,argMeta:f,explicitKey:c,universal:b,source:n}}function Ox(t,e,r){const n=t.library?Le(t.library,e):void 0;if(!n){const b=r.map(g=>R(g,t)),h=r.map(g=>{const y=Hr(g,t);return y!==null?{stateRef:y}:{}});return{args:b,argMeta:h}}const a=new Map;n.props.forEach((b,h)=>{if(a.set(b.name,h),b.aliases)for(const g of b.aliases)a.has(g)||a.set(g,h)});const i=sr(n),o=n.props.map(()=>({value:void 0,meta:{},filled:!1}));let s;const l=[],c=gn(hn(r),n);for(let b=0;b<r.length;b+=1){if(b===c)continue;const h=r[b];l.push({expr:h,value:R(h,t)})}if(c>=0){const b=r[c];if(b.kind==="Object")for(const h of b.properties){if(h.spread)continue;const g=a.get(h.key);if(g===void 0){pn.has(h.key)&&(s||(s={}),s[h.key]=R(h.value,t));continue}const y=R(h.value,t);o[g].value=y,o[g].filled=!0;const v=Hr(h.value,t);v!==null&&(o[g].meta={stateRef:v})}}if(l.length>0&&i>=0&&!o[i].filled){const{expr:b,value:h}=l.shift();o[i].value=h,o[i].filled=!0;const g=Hr(b,t);g!==null&&(o[i].meta={stateRef:g})}let d=0;for(const{expr:b,value:h}of l){for(;d<n.props.length&&o[d].filled;)d+=1;if(d>=n.props.length)break;o[d].value=h,o[d].filled=!0;const g=Hr(b,t);g!==null&&(o[d].meta={stateRef:g}),d+=1}const p=o.map(b=>b.value),f=o.map(b=>b.meta);for(;p.length>0&&p[p.length-1]===void 0;)p.pop(),f.pop();return{args:p,argMeta:f,universal:s}}function Bx(t,e,r,n){const a=[],i={};let o,s=-1;for(let h=e.length-1;h>=0;h-=1)if(e[h].kind==="Object"){s=h;break}let l=s>=0?e[s]:null,c=!1;if(l&&l.kind==="Object"){const h=new Set(t.params.map(v=>v.name)),g=[];let y=!0;for(const v of l.properties)v.spread||(g.push(v.key),(v.key==="key"||h.has(v.key))&&(c=!0),/^[A-Za-z_$][\w$]*$/.test(v.key)||(y=!1));if(!c&&y&&g.length>0&&e.length-1>=t.params.length&&(c=!0),!c&&r.strict&&g.length>0&&t.params.length>0){const v=`trailing:${t.name}:${g.slice().sort().join(",")}`;if(!r.strictWarned.has(v)){r.strictWarned.add(v);const x=n?` (line ${n.line}, col ${n.column})`:"";console.warn(`[aktion] strict: object { ${g.join(", ")} } passed to <${t.name}>${x} is being forwarded as a positional argument because none of its keys match a parameter (${t.params.map(w=>w.name).join(", ")||"none"}). If you meant named props, check for a renamed/misspelled parameter.`)}}}c||(s=-1,l=null);for(let h=0;h<e.length;h+=1)h!==s&&a.push(e[h]);if(l&&l.kind==="Object")for(const h of l.properties)h.spread||(h.key==="key"?o=h.value:i[h.key]=h.value);const d=a.map(h=>h.kind==="Spread"?R(h.argument,r):R(h,r)),p=[];for(let h=0;h<a.length;h+=1){const g=a[h],y=d[h];if(g.kind==="Spread"&&Array.isArray(y))for(const v of y)p.push(v);else p.push(y)}const f={};for(const[h,g]of Object.entries(i))f[h]=R(g,r);const b=o?R(o,r):void 0;return{__kind:"UserComponent",decl:t,positional:p,named:f,explicitKey:b,source:n}}function Ol(t,e,r){const{decl:n,positional:a,named:i}=t,o=[],s=(h,g)=>{o.push({name:h,had:e.loopVars.has(h),prev:e.loopVars.get(h)}),e.loopVars.set(h,g)};for(let h=0;h<n.params.length;h+=1){const g=n.params[h];if(g.pattern){let v=a[h];v===void 0&&g.defaultValue&&(v=R(g.defaultValue,e));for(const x of Wt(g.pattern,v,e))s(x.name,x.value);continue}let y;i[g.name]!==void 0?y=i[g.name]:a[h]!==void 0?y=a[h]:g.defaultValue?y=R(g.defaultValue,e):y=void 0,s(g.name,y)}if(a.length>n.params.length){const h=a.slice(n.params.length),g=h.length===1?h[0]:h;o.push({name:"children",had:e.loopVars.has("children"),prev:e.loopVars.get("children")}),e.loopVars.set("children",g)}const l=new Set;for(const h of n.params)h.name&&l.add(h.name);const c={};for(const h of n.slots)i[h]!==void 0&&(c[h]=i[h]);for(const[h,g]of Object.entries(i))l.has(h)||g===void 0||(c[h]=g,/^[A-Za-z_$][\w$]*$/.test(h)&&h!=="children"&&h!=="slots"&&!e.componentDecls.has(h)&&s(h,g));(Object.keys(c).length>0||n.slots.length>0)&&(o.push({name:"slots",had:e.loopVars.has("slots"),prev:e.loopVars.get("slots")}),e.loopVars.set("slots",c));const d=new Map;for(const h of n.body.body)if(h.kind==="Assignment"&&h.isState){const g=`${r}:${h.identifier}`;d.set(h.identifier,g)}e.stateAliases.push(d);const p=[];e.componentEffectStack.push(p);const f=e.hookScope,b={instanceKey:r,cursor:0};e.hookScope=b,e.activeComponentDecls.push(n.name);try{return{value:$a(n.body,e,{stateAsDeclaration:!0}),effects:p,hooks:b.cursor}}finally{e.activeComponentDecls.pop(),e.hookScope=f,e.componentEffectStack.pop(),e.stateAliases.pop();for(const h of o)h.had?e.loopVars.set(h.name,h.prev):e.loopVars.delete(h.name)}}function Bl(t,e,r){const n=!!(t.name&&r.componentDecls.has(t.name)&&r.library&&Le(r.library,t.name));n&&r.activeComponentDecls.push(t.name);try{if(!r.errorHook)return Ca(t.params,t.body,e,r);try{return Ca(t.params,t.body,e,r)}catch(a){if(a instanceof mt||a instanceof Pe||a instanceof ze)throw a;try{r.errorHook({error:a,source:t.name??"action"})}catch{}throw a}}finally{n&&r.activeComponentDecls.pop()}}function Fx(t,e){const r=t?R(t,e):void 0;if(typeof r!="function")return;const n=new Map;for(const[i,o]of e.state.entries())n.set(i,o);const a=()=>{for(const i of[...e.state.entries()].map(([o])=>o))n.has(i)||e.state.set(i,void 0);for(const[i,o]of n)e.state.set(i,o);e.notify?.()};try{const i=r();return i&&typeof i.then=="function"?i.catch(o=>{throw a(),o}):i}catch(i){throw i instanceof mt||i instanceof Pe||i instanceof ze||a(),i}}function Ca(t,e,r,n){const a=[],i=(o,s)=>{a.push({name:o,had:n.loopVars.has(o),prev:n.loopVars.get(o)}),n.loopVars.set(o,s)};for(let o=0;o<t.length;o+=1){const s=t[o];let l=r[o];if(l===void 0&&s.defaultValue&&(l=R(s.defaultValue,n)),s.pattern){for(const c of Wt(s.pattern,l,n))i(c.name,c.value);continue}i(s.name,l)}try{return $a(e,n,{stateAsDeclaration:n.state.isRendering()})}finally{for(const o of a)o.had?n.loopVars.set(o.name,o.prev):n.loopVars.delete(o.name)}}function Gt(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 _x(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 Ux(t,e,r){const n=Gt(e);if(!n)return Kt("state",r),[t[0]?R(t[0],e):void 0,()=>{}];const a=e.hookScope.cursor++;let i=n[a];(!i||i.kind!=="state")&&(i={kind:"state",value:t[0]?R(t[0],e):void 0},n[a]=i);const o=i,s=l=>{const c=typeof l=="function"?l(o.value):l;Object.is(c,o.value)||(o.value=c,e.notify?.())};return[o.value,s]}function Hx(t,e,r){const n=t[0],a=t[1],i=()=>{const f=n?R(n,e):void 0;return typeof f=="function"?f():f},o=Gt(e);if(!o)return Kt("memo",r),i();const s=e.hookScope.cursor++,l=a?R(a,e):void 0,c=Array.isArray(l)?l:void 0,d=o[s];if(d&&d.kind==="memo"&&c&&d.deps&&_x(d.deps,c))return d.value;const p=i();return o[s]={kind:"memo",deps:c,value:p},p}function qx(t,e,r){const n=Gt(e);if(!n)return Kt("ref",r),{current:t[0]?R(t[0],e):void 0};const a=e.hookScope.cursor++;let i=n[a];return(!i||i.kind!=="ref")&&(i={kind:"ref",box:{current:t[0]?R(t[0],e):void 0}},n[a]=i),i.box}function Vx(t,e,r){const n=t[0]?R(t[0],e):void 0,a=Gt(e),i=t[1]?R(t[1],e):void 0;if(!a)return Kt("reducer",r),[i,()=>{}];const o=e.hookScope.cursor++;let s=a[o];(!s||s.kind!=="reducer")&&(s={kind:"reducer",value:i},a[o]=s);const l=s,c=d=>{if(typeof n!="function")return;const p=n(l.value,d);Object.is(p,l.value)||(l.value=p,e.notify?.())};return[l.value,c]}let Fl=0;function Wx(t,e,r){const n=t[0]?String(R(t[0],e)):"rui",a=Gt(e);if(!a)return Kt("id",r),`${n}-${Fl+=1}`;const i=e.hookScope.cursor++;let o=a[i];return(!o||o.kind!=="id")&&(o={kind:"id",value:`${n}-${Fl+=1}`},a[i]=o),o.value}function Gx(t,e,r){const n=[];for(const a of e){if(a.kind==="Spread"){const i=R(a.argument,r);if(Array.isArray(i))for(const o of i)n.push(o);continue}n.push(R(a,r))}return Ca(t.params,t.body,n,r)}let _l=!1;function Kt(t,e){_l||(_l=!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 Ul(t,e){t.hookStore.delete(e)}function Kx(t,e){const r=e.stateAliases.map(a=>new Map(a)),n=new Map(e.loopVars);return(...a)=>{const i=new Map(e.loopVars),o=e.stateAliases.slice();e.loopVars.clear();for(const[s,l]of n)e.loopVars.set(s,l);e.stateAliases.length=0;for(const s of r)e.stateAliases.push(s);try{return Bl(t,a,e)}finally{e.loopVars.clear();for(const[s,l]of i)e.loopVars.set(s,l);e.stateAliases.length=0;for(const s of o)e.stateAliases.push(s)}}}function Yx(t,e){return(...r)=>({__kind:"UserComponent",decl:t,positional:r,named:{},explicitKey:void 0,source:t.loc})}function Xx(t,e){return(...r)=>({__kind:"Component",name:t,args:r,argMeta:r.map(()=>({})),source:void 0})}function Jx(t,e,r){return t==="__rui_assign__"?Zx(e,r):t==="__rui_postfix__"?ew(e,r):t==="__rui_prefix__"?tw(e,r):t==="__rui_await__"?e[0]?R(e[0],r):void 0:null}function at(t,e,r){switch(t){case"=":return r;case"+=":return typeof e=="string"||typeof r=="string"?`${e??""}${r??""}`:G(e)+G(r);case"-=":return G(e)-G(r);case"*=":return G(e)*G(r);case"/=":{const n=G(r);return n===0?0:G(e)/n}case"%=":{const n=G(r);return n===0?0:G(e)%n}case"**=":return G(e)**G(r);case"&&=":return e&&r;case"||=":return e||r;case"??=":return e??r;case"&=":return ge(e)&ge(r);case"|=":return ge(e)|ge(r);case"^=":return ge(e)^ge(r);case"<<=":return ge(e)<<(nt(r)&31);case">>=":return ge(e)>>(nt(r)&31);case">>>=":return nt(e)>>>(nt(r)&31);default:return r}}function Qx(t,e,r){const n=e[0]?R(e[0],r):null;if(typeof n!="function")return null;const a=n,i=e[1]?G(R(e[1],r)):0,o=[];for(let c=2;c<e.length;c+=1)o.push(R(e[c],r));const s=()=>{try{a(...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 l=setInterval(s,i);return r.timers.intervals.add(l),l}function Zx(t,e){const[r,n,a]=t;if(!r||!n)return null;const i=a&&a.kind==="Literal"?String(a.value??"="):"=",o=R(n,e);if(r.kind==="StateRef"){const s=Fe(e,r.name),l=e.state.get(s),c=at(i,l,o);return e.state.set(s,c),c}if(r.kind==="Member"){const s=Ur(r,e);if(s){const p=e.state.get(s.name);if(s.path.length>=1&&Us(p)){let h=p;for(let g=0;g<s.path.length-1;g+=1)h=h?.[s.path[g]];if(h&&typeof h=="object"){const g=s.path[s.path.length-1],y=h[g],v=at(i,y,o);return h[g]=v,e.notify?.(),v}}const f=Aa(p,s.path),b=at(i,f,o);return e.state.setPath(s.name,s.path,b),b}const l=Dl(r,e);if(l){const p=Aa(e.state.get(l.atom),l.path),f=at(i,p,o);return e.state.setPath(l.atom,l.path,f),f}const c=R(r.object,e),d=r.computed?r.computed.kind==="Literal"?r.computed.value:null:r.property;if(c&&typeof c=="object"&&d!=null){const p=c[String(d)],f=at(i,p,o);return c[String(d)]=f,f}return o}if(r.kind==="Identifier"){const s=r.name;if(e.loopVars.has(s)){const d=e.loopVars.get(s),p=at(i,d,o);return e.loopVars.set(s,p),p}if(e.bindings.has(s)||e.mutableBindings.has(s)){const d=e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)(),p=at(i,d,o);return e.mutableBindings.set(s,p),p}const l=e.loopVars.get(s),c=at(i,l,o);return e.loopVars.set(s,c),c}return o}function Aa(t,e){let r=t;for(const n of e){if(r==null)return;if(Array.isArray(r)){const a=Number(n);r=Number.isNaN(a)?void 0:r[a];continue}if(typeof r=="object"){r=r[n];continue}return}return r}function Hl(t,e,r){const[n,a]=t;if(!n)return null;const o=(a&&a.kind==="Literal"?String(a.value??"++"):"++")==="--"?-1:1;if(n.kind==="StateRef"){const s=Fe(e,n.name),l=G(e.state.get(s)),c=l+o;return e.state.set(s,c),r==="prefix"?c:l}if(n.kind==="Member"){const s=Ur(n,e);if(s){const l=G(Aa(e.state.get(s.name),s.path)),c=l+o;return e.state.setPath(s.name,s.path,c),r==="prefix"?c:l}}if(n.kind==="Identifier"){const s=n.name;if(e.loopVars.has(s)){const d=G(e.loopVars.get(s)),p=d+o;return e.loopVars.set(s,p),r==="prefix"?p:d}if(e.bindings.has(s)||e.mutableBindings.has(s)){const d=G(e.mutableBindings.has(s)?e.mutableBindings.get(s):e.bindings.get(s)()),p=d+o;return e.mutableBindings.set(s,p),r==="prefix"?p:d}const l=G(e.loopVars.get(s)),c=l+o;return e.loopVars.set(s,c),r==="prefix"?c:l}return null}function ew(t,e){return Hl(t,e,"postfix")}function tw(t,e){return Hl(t,e,"prefix")}function Ta(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 rw(t){const e=t.getPath(),r={...t.getParams()},n=t.getActivePattern(),a={};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,l]of o)a[s]=l}}return{path:e,params:r,pattern:n,query:a,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Ma(t,e){if(t!=null){if(Array.isArray(t)){const r=ql(e,t.length);return r===null?void 0:t[r]}if(typeof t=="string"){const r=ql(e,t.length);return r===null?void 0:t[r]}if(typeof t=="object")return t[String(e??"")]}}function ql(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 Na(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 G(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 nw=new Set(["colors","radius","font","fonts","spacing","shadows","gradients","zIndex","motion"]),aw=new Set(["name","direction"]),iw={sm:"s",md:"m",lg:"l"},ow={colors:"color",radius:"radius",font:"font",spacing:"spacing",shadows:"shadow",gradients:"gradient",zIndex:"z",motion:"motion"};function sw(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t.name;if(typeof e!="string")return null;const r=e.trim().toLowerCase();return r in Ut?r:null}function lw(t){const e={};if(!t||typeof t!="object"||Array.isArray(t))return e;const r=t;for(const[n,a]of Object.entries(r))if(a!=null&&!aw.has(n)&&nw.has(n)&&a&&typeof a=="object"&&!Array.isArray(a)){const i=ow[n]??n,o=n==="gradients";for(const[s,l]of Object.entries(a)){if(l==null)continue;const c=n==="spacing"?iw[s]??s:s,d=i+uw(c),p=o?cw(l):dw(l);p&&(e[d]=p)}}return e}function cw(t){const e=r=>{const n=typeof r=="string"?r.trim():"";return!n||n.length>64||!/^[a-zA-Z0-9#%.,()\s+-]+$/.test(n)||/url\s*\(|expression\s*\(|javascript\s*:|@import/i.test(n)?"":n};if(Array.isArray(t)){const r=t.map(e).filter(Boolean);return r.length<2?"":`linear-gradient(120deg, ${r.join(", ")})`}if(t&&typeof t=="object"){const r=t,n=Array.isArray(r.stops)?r.stops.map(e).filter(Boolean):[];return n.length<2?"":`linear-gradient(${typeof r.angle=="number"&&Number.isFinite(r.angle)?`${Math.round(r.angle)}deg`:"120deg"}, ${n.join(", ")})`}if(typeof t=="string"){const r=t.trim();if(/^(linear|radial|conic)-gradient\(/.test(r)&&!/expression\s*\(|javascript\s*:|@import|<\/?\w/i.test(r)&&r.length<=256)return r}return""}function uw(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function dw(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function Ia(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 pw="__AKTION_DEVTOOLS_HOOK__";function mw(){return globalThis}function Gr(){return mw()[pw]}function Pa(){const t=Gr();return t!==void 0&&t.active}function Ra(t){Gr()?.emit(t)}function fw(t){Gr()?.unregisterApp(t)}function we(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}const gw="$";function Vl(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 Wl(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(!Object.prototype.hasOwnProperty.call(e,a)||!Object.is(t[a],e[a]))return!1;return!0}class Ea{constructor(e){O(this,"instanceStates",new Map);O(this,"instanceDisposers",new Map);O(this,"aliveInstances",new Set);O(this,"instancesWithEffects",new Set);O(this,"instancesWithHooks",new Set);O(this,"memoCache",new Map);O(this,"changedPaths",new Set);O(this,"memoEnabled",!1);O(this,"profiling",!1);O(this,"profilerRecords",[]);O(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 n=0;n<e.length;n+=1)e[n]==="#"&&(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 n=r.lastIndexOf("::"),a=n===-1?r:r.slice(0,n);e.has(a)||this.instanceStates.delete(r)}for(const[r,n]of[...this.instanceDisposers.entries()])if(!e.has(r)){for(const a of n.values())this.safeDispose(a);this.instanceDisposers.delete(r)}if(this.options.unmountInstanceEffects){for(const r of[...this.instancesWithEffects])if(!e.has(r)){try{this.options.unmountInstanceEffects(r)}catch(n){console.error(`[aktion] unmountInstanceEffects threw for ${r}`,n)}this.instancesWithEffects.delete(r)}}if(this.options.unmountInstanceHooks){for(const r of[...this.instancesWithHooks])if(!e.has(r)){try{this.options.unmountInstanceHooks(r)}catch(n){console.error(`[aktion] unmountInstanceHooks threw for ${r}`,n)}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,n,a,i,o,s){this.profilerRecords.push({instanceKey:e,name:r,kind:n,phase:a,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 n=e.indexOf(".");if(n<0){this.options.state.set(e,r);return}const a=e.slice(0,n),i=e.slice(n+1).split(".");this.options.state.setPath(a,i,r)}render(e){return this.renderAt(e,gw)}renderAt(e,r){if(e==null)return document.createTextNode("");if(Array.isArray(e)){const n=document.createDocumentFragment();return e.forEach((a,i)=>{n.append(this.renderAt(a,`${r}/${i}`))}),n}return $l(e)?this.renderUserComponent(e,r):Sl(e)?this.renderComponent(e,r):typeof e=="string"||typeof e=="number"||typeof e=="boolean"?document.createTextNode(String(e)):document.createTextNode("")}renderUserComponent(e,r){const n=this.options.evaluationContext;if(!n){const p=document.createElement("div");return p.className="rui-unknown-component",p.textContent=`[unknown component: ${e.decl.name}]`,p}const a=n(),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&&Vl(e.positional,s.positional)&&Wl(e.named,s.named)&&!Bt(this.changedPaths,s.deps)){const p=a.trackedState;for(const f of s.deps)p.add(f);this.profiling&&this.profile(o,e.decl.name,"user","memo",0,"memoized (args + deps unchanged)",s.deps),ba(a,e.decl.name);try{return this.renderAt(s.value,o)}finally{va(a)}}const l=this.profiledInstances.has(o)?"update":"mount",c=s?Vl(e.positional,s.positional)?Wl(e.named,s.named)?Bt(this.changedPaths,s.deps)?"state dependency changed":"full render":"named args changed":"positional args changed":l==="mount"?"initial mount":"no memo (full render)",d=this.profiling?we():0;ba(a,e.decl.name);try{const p=a.trackedState,f=new Set;a.trackedState=f;let b;try{b=Ol(e,a,o)}finally{a.trackedState=p;for(const x of f)p.add(x)}const{value:h,effects:g,hooks:y}=b;this.profiling&&this.profile(o,e.decl.name,"user",l,we()-d,c,f),this.options.mountInstanceEffects&&(this.options.mountInstanceEffects(o,g,n),g.length>0&&this.instancesWithEffects.add(o)),y>0&&this.instancesWithHooks.add(o),this.memoCache.set(o,{positional:e.positional,named:e.named,deps:f,value:h});const v=this.renderAt(h,o);return e.explicitKey!=null&&v instanceof Element&&!v.hasAttribute("data-rui-key")&&v.setAttribute("data-rui-key",String(e.explicitKey)),v}finally{va(a)}}renderComponent(e,r){const n=Le(this.options.library,e.name);if(!n){const p=document.createElement("div");return p.className="rui-unknown-component",p.textContent=`[unknown component: ${e.name}]`,p}const a=lr(n,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 l={renderNode:p=>this.renderAt(p,`${o}>${s++}`),invoke:(p,...f)=>{if(typeof p=="function")try{const b=p(...f);b&&typeof b.then=="function"&&b.catch(h=>{console.error("[aktion] handler rejected",h)})}catch(b){console.error("[aktion] handler threw",b)}},setState:(p,f)=>{this.writeState(p,f)},resetState:(...p)=>{this.options.state.reset(...p)},sendToAssistant:p=>{this.options.onAssistantMessage?.(p)},openUrl:p=>{const f=qe(p,"#"),b=this.options.onOpenUrl;b?b(f):f!=="#"&&typeof window<"u"&&window.open(f,"_blank","noopener,noreferrer")},bindState:(p,f,b)=>{const g=`on${b?.event??this.eventFor(p)}`,y=b?.getValue??this.defaultValueGetter(p);p[g]=v=>{const x=v.currentTarget??v.target??p;this.writeState(f,y(x))}},useInstanceState:(p,f)=>{const b=`${o}::${p}`;return this.instanceStates.has(b)||this.instanceStates.set(b,f),{get:()=>this.instanceStates.get(b),set:h=>{this.instanceStates.set(b,h)}}},registerDisposer:(p,f)=>{let b=this.instanceDisposers.get(o);b||(b=new Map,this.instanceDisposers.set(o,b));const h=f??`__anon::${b.size}`,g=b.get(h);g&&g!==p&&this.safeDispose(g),b.set(h,p)},router:this.options.router},c=this.profiledInstances.has(o)?"update":"mount",d=this.profiling?we():0;try{const p=n.render(e,a,l);return e.universal&&Ku(p,e.universal),e.explicitKey!=null&&p instanceof Element&&!p.hasAttribute("data-rui-key")&&p.setAttribute("data-rui-key",String(e.explicitKey)),this.profiling&&this.profile(o,e.name,"library",c,we()-d,c==="mount"?"mounted":"re-rendered"),p}catch(p){this.profiling&&this.profile(o,e.name,"library",c,we()-d,"render threw"),console.error(`[aktion] failed to render ${n.name}`,p);const f=document.createElement("div");return f.className="rui-render-error",f.textContent=`[render error in ${n.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 n=r.value;if(n==="")return null;const a=Number(n);return Number.isFinite(a)?a:null}:e instanceof HTMLInputElement&&e.type==="range"?r=>Number(r.value):r=>r.value}}function hw(){return typeof document<"u"&&typeof document.createElement=="function"}function Gl(t,e={}){if(!hw())throw new Error("[aktion] renderToString requires a DOM. In Node, register happy-dom or jsdom globals before calling it.");const r=e.library??Tt,n=new Yn;e.initialState&&typeof e.initialState=="object"&&n.hydrate(e.initialState);const a=new ua({defaultPath:e.path??"/"}),i=new Xn,o=_r(n,{library:r,router:a,http:i,notify:()=>{}});let s;try{s=Se(t)}catch(x){return console.error("[aktion] renderToString parse error",x),{html:e.container===!1?"":'<div class="rui-root"></div>',state:n.snapshot(),head:"",headAttrs:{}}}xa(s,o);const l=new Ea({library:r,state:n,router:a,evaluationContext:()=>o}),c=o.bindings.get("aktion");let d=null;if(c)try{d=c()}catch(x){console.error("[aktion] renderToString entry-point error",x)}l.beginRender({changedPaths:new Set,memoize:!1});let p;try{p=l.render(d)}finally{l.endRender()}const f=document.createElement("div");f.className="rui-root",f.append(p);const b=f.innerHTML,h=e.container===!1?b:f.outerHTML,g=ga(o),y=g.serialize(),v=g.htmlAttrs();return{html:h,state:n.snapshot(),head:y,headAttrs:v}}function bw(t,e={}){return Gl(t,e).html}function vw(t){return t.kind==="Invoke"&&t.callee.kind==="StateRef"&&t.callee.name==="emit"}const Kr="::",yw=new Map;class Kl{constructor(e){O(this,"mounted",new Map);O(this,"errors",[]);this.options=e}getErrors(){return this.errors}syncEffects(e,r){this.errors=[];const n=new Set(e.map(a=>a.name));for(const a of[...this.mounted.keys()])a.includes(Kr)||n.has(a)||this.unmount(a);for(const a of e)this.mounted.has(a.name)||this.mount(a.name,a,r,[],yw)}syncInstanceEffects(e,r,n){const a=`${e}${Kr}`,i=new Set(r.map(o=>`${a}${o.decl.name}`));for(const o of[...this.mounted.keys()])o.startsWith(a)&&(i.has(o)||this.unmount(o));for(const o of r){const s=`${a}${o.decl.name}`,l=this.mounted.get(s);if(l){l.capturedLoopVars=o.capturedLoopVars;continue}this.mount(s,o.decl,n,o.capturedAliases,o.capturedLoopVars)}}unmountInstance(e){const r=`${e}${Kr}`;for(const n of[...this.mounted.keys()])n.startsWith(r)&&this.unmount(n)}reset(){for(const e of[...this.mounted.keys()])this.unmount(e);this.errors=[]}mount(e,r,n,a,i){const o={decl:r,cleanups:[],intervals:[],unsubscribers:[],ctxRef:n,capturedAliases:a,capturedLoopVars:i};this.mounted.set(e,o),this.emitEffect(e,r,"mount","mount");const l=xw(f=>{const b=o.cleanups.splice(0);if(b.length>0){for(const g of b)try{g()}catch(y){Xl(e,y)}this.emitEffect(e,r,"cleanup",f,{cleanups:b.length})}const h=we();try{Yl(r,n(),o,this.options),this.emitEffect(e,r,"run",f,{duration:we()-h})}catch(g){this.emitEffect(e,r,"error",f,{duration:we()-h,error:g instanceof Error?g.message:String(g)}),console.error(`[aktion] effect "${e}" failed`,g)}finally{this.options.notify()}},r.rateLimit,o);let c=!1,d=!1,p=!1;for(const f of r.triggers)switch(f.kind){case"lifecycle":f.name==="mount"&&(c=!0),f.name==="unmount"&&(d=!0);break;case"every":{p=!0;const b=`every(${f.intervalMs})`,h=setInterval(()=>l(b),f.intervalMs);o.intervals.push(h);break}case"state":{const b=$w(f.name,a),h=`state:${f.name}`,g=this.options.state.subscribe(y=>{Kn(y,b)&&l(h)});o.unsubscribers.push(g);break}}(r.triggers.length===0||c||!p&&!d&&r.triggers.every(f=>f.kind==="state"))&&l("mount")}emitEffect(e,r,n,a,i={}){const o=this.options.onEffectEvent;if(!o||!Pa())return;const s=e.lastIndexOf(Kr);o({effectKey:e,label:kw(r.name),instanceKey:s>=0?e.slice(0,s):null,phase:n,reason:a,triggers:Sw(r),...i})}unmount(e){const r=this.mounted.get(e);if(!r)return;this.mounted.delete(e);for(const a of r.intervals)clearInterval(a);for(const a of r.unsubscribers)try{a()}catch{}if(r.cleanups.length>0){const a=r.cleanups.length;for(const i of r.cleanups)try{i()}catch(o){Xl(e,o)}this.emitEffect(e,r.decl,"cleanup","unmount",{cleanups:a})}if(r.decl.triggers.some(a=>a.kind==="lifecycle"&&a.name==="unmount")){const a=we();try{Yl(r.decl,r.ctxRef(),r,this.options),this.emitEffect(e,r.decl,"run","unmount",{duration:we()-a})}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 xw(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),l=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(l)},e.ms)}}let n=0,a=null,i="";return r.cleanups.push(()=>{a&&(clearTimeout(a),a=null)}),o=>{const s=Date.now(),l=s-n;l>=e.ms?(n=s,t(o)):a?i=o:(i=o,a=setTimeout(()=>{a=null,n=Date.now(),t(i)},e.ms-l))}}function Yl(t,e,r,n){const a=r.capturedAliases.length>0?e.stateAliases.slice():null;if(a){e.stateAliases.length=0;for(const s of r.capturedAliases)e.stateAliases.push(new Map(s))}const i=r.capturedLoopVars.size>0?new Map(e.loopVars):null;if(i){e.loopVars.clear();for(const[s,l]of r.capturedLoopVars)e.loopVars.set(s,l)}const o=e.cleanupSink;e.cleanupSink=s=>{r.cleanups.push(s)};try{for(const s of t.body.body)ww(s,e,r,n)}finally{if(e.cleanupSink=o,a){e.stateAliases.length=0;for(const s of a)e.stateAliases.push(s)}if(i){e.loopVars.clear();for(const[s,l]of i)e.loopVars.set(s,l)}}}function ww(t,e,r,n){switch(t.kind){case"ExpressionStatement":{const a=t.expression;if(a.kind==="Call"&&a.callee==="cleanup"){const i=a.arguments[0]?R(a.arguments[0],e):null;typeof i=="function"&&r.cleanups.push(i);return}if(vw(a)){const i=a.arguments,o=i[0]?String(R(i[0],e)):"",s=i[1]?R(i[1],e):void 0;n.onEmit?.(o,s);return}return R(a,e)}case"Assignment":{const a=R(t.expression,e);if(t.identifier&&t.identifier!==""){const i=Fe(e,t.identifier);e.state.set(i,a)}return 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":Sa(t,e);return;default:return}}function Xl(t,e){console.error(`[aktion] cleanup for effect "${t}" threw`,e)}function kw(t){const e=/^__effect_L(\d+)_C(\d+)$/.exec(t);return e?`effect @ L${e[1]}:C${e[2]}`:t}function Sw(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 $w(t,e){const r=t.indexOf("."),n=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);for(let i=e.length-1;i>=0;i-=1){const o=e[i].get(n);if(o!==void 0)return o+a}return t}const Cw=["onclick","ondblclick","oncontextmenu","onmousedown","onmouseup","onmousemove","onmouseenter","onmouseleave","onmouseover","onmouseout","onpointerdown","onpointerup","onpointermove","onpointerenter","onpointerleave","onpointercancel","onscroll","onwheel","ondrag","ondragstart","ondragend","ondragenter","ondragleave","ondragover","ondrop","ontouchstart","ontouchmove","ontouchend","ontouchcancel","oninput","onchange","onsubmit","onreset","oninvalid","ontoggle","onkeydown","onkeyup","onkeypress","onfocus","onblur","onanimationend","ontransitionend","onerror"];function Aw(t,e){const r=e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(e.childNodes):[e];tc(t,r)}function Jl(t,e){if(t===e)return t;if(t.nodeType!==e.nodeType)return Ql(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,n=e;return r.tagName!==n.tagName?Ql(r,n):(Tw(r,n),r)}function Ql(t,e){return t.parentNode?.replaceChild(e,t),e}function Tw(t,e){if(t.hasAttribute("data-rui-preserve")||e.hasAttribute("data-rui-preserve")){Mw(t,e),Zl(t,e);return}Nw(t,e),Zl(t,e),tc(t,Array.from(e.childNodes)),Iw(t,e)}function Mw(t,e){const r=e.attributes;for(let n=0;n<r.length;n+=1){const a=r[n];t.getAttribute(a.name)!==a.value&&t.setAttribute(a.name,a.value)}}function Nw(t,e){const r=t.attributes;for(let a=r.length-1;a>=0;a-=1){const i=r[a];e.hasAttribute(i.name)||i.name==="open"&&t.tagName==="DETAILS"||t.tagName==="CANVAS"&&(i.name==="width"||i.name==="height")||t.removeAttribute(i.name)}const n=e.attributes;for(let a=0;a<n.length;a+=1){const i=n[a];t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}}function Zl(t,e){for(const r of Cw){const n=e[r],a=t[r];n!==a&&(t[r]=n??null)}}function Iw(t,e){if(t instanceof HTMLInputElement&&e instanceof HTMLInputElement){Pw(t,e);return}if(t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){Rw(t,e);return}if(t instanceof HTMLSelectElement&&e instanceof HTMLSelectElement){t.value!==e.value&&(t.value=e.value);return}}function Pw(t,e){if(t.type==="checkbox"||t.type==="radio"){const n=e.hasAttribute("checked")||e.checked;t.checked!==n&&(t.checked=n);return}const r=e.getAttribute("value")??e.value??"";t.value!==r&&ec(t,r)}function Rw(t,e){const r=e.value??e.textContent??"";t.value!==r&&ec(t,r)}function ec(t,e){if(!Ew(t)){t.value=e;return}let r=null,n=null;try{r=t.selectionStart,n=t.selectionEnd}catch{}const a=t.value.length;if(t.value=e,r==null||n==null)return;const i=r>=a&&n>=a,o=i?e.length:Math.min(r,e.length),s=i?e.length:Math.min(n,e.length);try{t.setSelectionRange(o,s)}catch{}}function Ew(t){const e=t.getRootNode();return e instanceof ShadowRoot||e instanceof Document?e.activeElement===t:t.ownerDocument?.activeElement===t}function tc(t,e){const r=new Map;for(const a of Array.from(t.childNodes)){const i=La(a);i&&r.set(i,a)}let n=0;for(const a of e){const i=t.childNodes[n]??null,o=La(a);if(o&&r.has(o)){const l=r.get(o);r.delete(o),l!==i&&t.insertBefore(l,i),Jl(l,a),n+=1;continue}if(!i){t.appendChild(a),n+=1;continue}const s=La(i);if(s&&(!o||s!==o)){t.insertBefore(a,i),n+=1;continue}Jl(i,a),n+=1}for(;t.childNodes.length>e.length;){const a=t.childNodes[t.childNodes.length-1];t.removeChild(a)}}function La(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 za(t,e={}){return e.mode==="chat"?jw(t,e):zw(t,e)}function Lw(t){return Yr(t)}function zw(t,e){const r=e.bindings??!0,n=e.toolCalls??!0,a=[];a.push(Dw(e.preamble)),a.push(Ow()),a.push(Bw()),r&&a.push(Fw()),a.push(_w()),a.push(Uw()),n&&a.push(Hw()),a.push(qw()),a.push(Vw()),a.push(Ww()),a.push(Gw()),a.push(Kw()),a.push(Xw()),a.push(Yw()),a.push(Jw()),a.push(Qw()),a.push(Zw(t)),e.inlineMode&&a.push(e0()),e.editMode&&a.push(t0()),e.tools&&e.tools.length>0&&a.push(f0(e.tools)),e.toolExamples&&e.toolExamples.length>0&&a.push(ja("Endpoint examples",e.toolExamples));const i=e.examples??n0();return i.length>0&&a.push(ja("Examples",i)),e.additionalRules&&e.additionalRules.length>0&&a.push(rc(e.additionalRules)),a.push(r0()),a.join(`
|
|
104
105
|
|
|
105
106
|
`).trim()+`
|
|
106
|
-
`}function
|
|
107
|
+
`}function jw(t,e){const r=[];r.push(i0(e.preamble)),r.push(o0()),r.push(s0(t)),r.push(l0()),e.tools&&e.tools.length>0&&r.push(u0(e.tools));const n=e.examples??d0();return n.length>0&&r.push(ja("Examples",n)),e.additionalRules&&e.additionalRules.length>0&&r.push(rc(e.additionalRules)),r.push(c0()),r.push(p0()),r.push(m0()),r.join(`
|
|
107
108
|
|
|
108
109
|
`).trim()+`
|
|
109
|
-
`}function
|
|
110
|
+
`}function Dw(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."}
|
|
110
111
|
|
|
111
|
-
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 bx(){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. **Argument forms** (per call, pick ONE): the canonical form is one bare positional — the prop tagged `(positional)` in the signature — plus a trailing `{ }` object for every other prop. Also supported: ALL-positional (arguments bind to the signature\'s props in listed order, so only use it for adjacent leading props), and ALL-named (a single `{ }` object naming every prop). Never split one object between roles.\n\n```\nButton("Save", { variant: "primary", loading: $isSaving }) // canonical: positional + trailing object\nStatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })\nStatCard("Revenue", "$48k", "up") // all-positional, signature order\nButton({ label: "Save", variant: "primary" }) // all-named single object\nRow([Card1(), Card2()], { gap: "md" })\n```\n\nMind the signature order with all-positional calls: `Button("Save", "primary")` puts `"primary"` in the second slot (`onClick`), NOT `variant` — prefer the trailing object for non-adjacent props. A lone object argument to a component whose positional prop is itself object-typed is that prop\'s payload, not named props. 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 vx(){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 yx(){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- `$ref(initial)` → a stable `{ current }` box (like `useRef`; writing `.current` does NOT re-render — for DOM nodes, timer ids, previous values).\n- `$reducer((state, action) => next, initial)` → `[state, dispatch]` (like `useReducer`; the clean way to manage many related transitions).\n- `$id(prefix?)` → a stable unique id per instance (like `useId`; for `for`/`aria-*` wiring).\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.\n\nAdd `persist: "key"` to mirror the store\'s data to `localStorage` (or `persistIn: "session"` for `sessionStorage`): declared fields hydrate from the saved snapshot on first render and every change writes back. `persist` / `persistIn` are config, not state fields.\n\n```\nprefs = $store({\n persist: "user-prefs", // restored on reload, saved on every change\n theme: "system",\n setTheme: (s, t) => { s.theme = t },\n})\n```\n\nAdd `history: true` (or `history: 50` for a depth cap) for **undo/redo**: the store gains `store.undo()` / `store.redo()` / `store.clearHistory()` methods and reactive `store.canUndo` / `store.canRedo` flags (wire them to button `disabled`). Each user mutation records a snapshot; a fresh edit after undo clears the redo branch.\n\n```\ndoc = $store({\n history: true,\n title: "", body: "",\n setTitle: (s, t) => { s.title = t },\n})\nundoBtn = Button("Undo", { onClick: () => doc.undo(), disabled: !doc.canUndo })\n```'}function xx(){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- **Named slots** (XIII.1): once positional args fill the params, extra named props become both a `slots` object and direct bindings — `function Panel(children) { return Column([slots.header, children, footer]) }` called as `Panel(body, { header: H, footer: F })`.\n- **Component-local helpers** (XIII.4): a `function Row() {…}` declared inside another component\'s body is scoped to it (callable by siblings, not leaked globally).\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. Wrap optimistic writes in `$optimistic(() => { … })` to snapshot state and auto-roll-back if the callback throws (or its promise rejects).\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}\nfunction addTodo(text) {\n $optimistic(() => {\n $todos = [...$todos, { id: $todos.length + 1, text }] // optimistic write\n if (text == "") throw new Error("empty") // → rolls $todos back\n })\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`.\n\n### Reactive environment globals (under `$util`)\nRead-only reactive namespaces the UI branches on without manual listeners (listeners attach lazily on first read, re-render on change). They live under `$util` so the top-level `$`-name space stays free for your own atoms:\n- `$util.viewport.width` / `.height`\n- `$util.breakpoint.active` (`base|sm|md|lg|xl`) + `.sm` / `.md` / `.lg` / `.xl` booleans\n- `$util.scroll.y` / `.x` / `.progress` (0–1) / `.direction` (`up|down`)\n- `$util.media.prefersDark` / `.prefersReducedMotion` / `.online` / `.pointer` (`coarse|fine`) / `.portrait`\n- `$util.mouse.x` / `.y`\n- `$util.url.path` / `.params` (route params) / `.query` (parsed object) / `.hash` + `.navigate(to)` / `.setQuery(name, value)` / `.setQuery({…})` / `.removeQuery(name)` — a reactive snapshot of the current URL plus query-param writers (IV.6).\n\n```\nShow($util.breakpoint.md, { children: Sidebar(), fallback: Drawer() })\nNavBar({ blur: $util.scroll.y > 12 })\n```\n\n### `$util.onError(fn)`\nRegister a program-level error sink: `fn({ error, source })` fires when a user action body throws (before the default logging) — report to a telemetry sink or surface a toast so a bad row never blanks the page.\n\n### `$util.onNavigate(fn)`\nRegister a navigation guard: `fn({ to, from })` runs before every route change (in-app `navigate(...)` and browser back/forward). Return `false` to block, a path string to redirect, or nothing to allow. `$util.onNavigate(null)` clears it.\n\n### `$util.onRequest(fn)` / `$util.onResponse(fn)`\nCross-cutting HTTP interceptors for every `$http` / `$query` / `$mutation` request (VI.5). `$util.onRequest(req => ({ headers: { Authorization: "Bearer " + $token } }))` returns a partial that is merged over the request (headers shallow-merged) — ideal for auth tokens. `$util.onResponse(async (res, retry) => …)` can inspect/replace the response or `await retry()` to re-issue once (e.g. after refreshing a token on a 401). They reset on each new program.'}function wx(){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 kx(){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```\n\n### `$query({...})` and `$mutation({...})`\nSame config shape as `$http`, for two common needs:\n- `$query({ url, key?, ttl?, refetchInterval?, refetchOnFocus?, refetchOnReconnect? })` — a **cached, deduplicated** read. Identical queries (same `key`, or same method+url+query+body) share one in-flight request and one cached bag, so calling it from several components fetches once. Pass `ttl` (ms) to auto-refetch stale data, `refetchInterval` (ms) to poll a live dashboard, and `refetchOnFocus` / `refetchOnReconnect` to refresh on tab focus / network reconnect. Same bag as `$http` (`.data`/`.loading`/`.error`/`.refetch()`).\n- `$mutation({ url, method? })` — a **deferred** write that fires only when you call `.mutate(overrides?)`, not on render (method defaults to `POST`). Assign it to an atom, then trigger it from a handler:\n```\n$save = $mutation({ url: "https://api.example.com/orders" })\n$save.onDone = () => $orders.refetch()\n...\nButton("Save", { onClick: () => $save.mutate({ body: { item: $item } }) })\n```\n`.mutate()` resolves with the response body; the bag exposes `.loading`/`.error`/`.data` plus `.reset()`.\n\n**Optimistic + invalidation (VI.2):** `$mutation({ url, optimistic: () => { … }, invalidates: ["key"] })` — `optimistic` runs synchronously before the request so the UI updates instantly (auto-rolled-back if it fails); `invalidates` refetches every cached `$query` whose key contains a listed substring once the write succeeds. `$util.invalidate("key")` does the same on demand.\n\n**Infinite / paginated reads (VI.1):** `$feed = $query({ url, infinite: { param?: "page", start?: 1, limit?: 20, mode?: "page"|"offset", select?: body => body.items } })` — `.data` is the flattened item list across loaded pages; call `.loadMore()` (often from `OnIntersect`) while `.hasMore` is true; `.loadingMore` flags the in-flight next page.\n\n**GraphQL (VI.6):** add `gql` (+ optional `variables`) to any `$http`/`$query`/`$mutation`: it POSTs `{ query, variables }` and `.data` is the unwrapped GraphQL `data` (a GraphQL `errors` array surfaces through `.error`).\n\n```\n$repos = $query({ url: "/graphql", gql: "query($n:Int){ repos(first:$n){ name } }", variables: { n: 10 } })\n```\n\n### Realtime — `$socket({...})` and `$sse({...})` (VI.3)\n- `$socket({ url, protocols?, bufferSize?, onMessage?, reconnect? })` — a reactive WebSocket. Read `.status` (`"connecting"|"open"|"closed"`), `.connected`, `.last`, `.messages` (re-render on change); `.send(data)` (objects auto-JSON; messages sent while connecting queue and flush on open); `.close()` (stops for good). `reconnect: true` (or a max-attempt number) retries dropped connections with exponential backoff — `.attempts` counts the current streak.\n- `$sse({ url, event?, withCredentials?, bufferSize? })` — a reactive Server-Sent Events stream with the same `.status`/`.connected`/`.last`/`.messages`/`.close()` surface (EventSource reconnects natively). Both tear down automatically on the next program.\n```\n$chat = $socket({ url: "wss://example.com/room/42" })\nsend = () => { $chat.send({ text: $draft }); $draft = "" }\nfeed = Column(map($chat.messages, m => Bubble(m.text)))\n```'}function Sx(){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. `$util.url` mirrors this (`$util.url.path` / `.params` / `.query` / `.hash`).\n- **Query-param ↔ state** (IV.6): write the URL query without leaving the page — `$util.url.setQuery("tab", "billing")`, `$util.url.setQuery({ sort: "name", page: 2 })` (a `null`/`""` value drops the key), or `$util.url.removeQuery("tab")`. Read it back reactively via `$util.url.query.tab` (or `route.query.tab`), so a tab/sort/filter survives reload and is shareable.\n- **Navigation guards** (IV.2): `$util.onNavigate(fn)` registers a guard. `fn({ to, from })` returns `false` to block, a path string to redirect, or nothing to allow — covers in-app `navigate(...)` and browser back/forward. Call `$util.onNavigate(null)` to clear.\n- **Scroll restoration** (IV.5): set `scroll-restoration="auto"` on `<aktion-app>` to restore scroll on back/forward and jump to top on a fresh navigation (`"top"` always jumps to top).\n- **Nested / layout routes** (IV.1): an arm whose value is `{ layout, routes }` matches as a path PREFIX and slots the matched child into the `outlet` identifier — so a shell (sidebar/topbar) stays mounted while only the inner page swaps. Child route keys are matched against the remaining path; `params` merges parent + child captures.\n```\npages = $router({\n "/app": {\n layout: AppShell(MainSidebar(), outlet), // `outlet` = the matched child\n routes: {\n "/": Dashboard(),\n "/orders/:id": OrderDetail({ id: params.id }),\n default: AppHome()\n }\n },\n default: Landing()\n})\n```\n- `NavLink(label, { to, exact?, icon? })` and `SidebarItem(label, { to, icon?, badge? })` derive active state from `route.path`. Never declare `route` yourself.\n\n```\n$util.onNavigate(({ to }) => $isLoggedIn || to === "/login" ? true : "/login") // auth gate\nfunction selectTab(name) { $util.url.setQuery("tab", name) } // shareable tab\nactiveTab = $util.url.query.tab ?? "overview"\n```'}function $x(){return'## Built-in globals — `storage`, `console` & `$toast`\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.show("Copied", { tone: "success" }) }\nid = crypto.randomUUID()\n```\n\n### `$toast` — imperative notifications\nInstead of hand-managing a `$toasts = [...]` array, use the reserved `$toast` namespace. `$toast.show(message, { tone?, title?, duration? })` appends a toast (auto-dismisses after `duration` ms, default 4000; pass `0` to keep it). Shortcuts: `$toast.success/.error/.info/.warning`. Remove with `$toast.dismiss(id)` / `$toast.clear()`. Render the reactive `$toast.items` list:\n\n```\nfunction save() { $save = $http({ url, method: "POST", body }); $save.onDone = () => $toast.success("Saved") }\ntoaster = Toasts(map($toast.items, t => Toast({ title: t.title, message: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))\n```'}function Cx(){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- `OnMount(child, { onMount?, onUnmount? })` — DOM-ref / lifecycle. `onMount(node)` fires once after attach (grab a node, focus it, hand it to a chart/map/editor); `onUnmount(node)` on teardown. Stash the node in a `$ref(...)`.\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 Ax(){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 Tx(){return'## Theming, i18n & icons\n\n### `$theme({ ... })`\nA bare `$theme({...})` statement (near the top) brands the response. Only the **structured form** is accepted — top-level keys must be a token group (`colors`, `radius`, `font`, `spacing`, `shadows`, `gradients`, `zIndex`, `motion`, `fonts`, `icons`) or a metadata key (`name`, `direction`). Flat-shape keys like `$theme({ colorPrimary: ... })` raise a schema error; unknown keys inside a group are silently ignored. **Every token value is a string.** Omit the whole call to inherit the host theme. `zIndex` layer tokens (`{ modal: 2000, toast: 2100, … }`) feed `sx.zIndex`; `motion` (`{ fast, base, slow, ease }`) → `--rui-motion-*`. Gradients accept color-stop arrays (`gradients: { brand: ["#6366f1", "#ec4899"] }`) and are referenced as `gradient.brand` in `sx`/`GradientText`. Custom icons register inline SVG by name (`icons: { logo: "<path …/>" }`) and are then usable anywhere a Font Awesome name is — `Icon("logo")`. Load web fonts with `fonts: { import: ["Inter:400,700", "JetBrains Mono"] }` (Google Fonts shorthand) alongside the `font.family` token.\n\nCore group keys (all optional):\n- `name?: string` — selects a built-in theme as the base palette (`"dark"`, `"neon"`, …; unknown names are ignored).\n- `direction?: "ltr" | "rtl"` — reading direction (metadata; not applied as a token).\n- `colors?: { ... }` — CSS color strings. Keys: `bg`, `bgSubtle`, `surface`, `surfaceMuted`, `border`, `borderSubtle`, `text`, `textMuted`, `primary`, `primaryHover`, `primaryText`, `accent`, `accentHover`, `accentText`, `focusRing`, `success`, `warning`, `danger`, `info`.\n- `radius?: { ... }` — CSS length strings. Keys: `xs`, `sm`, `md`, `lg`, `pill`, `button`, `input`.\n- `font?: { ... }` — CSS strings. Keys: `family`, `familyHeading`, `familyMono`, `sizeBase`, `sizeSm`, `sizeLg`, `sizeHeading`, `sizeTitle`, `weightBody`, `weightHeading`.\n\n```\n$theme({\n colors: { primary: "#635bff", primaryHover: "#4f46e5", accent: "#1f6feb", bg: "#0a0a23", surface: "#10103a", text: "#fff", textMuted: "#a5b4fc", focusRing: "#635bff" },\n radius: { md: "0.5rem", button: "999px", input: "8px" },\n font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif", weightHeading: "600" }\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. ICU plural and select forms are supported: `{ n, plural, =0{No items} one{1 item} other{# items} }`.\n\n### RTL / bidirectional text\nSet `dir="rtl"` / `"ltr"` / `"auto"` on the host `<aktion-app>` element (not in code). The runtime reflects it onto the render root so the whole tree — text direction, flex order, logical spacing — flips automatically. Programs do not need any code change; use logical CSS properties (no hard-coded `left`/`right`) in raw CSS.\n\n### Accessibility primitives\n- `VisuallyHidden(child)` — hides content visually, keeps it in the a11y tree.\n- `SkipLink({ to: "#main", label: "Skip to content" })` — first tab stop for keyboard users.\n- `LiveRegion(Text($status), { mode: "polite" })` — announces dynamic changes (`"polite"` queues; `"assertive"` interrupts).\n- `FocusTrap(child, { active: $isOpen })` — Tab cycles within the subtree; required for dialogs.\n- Pass `aria: { label, labelledBy, describedBy, ... }` to any component via the universal props channel.\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 Mx(){return'## Universal style props (`sx` / `animate`) — every component\n\nEVERY component accepts a universal style/behaviour channel as named props, in addition to its own props. These are **bounded** (tokens & enums, never raw CSS) so they stay theme-safe — prefer them over the `Css`/`Styles`/`HTMLTag` escape hatches.\n\n- **`sx: { … }`** — token-aware inline styling. Keys (all optional):\n - Spacing (`none|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl|auto` (`none` = 0), the `safe`/`safe-top`/`safe-right`/`safe-bottom`/`safe-left` notch insets, or a CSS length): `p px py pt pr pb pl`, `m mx my mt mr mb ml`, `gap`. `px`/`mx` are logical (`padding-inline`) and `ps pe ms me` set the inline start/end sides, so RTL apps mirror automatically.\n - Sizing (`full|half|screen|dvh|min|max|fit|auto` or length): `w h minW maxW minH maxH`.\n - Color (token `surface|bg|text|text-muted|primary|accent|success|warning|danger|border`, a gradient ref `gradient.brand|accent|warm|cool|success|danger`, or a raw color): `bg color borderColor`.\n - Surface: `border: none|subtle|strong|<color>`, `radius: xs|sm|md|lg|pill|full`, `shadow: sm|md|lg|none`, `opacity`, `backdrop: "blur"`, `bgImage` (http(s)/relative/data:image only) + `bgOverlay` (color or `gradient.*` wash over the image), `bgSize: cover|contain`.\n - Typography: `fontSize: xs|sm|base|lg|xl|2xl|3xl|4xl` (or a length), `weight: 100…900|bold|normal`, `textDecoration: underline|line-through|none`, `textAlign`.\n - Flex/grid: `display direction align justify wrap grow shrink basis columns`.\n - Position: `position top right bottom left inset zIndex(base|dropdown|sticky|modal|toast|…)`, `overflow cursor`. Layer tokens resolve through `--rui-z-*` so `$theme({ zIndex: {...} })` rebrands them.\n - Interaction: `hover: { lift|grow|glow|bright|border|scale }`, `focus: { glow|border }` (mapped to bounded utility classes). For arbitrary state CSS use `states: { hover|focus|active|disabled|focus-visible|checked|group-hover: { bg, color, borderColor, shadow, radius, opacity, scale, translateX, translateY, rotate, cursor } }` — compiled to scoped `:state` rules in the adopted stylesheet. Example: `sx: { states: { hover: { scale: 1.04, shadow: "lg" }, focus: { borderColor: "primary" } } }` (I.4).\n - Responsive: any value may be `{ base, sm, md, lg, xl }` (resolves to `base`).\n- **`animate: "fade-up"`** (or `{ preset, delay?, duration?, repeat? }`) — entrance/loop motion. Presets: `fade fade-up/down/left/right zoom slide-up/down/left/right pulse float shimmer bounce spin ping wiggle`. Auto-respects `prefers-reduced-motion`.\n- **`id` / `anchor`** — set the element id (smooth-scroll targets).\n- **`className` / `style`** — extra classes / a sanitised inline style string.\n- **`aria: {…}` / `data: {…}` / `tooltip` / `hidden`** — accessibility & metadata passthrough.\n\n```\nCard([Text("Lift on hover")], { sx: { p: "l", radius: "lg", bg: "surface", shadow: "md", hover: { lift: true } } })\nBadge("Live", { tone: "success", animate: "pulse" })\nDisplay(["Build in ", GradientText("record time")], { size: "hero", align: "center", animate: "fade-up" })\n```'}function Nx(){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`, `.partition(arr, field, op, value)`, `.keyBy(arr, field)`, `.chunk(arr, size)`, `.flatten(arr, depth?)`, `.zip(...arrays)`, `.range(start, end, step?)`.\n- **Objects**: `$util.pick(obj, keys)`, `.omit(obj, keys)`, `.merge(target, ...sources)` (deep), `.cloneDeep(value)`.\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- **Formatting / misc**: `.slugify / .truncate(text, len) / .initials / .currency(v, code?) / .percent(v) / .bytes(v) / .relativeTime(date) / .copy(text)` (async — resolves `true` once the clipboard write succeeds) `/ .sleep(ms) / .uuid() / .debounceFn(fn, ms) / .throttleFn(fn, ms)` (leading + trailing edge).\n- **Device / platform**: `.vibrate(pattern) / .share({ title, text, url }) / .readClipboard() / .geolocate() / .isOnline() / .deviceType()` (XII.3); `.worker(pureFn, ...args)` runs a closure-free function off the main thread, resolving its result (XI.5); `.registerServiceWorker(url) / .webManifest({ name, icons, … })` for PWA setup (XII.2).\n- **Reactive env getters**: `$util.scroll`, `$util.viewport`, `$util.breakpoint`, `$util.media`, `$util.mouse`, `$util.url` (listeners attach lazily on first read, re-render on change).\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```\n\n## `$util.style`, `$util.rules` and `$util.derived` — styling, validation & computed helpers\n\n- **`$util.style`** — bounded, sanitised CSS helpers (return safe strings for the `sx.style` / inline use): `$util.style.cx("a", { active: cond })` (classnames), `$util.style.gradient(["#6366f1", "#ec4899"], 120)`, `$util.style.alpha("primary", 0.12)` (color-mix), `$util.style.clamp("16px", "2vw", "24px")`, `$util.style.token("spacing.l")` → `var(--rui-spacing-l)`, `$util.style.toStyle({ padding: "8px" })`.\n- **`$util.rules`** — composable validators that return `(value) => message | null`: `$util.rules.required() / .email() / .url() / .min(n) / .max(n) / .minLength(n) / .maxLength(n) / .pattern(re) / .oneOf([...]) / .matches(other) / .custom(fn) / .asyncCustom(fn)` (`fn` may return a Promise — server-side checks like username uniqueness; `$form` awaits it before submitting). Run them with `$util.rules.validate(value, [..])` (first error or null; a Promise when an async rule is hit) or `$util.rules.validateAll(values, schema)` (→ `{ field: message }`).\n- **`$util.derived(fn)`** — a computed value: `total = $util.derived(() => $util.sum($cart.map(i => i.price)))` recomputes reactively from the atoms `fn` reads.\n\n```\n$email = ""\nerror = $util.rules.validate($email, [$util.rules.required(), $util.rules.email()])\nInput("email", { value: $email, error: error })\n```\n\n### `$form({...})` — the form engine (managed forms)\nFor anything beyond one or two fields, reach for `$form` instead of wiring atoms by hand. `$form({ values: {...initial}, rules: { field: [validators] }, onSubmit: (values) => {...} })` returns a managed bag:\n- `form.values.x` — two-way binds straight onto an input (`Input("email", { value: form.values.email })`).\n- `form.errors.x` / `form.touched.x` / `form.dirty` / `form.valid` / `form.submitting` / `form.validating` — reactive reads (`dirty` flips on the first edit and clears on `reset()`; `validating` is true while async rules are in flight).\n- `form.field("email")` — returns `{ value, error, name, onChange, onBlur }` to spread for a controlled, validated field.\n- `form.validate()` (all) / `form.validateField(name)` / `form.touch(name)` / `form.setField(name, v)` / `form.setValues({...})` / `form.reset()`.\n- `form.submit()` (alias `form.handleSubmit()`) — marks fields touched, validates (awaiting async rules), then calls `onSubmit(values)` only when valid. `form.submitting` stays true until an async `onSubmit` settles.\n\n```\nform = $form({\n values: { email: "", age: "" },\n rules: { email: [$util.rules.required(), $util.rules.email()], age: [$util.rules.min(18)] },\n onSubmit: (v) => { $saved = $mutation({ url: "/signup", body: v }); $saved.mutate() }\n})\n$app(Column([\n Input("email", { value: form.values.email, error: form.errors.email, onBlur: () => form.touch("email") }),\n Button("Submit", { onClick: () => form.handleSubmit(), disabled: form.submitting })\n]))\n```'}function Ix(){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 the async `loader` resolves; show `fallback` while pending. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised 1-D list — preferred for >100 rows. |\n| `VirtualGrid(items, { columns, rowHeight, render })` | Virtualised 2-D grid — only visible rows mount; essential for tables/grids >100 rows. |\n| `VisuallyHidden(child)` | Hides content visually but keeps it in the accessibility tree (extra context for screen readers). |\n| `SkipLink({ to, label })` | "Skip to main content" link that appears on focus — the first tab stop for keyboard users. |\n| `LiveRegion(child, { mode? })` | `aria-live` region (`mode: "polite"` default or `"assertive"`). Announces dynamic changes to screen readers. |\n| `FocusTrap(child, { active })` | Cycles Tab within its subtree and autofocuses the first control — required for accessible dialogs. |\n| `Fragment(children)` | Groups siblings without a layout box (`display:contents`) so a component can return several nodes into a parent Grid/Stack. |\n| `Transition(child, { show, preset, duration? })` | Enter/exit transition — keeps child mounted through exit animation; reduced-motion safe. |\n| `FlipList(children, { duration? })` | FLIP reorder animation — keyed children physically move to their new positions. |'}function Px(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(o=>o.name)}],r=new Map(t.components.map(o=>[o.name,o])),n=[];n.push("## Component library"),n.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. Canonical call: pass it bare and put every other prop in a trailing `{ prop: value }` object. Also valid: all-positional in the listed order (the first positional fills the `(positional)` slot, the rest fill the remaining slots top-to-bottom), or a single `{ prop: value }` object naming every prop."),n.push("");for(const o of e){n.push(`### ${o.name}`);for(const s of o.components){const l=r.get(s);l&&n.push(Or(l))}n.push("")}const a=new Set(e.flatMap(o=>o.components)),i=t.components.filter(o=>!a.has(o.name));if(i.length>0){n.push("### Other");for(const o of i)n.push(Or(o))}return n.join(`
|
|
112
|
-
`).trim()}function
|
|
112
|
+
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 Ow(){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. **Argument forms** (per call, pick ONE): the canonical form is one bare positional — the prop tagged `(positional)` in the signature — plus a trailing `{ }` object for every other prop. Also supported: ALL-positional (arguments bind to the signature\'s props in listed order, so only use it for adjacent leading props), and ALL-named (a single `{ }` object naming every prop). Never split one object between roles.\n\n```\nButton("Save", { variant: "primary", loading: $isSaving }) // canonical: positional + trailing object\nStatCard("Revenue", { value: "$48k", trend: "up", delta: "+12%" })\nStatCard("Revenue", "$48k", "up") // all-positional, signature order\nButton({ label: "Save", variant: "primary" }) // all-named single object\nRow([Card1(), Card2()], { gap: "md" })\n```\n\nMind the signature order with all-positional calls: `Button("Save", "primary")` puts `"primary"` in the second slot (`onClick`), NOT `variant` — prefer the trailing object for non-adjacent props. A lone object argument to a component whose positional prop is itself object-typed is that prop\'s payload, not named props. 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 Bw(){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 Fw(){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- `$ref(initial)` → a stable `{ current }` box (like `useRef`; writing `.current` does NOT re-render — for DOM nodes, timer ids, previous values).\n- `$reducer((state, action) => next, initial)` → `[state, dispatch]` (like `useReducer`; the clean way to manage many related transitions).\n- `$id(prefix?)` → a stable unique id per instance (like `useId`; for `for`/`aria-*` wiring).\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.\n\nAdd `persist: "key"` to mirror the store\'s data to `localStorage` (or `persistIn: "session"` for `sessionStorage`): declared fields hydrate from the saved snapshot on first render and every change writes back. `persist` / `persistIn` are config, not state fields.\n\n```\nprefs = $store({\n persist: "user-prefs", // restored on reload, saved on every change\n theme: "system",\n setTheme: (s, t) => { s.theme = t },\n})\n```\n\nAdd `history: true` (or `history: 50` for a depth cap) for **undo/redo**: the store gains `store.undo()` / `store.redo()` / `store.clearHistory()` methods and reactive `store.canUndo` / `store.canRedo` flags (wire them to button `disabled`). Each user mutation records a snapshot; a fresh edit after undo clears the redo branch.\n\n```\ndoc = $store({\n history: true,\n title: "", body: "",\n setTitle: (s, t) => { s.title = t },\n})\nundoBtn = Button("Undo", { onClick: () => doc.undo(), disabled: !doc.canUndo })\n```'}function _w(){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- **Named slots** (XIII.1): once positional args fill the params, extra named props become both a `slots` object and direct bindings — `function Panel(children) { return Column([slots.header, children, footer]) }` called as `Panel(body, { header: H, footer: F })`.\n- **Component-local helpers** (XIII.4): a `function Row() {…}` declared inside another component\'s body is scoped to it (callable by siblings, not leaked globally).\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. Wrap optimistic writes in `$optimistic(() => { … })` to snapshot state and auto-roll-back if the callback throws (or its promise rejects).\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}\nfunction addTodo(text) {\n $optimistic(() => {\n $todos = [...$todos, { id: $todos.length + 1, text }] // optimistic write\n if (text == "") throw new Error("empty") // → rolls $todos back\n })\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`.\n\n### Reactive environment globals (under `$util`)\nRead-only reactive namespaces the UI branches on without manual listeners (listeners attach lazily on first read, re-render on change). They live under `$util` so the top-level `$`-name space stays free for your own atoms:\n- `$util.viewport.width` / `.height`\n- `$util.breakpoint.active` (`base|sm|md|lg|xl`) + `.sm` / `.md` / `.lg` / `.xl` booleans\n- `$util.scroll.y` / `.x` / `.progress` (0–1) / `.direction` (`up|down`)\n- `$util.media.prefersDark` / `.prefersReducedMotion` / `.online` / `.pointer` (`coarse|fine`) / `.portrait`\n- `$util.mouse.x` / `.y`\n- `$util.url.path` / `.params` (route params) / `.query` (parsed object) / `.hash` + `.navigate(to)` / `.setQuery(name, value)` / `.setQuery({…})` / `.removeQuery(name)` — a reactive snapshot of the current URL plus query-param writers (IV.6).\n\n```\nShow($util.breakpoint.md, { children: Sidebar(), fallback: Drawer() })\nNavBar({ blur: $util.scroll.y > 12 })\n```\n\n### `$util.onError(fn)`\nRegister a program-level error sink: `fn({ error, source })` fires when a user action body throws (before the default logging) — report to a telemetry sink or surface a toast so a bad row never blanks the page.\n\n### `$util.onNavigate(fn)`\nRegister a navigation guard: `fn({ to, from })` runs before every route change (in-app `navigate(...)` and browser back/forward). Return `false` to block, a path string to redirect, or nothing to allow. `$util.onNavigate(null)` clears it.\n\n### `$util.onRequest(fn)` / `$util.onResponse(fn)`\nCross-cutting HTTP interceptors for every `$http` / `$query` / `$mutation` request (VI.5). `$util.onRequest(req => ({ headers: { Authorization: "Bearer " + $token } }))` returns a partial that is merged over the request (headers shallow-merged) — ideal for auth tokens. `$util.onResponse(async (res, retry) => …)` can inspect/replace the response or `await retry()` to re-issue once (e.g. after refreshing a token on a 401). They reset on each new program.'}function Uw(){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 Hw(){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```\n\n### `$query({...})` and `$mutation({...})`\nSame config shape as `$http`, for two common needs:\n- `$query({ url, key?, ttl?, refetchInterval?, refetchOnFocus?, refetchOnReconnect? })` — a **cached, deduplicated** read. Identical queries (same `key`, or same method+url+query+body) share one in-flight request and one cached bag, so calling it from several components fetches once. Pass `ttl` (ms) to auto-refetch stale data, `refetchInterval` (ms) to poll a live dashboard, and `refetchOnFocus` / `refetchOnReconnect` to refresh on tab focus / network reconnect. Same bag as `$http` (`.data`/`.loading`/`.error`/`.refetch()`).\n- `$mutation({ url, method? })` — a **deferred** write that fires only when you call `.mutate(overrides?)`, not on render (method defaults to `POST`). Assign it to an atom, then trigger it from a handler:\n```\n$save = $mutation({ url: "https://api.example.com/orders" })\n$save.onDone = () => $orders.refetch()\n...\nButton("Save", { onClick: () => $save.mutate({ body: { item: $item } }) })\n```\n`.mutate()` resolves with the response body; the bag exposes `.loading`/`.error`/`.data` plus `.reset()`.\n\n**Optimistic + invalidation (VI.2):** `$mutation({ url, optimistic: () => { … }, invalidates: ["key"] })` — `optimistic` runs synchronously before the request so the UI updates instantly (auto-rolled-back if it fails); `invalidates` refetches every cached `$query` whose key contains a listed substring once the write succeeds. `$util.invalidate("key")` does the same on demand.\n\n**Infinite / paginated reads (VI.1):** `$feed = $query({ url, infinite: { param?: "page", start?: 1, limit?: 20, mode?: "page"|"offset", select?: body => body.items } })` — `.data` is the flattened item list across loaded pages; call `.loadMore()` (often from `OnIntersect`) while `.hasMore` is true; `.loadingMore` flags the in-flight next page.\n\n**GraphQL (VI.6):** add `gql` (+ optional `variables`) to any `$http`/`$query`/`$mutation`: it POSTs `{ query, variables }` and `.data` is the unwrapped GraphQL `data` (a GraphQL `errors` array surfaces through `.error`).\n\n```\n$repos = $query({ url: "/graphql", gql: "query($n:Int){ repos(first:$n){ name } }", variables: { n: 10 } })\n```\n\n### Realtime — `$socket({...})` and `$sse({...})` (VI.3)\n- `$socket({ url, protocols?, bufferSize?, onMessage?, reconnect? })` — a reactive WebSocket. Read `.status` (`"connecting"|"open"|"closed"`), `.connected`, `.last`, `.messages` (re-render on change); `.send(data)` (objects auto-JSON; messages sent while connecting queue and flush on open); `.close()` (stops for good). `reconnect: true` (or a max-attempt number) retries dropped connections with exponential backoff — `.attempts` counts the current streak.\n- `$sse({ url, event?, withCredentials?, bufferSize? })` — a reactive Server-Sent Events stream with the same `.status`/`.connected`/`.last`/`.messages`/`.close()` surface (EventSource reconnects natively). Both tear down automatically on the next program.\n```\n$chat = $socket({ url: "wss://example.com/room/42" })\nsend = () => { $chat.send({ text: $draft }); $draft = "" }\nfeed = Column(map($chat.messages, m => Bubble(m.text)))\n```'}function qw(){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. `$util.url` mirrors this (`$util.url.path` / `.params` / `.query` / `.hash`).\n- **Query-param ↔ state** (IV.6): write the URL query without leaving the page — `$util.url.setQuery("tab", "billing")`, `$util.url.setQuery({ sort: "name", page: 2 })` (a `null`/`""` value drops the key), or `$util.url.removeQuery("tab")`. Read it back reactively via `$util.url.query.tab` (or `route.query.tab`), so a tab/sort/filter survives reload and is shareable.\n- **Navigation guards** (IV.2): `$util.onNavigate(fn)` registers a guard. `fn({ to, from })` returns `false` to block, a path string to redirect, or nothing to allow — covers in-app `navigate(...)` and browser back/forward. Call `$util.onNavigate(null)` to clear.\n- **Scroll restoration** (IV.5): set `scroll-restoration="auto"` on `<aktion-app>` to restore scroll on back/forward and jump to top on a fresh navigation (`"top"` always jumps to top).\n- **Nested / layout routes** (IV.1): an arm whose value is `{ layout, routes }` matches as a path PREFIX and slots the matched child into the `outlet` identifier — so a shell (sidebar/topbar) stays mounted while only the inner page swaps. Child route keys are matched against the remaining path; `params` merges parent + child captures.\n```\npages = $router({\n "/app": {\n layout: AppShell(MainSidebar(), outlet), // `outlet` = the matched child\n routes: {\n "/": Dashboard(),\n "/orders/:id": OrderDetail({ id: params.id }),\n default: AppHome()\n }\n },\n default: Landing()\n})\n```\n- `NavLink(label, { to, exact?, icon? })` and `SidebarItem(label, { to, icon?, badge? })` derive active state from `route.path`. Never declare `route` yourself.\n\n```\n$util.onNavigate(({ to }) => $isLoggedIn || to === "/login" ? true : "/login") // auth gate\nfunction selectTab(name) { $util.url.setQuery("tab", name) } // shareable tab\nactiveTab = $util.url.query.tab ?? "overview"\n```'}function Vw(){return'## Built-in globals — `storage`, `console` & `$toast`\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.show("Copied", { tone: "success" }) }\nid = crypto.randomUUID()\n```\n\n### `$toast` — imperative notifications\nInstead of hand-managing a `$toasts = [...]` array, use the reserved `$toast` namespace. `$toast.show(message, { tone?, title?, duration? })` appends a toast (auto-dismisses after `duration` ms, default 4000; pass `0` to keep it). Shortcuts: `$toast.success/.error/.info/.warning`. Remove with `$toast.dismiss(id)` / `$toast.clear()`. Render the reactive `$toast.items` list:\n\n```\nfunction save() { $save = $http({ url, method: "POST", body }); $save.onDone = () => $toast.success("Saved") }\ntoaster = Toasts(map($toast.items, t => Toast({ title: t.title, message: t.message, tone: t.tone, onClose: () => $toast.dismiss(t.id) })))\n```'}function Ww(){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- `OnMount(child, { onMount?, onUnmount? })` — DOM-ref / lifecycle. `onMount(node)` fires once after attach (grab a node, focus it, hand it to a chart/map/editor); `onUnmount(node)` on teardown. Stash the node in a `$ref(...)`.\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 Gw(){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 Kw(){return'## Third-party widgets & document head\n\n### Imperative / third-party widget interop\nFor a library that owns its own DOM (chart, map, editor, payment element, captcha) — NOT for normal markup (use components). The host carries `data-rui-preserve`, so the reconciler never touches the widget\'s DOM.\n- `Mount({ setup, update?, cleanup?, props?, tag?, sx? })` — managed imperative host. `setup(node, props)` runs once after attach and **returns the instance handle**; `update(instance, props)` runs when the (shallow-compared) `props` bag changes; `cleanup(instance)` runs on unmount. `props` is the reactive boundary; `tag` sets the host (default `"div"`).\n- `WebComponent(tag, { attributes?, properties?, on?, children? })` — render + hydrate a native custom element (tag must contain a hyphen). `attributes` is reactive, `properties` assigns rich JS props, `on` binds listeners that stay current.\n- `$script({ src, global?, type?, as?, attributes? })` — load an external script/stylesheet once (de-duplicated per `src`) → reactive `{ ready, loading, error, value }`. Gate a widget on `.ready`; `value` = `window[global]`. Stays un-ready under SSR.\n- `$dom` — managed observers, auto-disposed on replan: `$dom.onResize(node, cb)`, `$dom.onIntersect(node, cb, opts?)`, `$dom.onMutation(node, cb, opts?)`, and one-shot `$dom.measure(node)` → `{ rect, scroll, viewport }`. Pair with an `OnMount` / `Mount` node ref.\n\n```\n$chartjs = $script({ src: "https://cdn.jsdelivr.net/npm/chart.js", global: "Chart" })\nfunction SalesChart() {\n if (!$chartjs.ready) return Skeleton({ sx: { h: "320px" } })\n return Mount({\n sx: { h: "320px" },\n setup: (node, p) => new $chartjs.value(node, { type: "bar", data: { datasets: [{ data: p.series }] } }),\n update: (chart, p) => { chart.data.datasets[0].data = p.series; chart.update() },\n cleanup: (chart) => chart.destroy(),\n props: { series: $series }\n })\n}\n```\n\n### Document head — `$head({...})`\nReactive head manager: call it from a page component body. Sets the title, meta, canonical/alternate links, Open Graph + Twitter cards, JSON-LD, and `<html>` attrs. Reads `$state`, so it re-applies on change; per-route calls compose (later wins). `renderToString` returns the resolved `head` + `headAttrs` for crawlable SSR.\n\n```\nfunction ProductPage() {\n $head({\n title: `${$product.name} — Acme`,\n meta: { description: $product.summary },\n og: { title: $product.name, image: $product.image, type: "product" },\n link: [{ rel: "canonical", href: $canonicalUrl }],\n jsonLd: { "@type": "Product", name: $product.name }\n })\n return Column([ /* … */ ])\n}\n```'}function Yw(){return'## Theming, i18n & icons\n\n### `$theme({ ... })`\nA bare `$theme({...})` statement (near the top) brands the response. Only the **structured form** is accepted — top-level keys must be a token group (`colors`, `radius`, `font`, `spacing`, `shadows`, `gradients`, `zIndex`, `motion`, `fonts`, `icons`) or a metadata key (`name`, `direction`). Flat-shape keys like `$theme({ colorPrimary: ... })` raise a schema error; unknown keys inside a group are silently ignored. **Every token value is a string.** Omit the whole call to inherit the host theme. `zIndex` layer tokens (`{ modal: 2000, toast: 2100, … }`) feed `sx.zIndex`; `motion` (`{ fast, base, slow, ease }`) → `--rui-motion-*`. Gradients accept color-stop arrays (`gradients: { brand: ["#6366f1", "#ec4899"] }`) and are referenced as `gradient.brand` in `sx`/`GradientText`. Custom icons register inline SVG by name (`icons: { logo: "<path …/>" }`) and are then usable anywhere a Font Awesome name is — `Icon("logo")`. Load web fonts with `fonts: { import: ["Inter:400,700", "JetBrains Mono"] }` (Google Fonts shorthand) alongside the `font.family` token.\n\nCore group keys (all optional):\n- `name?: string` — selects a built-in theme as the base palette (`"dark"`, `"neon"`, …; unknown names are ignored).\n- `direction?: "ltr" | "rtl"` — reading direction (metadata; not applied as a token).\n- `colors?: { ... }` — CSS color strings. Keys: `bg`, `bgSubtle`, `surface`, `surfaceMuted`, `border`, `borderSubtle`, `text`, `textMuted`, `primary`, `primaryHover`, `primaryText`, `accent`, `accentHover`, `accentText`, `focusRing`, `success`, `warning`, `danger`, `info`.\n- `radius?: { ... }` — CSS length strings. Keys: `xs`, `sm`, `md`, `lg`, `pill`, `button`, `input`.\n- `font?: { ... }` — CSS strings. Keys: `family`, `familyHeading`, `familyMono`, `sizeBase`, `sizeSm`, `sizeLg`, `sizeHeading`, `sizeTitle`, `weightBody`, `weightHeading`.\n\n```\n$theme({\n colors: { primary: "#635bff", primaryHover: "#4f46e5", accent: "#1f6feb", bg: "#0a0a23", surface: "#10103a", text: "#fff", textMuted: "#a5b4fc", focusRing: "#635bff" },\n radius: { md: "0.5rem", button: "999px", input: "8px" },\n font: { family: "Inter, sans-serif", familyHeading: "Inter, sans-serif", weightHeading: "600" }\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. ICU plural and select forms are supported: `{ n, plural, =0{No items} one{1 item} other{# items} }`.\n\n### RTL / bidirectional text\nSet `dir="rtl"` / `"ltr"` / `"auto"` on the host `<aktion-app>` element (not in code). The runtime reflects it onto the render root so the whole tree — text direction, flex order, logical spacing — flips automatically. Programs do not need any code change; use logical CSS properties (no hard-coded `left`/`right`) in raw CSS.\n\n### Accessibility primitives\n- `VisuallyHidden(child)` — hides content visually, keeps it in the a11y tree.\n- `SkipLink({ to: "#main", label: "Skip to content" })` — first tab stop for keyboard users.\n- `LiveRegion(Text($status), { mode: "polite" })` — announces dynamic changes (`"polite"` queues; `"assertive"` interrupts).\n- `FocusTrap(child, { active: $isOpen })` — Tab cycles within the subtree; required for dialogs.\n- Pass `aria: { label, labelledBy, describedBy, ... }` to any component via the universal props channel.\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 Xw(){return'## Universal style props (`sx` / `animate`) — every component\n\nEVERY component accepts a universal style/behaviour channel as named props, in addition to its own props. These are **bounded** (tokens & enums, never raw CSS) so they stay theme-safe — prefer them over the `Css`/`Styles`/`HTMLTag` escape hatches.\n\n- **`sx: { … }`** — token-aware inline styling. Keys (all optional):\n - Spacing (`none|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl|auto` (`none` = 0), the `safe`/`safe-top`/`safe-right`/`safe-bottom`/`safe-left` notch insets, or a CSS length): `p px py pt pr pb pl`, `m mx my mt mr mb ml`, `gap`. `px`/`mx` are logical (`padding-inline`) and `ps pe ms me` set the inline start/end sides, so RTL apps mirror automatically.\n - Sizing (`full|half|screen|dvh|min|max|fit|auto` or length): `w h minW maxW minH maxH`.\n - Color (token `surface|bg|text|text-muted|primary|accent|success|warning|danger|border`, a gradient ref `gradient.brand|accent|warm|cool|success|danger`, or a raw color): `bg color borderColor`.\n - Surface: `border: none|subtle|strong|<color>`, `radius: xs|sm|md|lg|pill|full`, `shadow: sm|md|lg|none`, `opacity`, `backdrop: "blur"`, `bgImage` (http(s)/relative/data:image only) + `bgOverlay` (color or `gradient.*` wash over the image), `bgSize: cover|contain`.\n - Typography: `fontSize: xs|sm|base|lg|xl|2xl|3xl|4xl` (or a length), `weight: 100…900|bold|normal`, `textDecoration: underline|line-through|none`, `textAlign`.\n - Flex/grid: `display direction align justify wrap grow shrink basis columns`.\n - Position: `position top right bottom left inset zIndex(base|dropdown|sticky|modal|toast|…)`, `overflow cursor`. Layer tokens resolve through `--rui-z-*` so `$theme({ zIndex: {...} })` rebrands them.\n - Interaction: `hover: { lift|grow|glow|bright|border|scale }`, `focus: { glow|border }` (mapped to bounded utility classes). For arbitrary state CSS use `states: { hover|focus|active|disabled|focus-visible|checked|group-hover: { bg, color, borderColor, shadow, radius, opacity, scale, translateX, translateY, rotate, cursor } }` — compiled to scoped `:state` rules in the adopted stylesheet. Example: `sx: { states: { hover: { scale: 1.04, shadow: "lg" }, focus: { borderColor: "primary" } } }` (I.4).\n - Responsive: any value may be `{ base, sm, md, lg, xl }` (resolves to `base`).\n- **`animate: "fade-up"`** (or `{ preset, delay?, duration?, repeat? }`) — entrance/loop motion. Presets: `fade fade-up/down/left/right zoom slide-up/down/left/right pulse float shimmer bounce spin ping wiggle`. Auto-respects `prefers-reduced-motion`.\n- **`id` / `anchor`** — set the element id (smooth-scroll targets).\n- **`className` / `style`** — extra classes / a sanitised inline style string.\n- **`aria: {…}` / `data: {…}` / `tooltip` / `hidden`** — accessibility & metadata passthrough.\n\n```\nCard([Text("Lift on hover")], { sx: { p: "l", radius: "lg", bg: "surface", shadow: "md", hover: { lift: true } } })\nBadge("Live", { tone: "success", animate: "pulse" })\nDisplay(["Build in ", GradientText("record time")], { size: "hero", align: "center", animate: "fade-up" })\n```'}function Jw(){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`, `.partition(arr, field, op, value)`, `.keyBy(arr, field)`, `.chunk(arr, size)`, `.flatten(arr, depth?)`, `.zip(...arrays)`, `.range(start, end, step?)`.\n- **Objects**: `$util.pick(obj, keys)`, `.omit(obj, keys)`, `.merge(target, ...sources)` (deep), `.cloneDeep(value)`.\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- **Formatting / misc**: `.slugify / .truncate(text, len) / .initials / .currency(v, code?) / .percent(v) / .bytes(v) / .relativeTime(date) / .copy(text)` (async — resolves `true` once the clipboard write succeeds) `/ .sleep(ms) / .uuid() / .debounceFn(fn, ms) / .throttleFn(fn, ms)` (leading + trailing edge).\n- **Device / platform**: `.vibrate(pattern) / .share({ title, text, url }) / .readClipboard() / .geolocate() / .isOnline() / .deviceType()` (XII.3); `.worker(pureFn, ...args)` runs a closure-free function off the main thread, resolving its result (XI.5); `.registerServiceWorker(url) / .webManifest({ name, icons, … })` for PWA setup (XII.2).\n- **Reactive env getters**: `$util.scroll`, `$util.viewport`, `$util.breakpoint`, `$util.media`, `$util.mouse`, `$util.url` (listeners attach lazily on first read, re-render on change).\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```\n\n## `$util.style`, `$util.rules` and `$util.derived` — styling, validation & computed helpers\n\n- **`$util.style`** — bounded, sanitised CSS helpers (return safe strings for the `sx.style` / inline use): `$util.style.cx("a", { active: cond })` (classnames), `$util.style.gradient(["#6366f1", "#ec4899"], 120)`, `$util.style.alpha("primary", 0.12)` (color-mix), `$util.style.clamp("16px", "2vw", "24px")`, `$util.style.token("spacing.l")` → `var(--rui-spacing-l)`, `$util.style.toStyle({ padding: "8px" })`.\n- **`$util.rules`** — composable validators that return `(value) => message | null`: `$util.rules.required() / .email() / .url() / .min(n) / .max(n) / .minLength(n) / .maxLength(n) / .pattern(re) / .oneOf([...]) / .matches(other) / .custom(fn) / .asyncCustom(fn)` (`fn` may return a Promise — server-side checks like username uniqueness; `$form` awaits it before submitting). Run them with `$util.rules.validate(value, [..])` (first error or null; a Promise when an async rule is hit) or `$util.rules.validateAll(values, schema)` (→ `{ field: message }`).\n- **`$util.derived(fn)`** — a computed value: `total = $util.derived(() => $util.sum($cart.map(i => i.price)))` recomputes reactively from the atoms `fn` reads.\n\n```\n$email = ""\nerror = $util.rules.validate($email, [$util.rules.required(), $util.rules.email()])\nInput("email", { value: $email, error: error })\n```\n\n### `$form({...})` — the form engine (managed forms)\nFor anything beyond one or two fields, reach for `$form` instead of wiring atoms by hand. `$form({ values: {...initial}, rules: { field: [validators] }, onSubmit: (values) => {...} })` returns a managed bag:\n- `form.values.x` — two-way binds straight onto an input (`Input("email", { value: form.values.email })`).\n- `form.errors.x` / `form.touched.x` / `form.dirty` / `form.valid` / `form.submitting` / `form.validating` — reactive reads (`dirty` flips on the first edit and clears on `reset()`; `validating` is true while async rules are in flight).\n- `form.field("email")` — returns `{ value, error, name, onChange, onBlur }` to spread for a controlled, validated field.\n- `form.validate()` (all) / `form.validateField(name)` / `form.touch(name)` / `form.setField(name, v)` / `form.setValues({...})` / `form.reset()`.\n- `form.submit()` (alias `form.handleSubmit()`) — marks fields touched, validates (awaiting async rules), then calls `onSubmit(values)` only when valid. `form.submitting` stays true until an async `onSubmit` settles.\n\n```\nform = $form({\n values: { email: "", age: "" },\n rules: { email: [$util.rules.required(), $util.rules.email()], age: [$util.rules.min(18)] },\n onSubmit: (v) => { $saved = $mutation({ url: "/signup", body: v }); $saved.mutate() }\n})\n$app(Column([\n Input("email", { value: form.values.email, error: form.errors.email, onBlur: () => form.touch("email") }),\n Button("Submit", { onClick: () => form.handleSubmit(), disabled: form.submitting })\n]))\n```'}function Qw(){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 the async `loader` resolves; show `fallback` while pending. |\n| `ErrorBoundary(children, { fallback?, onError? })` | Catch render errors thrown by descendants. |\n| `VirtualList(items, { key, render })` | Virtualised 1-D list — preferred for >100 rows. |\n| `VirtualGrid(items, { columns, rowHeight, render })` | Virtualised 2-D grid — only visible rows mount; essential for tables/grids >100 rows. |\n| `VisuallyHidden(child)` | Hides content visually but keeps it in the accessibility tree (extra context for screen readers). |\n| `SkipLink({ to, label })` | "Skip to main content" link that appears on focus — the first tab stop for keyboard users. |\n| `LiveRegion(child, { mode? })` | `aria-live` region (`mode: "polite"` default or `"assertive"`). Announces dynamic changes to screen readers. |\n| `FocusTrap(child, { active })` | Cycles Tab within its subtree and autofocuses the first control — required for accessible dialogs. |\n| `Fragment(children)` | Groups siblings without a layout box (`display:contents`) so a component can return several nodes into a parent Grid/Stack. |\n| `Transition(child, { show, preset, duration? })` | Enter/exit transition — keeps child mounted through exit animation; reduced-motion safe. |\n| `FlipList(children, { duration? })` | FLIP reorder animation — keyed children physically move to their new positions. |'}function Zw(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(o=>o.name)}],r=new Map(t.components.map(o=>[o.name,o])),n=[];n.push("## Component library"),n.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. Canonical call: pass it bare and put every other prop in a trailing `{ prop: value }` object. Also valid: all-positional in the listed order (the first positional fills the `(positional)` slot, the rest fill the remaining slots top-to-bottom), or a single `{ prop: value }` object naming every prop."),n.push("");for(const o of e){n.push(`### ${o.name}`);for(const s of o.components){const l=r.get(s);l&&n.push(Yr(l))}n.push("")}const a=new Set(e.flatMap(o=>o.components)),i=t.components.filter(o=>!a.has(o.name));if(i.length>0){n.push("### Other");for(const o of i)n.push(Yr(o))}return n.join(`
|
|
113
|
+
`).trim()}function e0(){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 t0(){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 r0(){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 n0(){return[`// Tasks dashboard — $http, Async, an action, multi-section layout
|
|
113
114
|
$tasks = $http({ url: "https://api.example.com/tasks" })
|
|
114
115
|
|
|
115
116
|
function toggle(task) {
|
|
@@ -131,12 +132,12 @@ $app(Column([
|
|
|
131
132
|
empty: EmptyState("No tasks yet"),
|
|
132
133
|
data: Column($tasks.data.map(t => row(t)), { gap: "sm" })
|
|
133
134
|
})
|
|
134
|
-
], { gap: "lg" }))`]}const
|
|
135
|
+
], { gap: "lg" }))`]}const a0=["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 i0(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."}
|
|
135
136
|
|
|
136
|
-
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
|
|
137
|
-
### ${a.name}`);for(const o of i){const s=r.get(o);s&&n.push(
|
|
138
|
-
`)}function
|
|
139
|
-
`)}function
|
|
137
|
+
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 o0(){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- **Canonical call: one positional arg, the rest in a trailing object** — `Callout("info", { title: "Heads up", icon: "circle-info" })`, `Badge("Live", { tone: "success" })`. All-positional (signature order) and all-named (single `{ }` object) calls also work.\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 s0(t){const e=t.componentGroups??[{name:"Components",components:t.components.map(a=>a.name)}],r=new Map(t.components.map(a=>[a.name,a])),n=["## 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 a of e){const i=a.components.filter(o=>a0.includes(o));if(i.length!==0){n.push(`
|
|
138
|
+
### ${a.name}`);for(const o of i){const s=r.get(o);s&&n.push(Yr(s))}}}return n.join(`
|
|
139
|
+
`)}function l0(){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?) / .chunk / .partition / .keyBy`.\n- Objects: `$util.pick / .omit / .merge / .cloneDeep`.\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 c0(){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 u0(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(`
|
|
140
|
+
`)}function d0(){return[`// Comparison table with a template-literal summary and follow-ups
|
|
140
141
|
$app(Column([title, tbl, totals, follow]))
|
|
141
142
|
title = Text("Top languages by users", { variant: "large-heavy" })
|
|
142
143
|
tbl = Table([
|
|
@@ -151,12 +152,12 @@ langs = [
|
|
|
151
152
|
{ name: "Python", users: 15.7, year: 1991 },
|
|
152
153
|
{ name: "JavaScript", users: 14.2, year: 1995 },
|
|
153
154
|
{ name: "TypeScript", users: 8.5, year: 2012 }
|
|
154
|
-
]`]}function
|
|
155
|
-
`)}function
|
|
156
|
-
`)}function
|
|
155
|
+
]`]}function p0(){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 m0(){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. Prefer one positional arg per call with everything else in a trailing `{ }` object; no statement split across lines outside an unmatched bracket.'}function Yr(t){const e=mn(t),r=t.props.map(n=>{const a=n.enum?n.enum.map(o=>`"${o}"`).join("|"):n.type,i=n===e&&n.positional===!0?" (positional)":"";return`${n.name}${n.optional?"?":""}: ${a}${i}`}).join(", ");return`- ${t.name}(${r}) — ${t.description}`}function ja(t,e){const r=[`## ${t}`];for(const n of e)r.push("```"),r.push(n.trim()),r.push("```");return r.join(`
|
|
156
|
+
`)}function rc(t){const e=["## Additional rules"];for(const r of t)e.push(`- ${r}`);return e.join(`
|
|
157
|
+
`)}function f0(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 n=r.kind==="Mutation"?"POST/PUT/PATCH/DELETE":"GET",a=r.argsExample?` example body: ${JSON.stringify(r.argsExample)}`:" example body: {}";e.push(`- ${r.name} (${n}) — ${r.description}
|
|
157
158
|
${a}`)}return e.join(`
|
|
158
|
-
`)}const
|
|
159
|
-
`)}const
|
|
159
|
+
`)}const g0=[["none","0"],["3xs","var(--rui-spacing-3xs)"],["2xs","var(--rui-spacing-2xs)"],["xs","var(--rui-spacing-xs)"],["sm","var(--rui-spacing-s)"],["md","var(--rui-spacing-m)"],["lg","var(--rui-spacing-l)"],["xl","var(--rui-spacing-xl)"],["2xl","var(--rui-spacing-2xl)"],["3xl","var(--rui-spacing-3xl)"],["s","var(--rui-spacing-s)"],["m","var(--rui-spacing-m)"],["l","var(--rui-spacing-l)"]];function Ce(t,e,r){return g0.map(([n,a])=>`${t}[${e}="${n}"] { ${r(a)} }`).join(`
|
|
160
|
+
`)}const nc=`
|
|
160
161
|
:host {
|
|
161
162
|
display: block;
|
|
162
163
|
box-sizing: border-box;
|
|
@@ -320,7 +321,7 @@ input, textarea, select, button { color: inherit; font-family: inherit; }
|
|
|
320
321
|
}
|
|
321
322
|
.rui-stack[data-direction="row"] { flex-direction: row; }
|
|
322
323
|
.rui-stack[data-direction="column"] { flex-direction: column; }
|
|
323
|
-
${
|
|
324
|
+
${Ce(".rui-stack","data-gap",t=>`gap: ${t};`)}
|
|
324
325
|
.rui-stack[data-align="start"] { align-items: flex-start; }
|
|
325
326
|
.rui-stack[data-align="center"] { align-items: center; }
|
|
326
327
|
.rui-stack[data-align="end"] { align-items: flex-end; }
|
|
@@ -341,7 +342,7 @@ ${ke(".rui-stack","data-gap",t=>`gap: ${t};`)}
|
|
|
341
342
|
.rui-stack[data-inline="true"] { display: inline-flex; }
|
|
342
343
|
.rui-stack[data-direction="row-reverse"] { flex-direction: row-reverse; }
|
|
343
344
|
.rui-stack[data-direction="column-reverse"] { flex-direction: column-reverse; }
|
|
344
|
-
${
|
|
345
|
+
${Ce(".rui-stack","data-padding",t=>`padding: ${t};`)}
|
|
345
346
|
.rui-stack[data-direction="row"][data-uniform="true"] > *:not(.rui-stack-item) { flex: 1 1 auto; min-width: 0; }
|
|
346
347
|
.rui-stack[data-direction="row-reverse"][data-uniform="true"] > *:not(.rui-stack-item) { flex: 1 1 auto; min-width: 0; }
|
|
347
348
|
/* Compact inline pills should hug their content, even inside a row Stack
|
|
@@ -388,8 +389,8 @@ ${ke(".rui-stack","data-padding",t=>`padding: ${t};`)}
|
|
|
388
389
|
.rui-center[data-inline="true"] { display: inline-flex; width: auto; }
|
|
389
390
|
.rui-center[data-axis="horizontal"] { justify-content: flex-start; }
|
|
390
391
|
.rui-center[data-axis="vertical"] { align-items: stretch; text-align: left; }
|
|
391
|
-
${
|
|
392
|
-
${
|
|
392
|
+
${Ce(".rui-center","data-gap",t=>`gap: ${t};`)}
|
|
393
|
+
${Ce(".rui-center","data-padding",t=>`padding: ${t};`)}
|
|
393
394
|
|
|
394
395
|
/* Section */
|
|
395
396
|
.rui-section { display: flex; flex-direction: column; gap: var(--rui-spacing-s); }
|
|
@@ -1289,7 +1290,7 @@ ${ke(".rui-center","data-padding",t=>`padding: ${t};`)}
|
|
|
1289
1290
|
.rui-grid[data-columns="10"] { grid-template-columns: repeat(10, minmax(0, 1fr)); }
|
|
1290
1291
|
.rui-grid[data-columns="11"] { grid-template-columns: repeat(11, minmax(0, 1fr)); }
|
|
1291
1292
|
.rui-grid[data-columns="12"] { grid-template-columns: repeat(12, minmax(0, 1fr)); }
|
|
1292
|
-
${
|
|
1293
|
+
${Ce(".rui-grid","data-gap",t=>`gap: ${t};`)}
|
|
1293
1294
|
|
|
1294
1295
|
/* Responsive prop maps for Grid columns/gap and Stack direction/gap.
|
|
1295
1296
|
* Components set --rui-grid-cols-{bp} / --rui-stack-dir-{bp} CSS vars for
|
|
@@ -1431,8 +1432,8 @@ ${ke(".rui-grid","data-gap",t=>`gap: ${t};`)}
|
|
|
1431
1432
|
.rui-grid[data-columns="10"][data-min-child-width] { --rui-grid-col-count: 10; }
|
|
1432
1433
|
.rui-grid[data-columns="11"][data-min-child-width] { --rui-grid-col-count: 11; }
|
|
1433
1434
|
.rui-grid[data-columns="12"][data-min-child-width] { --rui-grid-col-count: 12; }
|
|
1434
|
-
${
|
|
1435
|
-
${
|
|
1435
|
+
${Ce(".rui-grid","data-row-gap",t=>`row-gap: ${t};`)}
|
|
1436
|
+
${Ce(".rui-grid","data-column-gap",t=>`column-gap: ${t};`)}
|
|
1436
1437
|
.rui-grid[data-align-items="start"] { align-items: start; }
|
|
1437
1438
|
.rui-grid[data-align-items="center"] { align-items: center; }
|
|
1438
1439
|
.rui-grid[data-align-items="end"] { align-items: end; }
|
|
@@ -1476,8 +1477,8 @@ ${ke(".rui-grid","data-column-gap",t=>`column-gap: ${t};`)}
|
|
|
1476
1477
|
|
|
1477
1478
|
/* Box — spacing / surface wrapper */
|
|
1478
1479
|
.rui-box { box-sizing: border-box; }
|
|
1479
|
-
${
|
|
1480
|
-
${
|
|
1480
|
+
${Ce(".rui-box","data-padding",t=>`padding: ${t};`)}
|
|
1481
|
+
${Ce(".rui-box","data-margin",t=>`margin: ${t};`)}
|
|
1481
1482
|
.rui-box[data-border="subtle"] { border: 1px solid color-mix(in srgb, var(--rui-color-border) 60%, transparent); border-radius: var(--rui-radius-md); }
|
|
1482
1483
|
.rui-box[data-border="default"] { border: 1px solid var(--rui-color-border); border-radius: var(--rui-radius-md); }
|
|
1483
1484
|
.rui-box[data-background="surface"] { background: var(--rui-color-surface); }
|
|
@@ -2891,12 +2892,12 @@ ${ke(".rui-box","data-margin",t=>`margin: ${t};`)}
|
|
|
2891
2892
|
.rui-container[data-size="lg"] { max-width: 1040px; }
|
|
2892
2893
|
.rui-container[data-size="xl"] { max-width: 1280px; }
|
|
2893
2894
|
.rui-container[data-size="full"] { max-width: 100%; }
|
|
2894
|
-
${
|
|
2895
|
+
${Ce(".rui-container","data-padding",t=>`padding-left: ${t}; padding-right: ${t};`)}
|
|
2895
2896
|
|
|
2896
2897
|
/* Spacer */
|
|
2897
2898
|
.rui-spacer { display: block; }
|
|
2898
2899
|
.rui-spacer[data-flex="true"] { flex: 1 1 auto; }
|
|
2899
|
-
${
|
|
2900
|
+
${Ce(".rui-spacer","data-size",t=>`min-width: ${t}; min-height: ${t};`)}
|
|
2900
2901
|
|
|
2901
2902
|
/* Cover */
|
|
2902
2903
|
.rui-cover {
|
|
@@ -7741,7 +7742,7 @@ th[data-active="true"] .rui-data-grid-sort-icon { opacity: 1; }
|
|
|
7741
7742
|
.rui-masonry-grid[data-columns="4"] { --rui-masonry-columns: 4; }
|
|
7742
7743
|
.rui-masonry-grid[data-columns="5"] { --rui-masonry-columns: 5; }
|
|
7743
7744
|
.rui-masonry-grid[data-columns="6"] { --rui-masonry-columns: 6; }
|
|
7744
|
-
${
|
|
7745
|
+
${Ce(".rui-masonry-grid","data-gap",t=>`--rui-masonry-gap: ${t};`)}
|
|
7745
7746
|
.rui-masonry-grid > * {
|
|
7746
7747
|
display: inline-block;
|
|
7747
7748
|
width: 100%;
|
|
@@ -8432,7 +8433,7 @@ ${ke(".rui-masonry-grid","data-gap",t=>`--rui-masonry-gap: ${t};`)}
|
|
|
8432
8433
|
collapse below can re-shape the grid without fighting inline styles. */
|
|
8433
8434
|
.rui-bento { display: grid; grid-template-columns: repeat(var(--rui-bento-cols, 6), minmax(0, 1fr)); gap: var(--rui-spacing-m); grid-auto-rows: var(--rui-bento-row, minmax(110px, auto)); }
|
|
8434
8435
|
.rui-bento[data-dense="true"] { grid-auto-flow: dense; }
|
|
8435
|
-
${
|
|
8436
|
+
${Ce(".rui-bento","data-gap",t=>`gap: ${t};`)}
|
|
8436
8437
|
.rui-bento[data-cols="1"] { --rui-bento-cols: 1; }
|
|
8437
8438
|
.rui-bento[data-cols="2"] { --rui-bento-cols: 2; }
|
|
8438
8439
|
.rui-bento[data-cols="3"] { --rui-bento-cols: 3; }
|
|
@@ -8773,7 +8774,7 @@ ${ke(".rui-bento","data-gap",t=>`gap: ${t};`)}
|
|
|
8773
8774
|
.rui-kbd-shortcut { display: inline-flex; align-items: center; gap: 4px; }
|
|
8774
8775
|
.rui-kbd-key { font-family: var(--rui-font-family-mono); font-size: 11px; line-height: 1; padding: 4px 6px; border-radius: var(--rui-radius-xs); border: 1px solid var(--rui-color-border); border-bottom-width: 2px; background: var(--rui-color-surface-muted); color: var(--rui-color-text); }
|
|
8775
8776
|
.rui-kbd-plus { color: var(--rui-color-text-muted); font-size: 11px; }
|
|
8776
|
-
`,xa="theme",Ht="streaming",wa="response",St="showerrors",$t="src",Kx="scroll-restoration",ka="dir",Rl="route";function Yx(t){const e=t.getPath(),r={...t.getParams()},n=t.getActivePattern(),a={};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,l]of o)a[s]=l}}return{path:e,params:r,pattern:n,query:a,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function Xx(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,n=e;return r.path!==n.path||r.pattern!==n.pattern?!1:Ll(r.params??{},n.params??{})&&Ll(r.query??{},n.query??{})}function Ll(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(t[a]!==e[a])return!1;return!0}let Sa=null,Fr=null,Zx=0;function Qx(){if(Fr===!1)return null;if(Sa)return Sa;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Fr=!1,null;const t=new CSSStyleSheet;return t.replaceSync(zl),Sa=t,Fr=!0,t}catch{return Fr=!1,null}}class qt extends HTMLElement{constructor(){super();j(this,"state",new Dn);j(this,"router",new Kn);j(this,"library",kt);j(this,"http",new jn);j(this,"effectRunner");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,"routeScrollPositions",new Map);j(this,"forceFullRender",!1);j(this,"parseErrors",[]);j(this,"srcDiagnostics",[]);j(this,"srcLoadToken",0);j(this,"hasConnected",!1);j(this,"scriptThemeKeys",[]);j(this,"devtoolsId",`aktion-app-${Zx+=1}`);j(this,"devtoolsCommitId",0);j(this,"devtoolsRegistered",!1);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=Qx();if(r)try{const a=Qr(),i=a?[r,a]:[r];this.root.adoptedStyleSheets=i,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 n=a=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:a},bubbles:!0,composed:!0}))};this.effectRunner=new Cl({state:this.state,notify:()=>this.requestFullRender(),onEmit:(a,i)=>this.emitCustomEvent(a,i),onEffectEvent:a=>this.emitDevtoolsEffect(a)}),this.context=Pr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(a,i)=>this.emitCustomEvent(a,i)}),this.renderer=new ha({library:this.library,state:this.state,router:this.router,onAssistantMessage:n,evaluationContext:()=>this.context,mountInstanceEffects:(a,i,o)=>this.effectRunner.syncInstanceEffects(a,i,o),unmountInstanceEffects:a=>this.effectRunner.unmountInstance(a),unmountInstanceHooks:a=>yl(this.context,a)}),this.state.subscribe(a=>{for(const i of a)this.pendingChangedPaths.add(i);fa()&&ga({kind:"state",appId:this.devtoolsId,snapshot:this.state.snapshot(),changedPaths:[...a],time:ve()}),(this.lastRenderDeps===null||zt(a,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(a=>this.handleRouteChange(a))}static get observedAttributes(){return[xa,Ht,wa,St,$t,ka]}connectedCallback(){this.hasConnected=!0,Oc(this.root),this.registerWithDevtools(),this.applyThemeFromAttribute(),this.applyDir(),this.startRouter();const r=this.getAttribute(wa);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}const n=this.getAttribute($t);if(n&&!this.currentResponse){this.loadFromSrc(n);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&&ra(this.context),this.router.stop(),this.devtoolsRegistered&&(Gy(this.devtoolsId),this.devtoolsRegistered=!1)}attributeChangedCallback(r,n,a){if(r===xa&&this.applyThemeFromAttribute(),r===ka&&this.applyDir(),r===Ht&&(this.updateErrorBanner(),this.scheduleRender()),r===St&&this.updateErrorBanner(),r===wa){const i=a??"";i!==this.currentResponse&&this.setResponse(i)}r===$t&&this.hasConnected&&a&&this.loadFromSrc(a)}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.srcDiagnostics=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const n=this.state.snapshot(),a=zc(this.currentResponse,r);return Object.assign(n,a.stateUpdates),this.loadSnapshot({programText:a.programText,state:n}),a.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.srcDiagnostics=[],this.state.hydrate(r.state),this.scheduleRender()}mountCompiled(r,n){if(!Za(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=[],this.srcDiagnostics=[],n&&this.state.hydrate(n),this.scheduleRender()}get sourceId(){return this.compiledSourceId}get src(){return this.getAttribute($t)}set src(r){r===null?this.removeAttribute($t):this.setAttribute($t,r)}async loadFromSrc(r){const n=this.srcLoadToken+=1;this.srcDiagnostics=[];let a;try{const s=typeof document<"u"?document.baseURI:void 0;a=new URL(r,s).href}catch{this.reportSrcError(`Invalid src "${r}".`);return}let i;try{if(typeof fetch!="function")throw new Error("global fetch is unavailable");const s=await fetch(a);if(!s.ok)throw new Error(`HTTP ${s.status}`);i=await s.text()}catch(s){if(this.isStaleSrcLoad(n))return;this.reportSrcError(`Failed to load "${r}": ${jl(s)}`);return}if(this.isStaleSrcLoad(n))return;let o;try{o=await ni({entry:a,files:{[a]:i}})}catch(s){if(this.isStaleSrcLoad(n))return;this.reportSrcError(`Failed to link "${r}": ${jl(s)}`);return}this.isStaleSrcLoad(n)||(this.mountCompiled({__aktionCompiled:Yt,program:o.program,source:o.source,path:a}),this.srcDiagnostics=o.diagnostics.filter(s=>s.severity!=="warning").map(s=>s.line>0?`Line ${s.line}: ${s.message}`:s.message))}isStaleSrcLoad(r){return r!==this.srcLoadToken||!this.isConnected}reportSrcError(r){this.srcDiagnostics.includes(r)||(this.srcDiagnostics=[...this.srcDiagnostics,r]),this.updateErrorBanner(),this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r}]},bubbles:!0,composed:!0}))}appendChunk(r){if(r==null)return;const n=typeof r=="string"?r:String(r);n!==""&&(this.currentResponse+=n,this.programDirty=!0,this.scheduleRender())}setTheme(r){Vn(this,qn(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,n){this.library=oi(this.library,{components:r,root:n}),this.renderer.setLibrary(this.library),this.scheduleRender()}registerIcons(r){pi(r),this.scheduleRender()}getSystemPrompt(r){return va(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.srcDiagnostics=[],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 Dl(this.getAttribute(Ht))}set streaming(r){r?this.setAttribute(Ht,"true"):this.removeAttribute(Ht)}get showErrors(){return Dl(this.getAttribute(St))}set showErrors(r){r?this.setAttribute(St,"true"):this.removeAttribute(St)}emitCustomEvent(r,n){this.dispatchEvent(new CustomEvent(r,{detail:n,bubbles:!0,composed:!0}))}registerWithDevtools(){if(this.devtoolsRegistered)return;const r=jr();if(!r)return;const n={id:this.devtoolsId,label:this.getAttribute("data-devtools-label")||this.id||this.devtoolsId,element:this,getState:()=>this.state.snapshot(),setState:(a,i)=>this.applyDevtoolsStateEdit(a,i),getProgram:()=>this.currentResponse,forceRender:()=>this.requestFullRender()};r.registerApp(n),this.devtoolsRegistered=!0}connectDevtools(){this.registerWithDevtools(),this.devtoolsRegistered&&this.requestFullRender()}applyDevtoolsStateEdit(r,n){const a=r.indexOf(".");if(a<0){this.state.set(r,n);return}const i=r.slice(0,a),o=r.slice(a+1).split(".");this.state.setPath(i,o,n)}emitDevtoolsEffect(r){ga({kind:"effect",appId:this.devtoolsId,time:ve(),...r})}buildInlineStyle(){const r=document.createElement("style");return r.textContent=zl,r}startRouter(){const r=this.getAttribute("router-mode"),n=this.getAttribute("router-base");(r||n)&&this.router.configure({mode:r==="history"?"history":r==="hash"?"hash":void 0,...n!==null?{basePath:n}:{}}),this.router.start(),this.writeRouteState()}writeRouteState(){const r=Yx(this.router);Xx(this.state.get(Rl),r)||this.state.set(Rl,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender(),this.handleScrollRestoration(r)}handleScrollRestoration(r){if(typeof window>"u")return;const n=(this.getAttribute(Kx)||"").toLowerCase();if(n!=="auto"&&n!=="top"||r.source==="init")return;n==="auto"&&r.previousPath!=null&&this.routeScrollPositions.set(r.previousPath,{x:window.scrollX||0,y:window.scrollY||0});const a=r.source==="hashchange"||r.source==="external",o=(n==="auto"&&a?this.routeScrollPositions.get(r.path):void 0)??{x:0,y:0},s=()=>{try{window.scrollTo(o.x,o.y)}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}applyThemeFromAttribute(){const r=this.getAttribute(xa);Vn(this,qn(r)),this.scriptThemeKeys=[]}applyDir(){const r=(this.getAttribute(ka)||"").toLowerCase();r==="rtl"||r==="ltr"||r==="auto"?this.rootEl.setAttribute("dir",r):this.rootEl.removeAttribute("dir")}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(Os(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let n;try{n=r()}catch{return}if(!bs(n))return;const a=Fs(n.tokens);Object.keys(a).length!==0&&(this.scriptThemeKeys=Bs(this,a))}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&&Jn(this.context.budget),this.devtoolsRegistered||this.registerWithDevtools();const r=fa();this.renderer.setProfiling(r);const n=r?ve():0,a=new Set,i=this.context.trackedState;this.context.trackedState=a;let o=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),rl(this.context);const s=this.context.bindings.get("aktion");let l=null;if(s)try{l=s()}catch(b){if(b instanceof Qe){this.handleRuntimeBudgetError(b);return}console.error("[aktion] entry point evaluation error",b)}const u=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const d=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:u,memoize:d});const p=this.captureFocus();let f;try{f=this.renderer.render(l)}catch(b){if(this.renderer.endRender(),b instanceof Qe){this.handleRuntimeBudgetError(b);return}throw b}if(ix(this.rootEl,f),this.renderer.endRender(),this.restoreFocus(p),o=!0,r){const b=this.renderer.drainProfilerRecords();let h=0,g=0;for(const y of b)y.phase==="memo"?g+=1:h+=1;ga({kind:"commit",appId:this.devtoolsId,commitId:this.devtoolsCommitId,startTime:n,duration:ve()-n,changedPaths:[...u],fullRender:!d,initial:this.devtoolsCommitId===0,components:b,rendered:h,memoized:g}),this.devtoolsCommitId+=1}}finally{this.context.trackedState=i,this.lastRenderDeps=o?a: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 n=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(n)||(this.parseErrors=[...this.parseErrors,n]),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 n=r.id||null;if(!n)return null;const a={id:n,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(a.selectionStart=r.selectionStart,a.selectionEnd=r.selectionEnd,a.selectionDirection=r.selectionDirection??null),a}restoreFocus(r){if(!r)return;const n=this.rootEl.querySelector(`#${Jx(r.id)}`);!n||n.tagName!==r.tagName||this.root.activeElement===n||(n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&tw(n,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&ra(this.context),this.context=Pr(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=this.pendingCompiled??xe(this.currentResponse);this.pendingCompiled=null;const n=sn(r,this.library);n.length>0&&(r.errors=[...r.errors,...n]),this.context.budget&&Jn(this.context.budget);try{na(r,this.context)}catch(i){if(i instanceof Qe)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const a=[...this.context.effectDecls.values()];a.length>0&&this.effectRunner.syncEffects(a,()=>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(){const r=[...this.parseErrors,...this.srcDiagnostics];if(!this.showErrors||this.streaming||r.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const n=document.createElement("div");n.textContent=`${r.length} parse issue${r.length===1?"":"s"} (rendered partial UI):`;const a=document.createElement("ul");for(const i of r.slice(0,5)){const o=document.createElement("li");o.textContent=i,a.append(o)}this.errorEl.replaceChildren(n,a)}}j(qt,"tagName","aktion-app");function Jx(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const ew=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function tw(t,e,r,n){if(t instanceof HTMLInputElement&&ew.has(t.type)){const a=t.type;try{t.type="text",t.setSelectionRange(e,r,n)}catch{}finally{t.type=a}return}try{t.setSelectionRange(e,r,n)}catch{}}function Dl(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===St}function jl(t){return t instanceof Error&&t.message?t.message:String(t)}function Bl(){customElements.get(qt.tagName)||customElements.define(qt.tagName,qt)}const rw=[{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([
|
|
8777
|
+
`,Da="theme",Yt="streaming",Oa="response",Nt="showerrors",It="src",h0="scroll-restoration",Ba="dir",ac="route";function b0(t){const e=t.getPath(),r={...t.getParams()},n=t.getActivePattern(),a={};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,l]of o)a[s]=l}}return{path:e,params:r,pattern:n,query:a,navigate(i){typeof i!="string"||!i||t.navigate(i)},toString(){return e}}}function v0(t,e){if(!t||!e||typeof t!="object"||typeof e!="object")return!1;const r=t,n=e;return r.path!==n.path||r.pattern!==n.pattern?!1:ic(r.params??{},n.params??{})&&ic(r.query??{},n.query??{})}function ic(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const a of r)if(t[a]!==e[a])return!1;return!0}let Fa=null,Xr=null,y0=0;function x0(){if(Xr===!1)return null;if(Fa)return Fa;try{if(typeof CSSStyleSheet>"u"||!("replaceSync"in CSSStyleSheet.prototype)||typeof document>"u"||!("adoptedStyleSheets"in Document.prototype))return Xr=!1,null;const t=new CSSStyleSheet;return t.replaceSync(nc),Fa=t,Xr=!0,t}catch{return Xr=!1,null}}class Xt extends HTMLElement{constructor(){super();O(this,"state",new Yn);O(this,"router",new ua);O(this,"library",Tt);O(this,"http",new Xn);O(this,"effectRunner");O(this,"renderer");O(this,"context");O(this,"root");O(this,"rootEl");O(this,"errorEl");O(this,"currentResponse","");O(this,"pendingCompiled",null);O(this,"compiledSourceId",null);O(this,"renderScheduled",!1);O(this,"programDirty",!0);O(this,"lastRenderDeps",null);O(this,"pendingChangedPaths",new Set);O(this,"routeScrollPositions",new Map);O(this,"forceFullRender",!1);O(this,"parseErrors",[]);O(this,"srcDiagnostics",[]);O(this,"srcLoadToken",0);O(this,"hasConnected",!1);O(this,"scriptThemeKeys",[]);O(this,"devtoolsId",`aktion-app-${y0+=1}`);O(this,"devtoolsCommitId",0);O(this,"devtoolsRegistered",!1);O(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=x0();if(r)try{const a=cn(),i=a?[r,a]:[r];this.root.adoptedStyleSheets=i,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 n=a=>{this.dispatchEvent(new CustomEvent("assistant-message",{detail:{message:a},bubbles:!0,composed:!0}))};this.effectRunner=new Kl({state:this.state,notify:()=>this.requestFullRender(),onEmit:(a,i)=>this.emitCustomEvent(a,i),onEffectEvent:a=>this.emitDevtoolsEffect(a)}),this.context=_r(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(a,i)=>this.emitCustomEvent(a,i)}),this.renderer=new Ea({library:this.library,state:this.state,router:this.router,onAssistantMessage:n,evaluationContext:()=>this.context,mountInstanceEffects:(a,i,o)=>this.effectRunner.syncInstanceEffects(a,i,o),unmountInstanceEffects:a=>this.effectRunner.unmountInstance(a),unmountInstanceHooks:a=>Ul(this.context,a)}),this.state.subscribe(a=>{for(const i of a)this.pendingChangedPaths.add(i);Pa()&&Ra({kind:"state",appId:this.devtoolsId,snapshot:this.state.snapshot(),changedPaths:[...a],time:we()}),(this.lastRenderDeps===null||Bt(a,this.lastRenderDeps))&&this.scheduleRender()}),this.router.subscribe(a=>this.handleRouteChange(a))}static get observedAttributes(){return[Da,Yt,Oa,Nt,It,Ba]}connectedCallback(){this.hasConnected=!0,cu(this.root),this.registerWithDevtools(),this.applyThemeFromAttribute(),this.applyDir(),this.startRouter();const r=this.getAttribute(Oa);if(r!==null&&r!==""&&r!==this.currentResponse){this.setResponse(r);return}const n=this.getAttribute(It);if(n&&!this.currentResponse){this.loadFromSrc(n);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&&ya(this.context),this.router.stop(),this.devtoolsRegistered&&(fw(this.devtoolsId),this.devtoolsRegistered=!1)}attributeChangedCallback(r,n,a){if(r===Da&&this.applyThemeFromAttribute(),r===Ba&&this.applyDir(),r===Yt&&(this.updateErrorBanner(),this.scheduleRender()),r===Nt&&this.updateErrorBanner(),r===Oa){const i=a??"";i!==this.currentResponse&&this.setResponse(i)}r===It&&this.hasConnected&&a&&this.loadFromSrc(a)}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.srcDiagnostics=[],this.scheduleRender())}serializeState(){return this.state.snapshot()}hydrateState(r){this.state.hydrate(r),this.scheduleRender()}applyDelta(r){const n=this.state.snapshot(),a=nu(this.currentResponse,r);return Object.assign(n,a.stateUpdates),this.loadSnapshot({programText:a.programText,state:n}),a.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.srcDiagnostics=[],this.state.hydrate(r.state),this.scheduleRender()}mountCompiled(r,n){if(!fi(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=[],this.srcDiagnostics=[],n&&this.state.hydrate(n),this.scheduleRender()}get sourceId(){return this.compiledSourceId}get src(){return this.getAttribute(It)}set src(r){r===null?this.removeAttribute(It):this.setAttribute(It,r)}async loadFromSrc(r){const n=this.srcLoadToken+=1;this.srcDiagnostics=[];let a;try{const s=typeof document<"u"?document.baseURI:void 0;a=new URL(r,s).href}catch{this.reportSrcError(`Invalid src "${r}".`);return}let i;try{if(typeof fetch!="function")throw new Error("global fetch is unavailable");const s=await fetch(a);if(!s.ok)throw new Error(`HTTP ${s.status}`);i=await s.text()}catch(s){if(this.isStaleSrcLoad(n))return;this.reportSrcError(`Failed to load "${r}": ${sc(s)}`);return}if(this.isStaleSrcLoad(n))return;let o;try{o=await xi({entry:a,files:{[a]:i}})}catch(s){if(this.isStaleSrcLoad(n))return;this.reportSrcError(`Failed to link "${r}": ${sc(s)}`);return}this.isStaleSrcLoad(n)||(this.mountCompiled({__aktionCompiled:tr,program:o.program,source:o.source,path:a}),this.srcDiagnostics=o.diagnostics.filter(s=>s.severity!=="warning").map(s=>s.line>0?`Line ${s.line}: ${s.message}`:s.message))}isStaleSrcLoad(r){return r!==this.srcLoadToken||!this.isConnected}reportSrcError(r){this.srcDiagnostics.includes(r)||(this.srcDiagnostics=[...this.srcDiagnostics,r]),this.updateErrorBanner(),this.dispatchEvent(new CustomEvent("error",{detail:{errors:[{line:0,column:0,message:r}]},bubbles:!0,composed:!0}))}appendChunk(r){if(r==null)return;const n=typeof r=="string"?r:String(r);n!==""&&(this.currentResponse+=n,this.programDirty=!0,this.scheduleRender())}setTheme(r){sa(this,oa(r)),this.scriptThemeKeys=[],this.scheduleRender()}registerComponents(r,n){this.library=Si(this.library,{components:r,root:n}),this.renderer.setLibrary(this.library),this.scheduleRender()}registerIcons(r){Ni(r),this.scheduleRender()}getSystemPrompt(r){return za(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.srcDiagnostics=[],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 oc(this.getAttribute(Yt))}set streaming(r){r?this.setAttribute(Yt,"true"):this.removeAttribute(Yt)}get showErrors(){return oc(this.getAttribute(Nt))}set showErrors(r){r?this.setAttribute(Nt,"true"):this.removeAttribute(Nt)}emitCustomEvent(r,n){this.dispatchEvent(new CustomEvent(r,{detail:n,bubbles:!0,composed:!0}))}registerWithDevtools(){if(this.devtoolsRegistered)return;const r=Gr();if(!r)return;const n={id:this.devtoolsId,label:this.getAttribute("data-devtools-label")||this.id||this.devtoolsId,element:this,getState:()=>this.state.snapshot(),setState:(a,i)=>this.applyDevtoolsStateEdit(a,i),getProgram:()=>this.currentResponse,forceRender:()=>this.requestFullRender()};r.registerApp(n),this.devtoolsRegistered=!0}connectDevtools(){this.registerWithDevtools(),this.devtoolsRegistered&&this.requestFullRender()}applyDevtoolsStateEdit(r,n){const a=r.indexOf(".");if(a<0){this.state.set(r,n);return}const i=r.slice(0,a),o=r.slice(a+1).split(".");this.state.setPath(i,o,n)}emitDevtoolsEffect(r){Ra({kind:"effect",appId:this.devtoolsId,time:we(),...r})}buildInlineStyle(){const r=document.createElement("style");return r.textContent=nc,r}startRouter(){const r=this.getAttribute("router-mode"),n=this.getAttribute("router-base");(r||n)&&this.router.configure({mode:r==="history"?"history":r==="hash"?"hash":void 0,...n!==null?{basePath:n}:{}}),this.router.start(),this.writeRouteState()}writeRouteState(){const r=b0(this.router);v0(this.state.get(ac),r)||this.state.set(ac,r)}handleRouteChange(r){this.writeRouteState(),this.dispatchEvent(new CustomEvent("route-change",{detail:r,bubbles:!0,composed:!0})),this.scheduleRender(),this.handleScrollRestoration(r)}handleScrollRestoration(r){if(typeof window>"u")return;const n=(this.getAttribute(h0)||"").toLowerCase();if(n!=="auto"&&n!=="top"||r.source==="init")return;n==="auto"&&r.previousPath!=null&&this.routeScrollPositions.set(r.previousPath,{x:window.scrollX||0,y:window.scrollY||0});const a=r.source==="hashchange"||r.source==="external",o=(n==="auto"&&a?this.routeScrollPositions.get(r.path):void 0)??{x:0,y:0},s=()=>{try{window.scrollTo(o.x,o.y)}catch{}};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}applyThemeFromAttribute(){const r=this.getAttribute(Da);sa(this,oa(r)),this.scriptThemeKeys=[]}applyDir(){const r=(this.getAttribute(Ba)||"").toLowerCase();r==="rtl"||r==="ltr"||r==="auto"?this.rootEl.setAttribute("dir",r):this.rootEl.removeAttribute("dir")}applyScriptThemeOverrides(){this.scriptThemeKeys.length>0&&(ll(this,this.scriptThemeKeys),this.scriptThemeKeys=[]);const r=this.context.bindings.get("theme");if(!r)return;let n;try{n=r()}catch{return}if(!Bs(n))return;const a=cl(n.tokens);Object.keys(a).length!==0&&(this.scriptThemeKeys=sl(this,a))}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&&ha(this.context.budget),this.devtoolsRegistered||this.registerWithDevtools();const r=Pa();this.renderer.setProfiling(r);const n=r?we():0,a=new Set,i=this.context.trackedState;this.context.trackedState=a;let o=!1;this.state.beginRenderPass();try{this.applyScriptThemeOverrides(),Cl(this.context);const s=this.context.bindings.get("aktion");let l=null;if(s)try{l=s()}catch(b){if(b instanceof rt){this.handleRuntimeBudgetError(b);return}console.error("[aktion] entry point evaluation error",b)}const c=this.pendingChangedPaths;this.pendingChangedPaths=new Set;const d=!this.forceFullRender&&this.lastRenderDeps!==null;this.forceFullRender=!1,this.renderer.beginRender({changedPaths:c,memoize:d});const p=this.captureFocus();let f;try{f=this.renderer.render(l)}catch(b){if(this.renderer.endRender(),b instanceof rt){this.handleRuntimeBudgetError(b);return}throw b}if(Aw(this.rootEl,f),this.renderer.endRender(),this.restoreFocus(p),o=!0,r){const b=this.renderer.drainProfilerRecords();let h=0,g=0;for(const y of b)y.phase==="memo"?g+=1:h+=1;Ra({kind:"commit",appId:this.devtoolsId,commitId:this.devtoolsCommitId,startTime:n,duration:we()-n,changedPaths:[...c],fullRender:!d,initial:this.devtoolsCommitId===0,components:b,rendered:h,memoized:g}),this.devtoolsCommitId+=1}}finally{this.context.trackedState=i,this.lastRenderDeps=o?a: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 n=`Runtime aborted (${r.kind}): ${r.message}`;this.parseErrors.includes(n)||(this.parseErrors=[...this.parseErrors,n]),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 n=r.id||null;if(!n)return null;const a={id:n,tagName:r.tagName};return(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(a.selectionStart=r.selectionStart,a.selectionEnd=r.selectionEnd,a.selectionDirection=r.selectionDirection??null),a}restoreFocus(r){if(!r)return;const n=this.rootEl.querySelector(`#${w0(r.id)}`);!n||n.tagName!==r.tagName||this.root.activeElement===n||(n.focus(),(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&r.selectionStart!=null&&r.selectionEnd!=null&&S0(n,r.selectionStart,r.selectionEnd,r.selectionDirection??"none"))}replan(){this.effectRunner.reset(),this.lastRenderDeps=null,this.warnedStateWriteDuringRender=!1,this.context&&ya(this.context),this.context=_r(this.state,{router:this.router,library:this.library,http:this.http,strict:this.hasAttribute("strict"),notify:()=>this.requestFullRender(),onEmit:(i,o)=>this.emitCustomEvent(i,o)});const r=this.pendingCompiled??Se(this.currentResponse);this.pendingCompiled=null;const n=bn(r,this.library);n.length>0&&(r.errors=[...r.errors,...n]),this.context.budget&&ha(this.context.budget);try{xa(r,this.context)}catch(i){if(i instanceof rt)r.errors=[...r.errors,{line:0,column:0,message:i.message}];else throw i}const a=[...this.context.effectDecls.values()];a.length>0&&this.effectRunner.syncEffects(a,()=>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(){const r=[...this.parseErrors,...this.srcDiagnostics];if(!this.showErrors||this.streaming||r.length===0){this.errorEl.hidden=!0,this.errorEl.replaceChildren();return}this.errorEl.hidden=!1;const n=document.createElement("div");n.textContent=`${r.length} parse issue${r.length===1?"":"s"} (rendered partial UI):`;const a=document.createElement("ul");for(const i of r.slice(0,5)){const o=document.createElement("li");o.textContent=i,a.append(o)}this.errorEl.replaceChildren(n,a)}}O(Xt,"tagName","aktion-app");function w0(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([^A-Za-z0-9_-])/g,"\\$1")}const k0=new Set(["email","number","tel","url","date","datetime-local","month","week","time","color"]);function S0(t,e,r,n){if(t instanceof HTMLInputElement&&k0.has(t.type)){const a=t.type;try{t.type="text",t.setSelectionRange(e,r,n)}catch{}finally{t.type=a}return}try{t.setSelectionRange(e,r,n)}catch{}}function oc(t){if(t===null)return!1;const e=t.trim().toLowerCase();return e===""||e==="true"||e==="1"||e===Nt}function sc(t){return t instanceof Error&&t.message?t.message:String(t)}function lc(){customElements.get(Xt.tagName)||customElements.define(Xt.tagName,Xt)}const $0=[{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([
|
|
8777
8778
|
CardHeader("\${2:Title}", { subtitle: "\${3:Subtitle}" }),
|
|
8778
8779
|
Column([
|
|
8779
8780
|
Text("\${4:Body copy goes here.}")
|
|
@@ -8901,5 +8902,5 @@ Column([
|
|
|
8901
8902
|
onConfirm: () => \${4:remove}(),
|
|
8902
8903
|
onCancel: () => {}
|
|
8903
8904
|
})
|
|
8904
|
-
])`}];function
|
|
8905
|
+
])`}];function cc(){return $0}function C0(t=Tt){const e=Ds(t);return{grammar:cr,tokenizer:to(cr),tagMap:ro,components:e,componentsByName:Os(e),builtins:ur,snippets:cc(),keywordDocs:eo,themeNames:Object.keys(Ut),severityTokenMap:{"parse-error":"error"},iconAliases:A0}}const A0=["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"];lc();const T0=za(Tt);return E.AktionElement=Xt,E.BreakSignal=Pe,E.COMPILED_PROGRAM_VERSION=tr,E.ContinueSignal=ze,E.DEFAULT_RUNTIME_BUDGET=Br,E.EffectRunner=Kl,E.HttpRuntime=Xn,E.Renderer=Ea,E.ReturnSignal=mt,E.Router=ua,E.RuntimeBudgetError=rt,E.SYSTEM_PROMPT_TEXT=T0,E.StateStore=Yn,E.anyPathAffects=Kn,E.applyPartialTheme=sl,E.applyTheme=sa,E.assertOnePositionalMax=Ji,E.brutalistTheme=il,E.buildFrontier=pi,E.builtInThemes=Ut,E.builtinCatalog=ur,E.builtinNames=no,E.builtinsByName=ao,E.callArgShapes=hn,E.chooseNamedBagIndex=gn,E.clearInstanceHooks=Ul,E.clearTokenOverrides=ll,E.compileLite=Hc,E.computeFrontier=Bc,E.consoleNs=hl,E.createContext=_r,E.createHttpResource=Zn,E.createI18n=Xs,E.createMemoryResolver=yi,E.createMutationResource=Ws,E.createQueryResource=Vs,E.createRuntimeBudget=wl,E.createStreamTokenizer=to,E.createToastManager=bl,E.darkTheme=tl,E.defaultLibrary=Tt,E.defaultTagMap=ro,E.defineCompiledProgram=Uc,E.defineElement=lc,E.describeComponentSpec=Lw,E.disposeContext=ya,E.enterUserComponent=ba,E.evaluate=R,E.evaluateUserComponent=Ol,E.extractStatePath=Ur,E.factoryResourceCatalog=wn,E.factoryResourceNames=kn,E.findBuiltin=nd,E.findBuiltinConfig=jd,E.findComponent=Le,E.findFactoryResource=kd,E.findNamespace=xd,E.findNamespaceMember=$d,E.findPositionalIndex=sr,E.findPositionalProp=mn,E.generatePrompt=za,E.getComponentCatalog=Ds,E.getHeadManager=ga,E.getLanguageSpec=C0,E.getSnippets=cc,E.glassTheme=al,E.grammarSpec=cr,E.i18nResultMembers=yd,E.indexCatalog=Os,E.invalidateQueries=Jn,E.isBuiltinName=ad,E.isCompiledProgram=fi,E.isComponentNode=Sl,E.isEndpointResource=Us,E.isNamespaceName=wd,E.isQuiescent=Fc,E.isStoreHandle=Fr,E.isThemeNode=Bs,E.isUserComponentNode=$l,E.joinStatePath=Fs,E.keywordDocs=eo,E.knownPropNames=Qi,E.leaveUserComponent=va,E.lightTheme=Ie,E.linkProgram=bi,E.linkProject=xi,E.mapPositionalArgs=lr,E.matchRoute=la,E.matchRoutePrefix=ca,E.mergeLibraries=Si,E.namespaceCatalog=io,E.namespaceMembersAt=Sd,E.neonTheme=rl,E.normalisePath=ye,E.parse=Se,E.pastelTheme=nl,E.pathAffects=_s,E.pathsOverlap=Bt,E.planProgram=xa,E.propExpectsObject=Et,E.renderToStaticMarkup=bw,E.renderToString=Gl,E.resetMutableBindings=Cl,E.resetRuntimeBudget=ha,E.resolvePatternBindings=Wt,E.resolveSpecifier=nn,E.resolveStateAlias=Fe,E.resolveTheme=oa,E.routeMembers=vd,E.runControlFlowStatement=Sa,E.sanitiseThemeTokens=cl,E.skylineTheme=ol,E.slotForNthPositional=fn,E.storage=pa,E.tokenize=Ha,E.validateProgram=Yu,E.validateProgramSchema=bn,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}),E}({});
|
|
8905
8906
|
//# sourceMappingURL=aktion.iife.js.map
|