@lipsjs/lips 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +68 -1
  2. package/dist/lips.js +3532 -1094
  3. package/dist/lips.js.map +44 -19
  4. package/dist/lips.min.js +13 -9
  5. package/dist/lips.min.js.map +44 -19
  6. package/dist/lynx.min.js +51 -0
  7. package/dist/lynx.min.js.map +17 -0
  8. package/dist/mf2.min.js +4 -0
  9. package/dist/mf2.min.js.map +38 -0
  10. package/dist/precompile.min.js +19 -16
  11. package/dist/precompile.min.js.map +7 -6
  12. package/dist/runtime.min.js +4 -3
  13. package/dist/runtime.min.js.map +13 -12
  14. package/dist/stylis.min.js +3 -0
  15. package/dist/stylis.min.js.map +16 -0
  16. package/dist/types/i18n/engine.d.ts +14 -0
  17. package/dist/types/i18n/index.d.ts +122 -5
  18. package/dist/types/i18n/intl.d.ts +1 -0
  19. package/dist/types/i18n/lookup.d.ts +22 -0
  20. package/dist/types/ir/compiler.d.ts +75 -2
  21. package/dist/types/ir/expression.d.ts +32 -3
  22. package/dist/types/ir/facade.d.ts +74 -30
  23. package/dist/types/ir/host.d.ts +75 -0
  24. package/dist/types/ir/index.d.ts +5 -2
  25. package/dist/types/ir/policy.d.ts +95 -0
  26. package/dist/types/ir/runtime.d.ts +54 -19
  27. package/dist/types/ir/signal.d.ts +6 -4
  28. package/dist/types/ir/style.d.ts +119 -0
  29. package/dist/types/ir/swap.d.ts +5 -0
  30. package/dist/types/ir/tree.d.ts +51 -0
  31. package/dist/types/lips.d.ts +20 -3
  32. package/dist/types/lynx/a11y.d.ts +61 -0
  33. package/dist/types/lynx/background.d.ts +71 -0
  34. package/dist/types/lynx/main.d.ts +46 -0
  35. package/dist/types/lynx/protocol.d.ts +52 -0
  36. package/dist/types/lynx/style.d.ts +49 -0
  37. package/dist/types/lynx/template.d.ts +37 -0
  38. package/dist/types/lynx.d.ts +22 -0
  39. package/dist/types/mf2.d.ts +14 -0
  40. package/dist/types/precompile.d.ts +30 -5
  41. package/dist/types/runtime.d.ts +1 -1
  42. package/dist/types/stylesheet.d.ts +12 -16
  43. package/dist/types/stylis.d.ts +2 -0
  44. package/dist/types/types.d.ts +138 -11
  45. package/dist/types/untrusted.d.ts +17 -0
  46. package/dist/untrusted.min.js +5 -0
  47. package/dist/untrusted.min.js.map +13 -0
  48. package/package.json +25 -3
@@ -0,0 +1,51 @@
1
+ var At=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ot=new Set(["pre","textarea"]),et=new Set(["if","else-if","switch","log"]),_t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&nbsp;":" "};function U(t){return t.replace(/&(?:amp|lt|gt|quot|#39|nbsp);/g,(e)=>_t[e])}class rt{src;pos=0;lineStarts=null;diagnostics=[];constructor(t){this.src=t}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
2
+ `)this.lineStarts.push(r+1)}let e=0,i=this.lineStarts.length-1;while(e<i){let r=e+i+1>>1;this.lineStarts[r]<=t?e=r:i=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,i,r,n=1,s){let{line:l,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:i,hint:s,loc:{line:l,col:o,offset:r,length:n}})}eof(){return this.pos>=this.src.length}peek(t=0){return this.src[this.pos+t]}startsWith(t){return this.src.startsWith(t,this.pos)}skipSpace(){while(!this.eof()&&/\s/.test(this.src[this.pos]))this.pos++}scanBalanced(t,e){let i=this.pos,r=0;while(!this.eof()){let n=this.src[this.pos];if(n==="'"||n==='"'||n==="`"){this.pos++;while(!this.eof()&&this.src[this.pos]!==n){if(this.src[this.pos]==="\\")this.pos++;this.pos++}this.pos++;continue}if(r===0&&n===t){let s=this.src.slice(i,this.pos);return this.pos++,{content:s,loc:{offset:i,length:s.length}}}if(n==="("||n==="["||n==="{")r++;else if(n===")"||n==="]"||n==="}"){if(r===0&&n!==t){this.report(e,"error",`Unbalanced '${n}'`,this.pos),this.pos++;continue}r--}this.pos++}return this.report(e,"error",`Unterminated — expected '${t}'`,i,this.pos-i),null}parse(){let t=[];while(!this.eof())if(t.push(...this.parseNodes([])),this.startsWith("</")){let e=this.pos;this.pos+=2;while(!this.eof()&&this.peek()!==">")this.pos++;!this.eof()&&this.pos++,this.report("LIPS-P005","error",`Stray closing tag ${this.src.slice(e,this.pos)}`,e,this.pos-e)}return{root:{t:"fragment",children:t,loc:{offset:0,length:this.src.length}},diagnostics:this.diagnostics}}parseNodes(t){let e=[];while(!this.eof()){if(this.startsWith("</"))break;let i=this.pos;if(this.peek()==="<"&&this.peek(1)!==void 0){let r=this.parseTag(t);r&&e.push(r)}else{let r=this.parseText(t);r&&e.push(r)}if(this.pos===i)this.pos++}return e}parseText(t){let e=this.pos,i=[],r="";while(!this.eof()&&this.peek()!=="<"){if(this.peek()==="{"){this.pos++;let o=this.scanBalanced("}","LIPS-P007");if(o)r&&i.push(r),r="",i.push({expr:o.content.trim(),loc:o.loc});continue}r+=this.peek(),this.pos++}r&&i.push(r);let n={offset:e,length:this.pos-e};if(i.some((o)=>typeof o!=="string"))return{t:"interp",parts:i.map((o)=>typeof o==="string"?U(o):o),loc:n};let s=i.length?i[0]:"",l=t.some((o)=>Ot.has(o));if(!s||!l&&!s.trim())return null;return{t:"text",value:U(s),loc:n}}parseTag(t){let e=this.pos;if(this.startsWith("<!--")){let s=this.src.indexOf("-->",this.pos+4);if(s===-1)return this.report("LIPS-P003","error","Unterminated comment",e,this.src.length-e),this.pos=this.src.length,null;let l=this.src.slice(this.pos+4,s);return this.pos=s+3,{t:"comment",value:l,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<>")){this.pos+=2;let s=[];while(!0)if(s.push(...this.parseNodes([...t,"#fragment"])),this.closeStatus("#fragment",e,t)!=="stray")break;return{t:"fragment",children:s,loc:{offset:e,length:this.pos-e}}}if(this.startsWith("<{")){this.pos+=2;let s=this.scanBalanced("}","LIPS-P008");if(!s)return null;let l={t:"element",tag:"#dynamic",dynamicTag:{expr:s.content.trim(),loc:s.loc},attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};return this.finishTag(l,t,e),l}this.pos++;let i=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let r=this.src.slice(i,this.pos);if(!r||!/^[A-Za-z]/.test(r))return this.report("LIPS-P002","error","Invalid tag name",e,this.pos-e+1),{t:"text",value:"<",loc:{offset:e,length:1}};let n={t:"element",tag:r.toLowerCase(),attrs:[],children:[],selfClosed:!1,loc:{offset:e,length:0}};if(this.peek()==="(")if(et.has(n.tag)){this.pos++;let s=this.scanBalanced(")","LIPS-P012");s&&(n.head={expr:s.content.trim(),loc:s.loc})}else this.report("LIPS-P011","error",`Head expression is not allowed on <${n.tag}>`,this.pos,1,`Only ${[...et].map((s)=>`<${s}(…)>`).join(", ")} take a head`);return this.finishTag(n,t,e),n}finishTag(t,e,i){if(this.parseAttrs(t),t.selfClosed||At.has(t.tag)){t.selfClosed=!0,t.loc={offset:i,length:this.pos-i};return}let r=t.tag==="#dynamic"?"#dynamic":t.tag;t.children=[];while(!0)if(t.children.push(...this.parseNodes([...e,r])),this.closeStatus(r,i,e)!=="stray")break;t.loc={offset:i,length:this.pos-i}}closeStatus(t,e,i){if(this.eof())return this.report("LIPS-P006","error",`Unclosed <${t==="#fragment"?"":t}> — reached end of template`,e,1,`Add </${t==="#fragment"||t==="#dynamic"?"":t}>`),"eof";if(!this.startsWith("</"))return"closed";let r=this.pos;if(this.pos+=2,this.peek()===">"){if(this.pos++,t!=="#fragment"&&t!=="#dynamic")this.report("LIPS-P004","warning",`Generic '</>' closes <${t}>`,r,3,`Prefer </${t}>`);return"closed"}let n=this.pos;while(!this.eof()&&/[A-Za-z0-9_-]/.test(this.peek()))this.pos++;let s=this.src.slice(n,this.pos).toLowerCase();if(this.skipSpace(),this.peek()===">"?this.pos++:this.report("LIPS-P001","error","Malformed closing tag",r,this.pos-r),s===t)return"closed";if(i.includes(s))return this.report("LIPS-P004","warning",`</${s}> auto-closes <${t}>`,r,this.pos-r,`Add the missing </${t}> before </${s}>`),this.pos=r,"ancestor";return this.report("LIPS-P005","error",`Stray closing tag </${s}> — <${t}> is open`,r,this.pos-r),"stray"}parseAttrs(t){while(!0){if(this.skipSpace(),this.eof()){this.report("LIPS-P001","error","Unexpected end of template inside tag",t.loc.offset);return}if(this.startsWith("/>")){this.pos+=2,t.selfClosed=!0;return}if(this.peek()===">"){this.pos++;return}let e=this.pos;if(this.startsWith("...")){this.pos+=3;let s=this.readUnquotedValue();t.attrs.push({k:"spread",source:s,loc:{offset:e,length:this.pos-e}});continue}if(this.peek()==="["){this.pos++;let s=this.scanBalanced("]","LIPS-P009");if(s){let l=s.content.split(",").map((o)=>o.trim()).filter(Boolean);t.attrs.push({k:"args",names:l,loc:{offset:e,length:this.pos-e}})}continue}let i=!1;if(this.peek()==="!")i=!0,this.pos++;let r=this.pos;while(!this.eof()&&/[^\s=/>()]/.test(this.peek()))this.pos++;let n=this.src.slice(r,this.pos);if(!n){this.report("LIPS-P009","error",`Invalid attribute syntax at '${this.peek()}'`,this.pos),this.pos++;continue}if(this.peek()==="("){this.pos++;let s=this.scanBalanced(")","LIPS-P010"),l=s?s.content.trim():"",o={offset:e,length:this.pos-e};n.startsWith("on-")?t.attrs.push({k:"event",name:n.slice(3),source:l,loc:o}):t.attrs.push({k:"fn",name:n,source:l,loc:o});continue}if(this.peek()==="="){this.pos++,this.parseAttrValue(t,n,e);continue}t.attrs.push({k:"bool",name:n,value:!i,loc:{offset:e,length:this.pos-e}})}}parseAttrValue(t,e,i){let r=this.peek();if(r==='"'||r==="'"){this.pos++;let s=this.pos,l=[],o="";while(!this.eof()&&this.peek()!==r){if(this.peek()==="{"){this.pos++;let c=this.scanBalanced("}","LIPS-P007");if(c)o&&l.push(o),o="",l.push({expr:c.content.trim(),loc:c.loc});continue}o+=this.peek(),this.pos++}o&&l.push(o),this.eof()?this.report("LIPS-P010","error",`Unterminated value for '${e}'`,s,this.pos-s):this.pos++;let a={offset:i,length:this.pos-i};l.some((c)=>typeof c!=="string")?t.attrs.push({k:"interp",name:e,parts:l.map((c)=>typeof c==="string"?U(c):c),loc:a}):t.attrs.push({k:"literal",name:e,value:U(l[0]??""),loc:a});return}if(r==="{"){this.pos++;let s=this.scanBalanced("}","LIPS-P007");t.attrs.push({k:"expr",name:e,source:s?s.content.trim():"",loc:{offset:i,length:this.pos-i}});return}let n=this.readUnquotedValue();n?t.attrs.push({k:"expr",name:e,source:n,loc:{offset:i,length:this.pos-i}}):this.report("LIPS-P010","error",`Missing value for attribute '${e}'`,i)}readUnquotedValue(){let t=this.pos,e=0;while(!this.eof()){let i=this.peek();if(i==="'"||i==='"'||i==="`"){this.pos++;while(!this.eof()&&this.peek()!==i){if(this.peek()==="\\")this.pos++;this.pos++}this.pos++;continue}if(e===0){if(/\s/.test(i)||i===">")break;if(i==="/"&&this.peek(1)===">")break}if(i==="("||i==="["||i==="{")e++;else if(i===")"||i==="]"||i==="}")e--;this.pos++}return this.src.slice(t,this.pos).trim()}}function H(t){return new rt(t||"").parse()}var jt=["===","!==","...","=>","==","!=","<=",">=","&&","||","??","?.","++","--","+=","-=","*=","/=","%=","+","-","*","/","%","<",">","!","?",":",".",",","(",")","[","]","{","}","="];function Bt(t,e){let i=[],r=0,n=(l)=>/[A-Za-z_$]/.test(l),s=(l)=>/[A-Za-z0-9_$]/.test(l);while(r<t.length){let l=t[r];if(/\s/.test(l)){r++;continue}if(/[0-9]/.test(l)||l==="."&&/[0-9]/.test(t[r+1])){let a=r;while(r<t.length&&/[0-9]/.test(t[r]))r++;if(t[r]==="."){r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}if(t[r]==="e"||t[r]==="E"){if(r++,t[r]==="+"||t[r]==="-")r++;while(r<t.length&&/[0-9]/.test(t[r]))r++}i.push({t:"num",value:t.slice(a,r),start:a,end:r});continue}if(l==="'"||l==='"'){let a=r;r++;let c="",u=!1;while(r<t.length){let x=t[r];if(x==="\\"){let E=t[r+1],S={n:`
3
+ `,t:"\t",r:"\r",b:"\b",f:"\f",v:"\v","0":"\x00"};if(E==="u"){let y=t.slice(r+2,r+6);c+=String.fromCharCode(parseInt(y,16)||0),r+=6}else c+=S[E]??E,r+=2;continue}if(x===l){u=!0,r++;break}c+=x,r++}if(!u)e.push({code:"LIPS-E001",message:"Unterminated string literal",loc:{offset:a,length:r-a}});i.push({t:"str",value:c,start:a,end:r});continue}if(n(l)){let a=r;while(r<t.length&&s(t[r]))r++;i.push({t:"id",value:t.slice(a,r),start:a,end:r});continue}let o=jt.find((a)=>t.startsWith(a,r));if(o==="?."&&/[0-9]/.test(t[r+2]??""))o="?";if(o){i.push({t:"punct",value:o,start:r,end:r+o.length}),r+=o.length;continue}e.push({code:"LIPS-E002",message:`Unexpected character '${l}'`,loc:{offset:r,length:1}}),r++}return i.push({t:"eof",value:"",start:t.length,end:t.length}),i}class it{tokens;diagnostics;pos=0;constructor(t,e){this.tokens=t;this.diagnostics=e}peek(t=0){return this.tokens[Math.min(this.pos+t,this.tokens.length-1)]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}at(t){let e=this.peek();return e.t==="punct"&&e.value===t}eat(t){if(this.at(t))return this.pos++,!0;return!1}error(t,e,i=this.peek()){return this.diagnostics.push({code:t,message:e,loc:{offset:i.start,length:Math.max(1,i.end-i.start)}}),{t:"error"}}expect(t,e){if(!this.eat(t))this.error(e,`Expected '${t}'`)}parse(){let t=this.assign();if(this.peek().t!=="eof")this.error("LIPS-E003",`Unexpected token '${this.peek().value}' after expression`);return t}isArrowAhead(){let t=this.peek();if(t.t==="id"){let e=this.peek(1);return e.t==="punct"&&e.value==="=>"}if(t.t==="punct"&&t.value==="("){let e=0,i=0;while(!0){let r=this.peek(i);if(r.t==="eof")return!1;if(r.t==="punct"&&r.value==="(")e++;if(r.t==="punct"&&r.value===")"){if(e--,e===0){let n=this.peek(i+1);return n.t==="punct"&&n.value==="=>"}}i++}}return!1}assign(){if(this.isArrowAhead()){let i=[];if(this.peek().t==="id")i.push(this.next().value);else{this.expect("(","LIPS-E004");while(!this.at(")")&&this.peek().t!=="eof"){let r=this.next();if(r.t!=="id")return this.error("LIPS-E005","Invalid arrow parameter",r);if(i.push(r.value),!this.eat(","))break}this.expect(")","LIPS-E004")}return this.expect("=>","LIPS-E004"),{t:"arrow",params:i,body:this.assign()}}let t=this.conditional(),e=this.peek();if(e.t==="punct"&&["=","+=","-=","*=","/=","%="].includes(e.value)){if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid assignment target",e);return this.next(),{t:"assign",op:e.value,target:t,value:this.assign()}}return t}conditional(){let t=this.nullish();if(this.eat("?")){let e=this.assign();return this.expect(":","LIPS-E007"),{t:"cond",test:t,cons:e,alt:this.assign()}}return t}nullish(){let t=this.or();while(this.at("??"))this.next(),t={t:"logic",op:"??",l:t,r:this.or()};return t}or(){let t=this.and();while(this.at("||"))this.next(),t={t:"logic",op:"||",l:t,r:this.and()};return t}and(){let t=this.equality();while(this.at("&&"))this.next(),t={t:"logic",op:"&&",l:t,r:this.equality()};return t}equality(){let t=this.relational();while(["===","!==","==","!="].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.relational()};return t}relational(){let t=this.additive();while(["<=",">=","<",">"].some((e)=>this.at(e)))t={t:"bin",op:this.next().value,l:t,r:this.additive()};return t}additive(){let t=this.multiplicative();while(this.at("+")||this.at("-"))t={t:"bin",op:this.next().value,l:t,r:this.multiplicative()};return t}multiplicative(){let t=this.unary();while(this.at("*")||this.at("/")||this.at("%"))t={t:"bin",op:this.next().value,l:t,r:this.unary()};return t}unary(){if(this.at("!")||this.at("-")||this.at("+"))return{t:"unary",op:this.next().value,arg:this.unary()};if(this.at("++")||this.at("--")){let t=this.next().value,e=this.unary();if(e.t!=="id"&&e.t!=="member")return this.error("LIPS-E006","Invalid update target");return{t:"update",op:t,arg:e,prefix:!0}}return this.postfix()}postfix(){let t=this.callMember();if(this.at("++")||this.at("--")){let e=this.next().value;if(t.t!=="id"&&t.t!=="member")return this.error("LIPS-E006","Invalid update target");t={t:"update",op:e,arg:t,prefix:!1}}return t}callMember(){let t=this.primary();while(!0)if(this.eat(".")){let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!1,at:e.start}}else if(this.eat("?."))if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!0};else if(this.eat("[")){let e=this.peek().start,i=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:i,computed:!0,optional:!0,at:e}}else{let e=this.next();if(e.t!=="id")return this.error("LIPS-E008","Expected property name",e);t={t:"member",obj:t,prop:e.value,computed:!1,optional:!0,at:e.start}}else if(this.eat("[")){let e=this.peek().start,i=this.assign();this.expect("]","LIPS-E009"),t={t:"member",obj:t,prop:i,computed:!0,optional:!1,at:e}}else if(this.at("("))t={t:"call",callee:t,args:this.argList(),optional:!1};else break;return t}argList(){this.expect("(","LIPS-E010");let t=[];while(!this.at(")")&&this.peek().t!=="eof")if(t.push(this.assign()),!this.eat(","))break;return this.expect(")","LIPS-E010"),t}primary(){let t=this.peek();if(t.t==="num")return this.next(),{t:"lit",v:parseFloat(t.value)};if(t.t==="str")return this.next(),{t:"lit",v:t.value};if(t.t==="id")switch(this.next(),t.value){case"true":return{t:"lit",v:!0};case"false":return{t:"lit",v:!1};case"null":return{t:"lit",v:null};case"undefined":return{t:"lit",v:void 0};case"NaN":return{t:"lit",v:NaN};case"Infinity":return{t:"lit",v:1/0};default:return{t:"id",name:t.value,at:t.start}}if(this.eat("(")){let e=this.assign();return this.expect(")","LIPS-E010"),e}if(this.eat("[")){let e=[];while(!this.at("]")&&this.peek().t!=="eof"){let i=this.eat("...");if(e.push({spread:i||void 0,value:this.assign()}),!this.eat(","))break}return this.expect("]","LIPS-E009"),{t:"arr",items:e}}if(this.eat("{")){let e=[];while(!this.at("}")&&this.peek().t!=="eof"){if(this.eat("..."))e.push({spread:!0,value:this.assign()});else{let i=this.next();if(i.t!=="id"&&i.t!=="str"&&i.t!=="num")return this.error("LIPS-E011","Invalid object key",i);if(this.eat(":"))e.push({key:String(i.value),value:this.assign(),at:i.start});else if(i.t==="id")e.push({key:i.value,value:{t:"id",name:i.value,at:i.start},at:i.start});else return this.error("LIPS-E011","Invalid shorthand property",i)}if(!this.eat(","))break}return this.expect("}","LIPS-E011"),{t:"obj",props:e}}return this.next(),this.error("LIPS-E012",t.t==="eof"?"Unexpected end of expression":`Unexpected token '${t.value}'`,t)}}function D(t){let e=[],i=Bt(t,e);return{ast:new it(i,e).parse(),diagnostics:e}}function nt(t){let e=new Set,i=(r,n)=>{switch(r.t){case"id":!n.has(r.name)&&e.add(r.name);return;case"member":i(r.obj,n),typeof r.prop!=="string"&&i(r.prop,n);return;case"call":i(r.callee,n),r.args.forEach((s)=>i(s,n));return;case"unary":case"update":i(r.arg,n);return;case"bin":case"logic":i(r.l,n),i(r.r,n);return;case"cond":i(r.test,n),i(r.cons,n),i(r.alt,n);return;case"assign":i(r.target,n),i(r.value,n);return;case"arrow":i(r.body,new Set([...n,...r.params]));return;case"arr":r.items.forEach((s)=>i(s.value,n));return;case"obj":r.props.forEach((s)=>i(s.value,n));return}};return i(t,new Set),[...e]}var Dt="<!--$-->",Mt=new Set(["if","else-if","else","for","switch","async","let","const","log","context","i18n"]),qt=new Set(["case","default","then","catch","loading"]),V=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","marker","mask","path","pattern","polygon","polyline","radialgradient","rect","stop","symbol","text","tspan","use"]),Wt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ut=(t)=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Vt=(t)=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),st=(t)=>t!==""&&!isNaN(Number(t)),ot=(t)=>{let e=t.trim(),i=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="'"||n==='"'||n==="`"){r++;while(r<e.length&&e[r]!==n){if(e[r]==="\\")r++;r++}continue}if(n==="("||n==="["||n==="{")i++;else if(n===")"||n==="]"||n==="}"){if(i--,i===0&&e[0]==="{"&&r===e.length-1)return ot(e.slice(1,-1))}else if(i===0){if(n==="?")return!1;if(n===":")return!0}}return!1},zt=(t)=>{if(t.k==="expr")return t.source;if(t.k!=="interp")return"";let e=t.parts.filter((i)=>typeof i!=="string");return e.length===1&&t.parts.every((i)=>typeof i!=="string"||!i.trim())?e[0].expr:""};class at{src;macros;tree;exprs=[];exprIndex=new Map;lineStarts=null;macroStack=[];diagnostics=[];constructor(t,e=new Map,i=!1){this.src=t;this.macros=e;this.tree=i}locate(t){if(!this.lineStarts){this.lineStarts=[0];for(let r=0;r<this.src.length;r++)if(this.src[r]===`
4
+ `)this.lineStarts.push(r+1)}let e=0,i=this.lineStarts.length-1;while(e<i){let r=e+i+1>>1;this.lineStarts[r]<=t?e=r:i=r-1}return{line:e+1,col:t-this.lineStarts[e]+1}}report(t,e,i,r,n=1,s){let{line:l,col:o}=this.locate(r);this.diagnostics.push({code:t,severity:e,message:i,hint:s,loc:{line:l,col:o,offset:r,length:n}})}expr(t,e){let i=this.exprIndex.get(t);if(i!==void 0)return i;let{diagnostics:r}=D(t);for(let s of r){let l=(e?.offset??0)+s.loc.offset;this.report(s.code,"error",s.message,l,s.loc.length)}let n=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,n),n}synth(t){let e=this.exprIndex.get(t);if(e!==void 0)return e;let i=this.exprs.length;return this.exprs.push(t),this.exprIndex.set(t,i),i}concat(t){t.filter((i)=>typeof i!=="string").forEach((i)=>{let{diagnostics:r}=D(i.expr);for(let n of r)this.report(n.code,"error",n.message,i.loc.offset+n.loc.offset,n.loc.length)});let e=t.map((i)=>typeof i==="string"?JSON.stringify(i):`((${i.expr})??"")`).join("+");return this.synth(e)}compInput(t){switch(t.k){case"literal":return{lit:t.value};case"bool":return{lit:t.value};case"expr":return{e:this.expr(t.source,t.loc)};case"interp":return{e:this.concat(t.parts)}}}compile(t){return{v:1,exprs:this.exprs,root:this.block(t,[])}}block(t,e){let i={html:"",scope:[...e],binds:[],blocks:[]},r=[],n=this.tree,s=[],l=(o,a,c,u=!1,x)=>{let E=0,S=!1,y=()=>(r.push(Dt),n&&c.push(0),S=!1,[...a,E++]);for(let I=0;I<o.length;I++){let d=o[I];switch(d.t){case"text":{if(u){let b={t:"text",p:y(),e:this.synth(JSON.stringify(d.value)),i18n:1};if(x)b.ik=x;i.binds.push(b);break}if(r.push(Ut(d.value)),n&&(S?c[c.length-1]+=d.value:c.push(d.value)),!S)E++;S=!0;break}case"comment":{if(n)break;let b=d.value.replace(/--/g,"- -");r.push(`<!--${/^-?>/.test(b)?" "+b:b}-->`),S=!1,E++;break}case"interp":{let b={t:"text",p:y(),e:this.concat(d.parts)};if(u)b.i18n=1;if(u&&x)b.ik=x;i.binds.push(b);break}case"fragment":{o=[...o.slice(0,I),...d.children,...o.slice(I+1)],I--;break}case"element":{if(Mt.has(d.tag)){if(this.controlBlock(d,o,I,y(),i,e),d.tag==="if"){let b=I+1;while(b<o.length){let R=o[b];if(R.t==="element"&&(R.tag==="else-if"||R.tag==="else"))b++;else break}o=[...o.slice(0,I+1),...o.slice(b)]}break}if(qt.has(d.tag)){this.report("LIPS-C002","error",`<${d.tag}> is only valid inside its parent construct`,d.loc.offset,d.loc.length);break}if(d.tag==="#dynamic"){i.blocks.push(this.compLike(d,y(),e,"dynamic"));break}if(this.macros.has(d.tag)){let b=this.macroCall(d,y(),e);b&&i.blocks.push(b);break}if(!V.has(d.tag)){i.blocks.push(this.compLike(d,y(),e,"comp"));break}this.emitElement(d,a,E++,r,i,l,c),S=!1;break}}}};if(l(t,[],s),i.html=r.join(""),n)i.nodes=s;return i}emitElement(t,e,i,r,n,s,l){let o=[...e,i],a=`<${t.tag}`,c=[t.tag],u={},x=(p,m)=>{Object.prototype.hasOwnProperty.call(u,p)||(u[p]=m)};this.tree&&l.push(c);let E=t.attrs.filter((p)=>("name"in p)),S=E.some((p)=>p.name==="i18n"&&(p.k==="bool"&&p.value||p.k==="literal")),y=(p)=>S&&(p==="title"||p==="placeholder"),I=(p)=>{let m=E.find((L)=>L.name===p&&L.k==="literal");return m&&"value"in m&&m.value?String(m.value):void 0},d=I("i18n"),b=(p)=>I(`i18n-${p}`);!S&&E.some((p)=>p.name.startsWith("i18n-"))&&this.report("LIPS-C014","warning",`i18n-* key on <${t.tag}> without the 'i18n' marker — the attribute will not be translated`,t.loc.offset,t.loc.length);for(let p of t.attrs){if(this.tree&&"name"in p&&p.name==="@html"){this.report("LIPS-C021","error",`@html on <${t.tag}>: the 'tree' target has no HTML parser`,p.loc.offset,p.loc.length,"Write the markup in the template, or use @text");continue}if("name"in p&&p.name==="style"){let m=zt(p);if(m&&ot(m)){this.report("LIPS-C019","error",`style= on <${t.tag}> takes CSS text, not an object literal`,p.loc.offset,p.loc.length,'Write the declarations as CSS — style="border: 2px solid gray; margin: 3rem" — '+`and interpolate values into it where they vary: style="margin: {state.gap}rem". Styles that need pseudo-classes, media queries or keyframes belong in the component's stylesheet.`);continue}}if(this.quotedEvent(t.tag,p))continue;switch(p.k){case"literal":if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.synth(JSON.stringify(p.value))});break}if(p.name==="i18n"||p.name.startsWith("i18n-"))break;if(y(p.name)){let m={t:"attr",p:o,name:p.name,e:this.synth(JSON.stringify(p.value)),i18n:1},L=b(p.name);if(L)m.ik=L;n.binds.push(m);break}a+=` ${p.name}="${Vt(p.value)}"`,x(p.name,p.value);break;case"bool":if(p.name!=="i18n"&&p.value)a+=` ${p.name}`,x(p.name,"");break;case"expr":{if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.expr(p.source,p.loc)});break}let m={t:"attr",p:o,name:p.name,e:this.expr(p.source,p.loc)};if(y(p.name)){m.i18n=1;let L=b(p.name);if(L)m.ik=L}n.binds.push(m);break}case"interp":{if(p.name==="@format"){n.binds.push(this.formatBind(o,p));break}if(p.name.startsWith("@")){n.binds.push({t:"prop",p:o,name:p.name.slice(1),e:this.concat(p.parts)});break}let m={t:"attr",p:o,name:p.name,e:this.concat(p.parts)};if(y(p.name)){m.i18n=1;let L=b(p.name);if(L)m.ik=L}n.binds.push(m);break}case"event":n.binds.push({t:"event",p:o,name:p.name,e:this.synth(p.source)});break;case"spread":n.binds.push({t:"spread",p:o,e:this.expr(p.source,p.loc)});break;case"fn":this.report("LIPS-C007","warning",`Callable attribute '${p.name}(…)' has no meaning on <${t.tag}>`,p.loc.offset,p.loc.length);break;case"args":this.report("LIPS-C008","warning",`Iterator arguments are not applicable to <${t.tag}>`,p.loc.offset,p.loc.length);break}}if(Object.keys(u).length&&(c[1]=u),Wt.has(t.tag)){r.push(a+">");return}r.push(a+">");let N=d,q=t.children.filter((p)=>p.t==="text"||p.t==="interp");if(N&&(q.length>1||q.some((p)=>p.t==="interp")))this.report("LIPS-C015","error",`<${t.tag} i18n="${N}"> keys text that is not a single fixed string. Use @format="${N}, { … }" for interpolated text.`,t.loc.offset,t.loc.length),N=void 0;let f=[];if(t.children.length&&s(t.children,o,f,S,N),f.length)c[1]=u,c[2]=f;r.push(`</${t.tag}>`)}formatBind(t,e){let i=e.k==="literal"?e.value:e.k==="expr"?e.source:e.parts.map((l)=>typeof l==="string"?l:`{${l.expr}}`).join(""),r=i.indexOf(",");if(r===-1)return this.report("LIPS-C012","error",'@format expects "reference, { params }"',e.loc.offset,e.loc.length),{t:"prop",p:t,name:"format",e:this.synth("({})"),ref:i.trim()};let n=i.slice(0,r).trim(),s=i.slice(r+1).trim();return{t:"prop",p:t,name:"format",e:this.expr(s,e.loc),ref:n}}attrsOf(t){let e=new Map,i=[];for(let r of t.attrs)if(r.k==="args")i.push(...r.names);else if("name"in r)e.set(r.name,r);return{byName:e,args:i}}controlBlock(t,e,i,r,n,s){switch(t.tag){case"if":{let l=[{when:t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),block:this.block(t.children,s)}];for(let o=i+1;o<e.length;o++){let a=e[o];if(a.t!=="element")break;if(a.tag==="else-if")l.push({when:a.head?this.expr(a.head.expr,a.head.loc):this.missingHead(a),block:this.block(a.children,s)});else if(a.tag==="else"){l.push({when:null,block:this.block(a.children,s)});break}else break}n.blocks.push({t:"if",p:r,branches:l});break}case"else-if":case"else":this.report("LIPS-C001","error",`<${t.tag}> without a preceding <if>`,t.loc.offset,t.loc.length);break;case"for":{let{byName:l,args:o}=this.attrsOf(t),a=l.get("in"),c=l.get("from"),u=l.get("to"),x=l.get("by");if(!a&&!c){this.report("LIPS-C004","error","<for> requires 'in' or 'from'/'to'",t.loc.offset,t.loc.length);break}let E={t:"for",p:r,args:o,block:this.block(t.children,[...s,...o])};if(a&&a.k==="expr")E.of=this.expr(a.source,a.loc);if(c)E.from=this.numInput(c);if(u)E.to=this.numInput(u);if(x&&(x.k==="literal"||x.k==="expr"))E.by=x.k==="literal"?{lit:x.value}:{e:this.expr(x.source,x.loc)};n.blocks.push(E);break}case"switch":{let l=t.head?this.expr(t.head.expr,t.head.loc):this.missingHead(t),o=[];for(let a of t.children){if(a.t!=="element")continue;if(a.tag==="case"){let{byName:c}=this.attrsOf(a),u=c.get("is");if(!u||u.k!=="literal"&&u.k!=="expr"){this.report("LIPS-C004","error","<case> requires an 'is' attribute",a.loc.offset,a.loc.length);continue}o.push({is:u.k==="literal"?{lit:u.value}:{e:this.expr(u.source,u.loc)},block:this.block(a.children,s)})}else if(a.tag==="default")o.push({is:null,block:this.block(a.children,s)});else this.report("LIPS-C003","error","Only <case>/<default> are valid inside <switch>",a.loc.offset,a.loc.length)}n.blocks.push({t:"switch",p:r,on:l,cases:o});break}case"async":{let l=t.attrs.find((a)=>a.k==="fn"&&a.name==="await");if(!l){this.report("LIPS-C004","error","<async> requires await(…)",t.loc.offset,t.loc.length);break}let o={t:"async",p:r,awaitE:this.expr(l.source,l.loc)};for(let a of t.children){if(a.t!=="element")continue;let{args:c}=this.attrsOf(a);if(a.tag==="then")o.then={args:c,block:this.block(a.children,[...s,...c])};else if(a.tag==="catch")o.catch={args:c,block:this.block(a.children,[...s,...c])};else if(a.tag==="loading")o.loading=this.block(a.children,s);else this.report("LIPS-C003","error","Only <then>/<catch>/<loading> are valid inside <async>",a.loc.offset,a.loc.length)}n.blocks.push(o);break}case"let":case"const":{let l={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C013","error",`Spread is not supported on <${t.tag}> — scope names must be known at compile time`,o.loc.offset,o.loc.length,`Assign it to one variable: <${t.tag} obj={ ${o.source} }/> and read obj.<key>`);continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")l[o.name]=this.compInput(o),!n.scope.includes(o.name)&&n.scope.push(o.name),!s.includes(o.name)&&s.push(o.name)}n.blocks.push({t:"let",p:r,const:t.tag==="const",vars:l});break}case"log":n.blocks.push({t:"log",p:r,e:t.head?this.synth(t.head.expr):this.missingHead(t)});break;case"context":{let l={};for(let o of t.attrs){if(o.k==="spread"){this.report("LIPS-C016","error","Spread is not supported on <context> — provided keys must be known at compile time",o.loc.offset,o.loc.length,"Provide them one by one: <context a=obj.a b=obj.b>");continue}if(o.k==="literal"||o.k==="expr"||o.k==="interp"||o.k==="bool")l[o.name]=this.compInput(o)}if(!Object.keys(l).length)this.report("LIPS-C017","warning","<context> provides nothing — it renders its children unchanged",t.loc.offset,t.loc.length);n.blocks.push({t:"provide",p:r,vars:l,block:this.block(t.children,s)});break}case"i18n":{let{byName:l}=this.attrsOf(t),o=l.get("lang");if(!o){this.report("LIPS-C018","error","<i18n> requires a 'lang' attribute: <i18n lang=state.docLang>",t.loc.offset,t.loc.length);break}n.blocks.push({t:"provide",p:r,vars:{},lang:this.compInput(o),block:this.block(t.children,s)});break}}}missingHead(t){return this.report("LIPS-C004","error",`<${t.tag}> requires a head expression: <${t.tag}( … )>`,t.loc.offset,t.loc.length),this.synth("undefined")}numInput(t){if(t.k==="literal")return{lit:st(t.value)?Number(t.value):t.value};if(t.k==="expr")return st(t.source)?{lit:Number(t.source)}:{e:this.expr(t.source,t.loc)};return{lit:void 0}}macroCall(t,e,i){let r=this.macros.get(t.tag);if(this.macroStack.includes(r.name))return this.report("LIPS-C009","error",`Recursive macro <${r.name}> (${[...this.macroStack,r.name].join(" → ")})`,t.loc.offset,t.loc.length),null;let n=[];for(let l of t.attrs)if(l.k==="literal"||l.k==="expr"||l.k==="interp"||l.k==="bool")n.push({name:l.name,ci:this.compInput(l)});else if(l.k==="spread")n.push({spread:this.expr(l.source,l.loc)});this.macroStack.push(r.name);let s=this.block(r.children,[...i,...r.argv]);return this.macroStack.pop(),{t:"macro",p:e,name:r.name,sets:n,args:r.argv,block:s}}quotedEvent(t,e){if(!("name"in e)||!e.name.startsWith("on-"))return!1;return this.report("LIPS-C020","error",`${e.name}="…" on <${t}> wires no listener`,e.loc.offset,e.loc.length,`Handlers use the instruction form: ${e.name}( … ). `+"Quoted, it is an ordinary attribute — the handler never runs and the source is emitted into the DOM."),!0}compLike(t,e,i,r){let n={},s=[],l=[],o=[];for(let c of t.attrs){if(c.k!=="event"&&this.quotedEvent(t.tag,c))continue;switch(c.k){case"literal":case"bool":case"expr":case"interp":n[c.name]=this.compInput(c);break;case"event":l.push({name:c.name,e:this.synth(c.source)});break;case"spread":s.push(this.expr(c.source,c.loc));break;case"args":o=[...o,...c.names];break;case"fn":n[c.name]={e:this.expr(c.source,c.loc)};break}}let a=t.children.length?{args:o,block:this.block(t.children,[...i,...o])}:void 0;return r==="comp"?{t:"comp",p:e,name:t.tag,inputs:n,spreads:s,events:l,contents:a}:{t:"dynamic",p:e,tag:this.expr(t.dynamicTag.expr,t.dynamicTag.loc),inputs:n,spreads:s,events:l,contents:a}}}function Gt(t,e,i){let r=new Map;if(!t?.trim())return r;let n=H(t);e.push(...n.diagnostics),i?.(n.root.children,e,t);for(let s of n.root.children){if(s.t!=="element")continue;if(s.tag!=="macro"){e.push({code:"LIPS-C010",severity:"warning",message:`Only <macro> definitions are allowed in the macros source — ignoring <${s.tag}>`,loc:{line:1,col:1,offset:s.loc.offset,length:s.loc.length}});continue}let l="",o=[];for(let a of s.attrs)if(a.k==="args")o.push(...a.names);else if(a.k==="literal"&&a.name==="name")l=a.value;if(!l){e.push({code:"LIPS-C011",severity:"error",message:"<macro> requires a name attribute",loc:{line:1,col:1,offset:s.loc.offset,length:s.loc.length}});continue}r.set(l.toLowerCase(),{name:l,argv:o,children:s.children})}return r}function lt(t,e){let i=[],r=Gt(e?.macros||"",i,e?.check),n=H(t);e?.check?.(n.root.children,i,t),e?.transform?.(n.root.children,i);let s=new at(t,r,e?.target==="tree");return{ir:s.compile(n.root.children),diagnostics:[...i,...n.diagnostics,...s.diagnostics]}}var Ft=null;var Ht=/^[-\w]+$/,ft=/^(%|[a-zA-Z]+)/,ct=["<number>","0"];function z(t,e){let i=t[e];e++;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===i)return e+1;e++}return e}function gt(t,e){let i=t.indexOf("*/",e+2);return i<0?t.length:i+2}function Yt(t,e){let i=t.indexOf(`
5
+ `,e+2);return i<0?t.length:i}var Zt=(t)=>t.replace(/["\\]/g,"\\$&");function j(t,e,i){let r=1,n=-1;for(let s=0;s<e;s++)if(t[s]===`
6
+ `)r++,n=s;return{line:r,col:e-n,offset:e,length:i}}function Y(t,e){let i=e+1,r=0,n=!1,s=!1;while(i<t.length){let o=t[i];if(o==='"'||o==="'"){i=z(t,i);continue}if(o==="{"||o===";")return null;if(o==="}")break;if(o==="("||o==="[")r++;else if(o===")"||o==="]")r--;else if(r===0){if(o==="?")n=!0;else if(o===":"&&!n)s=!0}i++}if(i>=t.length||s)return null;let l=t.slice(e+1,i).trim();return l?{end:i,expr:l}:null}var Xt=new Set(["state","input","static","context","self"]);function Kt(t,e,i,r){let n=[],s=e,l=e,o=0;while(s<t.length){let a=t[s];if(a==='"'||a==="'"){s=z(t,s);continue}if(a==="/"&&t[s+1]==="*"){let c=gt(t,s);if(!i)n.push(t.slice(l,s)," "),l=c;s=c;continue}if(a==="("){o++,s++;continue}if(a===")"){o--,s++;continue}if(o===0&&(a===";"||a==="}"))return n.push(t.slice(l,s)),{end:s,parts:n};if(a==="{"){let c=Y(t,s);if(!c)return t.indexOf("}",s+1)<0&&r?.(s),null;n.push(t.slice(l,s));let u=ft.exec(t.slice(c.end+1)),x=u?u[1]:"";n.push({expr:c.expr,unit:x,at:s}),s=c.end+1+x.length,l=s;continue}s++}return n.some((a)=>typeof a!=="string")&&r?.(e),null}var Jt=/^@(-\w+-)?(keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition|position-try|color-profile|function)\b/i,pt=/^@(import|charset|namespace)\b/i,Qt=/^@(media|supports|container|layer|scope|starting-style|document)\b/i,te=/^([a-zA-Z_*\\]|[^\x00-\x7f])/,ee=/^(?:[-\w*|]|[^\x00-\x7f]|\\[\s\S])+/,re=/&[-_]/,mt=/\s/,ht=/[{};]/,ut=/[-\w]/,dt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,ie=new RegExp(`(${dt.source})|\\s+`,"g"),ne=/\/\*[\s\S]*?\*\//g,se=/^@layer\b/i,oe=(t)=>t.replace(ie,(e,i)=>i||" ");function ae(t){let e=[],i=0,r=0;for(let n=0;n<t.length;n++){let s=t[n];if(s==="\\"){n++;continue}if(s==='"'||s==="'"){n=z(t,n)-1;continue}if(s==="("||s==="[")r++;else if(s===")"||s==="]")r--;else if(s===","&&!r)e.push(t.slice(i,n)),i=n+1}return e.push(t.slice(i)),e.map((n)=>{let s=n.trimStart(),l=s.length;while(l&&mt.test(s[l-1])&&s[l-2]!=="\\")l--;if(s=s.slice(0,l),!te.test(s))return s;return s.includes("&")?s.replace(ee,":is($&)"):`& ${s}`}).join(",")}function le(t,e,i,r){let n=[],s=[],l=[],o=`--${e.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}`,a=(h,v,g,k,w)=>r.push({code:h,severity:"error",message:v,hint:w,loc:j(t,g,k)}),c=(h,v,g,k,w)=>r.push({code:h,severity:"warning",message:v,hint:w,loc:j(t,g,k)}),u=(h,v,g,k)=>e.lint?.(h,k)?.forEach((w)=>r.push({...w,loc:j(t,v,g-v)})),x=(h)=>{let v=n.indexOf(h);if(v<0)v=n.push(h)-1;return v},E=(h)=>{let{ast:v,diagnostics:g}=D(h.expr),k=h.expr.length+2;if(g.length){a("LIPS-S004",`Invalid expression: ${g[0].message}`,h.at,k);return}for(let w of nt(v))if(!Xt.has(w)&&!(w in globalThis))a("LIPS-S003",`'${w}' is not readable from a stylesheet`,h.at,k,"Stylesheets see state, input, static, context and self — not <for> iterators or <let> names, "+"which are local to a template position.");h.unit&&v.t==="lit"&&typeof v.v==="string"&&c("LIPS-S005",`Unit '${h.unit}' after a string value`,h.at,k,`A unit suffix multiplies a number: drop the unit, or return ${h.unit==="%"?"50":"8"} instead of a string.`)},S="",y="",I="",d=!1,b=(h)=>{if(!h)return;if(d&&I&&!ht.test(I)&&!ht.test(h[0]))y+=" ";d=!1,y+=h,I=h[h.length-1]},R=(h)=>{S+=y+h,y="",I=h,d=!1},N=()=>{let h=y;return y=I="",d=!1,h},q=(h)=>":"+(oe(h).trim()||" "),f=0,p=0,m=0,L="",B="",K="",J=!1,C=[{ctx:e.meta?"top":"style"}],Ct=()=>{let h=C[C.length-1],v=y,g;if(h.ctx==="opaque"||u(v,m,f),v[0]==="@")if(h.ctx!=="opaque"&&Jt.test(v))g={ctx:"opaque",hoist:S.length};else if(Qt.test(v))g={ctx:h.ctx,group:v,at:S.length};else g={ctx:"opaque"};else{if(h.ctx==="style"){if(i)re.test(v.replace(dt,""))&&c("LIPS-S008",`'${v}' joins '&' to a name`,m,f-m,"Native nesting cannot: write the full selector, or use stylisPreprocessor."),y=ae(v)}g={ctx:h.ctx==="opaque"?"opaque":"style"}}C.push(g),R("{"),g.group&&(g.body=S.length)},Q=()=>{let h=C.pop();if(h.group&&!y&&S.length===h.body&&!se.test(h.group)){S=S.slice(0,h.at),I="",d=!1;return}if(R("}"),h.hoist===void 0)return;let v=S.slice(h.hoist),g=C.filter((O)=>O.group),k=g.map((O)=>O.group).join("{"),w="}".repeat(g.length);S=S.slice(0,h.hoist),I="",B=k&&k===K?B.slice(0,B.length-w.length)+v+w:B+g.map((O)=>O.group+"{").join("")+v+w,K=k};while(f<t.length){let h=t[f];if(h==="\\"){b(t.slice(f,f+2)),f+=2;continue}let v=h==="/"&&!t.slice(m,f).trim();if(h==="/"&&(t[f+1]==="*"||t[f+1]==="/"&&v)){let g=t[f+1]==="/",k=g?Yt(t,f):gt(t,f);if(!g&&!i)y?b(t.slice(f,k)):S+=t.slice(f,k);else ut.test(I)&&ut.test(t[k]||"")&&(d=!0);v&&(m=k),f=k;continue}if(h==='"'||h==="'"){let g=z(t,f);b(t.slice(f,g)),f=g;continue}if(mt.test(h)){m===f&&m++,d=!0,f++;continue}if(h==="(")p++;else if(h===")")p--;if(h===":"&&p===0){let g=t.slice(m,f).replace(ne,"").trim();if(Ht.test(g)){let k=Kt(t,f+1,!i,(w)=>{J=!0,a("LIPS-S004","Unterminated interpolation",w,t.length-w,"Close the expression with `}`.")});if(k){let w=k.parts.filter((P)=>typeof P!=="string");for(let P of w)E(P);if(d=!1,g.startsWith("--")&&w.length===1&&!w[0].unit&&k.parts.every((P)=>typeof P!=="string"||!P.trim())){s.push({prop:g,e:x(w[0].expr)}),N(),f=k.end+(t[k.end]===";"?1:0),m=f;continue}let W="";for(let P of k.parts){if(typeof P==="string"){W+=P;continue}let tt=x(P.expr),_=`${o}-${tt}`;if(!s.some((F)=>F.prop===_)){if(s.push({prop:_,e:tt}),P.unit&&!l.some((F)=>F.name===_))l.push({name:_,syntax:ct[0],inherits:!0,initial:ct[1]})}W+=P.unit?`calc(var(${_}) * 1${P.unit})`:`var(${_})`}u(g,m,k.end,W),b(q(W)),f=k.end;continue}}}if(h==="{"){if(p>0){let g=Y(t,f);if(g){a("LIPS-S002","Interpolation in an at-rule condition",f,g.end-f+1,"Media and container conditions cannot read custom properties. Keep the condition static.");let k=ft.exec(t.slice(g.end+1));f=g.end+1+(k?k[1].length:0);continue}}if(!t.slice(m,f).trim()){let g=Y(t,f);if(g){a("LIPS-S001","Interpolation in a selector",f,g.end-f+1,"Selectors are static in Layer 1. Bind a value inside the rule instead."),f=g.end+1,m=f;continue}}Ct(),m=++f;continue}if(h==="}"){if(C.length>1)Q();else c("LIPS-S007","Unmatched `}` dropped",f,1),y&&R(";");m=++f;continue}if(h===";"){if(y[0]==="@"&&u(y,m,f),C.length===1&&pt.test(y))L+=N()+";";else R(";");m=++f;continue}b(h),f++}if(C.length>1){J||c("LIPS-S007","Unclosed `{` closed at the end",t.length,0);while(C.length>1)Q()}return pt.test(y)&&(L+=N()+";"),R(""),{css:S,statements:L,hoisted:B,exprs:n,binds:s,props:l}}function bt(t,e){let i=[],r=e.preprocess||Ft,{css:n,statements:s,hoisted:l,exprs:o,binds:a,props:c}=le(t,e,!r,i),u={v:1,nsp:e.nsp,css:"",exprs:[],binds:[]},x=e.meta||!n?n:`${e.scope||`[rel="${Zt(e.nsp)}"]`}{${n}}`,E=l+x,S=e.layer?`@layer ${e.layer}{${E}}`:E,y;try{y=r?r(S):S}catch(b){return i.push({code:"LIPS-S006",severity:"error",message:`Style compilation failed: ${b.message}`,loc:j(t,0,t.length)}),{ir:u,diagnostics:i}}let I=c.map((b)=>`@property ${b.name}{syntax:"${b.syntax}";inherits:${b.inherits};initial-value:${b.initial}}`).join(""),d={v:1,nsp:e.nsp,css:s+I+y,exprs:o,binds:a};if(c.length)d.props=c;return{ir:d,diagnostics:i}}var ce=["div","section","article","nav","header","footer","main","aside","ul","ol","li","button","form","figure","dialog","details","summary","address","blockquote","hgroup","fieldset","legend","menu","dl","dt","dd","figcaption"],pe=["span","p","h1","h2","h3","h4","h5","h6","label","b","strong","i","em","small","a","code","mark","s","u","sub","sup","time","abbr","cite","kbd","q","var","samp","dfn","del","ins","data","bdi","bdo"],M=Object.fromEntries([...ce.map((t)=>[t,"view"]),...pe.map((t)=>[t,"text"]),["img","image"]]),xt=(t)=>`lips-${t.replace(/[^\w-]/g,"-")}`;var yt={button:["button"],link:["link"],heading:["header"],img:["image"],image:["image"],checkbox:["button","checkbox"],switch:["button","switch"],radio:["button","radio"],tab:["button","tab"],option:["button"],menuitem:["button"],menuitemcheckbox:["button","checkbox"],menuitemradio:["button","radio"],searchbox:["search"],progressbar:["none","progressbar"]};var kt={status:"polite",log:"polite",alert:"assertive"},vt=new Set(["none","presentation"]);var he=[["aria-checked","checked","unchecked"],["aria-pressed","pressed"],["aria-selected","selected"],["aria-expanded","expanded","collapsed"],["aria-current","current"],["aria-disabled","disabled"],["aria-invalid","invalid"],["aria-required","required"]],St=new Set(["role","alt","for","tabindex","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-live","aria-modal","aria-roledescription","aria-valuetext","aria-valuenow",...he.map((t)=>t[0])]),Et=(t,e)=>t.role?.trim().split(/\s+/)[0]||e||"";var X=new Set(["if","else-if","else","for","switch","case","default","async","then","catch","loading","let","const","log","context","i18n"]),It=new Set(["view","scroll-view","list-item","swiper","swiper-item","overlay","refresh-view","viewpager"]),wt=new Set(["text","image","input","textarea","canvas","svg","audio"]),T="Lynx has no tables: lay rows out with <div>s, in flex or grid",ue={table:T,thead:T,tbody:T,tfoot:T,tr:T,td:T,th:T,caption:T,col:T,colgroup:T,select:"Lynx has no native picker element: a list of <div>s, or a picker component",option:"Lynx has no native picker element: a list of <div>s, or a picker component",br:"End the <p> and start another one",hr:"A <div> with a border",pre:"A <p> styled white-space: pre",iframe:"Lynx's <webview>"},Lt=(t)=>M[t]||t,fe=(t)=>Lt(t)==="text";function Z(t){for(let e of t){if(e.t==="text"||e.t==="interp")return e;let i=e.t==="fragment"||e.t==="element"&&X.has(e.tag)?Z(e.children):void 0;if(i)return i}}var Pt=(t)=>t.every((e)=>e.t==="fragment"||e.t==="element"&&X.has(e.tag)?Pt(e.children):e.t!=="element"||fe(e.tag));function*Rt(t){for(let e of t)e.t==="fragment"||e.t==="element"&&X.has(e.tag)?yield*Rt(e.children):e.t!=="comment"&&(yield e)}function Tt(t){return(e,i)=>{let r=(o,a,c,u,x)=>i.push({code:o,severity:a,message:c,hint:x,loc:j(t,u.loc.offset,u.loc.length)}),n=(o)=>{for(let a of o.attrs){if(!("name"in a))continue;let c=a.k==="literal"?a.value:void 0,u=c!==void 0&&Et({role:c});if(a.name==="role"&&u&&!yt[u]&&!kt[u]&&!vt.has(u))r("LIPS-L105","warning",`role="${u}" has no Lynx equivalent: its content stays readable, the ${u} is not announced`,a,"Say what each item is and its state on the item: aria-label, aria-selected, aria-checked");else if(a.name.startsWith("aria-")&&!St.has(a.name)&&!(a.name==="aria-atomic"&&c==="true"))r("LIPS-L106","warning",`${a.name} has no Lynx equivalent: it is not read`,a,a.name==="aria-atomic"||a.name==="aria-relevant"?"Lynx announces the whole region on every change":"Put what it says in the aria-label or a state Lynx reads");else if(a.name==="tabindex"&&c&&+c>0)r("LIPS-L107","warning","A positive tabindex orders focus: Lynx has no focus order, so it reads as 0",a,'Use tabindex="0", and order the elements in the template')}},s=(o)=>{for(let a of o){if(a.t==="fragment")s(a.children);if(a.t!=="element")continue;let c=a.tag;if((V.has(c)||wt.has(c)||It.has(c)||c==="list")&&n(a),V.has(c)&&!M[c]&&!wt.has(c))r("LIPS-L101","error",`<${c}> has no Lynx element: it would render nothing`,a,ue[c]||"Use a tag Lynx renders: <div>, <p>, <span>, <img>, <input> or a Lynx element");else if(c==="list")for(let u of Rt(a.children))u.t==="element"&&u.tag==="list-item"||r("LIPS-L104","error","A <list> holds <list-item>s: Lynx renders nothing else in one",u,"Put each row in a <list-item>");else if(Lt(c)==="view"||It.has(c)){let u=Z(a.children);if(u&&Pt(a.children)){let x=a.attrs.filter((E)=>("name"in E)&&E.name==="i18n");a.children=[{t:"element",tag:"text",attrs:x,children:a.children,selfClosed:!1,loc:a.loc}]}else u&&r("LIPS-L102","error",`Text beside block content in <${c}>: Lynx renders text only inside a text element`,u,"Wrap the text in a <span> or a <p>")}s(a.children)}},l=Z(e);l&&r("LIPS-L103","warning","Text at the top level of a template renders only when the template is placed inside a text element",l,"Put it in a <p> or a <span>"),s(e)}}var ge=(t,e)=>lt(t,{...e,target:"tree",transform:Tt(t)});var me={enableCSSInlineVariables:!0,enableCSSRule:!0,enableCSSInheritance:!0};function de(t,e){let{ir:i,diagnostics:r}=bt(t,{nsp:e.nsp,meta:e.meta,preprocess:e.preprocess,scope:`.${xt(e.nsp)}`,lint:Le});return{ir:xe(i),diagnostics:r}}var $t=/calc\(var\((--[\w-]+?-(\d+))\)\s*\*\s*1(%|[a-zA-Z]+)\)/g,be=/@property\s[^{]+\{[^}]*\}/g;function xe(t){let e=`--${t.nsp.replace(/[^a-zA-Z0-9_-]/g,"-")}-`,i=[...t.binds],r=t.css.replace(be,"").replace($t,(s,l,o,a)=>{if(!l.startsWith(e)||l.length!==e.length+o.length)return s;let c=`${l}-${a==="%"?"pct":a}`;return i.some((u)=>u.prop===c)||i.push({prop:c,e:+o,u:a}),`var(${c})`}),n={...t,css:r,binds:i.filter((s)=>s.u||!s.prop.startsWith(e)||r.includes(`var(${s.prop})`))};return delete n.props,n}var A=(t,e,i)=>({code:t,severity:"error",message:e,hint:i}),G=(t,e,i)=>({code:t,severity:"warning",message:e,hint:i}),ye=new Set(`
7
+ -x-animation-color-interpolation -x-app-region -x-auto-font-size -x-auto-font-size-line-ranges
8
+ -x-auto-font-size-preset-sizes -x-caret-gradient -x-caret-height -x-caret-radius -x-caret-width
9
+ -x-handle-color -x-handle-size adapt-font-size align-content align-items align-self animation
10
+ animation-delay animation-direction animation-duration animation-fill-mode
11
+ animation-iteration-count animation-name animation-play-state animation-timing-function
12
+ aspect-ratio background background-clip background-color background-image background-origin
13
+ background-position background-repeat background-size border border-bottom border-bottom-color
14
+ border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width
15
+ border-color border-end-end-radius border-end-start-radius border-inline-end-color
16
+ border-inline-end-style border-inline-end-width border-inline-start-color
17
+ border-inline-start-style border-inline-start-width border-left border-left-color
18
+ border-left-style border-left-width border-radius border-right border-right-color
19
+ border-right-style border-right-width border-start-end-radius border-start-start-radius
20
+ border-style border-top border-top-color border-top-left-radius border-top-right-radius
21
+ border-top-style border-top-width border-width bottom box-shadow box-sizing caret-color
22
+ clip-path color column-gap content cursor direction display enter-transition-name
23
+ exit-transition-name filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink
24
+ flex-wrap font-family font-feature-settings font-optical-sizing font-size font-style
25
+ font-variation-settings font-weight gap grid-auto-columns grid-auto-flow grid-auto-rows
26
+ grid-column-end grid-column-gap grid-column-span grid-column-start grid-row-end grid-row-gap
27
+ grid-row-span grid-row-start grid-template-columns grid-template-rows height hyphens
28
+ image-rendering implicit-animation inset-inline-end inset-inline-start justify-content
29
+ justify-items justify-self layout-animation-create-delay layout-animation-create-duration
30
+ layout-animation-create-property layout-animation-create-timing-function
31
+ layout-animation-delete-delay layout-animation-delete-duration layout-animation-delete-property
32
+ layout-animation-delete-timing-function layout-animation-update-delay
33
+ layout-animation-update-duration layout-animation-update-timing-function left letter-spacing
34
+ line-height line-spacing linear-cross-gravity linear-direction linear-gravity
35
+ linear-layout-gravity linear-orientation linear-weight linear-weight-sum list-cross-axis-gap
36
+ list-main-axis-gap margin margin-bottom margin-inline-end margin-inline-start margin-left
37
+ margin-right margin-top mask mask-clip mask-image mask-origin mask-position mask-repeat
38
+ mask-size max-height max-width min-height min-width offset-distance offset-path offset-rotate
39
+ opacity order outline outline-color outline-style outline-width overflow overflow-x overflow-y
40
+ padding padding-bottom padding-inline-end padding-inline-start padding-left padding-right
41
+ padding-top pause-transition-name perspective pointer-events position relative-align-bottom
42
+ relative-align-inline-end relative-align-inline-start relative-align-left relative-align-right
43
+ relative-align-top relative-bottom-of relative-center relative-id relative-inline-end-of
44
+ relative-inline-start-of relative-layout-once relative-left-of relative-right-of relative-top-of
45
+ resume-transition-name right row-gap text-align text-decoration text-decoration-color
46
+ text-indent text-overflow text-shadow text-stroke text-stroke-color text-stroke-width top
47
+ transform transform-origin transition transition-delay transition-duration transition-property
48
+ transition-timing-function vertical-align visibility white-space width word-break z-index
49
+ `.trim().split(/\s+/)),ke=new Set(["src","font-display","unicode-range"]),ve=/^(width|height|(min|max)-(width|height)|(margin|padding)(-(top|right|bottom|left|inline-start|inline-end))?|top|right|bottom|left|inset-inline-(start|end)|gap|row-gap|column-gap|grid-(row|column)-gap|font-size|line-height|letter-spacing|flex-basis|text-indent|border(-(top|right|bottom|left|inline-start|inline-end))?-width|outline-width)$/,Se=new Set(["not","active","focus","root"]),Ee=new Set(["before","after","first-line","first-letter"]),Ie=new Set(["media","keyframes","font-face","import"]),we=new Set(["supports","layer"]),Nt=/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/g,Le=(t,e)=>t[0]==="@"?Re(t):e===void 0?Pe(t):Te(t,e);function Pe(t){let e=[],i=t.replace(Nt,'""');if(i.includes("["))e.push(A("LIPS-L001","Attribute selectors never match on Lynx","Select by class instead."));for(let[,r,n]of i.matchAll(/(::?)([-\w]+)/g)){let s=n.toLowerCase();if(r==="::"||Ee.has(s))e.push(A("LIPS-L002",`Pseudo-elements are not supported on Lynx: '${r}${n}'`,"Render it as an element."));else if(s==="hover")e.push(G("LIPS-L004","':hover' matches only on desktop Lynx","Mobile has no pointer to hover with."));else if(!Se.has(s))e.push(A("LIPS-L003",`':${n}' never matches on Lynx`,"Lynx matches :not(), :active, :focus and :root. Use a class."))}for(let[,,r]of i.replace(/\[[^\]]*\]/g,"").matchAll(/(^|[\s>+~,(])([a-zA-Z][-\w]*)/g)){let n=M[r.toLowerCase()];n&&e.push(A("LIPS-L005",`'${r}' renders as '${n}' on Lynx, so this selector never matches`,`Use a class. A '${n}' selector would match every ${n}, not just the ${r}s.`))}return e}function Re(t){let e=/^@(?:-\w+-)?([-\w]+)/.exec(t)?.[1].toLowerCase();if(!e||Ie.has(e))return;return[we.has(e)?G("LIPS-L007",`'@${e}' is untested on Lynx`,"The engine evaluates it, but its docs say it is unsupported."):A("LIPS-L006",`'@${e}' is not supported on Lynx`)]}function Te(t,e){let i=[];if(t.startsWith("--"))return i;let r=t.toLowerCase();ye.has(r)||ke.has(r)||i.push(G("LIPS-L008",`'${t}' is not a Lynx CSS property`,"Lynx ignores it."));let n=e.replace(Nt,'""').replace($t,"var()"),s=/(?:^|[^-\w])(min|max|clamp)\(/i.exec(n);return s&&i.push(A("LIPS-L009",`'${s[1]}()' is not supported on Lynx`,"Compute the value in the expression instead.")),/(?:^|[^-\w])calc\(/i.test(n)&&!ve.test(r)&&i.push(A("LIPS-L010",`'calc()' works on length properties only on Lynx, not '${t}'`,"Bind the computed value instead: `{expr}` writes it whole.")),/!\s*important/i.test(n)&&i.push(G("LIPS-L011","'!important' is ignored on Lynx unless the page enables it")),i}export{me as LYNX_PAGE_CONFIG,de as compileLynxStyle,ge as compileLynxTemplate,Tt as lynxVocabulary};
50
+
51
+ //# debugId=EB6D312A10AE381364756E2164756E21