@lokascript/semantic 2.6.0 → 2.7.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 (40) hide show
  1. package/dist/browser-ar.ar.global.js +5 -5
  2. package/dist/browser-bn.bn.global.js +4 -4
  3. package/dist/browser-de.de.global.js +4 -4
  4. package/dist/browser-east-asian.east-asian.global.js +3 -3
  5. package/dist/browser-en-tr.en-tr.global.js +4 -4
  6. package/dist/browser-es.es.global.js +4 -4
  7. package/dist/browser-fr.fr.global.js +3 -3
  8. package/dist/browser-hi.hi.global.js +3 -3
  9. package/dist/browser-id.id.global.js +4 -4
  10. package/dist/browser-it.it.global.js +3 -3
  11. package/dist/browser-ja.ja.global.js +4 -4
  12. package/dist/browser-ko.ko.global.js +5 -5
  13. package/dist/browser-lazy.lazy.global.js +1 -1
  14. package/dist/browser-ms.ms.global.js +4 -4
  15. package/dist/browser-pl.pl.global.js +4 -4
  16. package/dist/browser-priority.priority.global.js +1 -1
  17. package/dist/browser-qu.qu.global.js +5 -5
  18. package/dist/browser-ru.ru.global.js +5 -5
  19. package/dist/browser-sw.sw.global.js +4 -4
  20. package/dist/browser-th.th.global.js +3 -3
  21. package/dist/browser-tl.tl.global.js +4 -4
  22. package/dist/browser-tr.tr.global.js +4 -4
  23. package/dist/browser-uk.uk.global.js +5 -5
  24. package/dist/browser-vi.vi.global.js +3 -3
  25. package/dist/browser.global.js +22 -22
  26. package/dist/browser.global.js.map +1 -1
  27. package/dist/generators/index.d.ts +1 -0
  28. package/dist/generators/index.d.ts.map +1 -1
  29. package/dist/generators/profile-queries.d.ts +32 -0
  30. package/dist/generators/profile-queries.d.ts.map +1 -0
  31. package/dist/index.cjs +19 -0
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +17 -0
  36. package/dist/index.js.map +1 -1
  37. package/package.json +3 -3
  38. package/src/generators/index.ts +3 -0
  39. package/src/generators/profile-queries.ts +53 -0
  40. package/src/index.ts +4 -0
@@ -1,6 +1,6 @@
1
- "use strict";var LokaScriptSemanticTr=(()=>{var ht=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Kn=Object.prototype.hasOwnProperty;var Fn=(o,e)=>{for(var t in e)ht(o,t,{get:e[t],enumerable:!0})},Un=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Kn.call(o,r)&&r!==t&&ht(o,r,{get:()=>e[r],enumerable:!(n=qn(e,r))||n.enumerable});return o};var Hn=o=>Un(ht({},"__esModule",{value:!0}),o);var ua={};Fn(ua,{ASTBuilder:()=>Oe,DEFAULT_CONFIDENCE_THRESHOLD:()=>Ft,HIGH_CONFIDENCE_THRESHOLD:()=>Ut,VERSION:()=>ia,buildAST:()=>Yt,canParse:()=>Dt,createCommandNode:()=>H,createEventHandler:()=>me,createLiteral:()=>j,createPropertyPath:()=>ae,createReference:()=>Z,createSelector:()=>ne,fromExplicit:()=>Wt,getCommandMapper:()=>Me,getPatternsForLanguage:()=>$n,getPatternsForLanguageAndCommand:()=>ca,getProfile:()=>Ze,getSupportedLanguages:()=>sa,getTokenizer:()=>Ye,isExplicitSyntax:()=>de,isLanguageSupported:()=>bt,parse:()=>Ae,parseAny:()=>Kt,parseExplicit:()=>Ne,registerCommandMapper:()=>vt,render:()=>Fe,renderExplicit:()=>Ue,toExplicit:()=>qt,tokenize:()=>la,turkishProfile:()=>ve,turkishTokenizer:()=>lt});var Ft=.5,Ut=.8;var Gn=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),Yn=new Set(["and","or","not","no"]),Zn=new Set(["true","false","null","undefined"]),Jn=new Set(["is","matches","match","contains","in"]),Xn=new Set(["next","previous","closest","first","last"]),Qn=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Ht(o){let e=[],t=0,n=1,r=1;function i(){if(e.length===0)return!0;let p=e[e.length-1];return p.type==="IDENTIFIER"&&Jn.has(p.value.toLowerCase())||p.type==="IDENTIFIER"&&Xn.has(p.value.toLowerCase())?!0:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(p.type)}function s(p=0){return o[t+p]??""}function a(){let p=o[t];return t++,p===`
2
- `?(n++,r=1):r++,p}function l(){for(;t<o.length&&/\s/.test(o[t]);)a()}function c(p){let h="";for(;t<o.length&&p(o[t]);)h+=a();return h}function u(p){let h=p;for(a();t<o.length&&o[t]!==p;)o[t]==="\\"&&t+1<o.length&&(h+=a()),h+=a();return t<o.length&&(h+=a()),h}function d(){let p="`";for(a();t<o.length&&o[t]!=="`";)o[t]==="\\"&&t+1<o.length&&(p+=a()),p+=a();return t<o.length&&(p+=a()),p}function f(){let p="<";for(a();t<o.length&&(p+=a(),!p.endsWith("/>")););return p}function m(p,h,y){return{type:p,value:h,start:y,end:t,line:n,column:r-h.length}}for(;t<o.length&&(l(),!(t>=o.length));){let p=t,h=s();if(h==="'"&&s(1)==="s"&&!/\w/.test(s(2))){a(),a(),e.push(m("POSSESSIVE","'s",p));continue}if(h==='"'||h==="'"){let y=u(h);e.push(m("STRING",y,p));continue}if(h==="`"){let y=d();e.push(m("TEMPLATE_LITERAL",y,p));continue}if(h==="<"&&/[a-zA-Z.#\[]/.test(s(1))){let y=f();e.push(m("QUERY_SELECTOR",y,p));continue}if(h==="#"&&i()){a();let y=c(g=>/[\w-]/.test(g));e.push(m("ID_SELECTOR","#"+y,p));continue}if(h==="."&&/[a-zA-Z_-]/.test(s(1))&&i()){a();let y=c(g=>/[\w-]/.test(g));e.push(m("CLASS_SELECTOR","."+y,p));continue}if(h==="@"&&/[a-zA-Z_]/.test(s(1))){a();let y=c(g=>/[\w-]/.test(g));e.push(m("ATTRIBUTE_REF","@"+y,p));continue}if(h==="["&&i()){let y=s(1);if(y==="@"||/[a-zA-Z]/.test(y)){let g="";for(g+=a();t<o.length&&o[t]!=="]";)o[t]==='"'||o[t]==="'"?g+=u(o[t]):g+=a();t<o.length&&(g+=a()),e.push(m("ATTRIBUTE_SELECTOR",g,p));continue}}if(h==="["){a(),e.push(m("LBRACKET","[",p));continue}if(h==="]"){a(),e.push(m("RBRACKET","]",p));continue}if(/\d/.test(h)){let y=c(T=>/[\d.]/.test(T)),g=t,x=c(T=>/[a-zA-Z]/.test(T));Qn.has(x)?e.push(m("TIME_EXPRESSION",y+x,p)):(t=g,e.push(m("NUMBER",y,p)));continue}if(h==="("){a(),e.push(m("LPAREN","(",p));continue}if(h===")"){a(),e.push(m("RPAREN",")",p));continue}if(h==="{"){a(),e.push(m("LBRACE","{",p));continue}if(h==="}"){a(),e.push(m("RBRACE","}",p));continue}if(h===","){a(),e.push(m("COMMA",",",p));continue}if(h===":"){a(),e.push(m("COLON",":",p));continue}if(h==="."){a(),e.push(m("DOT",".",p));continue}if(h==="+"||h==="-"||h==="*"||h==="/"||h==="%"){a(),e.push(m("OPERATOR",h,p));continue}if(h==="="||h==="!"||h==="<"||h===">"){let y=a();s()==="="&&(y+=a()),e.push(m("COMPARISON",y,p));continue}if(/[a-zA-Z_$]/.test(h)){let y=c(x=>/[\w$]/.test(x)),g=y.toLowerCase();Gn.has(g)?e.push(m("CONTEXT_VAR",y,p)):Yn.has(g)?e.push(m("LOGICAL",y,p)):Zn.has(g)?e.push(m("BOOLEAN",y,p)):e.push(m("IDENTIFIER",y,p));continue}a()}return e.push(m("EOF","",t)),e}var er=new Set(["my","its","your"]),tr=new Set(["is","matches","match","contains","in","exists","does"]),nr=new Set(["next","previous","closest","first","last"]),Ge=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=Ht(e),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(e){return this.tokens[this.current+e]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.peek().type===e}checkValue(e){return this.peek().value.toLowerCase()===e.toLowerCase()}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let e=this.parseAnd();for(;this.checkValue("or");){let t=this.advance().value,n=this.parseAnd();e=this.createBinaryExpression(t,e,n)}return e}parseAnd(){let e=this.parseEquality();for(;this.checkValue("and");){let t=this.advance().value,n=this.parseEquality();e=this.createBinaryExpression(t,e,n)}return e}parseEquality(){let e=this.parseComparison();for(;;){let t;if(this.match("COMPARISON"))t=this.previous().value;else if(this.checkValue("is")||this.checkValue("matches")||this.checkValue("match")||this.checkValue("contains")||this.checkValue("in")){let r=this.advance().value;t=r.toLowerCase()==="match"?"matches":r}else break;if(t.toLowerCase()==="is"){if(this.checkValue("empty")){this.advance(),e=this.createPostfixUnary("is empty",e);continue}if(this.checkValue("not")&&this.peekAt(1).value.toLowerCase()==="empty"){this.advance(),this.advance(),e=this.createPostfixUnary("is not empty",e);continue}}let n=this.parseComparison();e=this.createBinaryExpression(t,e,n)}return e}parseComparison(){let e=this.parseAddition();for(;this.check("COMPARISON");){let t=this.advance().value,n=this.parseAddition();e=this.createBinaryExpression(t,e,n)}return e}parseAddition(){let e=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let t=this.advance().value,n=this.parseMultiplication();e=this.createBinaryExpression(t,e,n)}return e}parseMultiplication(){let e=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let t=this.advance().value,n=this.parseUnary();e=this.createBinaryExpression(t,e,n)}return e}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let e=this.advance().value,t=this.parseUnary();return this.createUnaryExpression(e,t)}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPossessiveExpression(e,t)}else break;else if(this.match("LPAREN")){let t=this.parseArguments();e=this.createCallExpression(e,t)}else if(this.match("LBRACKET")){let t=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");e=this.createPropertyAccess(e,t)}else if(e.type==="contextReference"&&er.has(e.contextType??"")&&this.check("IDENTIFIER")&&!tr.has(this.peek().value.toLowerCase())){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),e=this.createPostfixUnary("exists",e);else break;return e}parsePrimary(){let e=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(e.value),"number",e);if(this.match("STRING")){let t=e.value.slice(1,-1);return this.createLiteral(t,"string",e)}if(this.match("BOOLEAN")){let t=e.value==="true"?!0:e.value==="false"?!1:e.value==="null"?null:void 0,n={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(t,n[e.value]??"string",e)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:e.value,start:e.start,end:e.end,line:e.line,column:e.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(e);if(this.match("ID_SELECTOR"))return this.createSelector(e.value,"id",e);if(this.match("CLASS_SELECTOR"))return this.createSelector(e.value,"class",e);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(e.value,"attribute",e);if(this.match("ATTRIBUTE_REF"))return{type:"attributeAccess",attributeName:e.value.slice(1),start:e.start,end:e.end};if(this.match("QUERY_SELECTOR")){let t=e.value.slice(1,-2);return this.createSelector(t,"query",e)}if(this.match("CONTEXT_VAR"))return this.createContextReference(e.value,e);if(this.match("IDENTIFIER")){if(nr.has(e.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let t=this.advance(),n=t.type==="QUERY_SELECTOR"?t.value.slice(1,-2):t.value,r=t.type==="CLASS_SELECTOR"?"class":t.type==="ID_SELECTOR"?"id":"query";return{type:"callExpression",callee:this.createIdentifier(e.value,e),arguments:[this.createSelector(n,r,t)],start:e.start,end:t.end}}return this.createIdentifier(e.value,e)}if(this.match("LPAREN")){let t=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return t}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${e.value}`)}parseArguments(){let e=[];if(!this.check("RPAREN"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return e}parseArrayLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACKET"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:e,start:t,end:this.previous().end}}parseObjectLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACE"))do{let n;if(this.check("STRING"))n=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER"))n=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let r=this.parseExpression();e.push({key:n,value:r})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:e.map(n=>({type:"objectProperty",key:n.key,value:n.value})),start:t,end:this.previous().end}}parseTimeExpression(e){let t=e.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!t)throw new Error(`Invalid time expression: ${e.value}`);let n=parseFloat(t[1]),r=t[2].toLowerCase();return{type:"timeExpression",value:n,unit:r,raw:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createLiteral(e,t,n){return{type:"literal",value:e,dataType:t,raw:n.value,start:n.start,end:n.end,line:n.line,column:n.column}}createSelector(e,t,n){return{type:"selector",value:e,selector:e,selectorType:t,start:n.start,end:n.end,line:n.line,column:n.column}}createContextReference(e,t){return{type:"contextReference",contextType:e,name:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createIdentifier(e,t){return{type:"identifier",name:e,start:t.start,end:t.end,line:t.line,column:t.column}}createPropertyAccess(e,t){return{type:"propertyAccess",object:e,property:typeof t=="string"?t:t.type==="identifier"?t.name:"",start:e.start,end:this.previous().end}}createPossessiveExpression(e,t){return{type:"possessiveExpression",object:e,property:t,start:e.start,end:this.previous().end}}createBinaryExpression(e,t,n){return{type:"binaryExpression",operator:e,left:t,right:n,start:t.start,end:n.end}}createUnaryExpression(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!0,start:this.previous().start,end:t.end}}createPostfixUnary(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!1,start:t.start,end:this.previous().end}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function yt(o){return new Ge().parse(o)}function Y(o,e){switch(o.type){case"literal":return rr(o);case"selector":return or(o,e);case"reference":return ir(o);case"property-path":return ar(o,e);case"expression":return sr(o);case"flag":return{type:"literal",value:o.enabled};default:let t=o;throw new Error(`Unknown semantic value type: ${t.type}`)}}function rr(o){let e={type:"literal",value:o.value};return o.dataType?{...e,dataType:o.dataType}:e}function or(o,e){return o.value.startsWith("@")&&/^[a-zA-Z_]/.test(o.value.slice(1))?{type:"attributeAccess",attributeName:o.value.slice(1)}:(e&&o.value.startsWith("*")&&/^[a-zA-Z-]/.test(o.value.slice(1))&&e.push(`Converted '${o.value}' to a CSS selector, but it looks like a CSS property name. CSS properties in commands like 'transition' should be literal strings, not selectors. Consider using expectedTypes: ['literal'] instead of ['literal', 'selector'] in the command schema.`),o.value.startsWith("<")?{type:"selector",value:o.value,selector:o.value,selectorType:o.selectorKind,raw:o.value}:{type:"selector",value:o.value,selector:o.value,selectorType:o.selectorKind})}function ir(o){return{type:"contextReference",contextType:o.value,name:o.value}}function ar(o,e){return{type:"propertyAccess",object:Y(o.object,e),property:o.property}}function sr(o){let e=yt(o.raw);return!e.success||!e.node?{type:"identifier",name:o.raw}:e.node}function gt(o,e){return o.roles.get(e)}function w(o,e,t){let n=gt(o,e);return n?Y(n,t):void 0}function P(o,e=[],t,n={}){let r={type:"command",name:o,args:e};return t&&Object.keys(t).length>0&&(r.modifiers=t),n.isBlocking&&(r.isBlocking=n.isBlocking),n.implicitTarget&&(r.implicitTarget=n.implicitTarget),n.semanticRoles&&Object.keys(n.semanticRoles).length>0&&(r.semanticRoles=n.semanticRoles),r}var lr={action:"toggle",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=w(o,"duration"),i=t?[t]:[],s={};return n&&(s.on=n),r&&(s.for=r),P("toggle",i,s)}},cr={action:"add",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("add",r,i)}},ur={action:"remove",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("remove",r,i)}},dr={action:"set",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"scope"),i=[],s={};return t&&i.push(t),n&&(s.to=n),r&&(s.on=r),P("set",i,s)}},pr={action:"show",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"duration"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.with=r),P("show",i,s)}},mr={action:"hide",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"duration"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.with=r),P("hide",i,s)}},fr={action:"increment",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"quantity"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.by=r),P("increment",i,s)}},hr={action:"decrement",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"quantity"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.by=r),P("decrement",i,s)}},yr={action:"wait",toAST(o,e){let t=w(o,"event");if(t){let i={for:t},s=w(o,"source");return s&&(i.from=s),P("wait",[],i,{isBlocking:!0})}let n=w(o,"duration");return P("wait",n?[n]:[],void 0,{isBlocking:!0})}},gr={action:"log",toAST(o,e){let t=w(o,"patient"),n=[];return t&&n.push(t),P("log",n)}},vr={action:"put",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=gt(o,"manner")??gt(o,"method"),i=t?[t]:[],s={};if(n){let a=r?.type==="literal"?String(r.value):"into";s[a]=n}return P("put",i,s)}},kr={action:"fetch",toAST(o,e){let t=w(o,"source"),n=w(o,"method"),r=w(o,"responseType"),i=w(o,"patient"),s=t?[t]:[],a={};return n&&(a.with=n),r&&(a.as=r),i&&(a.body=i),P("fetch",s,a,{isBlocking:!0})}},Sr={action:"append",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("append",r,i)}},xr={action:"prepend",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("prepend",r,i)}},br={action:"trigger",toAST(o,e){let t=w(o,"event"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.on=n),P("trigger",r,i)}},wr={action:"send",toAST(o,e){let t=w(o,"event"),n=w(o,"destination"),r=w(o,"patient"),i=t?[t]:[],s={};return n&&(s.to=n),r&&(s.detail=r),P("send",i,s)}},Tr={action:"go",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=[],i={};return t&&r.push(t),n&&(i.to=n),P("go",r,i)}},Er={action:"transition",toAST(o,e){let t=w(o,"patient"),n=w(o,"goal"),r=w(o,"duration"),i=w(o,"destination"),s=t?[t]:[],a={};return n&&(a.to=n),r&&(a.over=r),i&&(a.on=i),P("transition",s,a)}},Lr={action:"focus",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i={},s=t??n;return s&&r.push(s),P("focus",r,i)}},Cr={action:"blur",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("blur",r)}},Nr={action:"get",toAST(o,e){let t=w(o,"source"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("get",r)}},Pr={action:"take",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("take",r,i)}},Rr={action:"call",toAST(o,e){let t=w(o,"patient");return P("call",t?[t]:[])}},Ar={action:"return",toAST(o,e){let t=w(o,"patient");return P("return",t?[t]:[])}},Mr={action:"halt",toAST(o,e){let t=o.roles.get("patient");return t?P("halt",[Y(t)]):P("halt",[])}},Or={action:"throw",toAST(o,e){let t=w(o,"patient");return P("throw",t?[t]:[])}},zr={action:"settle",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("settle",r,void 0,{isBlocking:!0})}},Vr={action:"swap",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=w(o,"destination"),i=w(o,"style"),s=[],a={};return t&&s.push(t),n&&s.push(n),r&&(a.on=r),i&&(a.with=i),P("swap",s,a)}},Ir={action:"morph",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=w(o,"patient"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.on=r),P("morph",i,s)}},_r={action:"clone",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=w(o,"patient"),i=[],s={},a=t??r;return a&&i.push(a),n&&(s.into=n),P("clone",i,s)}},jr={action:"make",toAST(o,e){let t=w(o,"patient");return P("make",t?[t]:[])}},Br={action:"measure",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=w(o,"source"),i=[],s={};t&&i.push(t);let a=n??r;return a&&(s.of=a),P("measure",i,s)}},$r={action:"tell",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("tell",r)}},Dr={action:"js",toAST(o,e){let t=w(o,"patient");return P("js",t?[t]:[])}},qr={action:"async",toAST(o,e){return P("async",[])}},Wr={action:"if",toAST(o,e){let t=w(o,"condition");return P("if",t?[t]:[])}},Kr={action:"unless",toAST(o,e){let t=w(o,"condition");return P("unless",t?[t]:[])}},Fr={action:"repeat",toAST(o,e){let t=w(o,"quantity"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("repeat",r)}},Ur={action:"for",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.in=n),P("for",r,i)}},Hr={action:"while",toAST(o,e){let t=w(o,"condition");return P("while",t?[t]:[])}},Gr={action:"continue",toAST(o,e){return P("continue",[])}},Yr={action:"default",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.to=n),P("default",r,i)}},Zr={action:"init",toAST(o,e){return P("init",[])}},Jr={action:"behavior",toAST(o,e){let t=w(o,"patient");return P("behavior",t?[t]:[])}},Xr={action:"install",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.on=n),P("install",r,i)}},Qr={action:"on",toAST(o,e){let t=w(o,"event"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("on",r,i)}},Gt=new Map([["toggle",lr],["add",cr],["remove",ur],["set",dr],["show",pr],["hide",mr],["increment",fr],["decrement",hr],["wait",yr],["log",gr],["put",vr],["fetch",kr],["append",Sr],["prepend",xr],["get",Nr],["take",Pr],["trigger",br],["send",wr],["on",Qr],["go",Tr],["transition",Er],["focus",Lr],["blur",Cr],["call",Rr],["return",Ar],["halt",Mr],["throw",Or],["settle",zr],["swap",Vr],["morph",Ir],["clone",_r],["measure",Br],["make",jr],["tell",$r],["default",Yr],["js",Dr],["async",qr],["if",Wr],["unless",Kr],["repeat",Fr],["for",Ur],["while",Hr],["continue",Gr],["init",Zr],["behavior",Jr],["install",Xr]]);function Me(o){return Gt.get(o)}function vt(o){Gt.set(o.action,o)}var Oe=class{constructor(e={}){this.warnings=[]}build(e){switch(e.kind){case"command":return this.buildCommand(e);case"event-handler":return this.buildEventHandler(e);case"conditional":return this.buildConditional(e);case"compound":return this.buildCompound(e);case"loop":return this.buildLoop(e);case"behavior":return this.buildBehavior(e);case"def":return this.buildDef(e);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildBehavior(e){let t=e.eventHandlers.map(r=>this.buildEventHandler(r)),n={type:"behavior",name:e.name,parameters:[...e.parameters],eventHandlers:t};return e.initBlock&&e.initBlock.length>0&&(n.initBlock={type:"initBlock",commands:e.initBlock.map(r=>this.build(r))}),n}buildDef(e){return{type:"def",name:e.name,params:[...e.parameters],body:e.body.map(t=>this.build(t))}}buildCommand(e){let t=Me(e.action),n;if(t){let r=t.toAST(e,this);if("ast"in r&&"warnings"in r){let i=r;this.warnings.push(...i.warnings),n=i.ast}else n=r}else n=this.buildGenericCommand(e);if(e.roles&&e.roles.size>0){let r={};for(let[i,s]of e.roles)r[i]=Y(s);Object.keys(r).length>0&&(n.semanticRoles=r)}return n}buildGenericCommand(e){let t=[],n={},r=["patient","source","quantity"],i=["destination","duration","method","style"];for(let a of r){let l=e.roles.get(a);l&&t.push(Y(l))}for(let a of i){let l=e.roles.get(a);if(l){let c=this.roleToModifierKey(a);n[c]=Y(l)}}let s={type:"command",name:e.action,args:t};return Object.keys(n).length>0?{...s,modifiers:n}:s}roleToModifierKey(e){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[e]??e}buildEventHandler(e){let t=e.roles.get("event"),n="click",r,i=t?.type==="literal"?String(t.value):t?.type==="expression"?t.raw:t?.type==="reference"?t.value:void 0;i!==void 0&&(i.includes("|")||i.includes(" or ")?(r=i.split(/\s+or\s+|\|/).map(g=>g.trim()),n=r[0]):n=i);let s=e.body.map(g=>this.build(g)),a=e.roles.get("source"),l,c;a?.type==="selector"?(l=a.value,c=a.value):a?.type==="reference"?c=a.value:a?.type==="literal"&&(c=String(a.value));let u=e.roles.get("condition"),d=u?Y(u):void 0,f=e.roles.get("destination"),m=f?Y(f):void 0,p=e.eventModifiers,h=l;if(p?.from){let g=p.from;g.type==="selector"&&!l&&(h=g.value)}let y=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:n,commands:s,...r&&r.length>1?{events:r}:{},...h?{selector:h}:{},...c?{target:c}:{},...d?{condition:d}:{},...m?{watchTarget:m}:{},...y&&y.length>0?{args:y,params:y}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let n=Y(t),r=e.thenBranch.map(a=>this.build(a)),i=e.elseBranch?.map(a=>this.build(a)),s=[n,{type:"block",commands:r}];return i&&i.length>0&&s.push({type:"block",commands:i}),{type:"command",name:"if",args:s}}buildCompound(e){let t=e.statements.map(r=>this.build(r));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:t.every(r=>r.type==="eventHandler")?{type:"Program",statements:t}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(r=>this.build(r)),n=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let r=e.roles.get("quantity");r&&n.push(Y(r));break}case"for":{e.loopVariable&&n.push({type:"string",value:e.loopVariable});let r=e.roles.get("source");r&&n.push(Y(r));break}case"while":case"until":{let r=e.roles.get("condition");r&&n.push(Y(r));break}case"forever":break}return n.push({type:"block",commands:t}),{type:"command",name:"repeat",args:n}}buildBlock(e){return{type:"block",commands:e.map(n=>this.build(n))}}};function Yt(o){let e=new Oe;return{ast:e.build(o),warnings:e.warnings}}var ye=new Map,ge=new Map,ze=new Map;var Zt=null;function Xt(o,e){let t={...o};for(let n of Object.keys(e)){let r=e[n],i=o[n];r!==void 0&&(typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?t[n]=Xt(i,r):t[n]=r)}return t}function Qt(o,e){return Xt(o,e)}function kt(o){if(!o.extends)return o;let e=ge.get(o.extends);if(!e)return console.warn(`[Registry] Profile '${o.code}' extends '${o.extends}' but base is not registered. Make sure to import the base language before the variant.`),o;let t=kt(e);return Qt(t,o)}function St(o,e,t){ye.set(o,e),ge.set(o,t),ze.delete(o)}var Jt=new Map;function be(o){return o.split("-")[0]}function we(o){return o.includes("-")}function Ye(o){let e=ye.get(o);if(!e&&we(o)){let t=be(o);e=ye.get(t)}if(!e){let t=Array.from(ye.keys()).join(", ");throw new Error(`Language '${o}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${o}';`)}return e}function Ze(o){let e=ge.get(o);if(!e&&we(o)){let t=be(o);e=ge.get(t)}if(!e){let t=Array.from(ge.keys()).join(", ");throw new Error(`Language profile '${o}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${o}';`)}return kt(e)}function I(o){let e=ge.get(o);return!e&&we(o)&&(e=ge.get(be(o))),e?kt(e):void 0}function xt(){return Array.from(ye.keys())}function bt(o){return ye.has(o)?!0:we(o)?ye.has(be(o)):!1}function en(o,e){return Ye(e).tokenize(o)}function Q(o){let e=ze.get(o);if(!e&&we(o)&&(e=ze.get(be(o))),e)return e;let t=Jt.get(o);if(!t&&we(o)&&(t=Jt.get(be(o))),t)return ze.set(o,t),t;if(!Zt)throw new Error(`No patterns registered for language '${o}'. Either import the language module or set a pattern generator.`);let n=Ze(o),r=Zt(n);return ze.set(o,r),r}function wt(o,e){return Q(o).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}var ve={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:!0,markersOptional:!0,verb:{position:"end",suffixes:["mek","mak","yor","di","mi\u015F"],subjectDrop:!0},references:{me:"ben",it:"o",you:"sen",result:"sonu\xE7",event:"olay",target:"hedef",body:"g\xF6vde"},possessive:{marker:"\u0131n",markerPosition:"after-object",usePossessiveAdjectives:!0,specialForms:{me:"benim",it:"onun",you:"senin"},keywords:{benim:"me",senin:"you",onun:"it"}},roleMarkers:{patient:{primary:"i",alternatives:["\u0131","u","\xFC","yi","y\u0131","yu","y\xFC","ni","n\u0131","nu","n\xFC"],position:"after"},destination:{primary:"e",alternatives:["a","ye","ya","ne","na","de","da","te","ta","\u0131n","in","un","\xFCn","n\u0131n","nin","nun","n\xFCn"],position:"after"},source:{primary:"den",alternatives:["dan","ten","tan"],position:"after"},style:{primary:"le",alternatives:["la","yle","yla"],position:"after"},event:{primary:"i",alternatives:["\u0131","u","\xFC"],position:"after"}},keywords:{toggle:{primary:"de\u011Fi\u015Ftir",alternatives:["a\xE7/kapat"],normalized:"toggle"},add:{primary:"ekle",normalized:"add"},remove:{primary:"kald\u0131r",alternatives:["sil"],normalized:"remove"},put:{primary:"koy",normalized:"put"},append:{primary:"ili\u015Ftir",normalized:"append"},prepend:{primary:"ba\u015F\u0131naekle",normalized:"prepend"},take:{primary:"tut",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"klonla",normalized:"clone"},swap:{primary:"takas",normalized:"swap"},morph:{primary:"d\xF6n\xFC\u015Ft\xFCr",alternatives:["\u015Fekil de\u011Fi\u015Ftir"],normalized:"morph"},set:{primary:"ayarla",alternatives:["belirle"],normalized:"set"},get:{primary:"al",normalized:"get"},increment:{primary:"art\u0131r",normalized:"increment"},decrement:{primary:"azalt",normalized:"decrement"},log:{primary:"kaydet",normalized:"log"},show:{primary:"g\xF6ster",normalized:"show"},hide:{primary:"gizle",normalized:"hide"},transition:{primary:"ge\xE7i\u015F",normalized:"transition"},on:{primary:"\xFCzerinde",alternatives:["zaman"],normalized:"on"},trigger:{primary:"tetikle",normalized:"trigger"},send:{primary:"g\xF6nder",normalized:"send"},focus:{primary:"odak",alternatives:["odaklanma"],normalized:"focus"},blur:{primary:"bulan\u0131k",alternatives:["bulan\u0131kl\u0131k","bulanik"],normalized:"blur"},empty:{primary:"bo\u015Falt",alternatives:["bosalt","bo\u015F"],normalized:"empty"},open:{primary:"a\xE7",alternatives:["ac"],normalized:"open"},close:{primary:"kapat",normalized:"close"},select:{primary:"vurgula",normalized:"select"},clear:{primary:"temizle",normalized:"clear"},reset:{primary:"s\u0131f\u0131rla",alternatives:["sifirla"],normalized:"reset"},breakpoint:{primary:"kesme-noktas\u0131",alternatives:["kesme-noktasi"],normalized:"breakpoint"},click:{primary:"t\u0131klama",alternatives:["t\u0131kla","tiklama","t\u0131k","tik"],normalized:"click"},hover:{primary:"\xFCzerine gelme",alternatives:["\xFCzerinde gezinme"],normalized:"hover"},submit:{primary:"g\xF6nderme",normalized:"submit"},input:{primary:"giri\u015F",alternatives:["girdi","giris"],normalized:"input"},change:{primary:"de\u011Fi\u015Fiklik",alternatives:["de\u011Fi\u015Fim","degisim"],normalized:"change"},load:{primary:"y\xFCkle",normalized:"load"},go:{primary:"git",normalized:"go"},scroll:{primary:"kayd\u0131r",alternatives:["kaydir"],normalized:"scroll"},push:{primary:"itele",alternatives:["push"],normalized:"push"},replace:{primary:"de\u011Fi\u015Ftir_url",alternatives:["degistir_url"],normalized:"replace"},process:{primary:"i\u015Fle",alternatives:["isle"],normalized:"process"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},unless:{primary:"de\u011Filse",normalized:"unless"},when:{primary:"iken",alternatives:["durumunda","oldu\u011Funda"],normalized:"when"},where:{primary:"nerede",normalized:"where"},else:{primary:"yoksa",normalized:"else"},repeat:{primary:"tekrarla",normalized:"repeat"},for:{primary:"i\xE7in",normalized:"for"},while:{primary:"s\xFCresince",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"devam",normalized:"continue"},halt:{primary:"durdur",normalized:"halt"},throw:{primary:"f\u0131rlat",normalized:"throw"},call:{primary:"\xE7a\u011F\u0131r",normalized:"call"},return:{primary:"d\xF6n",normalized:"return"},then:{primary:"ard\u0131ndan",alternatives:["daha sonra","ardindan"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},or:{primary:"veya",normalized:"or"},not:{primary:"de\u011Fil",alternatives:["degil"],normalized:"not"},end:{primary:"son",alternatives:["biti\u015F","bitti"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asenkron",normalized:"async"},tell:{primary:"s\xF6yle",normalized:"tell"},default:{primary:"varsay\u0131lan",normalized:"default"},init:{primary:"ba\u015Flat",normalized:"init"},behavior:{primary:"davran\u0131\u015F",normalized:"behavior"},install:{primary:"kur",alternatives:["y\xFCklemek"],normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"dur",normalized:"break"},copy:{primary:"kopyala",normalized:"copy"},exit:{primary:"\xE7\u0131k",normalized:"exit"},pick:{primary:"se\xE7",normalized:"pick"},render:{primary:"render",normalized:"render"},into:{primary:"i\xE7ine",normalized:"into"},before:{primary:"\xF6nce",normalized:"before"},after:{primary:"sonra",normalized:"after"},until:{primary:"kadar",normalized:"until"},event:{primary:"olay",normalized:"event"},from:{primary:"den",alternatives:["dan"],normalized:"from"},connect:{primary:"ba\u011Flan",alternatives:["ba\u011Fla","ba\u011Flant\u0131"],normalized:"connect"},stream:{primary:"yay\u0131nla",alternatives:["ak\u0131t","ak\u0131\u015F"],normalized:"stream"},live:{primary:"canl\u0131",alternatives:["ger\xE7ek-zamanl\u0131"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"bind",normalized:"bind"},intercept:{primary:"yakala",alternatives:["araya-gir","intercept"],normalized:"intercept"},worker:{primary:"i\u015F\xE7i",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["olay-kayna\u011F\u0131"],normalized:"eventsource"}},eventHandler:{eventMarker:{primary:"da",alternatives:["de","ta","te"],position:"after"},temporalMarkers:["d\u0131\u011F\u0131nda","di\u011Finde"]}};function F(o,e){return e?{type:"literal",value:o,dataType:e}:{type:"literal",value:o}}function Ve(o,e){return e?{type:"selector",value:o,selectorKind:e}:{type:"selector",value:o}}function Te(o){return{type:"reference",value:o}}function Xe(o,e){return{type:"property-path",object:o,property:e}}function Tt(o,e=!0){return{type:"flag",name:o,enabled:e}}function nn(o,e,t){let n=e instanceof Map?e:new Map(Object.entries(e)),r={kind:"command",action:o,roles:n};return t?{...r,metadata:t}:r}function Et(o,e,t,n,r){let i=e instanceof Map?e:new Map(Object.entries(e));return{kind:"event-handler",action:o,roles:i,body:t,...r&&{eventModifiers:r},...n&&{metadata:n}}}function rn(o,e,t,n,r){let i=e instanceof Map?e:new Map(Object.entries(e));return{kind:"conditional",action:o,roles:i,thenBranch:t,...n&&{elseBranch:n},...r&&{metadata:r}}}function on(o,e,t,n,r,i,s){let a=e instanceof Map?e:new Map(Object.entries(e));return{kind:"loop",action:o,roles:a,loopVariant:t,body:n,...r&&{loopVariable:r},...i&&{indexVariable:i},...s&&{metadata:s}}}var Lt=new Set(["me","you","it","result","event","target","body"]);function Qe(o,e=Lt){return e.has(o)}var tn=new Set(["body","then","else","condition","loop-body","variable","catch","finally"]);function eo(o){let e=o.slice(1,-1),t=0;for(let n of e)if(n==="[")t++;else if(n==="]")t--;else if(t===0&&(n===" "||n===":"))return!0;return!1}function et(o,e={}){let t=o.trim(),n=e.collectDiagnostics===!0,r=[];if(!t.startsWith("[")||!t.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let i=t.slice(1,-1).trim();if(!i)throw new Error("Empty explicit statement");let s=no(i);if(s.length===0)throw new Error("No command specified in explicit statement");let a=s[0].toLowerCase(),l=new Map,c=e.referenceSet??Lt,u=e.schemaLookup?.getSchema(a),d=u?new Set(u.roles.map(m=>m.role)):null;for(let m=1;m<s.length;m++){let p=s[m];if(p.startsWith("+")||p.startsWith("~")){let L=p.startsWith("+"),S=p.slice(1);if(!S){if(n){r.push({severity:"error",code:"EMPTY_FLAG",message:`Empty flag name: "${p}"`,source:"schema"});continue}throw new Error(`Empty flag name: "${p}"`)}if(d&&!d.has(S)){if(n){r.push({severity:"error",code:"UNKNOWN_FLAG",message:`Unknown flag "${S}" for command "${a}"`,source:"schema",suggestions:[...d].map(k=>`+${k}`)}),l.set(S,Tt(S,L));continue}throw new Error(`Unknown flag "${S}" for command "${a}". Valid roles: ${[...d].join(", ")}`)}l.set(S,Tt(S,L));continue}let h=p.indexOf(":");if(h===-1){if(n){r.push({severity:"error",code:"INVALID_ROLE_FORMAT",message:`Invalid role format: "${p}". Expected role:value or +flag`,source:"schema"});continue}throw new Error(`Invalid role format: "${p}". Expected role:value or +flag`)}let y=p.slice(0,h);if(d&&!tn.has(y)&&!d.has(y))if(n)r.push({severity:"error",code:"UNKNOWN_ROLE",message:`Unknown role "${y}" for command "${a}"`,source:"schema",suggestions:[...d]});else throw new Error(`Unknown role "${y}" for command "${a}". Valid roles: ${[...d].join(", ")}`);let g=y,x=p.slice(h+1);if(tn.has(y)&&x.startsWith("[")&&eo(x)){let L=oo(p,h+1),S=p.slice(h+1,L+1);l.set(g,{type:"expression",raw:S});continue}let T=ro(x,c);l.set(g,T)}if(u&&a!=="on"){for(let m of u.roles)if(m.required&&!l.has(m.role)&&!m.default)if(n)r.push({severity:"error",code:"MISSING_REQUIRED_ROLE",message:`Missing required role "${m.role}" for command "${a}": ${m.description}`,source:"schema"});else throw new Error(`Missing required role "${m.role}" for command "${a}": ${m.description}`)}let f=m=>r.length===0?m:{...m,diagnostics:r};switch(a){case"on":{if(!l.get("event")){if(n)return r.push({severity:"error",code:"MISSING_EVENT_ROLE",message:"Event handler requires event role: [on event:click ...]",source:"schema"}),f(Et("on",l,[],{sourceLanguage:"explicit"}));throw new Error("Event handler requires event role: [on event:click ...]")}let p=Je(l,"body",e);return l.delete("body"),f(Et("on",l,p,{sourceLanguage:"explicit"}))}case"if":{let m=Je(l,"then",e),p=Je(l,"else",e);return l.delete("then"),l.delete("else"),f(rn(a,l,m,p.length>0?p:void 0,{sourceLanguage:"explicit"}))}case"repeat":{let m=Je(l,"loop-body",e),p=l.get("loop-variant"),h=l.get("variable"),y=l.get("index-variable");l.delete("loop-body"),l.delete("loop-variant"),l.delete("variable"),l.delete("index-variable");let g;p&&p.type==="literal"&&typeof p.value=="string"?g=p.value:l.has("quantity")?g="times":l.has("source")?g="for":l.has("condition")?g="while":g="forever";let x=h?.type==="literal"&&typeof h.value=="string"?h.value:h?.type==="expression"?h.raw:void 0,T=y?.type==="literal"&&typeof y.value=="string"?y.value:void 0;return f(on(a,l,g,m,x,T,{sourceLanguage:"explicit"}))}default:return f(nn(a,l,{sourceLanguage:"explicit"}))}}function de(o){let e=o.trim();return e.startsWith("[")&&e.endsWith("]")}function Je(o,e,t){let n=o.get(e);return n?n.type==="expression"?[et(n.raw,t)]:[]:[]}function to(o){if(o){if(o.startsWith("#"))return"id";if(o.startsWith("."))return"class";if(o.startsWith("["))return"attribute";if(o.startsWith("<")||o.startsWith("*"))return"element";if(/[>+~ ]/.test(o)&&o.length>1)return"complex"}}function no(o){let e=[],t="",n=!1,r="",i=0;for(let s=0;s<o.length;s++){let a=o[s];if(n){t+=a,a===r&&o[s-1]!=="\\"&&(n=!1);continue}if(a==='"'||a==="'"){n=!0,r=a,t+=a;continue}if(a==="["){i++,t+=a;continue}if(a==="]"){i--,t+=a;continue}if(a===" "&&i===0){t&&(e.push(t),t="");continue}t+=a}return t&&e.push(t),e}function ro(o,e){if(o.startsWith("#")||o.startsWith(".")||o.startsWith("[")||o.startsWith("@")||o.startsWith("*"))return Ve(o,to(o));if(o.startsWith('"')||o.startsWith("'"))return F(o.slice(1,-1),"string");if(o==="true")return F(!0,"boolean");if(o==="false")return F(!1,"boolean");let t=o.toLowerCase();if(Qe(t,e))return Te(t);let n=o.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(n){let r=parseFloat(n[1]);return n[2]?F(o,"duration"):F(r,"number")}return F(o)}function oo(o,e){let t=0;for(let n=e;n<o.length;n++)if(o[n]==="[")t++;else if(o[n]==="]"&&(t--,t===0))return n;return o.length-1}function ee(o){let e;if(o.kind==="compound"){let t=o;e=t.statements.map(n=>ee(n)).join(` ${t.chainType} `)}else e=io(o);return o.annotations&&o.annotations.length>0?o.annotations.map(n=>n.value!==void 0?`@${n.name}(${n.value})`:`@${n.name}`).join(" ")+" "+e:e}function io(o){let e=[o.action];for(let[t,n]of o.roles)n.type==="flag"?e.push(n.enabled?`+${n.name}`:`~${n.name}`):e.push(`${t}:${an(n)}`);if(o.kind==="event-handler"){let t=o;t.body&&t.body.length>0&&e.push(`body:${t.body.map(n=>ee(n)).join(" ")}`)}if(o.kind==="conditional"){let t=o;t.thenBranch&&t.thenBranch.length>0&&e.push(`then:${t.thenBranch.map(n=>ee(n)).join(" ")}`),t.elseBranch&&t.elseBranch.length>0&&e.push(`else:${t.elseBranch.map(n=>ee(n)).join(" ")}`)}if(o.kind==="loop"){let t=o;t.loopVariant&&e.push(`loop-variant:${t.loopVariant}`),t.loopVariable&&e.push(`variable:${t.loopVariable}`),t.indexVariable&&e.push(`index-variable:${t.indexVariable}`),t.body&&t.body.length>0&&e.push(`loop-body:${t.body.map(n=>ee(n)).join(" ")}`)}if(o.kind==="command"){let t=o;t.body&&t.body.length>0&&e.push(`body:${t.body.map(n=>ee(n)).join(" ")}`),t.catchBranch&&t.catchBranch.length>0&&e.push(`catch:${t.catchBranch.map(n=>ee(n)).join(" ")}`),t.finallyBranch&&t.finallyBranch.length>0&&e.push(`finally:${t.finallyBranch.map(n=>ee(n)).join(" ")}`),t.asyncVariant&&e.push(`async-variant:${t.asyncVariant}`),t.asyncBody&&t.asyncBody.length>0&&e.push(`async-body:${t.asyncBody.map(n=>ee(n)).join(" ")}`)}return`[${e.join(" ")}]`}function an(o){switch(o.type){case"literal":return typeof o.value=="string"?o.dataType==="string"||/\s/.test(o.value)?`"${o.value}"`:o.value:String(o.value);case"selector":return o.value;case"reference":return o.value;case"property-path":return`${an(o.object)}'s ${o.property}`;case"expression":return o.raw;case"flag":return o.name}}var ao=class{constructor(o){this.namespace=o,this.enabled=this.checkEnabled()}checkEnabled(){if(typeof process<"u"&&process.env){let o=process.env.DEBUG||"";return o==="*"||o.includes("framework:*")||o.includes(`framework:${this.namespace}`)}return!1}log(o,e,...t){if(!this.enabled)return;let n=`[framework:${this.namespace}]`,r=new Date().toISOString();switch(o){case"debug":console.debug(`${r} ${n} DEBUG:`,e,...t);break;case"info":console.info(`${r} ${n} INFO:`,e,...t);break;case"warn":console.warn(`${r} ${n} WARN:`,e,...t);break;case"error":console.error(`${r} ${n} ERROR:`,e,...t);break}}debug(o,...e){this.log("debug",o,...e)}info(o,...e){this.log("info",o,...e)}warn(o,...e){this.log("warn",o,...e)}error(o,...e){this.log("error",o,...e)}isEnabled(){return this.enabled}enable(){this.enabled=!0}disable(){this.enabled=!1}};function so(o){return new ao(o)}function Ee(o,e){return!e||e.length===0||e.includes(o)||e.includes("expression")?!0:o==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function lo(o,e){return o?.possessive?.keywords?.[e]}function sn(o){return!1}var Ie=class Le{constructor(){this.logger=so("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,n){let r=e.mark(),i=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let l=[];for(let c=0;c<10;c++){let u=e.peek(c);if(u)l.push({type:u.type,value:u.value,kind:u.kind});else break}this.logger.debug("Input tokens (first 10):",l),this.logger.debug("Profile code:",n?.code)}this.currentProfile=n,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,i);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(i.entries()).map(([l,c])=>[l,JSON.stringify(c)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(r),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-r.position,confidence:a}}matchBest(e,t,n){let r=[];for(let s of t){let a=e.mark(),l=this.matchPattern(e,s,n);l&&r.push(l),e.reset(a)}if(r.length===0)return null;r.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;if(l!==0)return l;let c=a.confidence-s.confidence;return Math.abs(c)>.001?c:a.consumedTokens-s.consumedTokens});let i=r[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n,r){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,l=null;for(let c=0;c<t.length;c++){let u=t[c];this.logger.debug(" >> Matching pattern token:",JSON.stringify(u,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),u.type==="role"&&u.greedy){let y=this.collectStopMarkers(t,c+1);if(r)for(let x of r)y.add(x);let g=[];for(;!e.isAtEnd();){let x=e.peek();if(!x||this.isStopMarker(x,y))break;g.push(x.value),e.advance()}if(g.length>0){n.set(u.role,{type:"expression",raw:g.join(" ")}),a=null,l=null;continue}else{if(u.optional)continue;return!1}}if(u.type==="group"){let y=this.collectStopMarkers(t,c+1);if(r)for(let x of r)y.add(x);if(this.matchGroupToken(e,u,n,y)){a=null,l=null;continue}if(this.isOptional(u))continue;return!1}let f=u.type==="role"&&u.optional===!0,m=f?e.mark():null;if(u.type==="role"&&!f){let y=c+1<t.length?t[c+1]:null;if(y?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(u))continue;if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),n.delete(l),a=null,l=null;let x=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Backtrack retry result:",x),x)continue}return!1}}}let h=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Match result:",h),h){f?(a=m,l=u.role):(a=null,l=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(u)){if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),n.delete(l),a=null,l=null;let y=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return!1}}return!0}matchPatternToken(e,t,n){switch(t.type){case"literal":return this.matchLiteralToken(e,t);case"role":return this.matchRoleToken(e,t,n);case"group":return this.matchGroupToken(e,t,n);default:return!1}}matchLiteralToken(e,t){let n=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",n?JSON.stringify({type:n.type,value:n.value,kind:n.kind}):"null"),!n)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),!1;let r=this.getMatchType(n,t.value);if(this.logger.debug(" >>> matchType for",n.value,"vs",t.value,":",r),r!=="none")return this.totalKeywordMatches++,r==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(n,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,n){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let r=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",r?JSON.stringify({value:r.value,kind:r.kind}):"null"),!r)return t.optional||!1;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(i.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,i),!0);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(s.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,s),!0);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(a.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,a),!0);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(l.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(c.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,c),!0);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",r?JSON.stringify({value:r.value,kind:r.kind}):"null");let u=this.tokenToSemanticValue(r);return this.logger.debug(" >>> tokenToSemanticValue returned:",u?JSON.stringify(u):"null"),u?(this.logger.debug(" >>> Validating type:",u.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!Ee(u.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||!1),t.optional||!1):(this.logger.debug(" >>> Type validation PASSED"),n.set(t.role,u),e.advance(),!0)):t.optional||!1}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=t.normalized||t.value,r=this.safeToLowerCase(n),i=lo(this.currentProfile,r);if(!i)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),Xe(Te(i),c)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<Le.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<Le.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<Le.MAX_METHOD_ARGS;){let f=e.peek();if(!f)break;if(f.kind==="punctuation"&&f.value===")"){if(u===0){e.advance();break}u--}if(f.kind==="punctuation"&&f.value==="("&&u++,f.kind==="punctuation"&&f.value===","){e.advance();continue}c.push(f.value),e.advance()}return{type:"expression",raw:`${s}(${c.join(", ")})`}}return{type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="punctuation"||r.value!=="'s")return e.reset(n),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(n),null):(e.advance(),Xe(Ve(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("."))return e.reset(n),null;let i=e.peek(1);i&&i.kind,e.advance();let s=r.value.slice(1);return Xe(Ve(t.value),s)}matchGroupToken(e,t,n,r){let i=e.mark(),s=new Set(n.keys());if(this.matchTokenSequence(e,t.tokens,n,r))return!0;e.reset(i);for(let c of n.keys())s.has(c)||n.delete(c);if(!t.optional)return!1;let l=this.getGroupLeadingMarker(t);if(l)for(let c=1;c<=Le.MAX_MARKER_SCAN;c++){let u=e.peek(c);if(!u)break;if((u.normalized||u.value).toLowerCase()===l){this.logger.debug(" >> MARKER SCAN: found",l,"at offset",c,"- skipping intervening tokens");for(let m=0;m<c;m++)e.advance();if(this.matchTokenSequence(e,t.tokens,n,r))return!0;e.reset(i);for(let m of n.keys())s.has(m)||n.delete(m);break}}return!0}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let n=new Set;for(let r=t;r<e.length;r++){let i=e[r];if(i.type==="literal"){if(n.add(i.value.toLowerCase()),i.alternatives)for(let s of i.alternatives)n.add(s.toLowerCase());break}if(i.type==="group"){for(let s of i.tokens)if(s.type==="literal"){if(n.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)n.add(a.toLowerCase());break}if(!i.optional)break}}return n}isStopMarker(e,t){return t.size===0?!1:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case"selector":return Ve(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=e.normalized||e.value,n=this.safeToLowerCase(t);return sn(n)?Te(n):F(e.normalized||e.value);case"identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Te(e.value);let r=this.safeToLowerCase(e.value);return sn(r)?Te(r):{type:"expression",raw:e.value};case"url":return F(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let r=e.slice(1,-1);return F(r,"string")}if(e==="true")return F(!0,"boolean");if(e==="false")return F(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let r=parseFloat(t[1]);return t[2]?F(e,"duration"):F(r,"number")}let n=parseFloat(e);return isNaN(n)?F(e,"string"):F(n,"number")}applyExtractionRules(e,t){for(let[n,r]of Object.entries(e.extraction))t.has(n)||(r.value!==void 0?t.set(n,{type:"literal",value:r.value}):r.default&&t.set(n,r.default))}isOptional(e){return e.type!=="literal"&&e.optional===!0}calculateConfidence(e,t){let n=0,r=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")r+=1,t.has(c.role)&&(n+=1);else if(c.type==="group"){for(let u of c.tokens)if(u.type==="role"){let d=i(u.role),f=.8;r+=f,t.has(u.role)?n+=f:d&&(n+=f*.6)}}let s=r>0?n/r:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c)}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(t.value))return .15;if(t.alternatives){for(let r of t.alternatives)if(n.has(r))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,r={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[i,s]of t.entries()){let a=r[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?n+=.1:n-=.1}}return Math.max(-.1,Math.min(.1,n))}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=this.safeToLowerCase(t.value);if(Le.ENGLISH_NOISE_WORDS.has(n)){let r=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(r)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let r=e.peek();if(!r||r.kind!=="event-modifier")break;let i=r.metadata;if(!i)break;switch(n=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return n?t:void 0}};Ie.MAX_MARKER_SCAN=3;Ie.MAX_PROPERTY_DEPTH=10;Ie.MAX_METHOD_ARGS=20;Ie.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var co=Ie,Ua=new co;var Ct=class{constructor(){this.name="string-literal"}canExtract(o,e){let t=o[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(o,e){let t=o[e];if(t==="\u201C"){let i=1;for(;e+i<o.length;){if(o[e+i]==="\u201D")return i++,{value:o.substring(e,e+i),length:i};i++}return null}if(t==="\u2018"){let i=1;for(;e+i<o.length;){if(o[e+i]==="\u2019")return i++,{value:o.substring(e,e+i),length:i};i++}return null}let n=1,r=!1;for(;e+n<o.length;){let i=o[e+n];if(r){r=!1,n++;continue}if(i==="\\"){r=!0,n++;continue}if(i===t)return n++,{value:o.substring(e,e+n),length:n};n++}return null}},Nt=class{constructor(){this.name="number"}canExtract(o,e){return/\d/.test(o[e])}extract(o,e){let t=0,n=!1;for(;e+t<o.length;){let s=o[e+t];if(/\d/.test(s))t++;else if(s==="."&&!n)n=!0,t++;else break}if(t===0)return null;let r=o.substring(e,e+t),i=e+t;if(i<o.length){let s=o.slice(i),a=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let c of a)if(s.startsWith(c.pattern))return{value:r+c.suffix,length:t+c.pattern.length,metadata:{hasTimeUnit:!0}};if(s.startsWith("ms"))return{value:r+"ms",length:t+2,metadata:{hasTimeUnit:!0}};let l=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let c of l)if(s.startsWith(c.pattern))return{value:r+c.suffix,length:t+1,metadata:{hasTimeUnit:!0}};if(/^[smh](?![a-zA-Z])/.test(s))return{value:r+s[0],length:t+1,metadata:{hasTimeUnit:!0}}}return{value:r,length:t}}};function uo(o){return"setContext"in o&&typeof o.setContext=="function"}function po(o){let e={language:o.language,direction:o.direction,lookupKeyword:o.lookupKeyword.bind(o),isKeyword:o.isKeyword.bind(o),isKeywordStart:o.isKeywordStart.bind(o),...o.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:o.isKeywordStartAtBoundary.bind(o)}:{}};return o.normalizer?{...e,normalizer:o.normalizer}:e}var X=class{constructor(o,e){this.pos=0,this.tokens=o,this.language=e}peek(o=0){let e=this.pos+o;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return{position:this.pos}}reset(o){this.pos=o.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(o){let e=[];for(;!this.isAtEnd()&&o(this.peek());)e.push(this.advance());return e}skipWhile(o){for(;!this.isAtEnd()&&o(this.peek());)this.advance()}};function B(o,e){return{start:o,end:e}}function $(o,e,t,n){if(typeof o=="object"){let{value:i,kind:s,position:a,normalized:l,stem:c,stemConfidence:u,metadata:d}=o;return{value:i,kind:s,position:a,...l!==void 0&&{normalized:l},...c!==void 0&&{stem:c},...u!==void 0&&{stemConfidence:u},...d!==void 0&&{metadata:d}}}let r=o;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof n=="string")return{value:r,kind:e,position:t,normalized:n};if(n){let{normalized:i,stem:s,stemConfidence:a,metadata:l}=n;return{value:r,kind:e,position:t,...i!==void 0&&{normalized:i},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...l!==void 0&&{metadata:l}}}return{value:r,kind:e,position:t}}function pe(o){return/\s/.test(o)}function tt(o){return o==="#"||o==="."||o==="["||o==="@"||o==="*"||o==="<"}function nt(o){return o==='"'||o==="'"||o==="`"||o==="\u300C"||o==="\u300D"}function ie(o){return/\d/.test(o)}function rt(o){return/[a-zA-Z]/.test(o)}function W(o){return/[a-zA-Z0-9_-]/.test(o)}function ln(o,e){if(e>=o.length)return null;let t=o[e];if(!tt(t))return null;let n=e,r="";if(t==="#"||t==="."){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null;if(n<o.length&&o[n]==="."&&t==="#"){let s=n+1;for(;s<o.length&&W(o[s]);)s++;if(s<o.length&&o[s]==="(")return r}}else if(t==="["){let i=1,s=!1,a=null,l=!1;for(r+=o[n++];n<o.length&&i>0;){let c=o[n];r+=c,l?l=!1:c==="\\"?l=!0:s?c===a&&(s=!1,a=null):c==='"'||c==="'"||c==="`"?(s=!0,a=c):c==="["?i++:c==="]"&&i--,n++}if(i!==0)return null}else if(t==="@"){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null}else if(t==="*"){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null}else if(t==="<"){if(r+=o[n++],n>=o.length||!rt(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++];for(;n<o.length;){let i=o[n];if(i==="."){if(r+=o[n++],n>=o.length||!W(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++]}else if(i==="#"){if(r+=o[n++],n>=o.length||!W(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++]}else if(i==="["){let s=1,a=!1,l=null,c=!1;for(r+=o[n++];n<o.length&&s>0;){let u=o[n];r+=u,c?c=!1:u==="\\"?c=!0:a?u===l&&(a=!1,l=null):u==='"'||u==="'"||u==="`"?(a=!0,l=u):u==="["?s++:u==="]"&&s--,n++}if(s!==0)return null}else break}for(;n<o.length&&pe(o[n]);)r+=o[n++];if(n<o.length&&o[n]==="/")for(r+=o[n++];n<o.length&&pe(o[n]);)r+=o[n++];if(n>=o.length||o[n]!==">")return null;r+=o[n++]}return r||null}function mo(o,e){if(e>=o.length||o[e]!=="'"||e+1>=o.length||o[e+1].toLowerCase()!=="s")return!1;if(e+2>=o.length)return!0;let n=o[e+2];return pe(n)||n==="*"||!W(n)}function cn(o,e){if(e>=o.length)return null;let t=o[e];if(!nt(t)||t==="'"&&mo(o,e))return null;let r={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!r)return null;let i=e+1,s=t,a=!1;for(;i<o.length;){let l=o[i];if(s+=l,a)a=!1;else if(l==="\\")a=!0;else if(l===r)return s;i++}return s}function un(o,e){if(e>=o.length)return!1;let t=o[e],n=o[e+1]||"",r=o[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(r)||t==="."&&(n==="/"||n==="."&&r==="/"))return!0;let i=o.slice(e,e+8).toLowerCase();return!!(i.startsWith("http://")||i.startsWith("https://"))}function dn(o,e){if(!un(o,e))return null;let t=e,n="",r=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<o.length;){let i=o[t];if(i==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=i,t++;t<o.length&&/[a-zA-Z0-9_-]/.test(o[t]);)n+=o[t++];break}if(r.test(i))n+=i,t++;else break}return n.length<2?null:n}function pn(o,e){if(e>=o.length)return null;let t=o[e];if(!ie(t)&&t!=="-"&&t!=="+")return null;let n=e,r="";if((o[n]==="-"||o[n]==="+")&&(r+=o[n++]),n>=o.length||!ie(o[n]))return null;for(;n<o.length&&ie(o[n]);)r+=o[n++];if(n<o.length&&o[n]===".")for(r+=o[n++];n<o.length&&ie(o[n]);)r+=o[n++];return n<o.length&&(o.slice(n,n+2)==="ms"?r+="ms":(o[n]==="s"||o[n]==="m"||o[n]==="h")&&(r+=o[n])),r}var fo=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];var Ja=new Set(fo),ho=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]),yo=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],mn=class fn{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[]}getExtraKeywordEntries(){return this.rawExtraEntries}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){uo(e)&&e.setContext(po(this)),this.extractors.push(e)}registerExtractors(e){for(let t of e)this.registerExtractor(t)}clearExtractors(){this.extractors=[]}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&pe(e[n]);)n++;if(n>=e.length)break;let r=this.tryMultiWordKeyword(e,n);if(r){t.push(r),n=r.position.end;continue}let i=!1;for(let s of this.extractors)if(s.canExtract(e,n)){let a=s.extract(e,n);if(a){let l=a.metadata?.normalized,c=a.metadata?.stem,u=a.metadata?.stemConfidence,d={};if(a.metadata)for(let[m,p]of Object.entries(a.metadata))m!=="normalized"&&m!=="stem"&&m!=="stemConfidence"&&(d[m]=p);let f={};l&&(f.normalized=l),c&&(f.stem=c),u!==void 0&&(f.stemConfidence=u),Object.keys(d).length>0&&(f.metadata=d),t.push($(a.value,this.classifyToken(a.value),B(n,n+a.length),Object.keys(f).length>0?f:void 0)),n+=a.length,i=!0;break}}if(!i){let s=e[n],a=this.classifyUnknownChar(s);t.push($(s,a,B(n,n+1))),n++}}return new X(t,this.language)}classifyUnknownChar(e){return"()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,n){if(e[t]!==".")return!1;let r=n[n.length-1],i=r&&r.position.end<t;if(r&&!i&&(r.kind==="identifier"||r.kind==="keyword"||r.kind==="selector"))return n.push($(".","operator",B(t,t+1))),!0;let l=t+1;for(;l<e.length&&W(e[l]);)l++;return l<e.length&&e[l]==="("?(n.push($(".","operator",B(t,t+1))),!0):!1}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(this.rawExtraEntries=t,e.keywords){for(let[r,i]of Object.entries(e.keywords))if(n.set(i.primary,{native:i.primary,normalized:i.normalized||r}),i.alternatives)for(let s of i.alternatives)n.set(s,{native:s,normalized:i.normalized||r})}if(e.references){for(let[r,i]of Object.entries(e.references))n.set(i,{native:i,normalized:r});for(let r of Object.keys(e.references))n.has(r)||n.set(r,{native:r,normalized:r})}if(e.roleMarkers){for(let[r,i]of Object.entries(e.roleMarkers))if(i.primary&&n.set(i.primary,{native:i.primary,normalized:r}),i.alternatives)for(let s of i.alternatives)n.set(s,{native:s,normalized:r})}if(e.possessive?.keywords)for(let[r,i]of Object.entries(e.possessive.keywords))n.set(r,{native:r,normalized:i});for(let r of yo)n.has(r)||n.set(r,{native:r,normalized:r});for(let r of t)n.set(r.native,r);this.profileKeywords=Array.from(n.values()).sort((r,i)=>i.native.length-r.native.length),this.multiWordKeywords=this.profileKeywords.filter(r=>r.native.includes(" ")&&!ho.has(r.normalized)),this.profileKeywordMap=new Map;for(let r of this.profileKeywords){this.profileKeywordMap.set(r.native.toLowerCase(),r);let i=this.removeDiacritics(r.native);i!==r.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),r)}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let n of this.profileKeywords)if(e.slice(t).startsWith(n.native))return $(n.native,"keyword",B(t,t+n.native.length),n.normalized);return null}tryMultiWordKeyword(e,t,n=r=>/[\p{L}\p{N}_]/u.test(r)){if(this.multiWordKeywords.length===0)return null;let r=e.slice(t);for(let i of this.multiWordKeywords){if(!r.startsWith(i.native))continue;let s=e[t+i.native.length];if(!(s!==void 0&&n(s)))return $(i.native,"keyword",B(t,t+i.native.length),i.normalized)}return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(r=>n.startsWith(r.native))}isKeywordStartAtBoundary(e,t,n=r=>/[\p{L}\p{N}_]/u.test(r)){let r=e.slice(t);return this.profileKeywords.some(i=>{if(!r.startsWith(i.native))return!1;let s=e[t+i.native.length];return s===void 0||!n(s)})}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,n){let r=this.tryNormalize(e);if(!r)return null;let i=this.lookupKeyword(r.stem);if(!i)return null;let s={normalized:i.normalized,stem:r.stem,stemConfidence:r.confidence};return $(e,"keyword",B(t,n),s)}trySelector(e,t){let n=ln(e,t);return n?$(n,"selector",B(t,t+n.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let n=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let r=n[0].replace(/(\s|\.)$/,""),i=r.slice(1).split("(")[0],s=n[1];return{...$(r,"event-modifier",B(t,t+r.length)),metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let n=cn(e,t);return n?$(n,"literal",B(t,t+n.length)):null}tryNumber(e,t){let n=pn(e,t);return n?$(n,"literal",B(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,r=!1){let i=t;if(r)for(;i<e.length&&pe(e[i]);)i++;let s=e.slice(i);for(let a of n){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let u=s[a.length]||"";if(W(u))continue}return{suffix:a.suffix,endPos:i+a.length}}}return null}parseBaseNumber(e,t,n=!0){let r=t,i="";if(n&&(e[r]==="-"||e[r]==="+")&&(i+=e[r++]),r>=e.length||!ie(e[r]))return null;for(;r<e.length&&ie(e[r]);)i+=e[r++];if(r<e.length&&e[r]===".")for(i+=e[r++];r<e.length&&ie(e[r]);)i+=e[r++];return!i||i==="-"||i==="+"?null:{number:i,endPos:r}}tryNumberWithTimeUnits(e,t,n,r={}){let{allowSign:i=!0,skipWhitespace:s=!1}=r,a=this.parseBaseNumber(e,t,i);if(!a)return null;let{number:l,endPos:c}=a,u=[...n,...fn.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,c,u,s);return d&&(l+=d.suffix,c=d.endPos),$(l,"literal",B(t,c))}tryUrl(e,t){let n=dn(e,t);return n?$(n,"url",B(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!W(e[t+1]))return null;let n=t+1;for(;n<e.length&&W(e[n]);)n++;let r=e.slice(t,n);return $(r,"identifier",B(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return $(n,"operator",B(t,t+2));let r=e[t];return["<",">","!","+","-","*","/","="].includes(r)?$(r,"operator",B(t,t+1)):["(",")","{","}",",",";",":"].includes(r)?$(r,"punctuation",B(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let r of n)if(e.slice(t,t+r.length)===r)return $(r,"particle",B(t,t+r.length));return null}};mn.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:!0},{pattern:"m",suffix:"m",length:1,checkBoundary:!0,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:!0}];var _e=mn;function Pt(o){return{stem:o,confidence:1}}function ot(o,e,t){return t?{stem:o,confidence:e,metadata:t}:{stem:o,confidence:e}}function ne(o){let e="complex";return o.startsWith("#")&&!o.includes(" ")?e="id":o.startsWith(".")&&!o.includes(" ")?e="class":o.startsWith("[")&&o.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(o)&&(e="element"),{type:"selector",value:o,selectorKind:e}}function j(o,e){let t={type:"literal",value:o};return e!==void 0?{type:"literal",value:o,dataType:e}:t}function ke(o){return Qe(o)}function Z(o){return{type:"reference",value:o}}function ae(o,e){return{type:"property-path",object:o,property:e}}function H(o,e,t){let n={kind:"command",action:o,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function me(o,e,t,n,r,i){let s=new Map;s.set("event",o);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),r!==void 0&&r.length>0&&(a.parameterNames=r),i!==void 0&&i.length>0&&(a.additionalEvents=i),a}function hn(o,e,t,n,r){let i={kind:"behavior",action:"behavior",roles:new Map,name:o,parameters:e,eventHandlers:t};return n!==void 0&&n.length>0&&(i.initBlock=n),r!==void 0&&(i.metadata=r),i}function yn(o,e,t,n){let r={kind:"def",action:"def",roles:new Map,name:o,parameters:e,body:t};return n!==void 0&&(r.metadata=n),r}function je(o,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:o,chainType:e};return t!==void 0&&(n.metadata=t),n}function gn(o,e,t,n){let r=new Map;r.set("condition",o);let i={kind:"conditional",action:"if",roles:r,thenBranch:e};return t!==void 0&&(i.elseBranch=t),n!==void 0&&(i.metadata=n),i}function Be(o,e){return!e||e.length===0||e.includes(o)||e.includes("expression")?!0:o==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):o==="expression"?e.some(t=>["selector","reference","expression"].includes(t)):!1}var go={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:!0,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},vo={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:!0,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},ko={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},So={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"},markerVariants:{en:["before","after"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},xo={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:!0,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"patient",description:"The value to set",required:!0,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},bo={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:!0,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},wo={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},To={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Eo={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Lo={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Co={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},No={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Po={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Ro={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:!0,roles:[{role:"event",description:"The event to handle",required:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ao={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Mo={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Oo={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:!1,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:!1,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},zo={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Vo={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Io={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},_o={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},jo={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Bo={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:!1,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},$o={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Do={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:!0,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},qo={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:!1,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Wo={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ko={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Fo={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},Uo={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate",required:!0,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Ho={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:!0,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Go={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},Yo={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:!0,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:!0,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Zo={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The iteration variable",required:!0,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},Jo={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to check",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Xo={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Qo={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""},markerOptional:{en:!0},markerVariants:{he:["\u05D0\u05EA"],zh:["\u628A"]}}]},ei={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:!0,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:!1,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:!1,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ti={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:!1,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},ni={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ri={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},oi={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ii={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},ai={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},si={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},li={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ci={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ui={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:!0},di={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:!0,expectedTypes:["expression","reference"],markerOptional:{he:!0,zh:!0},svoPosition:1,sovPosition:1}]},pi={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:!1,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},mi={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The JavaScript code to execute",required:!1,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},fi={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},hi={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:!0,roles:[{role:"destination",description:"The element to tell",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},yi={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:!0,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},gi={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},vi={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ki={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Si={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},xi={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:!1,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{role:"patient",description:"The content to swap in (optional for delete)",required:!1,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528"}}]},bi={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to morph",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:!0,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},wi={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:!1,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Ti={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ei={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Li={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:!0},Ci={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:!0,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:!1,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Ni={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},vn={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},Pi={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Ri={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:vn}]},Ai={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:vn}]},Mi={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Pi}]},Oi={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:!1,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},Ce={toggle:go,add:vo,remove:ko,put:So,set:xo,show:No,hide:Po,on:Ro,trigger:Ao,wait:Mo,fetch:Oo,increment:zo,decrement:Vo,append:Io,prepend:_o,log:jo,get:Bo,take:$o,make:Do,halt:qo,settle:Wo,throw:Ko,send:Fo,if:Uo,unless:Ho,else:Go,repeat:Yo,for:Zo,while:Jo,continue:Xo,go:Qo,scroll:Ni,push:Ri,replace:Ai,process:Mi,transition:ei,clone:ti,focus:ni,blur:ri,empty:oi,open:ii,close:ai,select:si,clear:li,reset:ci,breakpoint:ui,call:di,return:pi,js:mi,async:fi,tell:hi,default:yi,init:gi,behavior:vi,install:ki,measure:Si,swap:xi,morph:bi,beep:wi,break:Ti,copy:Ei,exit:Li,pick:Ci,render:Oi,bind:bo,live:wo,eventsource:To,socket:Eo,worker:Lo,intercept:Co,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function re(o){return Ce[o]}function ce(o,e){let t=o.possessive?.keywords?.[e];if(t)return t;let n=o.possessive?.specialForms;if(n){for(let[r,i]of Object.entries(n))if(i===e)return r}}var kn=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:!0,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:!0,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:!0,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:!0,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:!0,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:!0,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function Rt(o,e,t,n){let r=kn.find(s=>s.lang===o);if(!r)return!1;let i=(s,a)=>(s??"").toLowerCase()===a.toLowerCase();return i(e,r.end)&&i(t,r.at)&&i(n,r.of)}function Sn(o,e){let t=kn.find(r=>r.lang===o);if(!t)return!1;let n=e.toLowerCase();return n===t.at.toLowerCase()||n===t.of.toLowerCase()||n===t.end.toLowerCase()}var xn=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]),zi={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]},At=class{calculate(e){return this.calculateWithBreakdown(e).final}calculateWithBreakdown(e){let t=this.scoreRoleCoverage(e),n=this.scoreStemPenalty(e),r=this.scoreLanguageBoost(e),i=this.scoreLanguageAdjustment(e),s=t;return s=Math.max(.5,s+n),s=Math.min(1,s+r),s=Math.max(0,Math.min(1,s+i)),{roleCoverage:t,stemPenalty:n,languageBoost:r,languageAdjustment:i,final:s}}scoreRoleCoverage(e){let{pattern:t,captured:n}=e,r=0,i=0,s=a=>t.extraction?.[a]?.default!==void 0;for(let a of t.template.tokens)if(a.type==="role")i+=1,n.has(a.role)&&(r+=1);else if(a.type==="group")for(let l of a.tokens)l.type==="role"&&(i+=.8,n.has(l.role)?r+=.8:s(l.role)&&(r+=.8*.6));return i>0?r/i:1}scoreStemPenalty(e){let{stemMatchCount:t,totalKeywordMatches:n}=e;return t<=0||n<=0?0:-(t/n)*.15}scoreLanguageBoost(e){let{pattern:t}=e;if(t.language!=="ar")return 0;let n=t.template.tokens[0];return!n||n.type!=="literal"?0:xn.has(n.value)||n.alternatives?.some(r=>xn.has(r))?.15:0}scoreLanguageAdjustment(e){let{pattern:t,captured:n}=e;if(t.language!=="ar")return 0;let r=0;for(let[i,s]of n.entries()){let a=zi[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;l&&typeof l.prepositionValue=="string"&&(a.includes(l.prepositionValue)?r+=.1:r-=.1)}return Math.max(-.1,Math.min(.1,r))}},bn=new At;var Vi=new Set(Object.values(Ce).filter(o=>o.bareKeyword===!0).map(o=>o.action)),A=class A{constructor(e){this.matchCache=new Map;this.stemMatchCount=0;this.totalKeywordMatches=0;this.confidenceModel=e??bn}matchPattern(e,t){let n=e.mark(),r=new Map;if(this.currentProfile=I(t.language),this.currentPatternCommand=t.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,r))return e.reset(n),null;let s=this.confidenceModel.calculate({pattern:t,captured:r,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,r),{pattern:t,captured:r,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let n=[],r=e.position();for(let s of t){let a=e.mark(),l=`${r}:${s.id}`,c;this.matchCache.has(l)?c=this.matchCache.get(l):(c=this.matchPattern(e,s),this.matchCache.set(l,c)),c&&n.push(c),e.reset(a)}if(n.length===0)return null;n.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;return l!==0?l:a.confidence-s.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n,r){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=0;for(let l=0;l<t.length;l++){let c=t[l];a>0&&c.type==="literal"&&this.tryConsumeEventSourceClause(e,n,c);let u=this.matchPatternToken(e,c,n,t[l+1]??r);if(a=c.type==="role"&&c.role==="event"?2:Math.max(0,a-1),!u){if(this.isOptional(c))continue;return!1}}return!0}tryConsumeEventSourceClause(e,t,n){if(t.has("source"))return;let r=e.peek(),i=e.peek(1);if(!r||!i||this.patternTokenWouldMatch(n,r))return;let s=this.currentProfile?.roleMarkers?.source,a=c=>{if(c.kind!=="particle"&&c.kind!=="keyword")return!1;if((c.normalized??"").toLowerCase()==="source")return!0;if(!s)return!1;let u=c.value.toLowerCase();return s.primary?.toLowerCase()===u?!0:!!s.alternatives?.some(d=>d.toLowerCase()===u)},l=s?.position;if(l!=="after"&&a(r)&&i.kind==="selector"){e.advance();let c=this.tokenToSemanticValue(e.advance());c&&t.set("source",c);return}if(l==="after"&&r.kind==="selector"&&a(i)){let c=this.tokenToSemanticValue(r);e.advance(),e.advance(),c&&t.set("source",c)}}matchPatternToken(e,t,n,r){switch(t.type){case"literal":return this.matchLiteralToken(e,t);case"role":return this.matchRoleToken(e,t,n,r);case"group":return this.matchGroupToken(e,t,n,r);default:return!1}}matchLiteralToken(e,t){let n=e.peek();if(!n)return!1;let r=this.getMatchType(n,t.value);if(r!=="none")return this.totalKeywordMatches++,r==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(n,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),!0}for(let i of[t.value,...t.alternatives??[]])for(let s of["-","_"])if(i.includes(s)&&this.tryMatchShatteredCompound(e,i,s))return this.totalKeywordMatches++,!0;return!1}tryFoldHyphenActionKeyword(e){let t=this.currentProfile;if(!t)return null;let n=e.mark(),r=[];for(;;){let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword")break;r.push(s.value),e.advance();let a=e.peek();if(!a||a.value!=="-")break;e.advance(),r.push("-")}if(r.length<3||r[r.length-1]==="-")return e.reset(n),null;let i=r.join("").toLowerCase();for(let[s,a]of Object.entries(t.keywords))if(a.primary.toLowerCase()===i||a.alternatives?.some(l=>l.toLowerCase()===i))return j(s);return e.reset(n),null}tryMatchShatteredCompound(e,t,n){let r=t.split(n);if(r.length<2||r.some(s=>s.length===0))return!1;let i=e.mark();for(let s=0;s<r.length;s++){if(s>0){let l=e.peek();if(!l||l.value!==n)return e.reset(i),!1;e.advance()}let a=e.peek();if(!a||a.kind!=="identifier"&&a.kind!=="keyword"&&a.kind!=="particle"||a.value.toLowerCase()!==r[s].toLowerCase())return e.reset(i),!1;e.advance()}return!0}matchRoleToken(e,t,n,r){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||!1;if(t.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return n.set(t.role,g),!0}if(t.role==="event"&&this.currentPatternCommand==="on"){if(!A.tokenLooksLikeEvent(i))return t.optional||!1;let g=(i.normalized??i.value).toLowerCase();if(A.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(ce(this.currentProfile,i.value)??ce(this.currentProfile,g))!==void 0||i.value.includes("?."))return t.optional||!1}if(t.role==="event"){let g=(i.normalized??i.value).toLowerCase();if(A.STRUCTURAL_NEVER_EVENT.has(g))return t.optional||!1}if(t.role==="duration"){let g=(i.normalized??i.value).toLowerCase();if(A.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return t.optional||!1}if(t.optional&&r===void 0&&t.role!=="event"&&t.role!=="action"&&i.kind==="keyword"&&(i.normalized??i.value).toLowerCase()in Ce)return!0;let s=this.tryMatchPositionalExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(s.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,s),!0);let a=this.tryMatchCaretScopeExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(a.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,a),!0);if(t.role!=="event"&&(!t.expectedTypes||t.expectedTypes.includes("expression"))){let g=this.tryMatchOperatorRunExpression(e);if(g)return n.set(t.role,g),!0}if(t.expectedTypes?.includes("property-path")){let g=this.tryMatchOfPossessiveExpression(e);if(g)return n.set(t.role,g),!0;let x=this.tryMatchPostNominalPossessiveExpression(e);if(x)return n.set(t.role,x),!0}let l=this.tryMatchPossessiveExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,l),!0);let c=this.tryMatchMethodCallExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,c),!0);let d=t.role==="event"&&this.currentPatternCommand==="on"||A.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(d)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(d.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,d),!0);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(f.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,f),!0);let m=t.role!=="condition",p=this.tryMatchPropertyAccessExpression(e,m);if(p)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(p.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,p),!0);let h=this.tryMatchSelectorPropertyExpression(e);if(h)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(h.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,h),!0);if(i.kind==="identifier"&&i.value==="{"&&(!t.expectedTypes?.length||t.expectedTypes.includes("literal"))){let g=this.tryMatchBraceRunLiteral(e);if(g)return n.set(t.role,g),!0}let y=this.tokenToSemanticValue(i);if(!y)return t.optional||!1;if(t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(y.type)){let g=y.type==="selector"&&String(y.value).startsWith("@"),x=t.expectedTypes.some(T=>T==="expression"||T==="reference");if(!(g&&x))return t.optional||!1}if(n.set(t.role,y),e.advance(),t.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in y&&(n.set(t.role,j(`${String(y.value)}${g.value}`)),e.advance());let x=e.peek();if(x&&(x.kind==="particle"||x.kind==="keyword")&&(x.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(r,x)){let T=e.peek(1);if(T&&(T.kind==="selector"||T.kind==="identifier")){e.advance();let L=this.tokenToSemanticValue(e.advance());L&&!n.has("source")&&n.set("source",L)}}}return!0}patternTokenWouldMatch(e,t){return e?e.type==="literal"?this.getMatchType(t,e.value)!=="none"?!0:!!e.alternatives?.some(n=>this.getMatchType(t,n)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],t):!1:!1}tryMatchPositionalExpression(e){let t=e.peek();if(!t)return null;let n=(t.normalized??t.value).toLowerCase();if(!A.POSITIONAL_KEYWORDS.has(n)&&!A.POSITIONAL_KEYWORDS.has(t.value.toLowerCase()))return null;let r=e.mark(),i=[t.normalized??t.value];e.advance();let s=e.peek();if(!s||s.kind!=="selector")return e.reset(r),null;i.push(s.value),e.advance();let a=0;for(;a++<8;){let u=e.peek();if(u&&u.kind==="selector"&&u.value.startsWith("."))i.push(u.value),e.advance();else break}let l=e.peek(),c=e.peek(1);return l&&c&&c.kind==="selector"&&(l.kind==="keyword"||l.kind==="particle"||l.kind==="identifier")&&!A.POSITIONAL_KEYWORDS.has((l.normalized??l.value).toLowerCase())&&!A.COMMAND_ACTION_KEYWORDS.has((l.normalized??l.value).toLowerCase())&&(i.push(l.normalized??l.value,c.value),e.advance(),e.advance()),{type:"expression",raw:i.join(" ")}}tryMatchCaretScopeExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!t.value.startsWith("^"))return null;let n=e.peek(1),r=e.peek(2),i=(n?.normalized??"").toLowerCase(),s=!!n&&(n.value.toLowerCase()==="on"||i==="destination"||i==="on");return!n||!r||r.kind!=="selector"||!s?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${t.value} on ${r.value}`})}isOfPossessiveMarker(e){let t=e.value.toLowerCase(),n=(e.normalized??"").toLowerCase();if(t==="of"||t==="ng"||n==="of"||n==="source")return!0;let r=this.currentProfile?.code?A.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return!!r&&r.has(t)}tryMatchOperatorRunExpression(e){let t=e.mark(),n=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(t),null;let r=1;for(;;){let s=e.peek();if(!s||!A.RUN_OPERATORS.has(s.value))break;let a=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(a);break}r++}if(r<2)return e.reset(t),null;let i=e.tokens.slice(n,e.position()).map(s=>s.value).join(" ");return{type:"expression",raw:i,value:i}}tryConsumeRunOperand(e){let t=e.peek();if(!t)return!1;if(t.value==="("){let n=e.mark(),r=0;for(;!e.isAtEnd();){let i=e.advance();if(i.value==="(")r++;else if(i.value===")"&&(r--,r===0))return!0}return e.reset(n),!1}return this.tryMatchPossessiveExpression(e)?!0:(t.kind==="literal"||t.kind==="identifier"||t.kind==="selector"||t.kind==="keyword")&&!A.RUN_OPERATORS.has(t.value)&&t.value!==")"?(e.advance(),!0):!1}tryMatchOfPossessiveExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||!this.isOfPossessiveMarker(r))return e.reset(n),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"?(e.reset(n),null):(e.advance(),ae(ne(i.value),t.value))}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=[t.value,t.normalized].filter(Boolean),r;for(let l of n)if(r=ce(this.currentProfile,l)??ce(this.currentProfile,l.toLowerCase()),r)break;if(!r)return null;let i=e.mark();e.advance();let s=this.currentProfile.possessive?.connectors;if(s&&s.length>0){let l=e.peek();if(l){let c=l.value.toLowerCase(),u=(l.normalized??"").toLowerCase();s.some(d=>d.toLowerCase()===c||d.toLowerCase()===u)&&e.advance()}}let a=e.peek();if(!a||Sn(this.currentProfile.code,a.value))return e.reset(i),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)&&!(a.normalized&&this.isStructuralKeyword(a.normalized))&&!(a.normalized&&this.isRoleMarkerConcept(a.normalized))||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();if(u&&u.value.startsWith("(")){let d="",f=0,m=0;for(;!e.isAtEnd()&&m++<A.MAX_METHOD_ARGS+2;){let p=e.peek();if(!p)break;d+=p.value,e.advance();for(let h of p.value)h==="("?f++:h===")"&&f--;if(f<=0)break}c+=d}return ae(Z(r),c)}return e.reset(i),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let t=d=>{for(let f of[d.value,d.normalized].filter(Boolean))if(ce(this.currentProfile,f)??ce(this.currentProfile,f.toLowerCase()))return!0;return!1},n=e.peek();if(!n)return null;let r=n.kind==="selector"&&n.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(n.value);if(!(n.kind==="identifier"&&!this.isStructuralKeyword(n.value)&&!(n.normalized&&this.isStructuralKeyword(n.normalized))&&!(n.normalized&&this.isRoleMarkerConcept(n.normalized))||n.kind==="selector"&&(n.value.startsWith("*")||n.value.startsWith("@"))||r)||t(n))return null;let s=e.mark(),a=n.value;r&&(a=a.substring(1)),e.advance();let l=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();if(!c)return e.reset(s),null;let u;for(let d of[c.value,c.normalized].filter(Boolean))if(u=ce(this.currentProfile,d)??ce(this.currentProfile,d.toLowerCase()),u)break;return u?(e.advance(),ae(Z(u),l)):(e.reset(s),null)}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return!1;let t=e.value;if(/[/#@*]/.test(t)||t.startsWith('"')||t.startsWith("'")||t.startsWith("`"))return!1;let n=e.normalized?.toLowerCase();return!(n&&Vi.has(n))}tryMatchBraceRunLiteral(e){let t=e.peek();if(!t||t.kind!=="identifier"||t.value!=="{")return null;let n=e.mark();e.advance();let r=["{"],i=1,s=0;for(;!e.isAtEnd()&&s++<A.MAX_BRACE_RUN_TOKENS;){let a=e.advance();if(!a)break;if(a.value==="{")i++;else if(a.value==="}"&&(i--,i===0))return r.push("}"),j(r.join(" "));r.push(a.value)}return e.reset(n),null}tryMatchBareCallExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(t.value))return null;let n=e.peek(1);if(!n||n.value!=="(")return null;let r=e.mark();e.advance(),e.advance();let i=[],s=!1,a=0;for(;!e.isAtEnd()&&a++<A.MAX_METHOD_ARGS+2;){let l=e.peek();if(!l)break;if(l.value===")"){e.advance(),s=!0;break}if(l.value===","){e.advance();continue}i.push(l.value),e.advance()}return s?{type:"expression",raw:`${t.value}(${i.join(", ")})`}:(e.reset(r),null)}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<A.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e,t=!0){let n=e.peek();if(!n||n.kind!=="identifier"&&n.kind!=="keyword")return null;let r=e.mark();e.advance();let i=n.value.toLowerCase(),s=e.peek();if((n.kind==="identifier"||A.PROPERTY_ACCESS_BASES.has(i))&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value)){let m=n.value,p=[],h=0;for(;h<A.MAX_PROPERTY_DEPTH;){let x=e.peek();if(x&&x.kind==="selector"&&/^\.[a-zA-Z_]/.test(x.value))m+=`.${x.value.slice(1)}`,p.push(x.value.slice(1)),e.advance(),h++;else break}let y=e.peek(),g=!!y&&y.value.startsWith("(");if(t&&!g&&p.length>0&&ke(i))return ae(Z(i),p.join("."));if(g){let x=e.mark(),T=[],L=0,S=!1;for(;!e.isAtEnd();){let k=e.peek();if(!k)break;if(k.value==="(")L++;else if(k.value===")"){if(T.push(k.value),e.advance(),L--,L===0&&(S=!0),S)break;continue}T.push(k.value),e.advance()}S?m+=T.join(""):e.reset(x)}return{type:"expression",raw:m}}let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(r),null;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")return e.reset(r),null;e.advance();let c=`${n.value}.${l.value}`,u=1;for(;!e.isAtEnd()&&u<A.MAX_PROPERTY_DEPTH;){let m=e.peek();if(!m||m.kind!=="operator"||m.value!==".")break;e.advance();let p=e.peek();if(!p||p.kind!=="identifier")break;e.advance(),c+=`.${p.value}`,u++}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let m=[],p=0;for(;!e.isAtEnd()&&m.length<A.MAX_METHOD_ARGS;){let y=e.peek();if(!y)break;if(y.kind==="punctuation"&&y.value===")"){if(p===0){e.advance();break}p--}if(y.kind==="punctuation"&&y.value==="("&&p++,y.kind==="punctuation"&&y.value===","){e.advance();continue}m.push(y.value),e.advance()}return{type:"expression",raw:`${c}(${m.join(", ")})`}}let f=n.value.toLowerCase();if(t&&ke(f)){let m=c.split(".").slice(1).join(".");return ae(Z(f),m)}return{type:"expression",raw:c}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek(),i=this.currentProfile?.possessive?.marker?.replace(/^-/,""),s=!!r&&r.kind==="punctuation"&&r.value==="'s",a=!!r&&r.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",l=(()=>{if(!this.currentPatternCommand||(r?.normalized??"").toLowerCase()!=="source")return!1;let f=Ce[this.currentPatternCommand];return!!f&&f.roles.some(m=>m.role==="source")})(),c=!!r&&!!i&&i!=="'s"&&r.value===i&&(r.kind==="particle"||r.kind==="punctuation")&&!l;if(!s&&!c&&!a)return e.reset(n),null;e.advance(),a&&e.advance();let u=e.peek();return!u||!(u.kind==="identifier"||(s||a)&&(u.kind==="selector"||u.kind==="keyword"))?(e.reset(n),null):(e.advance(),ae(ne(t.value),u.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("."))return e.reset(n),null;let i=e.peek(1);i&&i.kind,e.advance();let s=r.value.slice(1);return ae(ne(t.value),s)}matchGroupToken(e,t,n,r){let i=e.mark(),s=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n,r)){e.reset(i);for(let l of n.keys())s.has(l)||n.delete(l);return t.optional||!1}return!0}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case"selector":return ne(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return ke(t)?Z(t):j(e.normalized||e.value);case"identifier":if(e.value.startsWith("@"))return ne(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return Z(e.value);let n=e.value.toLowerCase();return ke(n)?Z(n):{type:"expression",raw:e.value};case"url":return j(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let r=e.slice(1,-1);return j(r,"string")}if(e==="true")return j(!0,"boolean");if(e==="false")return j(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let r=parseFloat(t[1]);return t[2]?j(e,"duration"):j(r,"number")}let n=parseFloat(e);return isNaN(n)?j(e,"string"):j(n,"number")}applyExtractionRules(e,t){for(let[n,r]of Object.entries(e.extraction))t.has(n)||(r.value!==void 0?t.set(n,{type:"literal",value:r.value}):r.default&&t.set(n,r.default))}isOptional(e){return e.type!=="literal"&&e.optional===!0}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=t.value.toLowerCase();if(A.ENGLISH_NOISE_WORDS.has(n)){let r=e.mark();e.advance();let i=e.peek();if(i&&(i.kind==="selector"||i.kind==="identifier"))return;let s=e.peek(1);if(i&&i.kind==="keyword"&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value))return;let a=i?(i.normalized??i.value).toLowerCase():"";if(i&&A.POSITIONAL_OR_SCOPE_KEYWORDS.has(a))return;let l=e.peek(1),c=l?(l.normalized??l.value).toLowerCase():"",u=this.currentProfile?.wordOrder!=="SOV"&&A.COMMAND_ACTION_KEYWORDS.has(c),d=!l||l.kind==="particle"||A.CLAUSE_BOUNDARY_KEYWORDS.has(c)||u;if(i&&i.kind==="keyword"&&this.currentProfile?.code!=="en"&&ke(a)&&d||i&&i.kind==="keyword"&&this.currentProfile?.code==="en"&&ke(a))return;e.reset(r)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let r=e.peek();if(!r||r.kind!=="event-modifier")break;let i=r.metadata;if(!i)break;switch(n=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return n?t:void 0}};A.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]),A.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]),A.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]),A.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]),A.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(Ce).map(e=>e.toLowerCase())),A.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]),A.OF_POSSESSIVE_MARKERS={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin"])},A.RUN_OPERATORS=new Set(["+","-","*","/"]),A.MAX_BRACE_RUN_TOKENS=64,A.MAX_PROPERTY_DEPTH=10,A.MAX_METHOD_ARGS=20,A.DECLARATION_COMMANDS=new Set(["behavior","def","install"]),A.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Mt=A,se=new Mt;var Ii=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],it=class{constructor(e=Ii){this.name="operator";this.operators=[...e].sort((t,n)=>n.length-t.length)}canExtract(e,t){return this.operators.some(n=>e.startsWith(n,t))}extract(e,t){for(let n of this.operators)if(e.startsWith(n,t))return{value:n,length:n.length};return null}},_i="()[]{},:;",at=class{constructor(e=_i){this.punctuation=e;this.name="punctuation"}canExtract(e,t){return this.punctuation.includes(e[t])}extract(e,t){let n=e[t];return this.punctuation.includes(n)?{value:n,length:1}:null}};function Ot(o,e){let t=o[e];if(t==="#"){let n=o.slice(e).match(/^#[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="."){let n=o.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(n)return n[0];let r=o.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="@"){let n=o.slice(e).match(/^@[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="*"){let n=o.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="["){let n=0,r=e;for(;r<o.length;){if(o[r]==="["&&n++,o[r]==="]"&&(n--,n===0))return o.slice(e,r+1);r++}return null}if(t==="<"){let n=o.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return n?n[0]:null}return null}var $e=class{constructor(){this.name="css-selector"}canExtract(e,t){let n=e[t];return n==="#"||n==="."||n==="["||n==="<"?!0:n==="@"||n==="*"?Ot(e,t)!==null:!1}extract(e,t){let n=Ot(e,t);return n?{value:n,length:n.length,metadata:{type:"css-selector"}}:null}};var De=class{constructor(){this.name="event-modifier"}canExtract(e,t){if(e[t]!==".")return!1;let n=e.slice(t);return/^\.(once|prevent|stop|debounce|throttle|queue)/.test(n)}extract(e,t){let n=e.slice(t).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!n)return null;let r=n[0],i=r.slice(1).split("(")[0],s=n[1];return{value:r,length:r.length,metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}};function wn(o,e){let t=o.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let n=t.match(/^https?:\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("//")){let n=t.match(/^\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("./")||t.startsWith("../")){let n=t.match(/^\.\.?\/[^\s]*/);return n?n[0]:null}if(t.startsWith("/")){let n=t.match(/^\/[^\s]*/);return n?n[0]:null}return null}var qe=class{constructor(){this.name="url"}canExtract(e,t){let n=e.slice(t);return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("//")||n.startsWith("./")||n.startsWith("../")||n.startsWith("/")}extract(e,t){let n=wn(e,t);return n?{value:n,length:n.length,metadata:{type:"url"}}:null}};var We=class{constructor(){this.name="variable-ref"}canExtract(e,t){let n=e[t];return(n===":"||n==="$"||n==="^")&&t+1<e.length&&/[a-zA-Z_]/.test(e[t+1])}extract(e,t){if(!this.canExtract(e,t))return null;let n=1;for(;t+n<e.length&&/[a-zA-Z0-9_]/.test(e[t+n]);)n++;return{value:e.substring(t,t+n),length:n,metadata:{type:"variable-reference"}}}};function st(o){let e=o.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?!0:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(o)}var ji=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),Bi=new Set(["de","da","te","ta","den","dan","ten","tan","e","a","ye","ya","i","\u0131","u","\xFC","in","\u0131n","un","\xFCn","le","la","yle","yla"]),zt=class{constructor(){this.name="turkish-keyword"}setContext(e){this.context=e}canExtract(e,t){return st(e[t])}extract(e,t){if(!this.context)throw new Error("TurkishKeywordExtractor: context not set");let n=t,r=12;for(let f=Math.min(r,e.length-n);f>=2;f--){let m=e.slice(n,n+f);if(n+f<e.length&&st(e[n+f]))continue;let p=!0;for(let y=0;y<m.length;y++)if(!st(m[y])){p=!1;break}if(!p)continue;let h=this.context.lookupKeyword(m);if(h)return{value:m,length:f,metadata:{normalized:h.normalized!==h.native?h.normalized:void 0}};if(this.context.normalizer){let y=this.context.normalizer.normalize(m);if(y.stem!==m&&y.confidence>=.7){let g=this.context.lookupKeyword(y.stem);if(g)return{value:m,length:f,metadata:{normalized:g.normalized,stem:y.stem,stemConfidence:y.confidence}}}}}let i="",s=t;for(;s<e.length&&st(e[s]);)i+=e[s],s++;for(let f=i.length;f>=2&&!(f<i.length);f--){let m=i.substring(0,f),p=this.context.lookupKeyword(m);if(p)return{value:m,length:f,metadata:{normalized:p.normalized!==p.native?p.normalized:void 0}}}if(!i||!i)return null;if(ji.has(i.toLowerCase()))return{value:i,length:s-n,metadata:{postpositionValue:i.toLowerCase()}};if(Bi.has(i.toLowerCase()))return{value:i,length:s-n,metadata:{caseSuffixValue:i.toLowerCase()}};let a=this.context.lookupKeyword(i),l=a&&a.normalized!==a.native?a.normalized:void 0,c,u,d;if(!a&&this.context.normalizer){let f=this.context.normalizer.normalize(i);if(f.stem!==i&&f.confidence>=.7){let m=this.context.lookupKeyword(f.stem);m&&(c=m.normalized,u=f.stem,d=f.confidence)}}return{value:i,length:s-n,metadata:{normalized:l||c,stem:u,stemConfidence:d}}}};function Tn(){return new zt}function En(){return[new qe,new De,new We,new $e]}function $i(o){let e=o.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?!0:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(o)}function Di(o){for(let e of o)if($i(e))return!0;return!1}function Vt(o){return"a\u0131ouAIOU".includes(o)}function Ln(o){return"ei\xF6\xFCE\u0130\xD6\xDC".includes(o)}function Cn(o){return Vt(o)||Ln(o)}function qi(o){for(let e=o.length-1;e>=0;e--)if(Cn(o[e]))return o[e];return null}function Wi(o,e){let t=qi(o);if(!t)return!0;let n=e.split("").find(r=>Cn(r));return n?Vt(t)?Vt(n):Ln(n):!0}var Ki=[{pattern:"iyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"uyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"iyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"eceksiniz",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaks\u0131n\u0131z",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"eceksin",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaks\u0131n",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"ece\u011Fiz",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"aca\u011F\u0131z",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"ece\u011Fim",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"aca\u011F\u0131m",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"ecekler",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaklar",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"mi\u015Fsiniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Fs\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fs\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fsunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fsin",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Fs\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fs\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fsun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fiz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Flar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Flar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"diniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tiniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"diler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131lar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dular",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tiler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131lar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tular",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"din",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tin",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131k",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"duk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131k",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tuk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"dum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"iyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"uyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"ecek",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"acak",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"mi\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mu\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"di",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\u0131",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\xFC",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"du",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"ti",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\u0131",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\xFC",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tu",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mek",confidence:.88,conjugationType:"dictionary",minStemLength:2},{pattern:"mak",confidence:.88,conjugationType:"dictionary",minStemLength:2},{pattern:"eyelim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"ayal\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"eyim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"ay\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"elim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"al\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"melisiniz",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131s\u0131n\u0131z",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"melisin",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131s\u0131n",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meliyiz",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131y\u0131z",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meliyim",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131y\u0131m",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"meliler",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131lar",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meli",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"ebiliyor",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"abiliyor",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"ebilir",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"abilir",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"ebildi",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"abildi",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"ebilmek",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"abilmek",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"iniz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"\u0131n\u0131z",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"\xFCn\xFCz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"unuz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"in",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"\u0131n",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"\xFCn",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"un",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"ildi",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\u0131ld\u0131",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\xFCld\xFC",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"uldu",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ilir",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\u0131l\u0131r",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\xFCl\xFCr",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ulur",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"tirmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"t\u0131rmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"t\xFCrmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"turmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"dirmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"d\u0131rmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"d\xFCrmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"durmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"miyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"muyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"miyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"muyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"medi",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"mad\u0131",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"me",confidence:.75,conjugationType:"negative",minStemLength:3},{pattern:"ma",confidence:.75,conjugationType:"negative",minStemLength:3}],Ke=class{constructor(){this.language="tr"}isNormalizable(e){return!(!Di(e)||e.length<3)}normalize(e){let t=e.toLowerCase();for(let n of Ki)if(t.endsWith(n.pattern)){let r=t.slice(0,-n.pattern.length),i=n.minStemLength??2;if(r.length<i)continue;if(!Wi(r,n.pattern)){let a=n.confidence*.9,l={removedSuffixes:[n.pattern]};return n.conjugationType&&(l.conjugationType=n.conjugationType),ot(r,a,l)}let s={removedSuffixes:[n.pattern]};return n.conjugationType&&(s.conjugationType=n.conjugationType),ot(r,n.confidence,s)}return Pt(e)}},Ks=new Ke;var Fi=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","boyunca"]),Ui=new Set(["de","da","te","ta","den","dan","ten","tan","e","a","ye","ya","i","\u0131","u","\xFC","in","\u0131n","un","\xFCn","le","la","yle","yla"]),Hi=[{native:"do\u011Fru",normalized:"true"},{native:"dogru",normalized:"true"},{native:"yanl\u0131\u015F",normalized:"false"},{native:"yanlis",normalized:"false"},{native:"null",normalized:"null"},{native:"bo\u015F",normalized:"null"},{native:"bos",normalized:"null"},{native:"tan\u0131ms\u0131z",normalized:"undefined"},{native:"tanimsiz",normalized:"undefined"},{native:"ilk",normalized:"first"},{native:"son",normalized:"last"},{native:"sonuncu",normalized:"last"},{native:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"enyak\u0131n",normalized:"closest"},{native:"enyakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{native:"farebas",normalized:"mousedown"},{native:"fareb\u0131rak",normalized:"mouseup"},{native:"farebirak",normalized:"mouseup"},{native:"kayd\u0131r",normalized:"scroll"},{native:"kaydir",normalized:"scroll"},{native:"tu\u015F_bas",normalized:"keydown"},{native:"tus_bas",normalized:"keydown"},{native:"tu\u015F_b\u0131rak",normalized:"keyup"},{native:"tus_birak",normalized:"keyup"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"}],It=class extends _e{constructor(){super();this.language="tr";this.direction="ltr";this.initializeKeywordsFromProfile(ve,Hi),this.setNormalizer(new Ke),this.registerExtractors(En()),this.registerExtractor(new Ct),this.registerExtractor(new Nt),this.registerExtractor(Tn()),this.registerExtractor(new it),this.registerExtractor(new at)}classifyToken(t){let n=t.toLowerCase();return Fi.has(n)||Ui.has(n)?"particle":this.isKeyword(n)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":"identifier"}},lt=new It;function G(o,e){return en(o,e)}function ct(){return xt()}var dt=["if","unless","repeat","for","while"];function le(o,e){let t=new Set([e]),r=I(o)?.keywords?.[e];if(r){r.primary&&t.add(r.primary.toLowerCase());for(let i of r.alternatives??[])t.add(i.toLowerCase())}return t}function te(o,e){return e.has(o.value.toLowerCase())?!0:o.normalized?e.has(o.normalized.toLowerCase()):!1}var Yi=new Set(dt);function jt(o,e){let t=o.normalized?.toLowerCase();return t?Yi.has(t):e.some(n=>te(o,n))}var Nn=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Zi=new Set(["destination","source","style","patient","on","from","to"]);function Ji(o){if(!o||o.kind==="selector")return!1;let e=(o.normalized??o.value).toLowerCase(),t=o.value.toLowerCase();return!(Nn.has(e)||Nn.has(t)||Zi.has(e))}var Pn=new Set(["ja","ko"]);function _t(o){let e=new Set;o?.primary&&e.add(o.primary.toLowerCase());for(let t of o?.alternatives??[])e.add(t.toLowerCase());return e}function An(o,e){let t=[],n=e.position.end,r=o.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(r){n=e.position.end+r[0].length;for(let i of r[1].split(/[,،、]/)){let s=i.trim();s&&t.push(s)}}return{parameters:t,headerEnd:n}}function Mn(o,e,t){let n=e+1;if(n>=o.length)return-1;let r=_t(I(t)?.roleMarkers?.patient);return r.size>0&&te(o[n],r)&&n++,n<o.length?n:-1}function On(o,e,t){if(!I(e))return null;let n=le(e,"behavior"),r=le(e,"def"),i=o.toLowerCase(),s=[...n].some(u=>i.includes(u)),a=/\bdef\b/.test(i)||[...r].some(u=>u!=="def"&&i.includes(u));if(!s&&!a)return null;let l=G(o,e).tokens;if(l.length<2)return null;if(te(l[0],n))return Rn(o,e,l,t,0);let c=l.findIndex((u,d)=>d>0&&te(u,n));return c>0&&/^[A-Z][A-Za-z0-9_]*$/.test(l[0].value)?Rn(o,e,l,t,c):te(l[0],r)?Xi(o,e,l,t):null}function zn(o,e,t){let n=I(e);if(!n)return null;let r=n.wordOrder!=="SOV",i=Pn.has(e)?_t(n.roleMarkers?.event):new Set,s=Pn.has(e)?_t(n.keywords?.on):new Set,a=i.size>0&&s.size>0,l=le(e,"end"),c=le(e,"on"),u=o.toLowerCase(),d=[...l].some(k=>u.includes(k)),f=(r||a)&&(()=>{let k=0;for(let E of c)if(E){for(let v=u.indexOf(E);v>=0;v=u.indexOf(E,v+E.length))if(++k>=2)return!0}return!1})();if(!d&&!f)return null;let m=G(o,e).tokens;if(m.length<2)return null;let p=dt.map(k=>le(e,k)),h=k=>jt(k,p),y=k=>te(k,l),g=[],x=0,T=0;for(let k=0;k<m.length;k++){let E=m[k];if(y(E)){if(x>0){x--;continue}let v=o.slice(m[T].position.start,E.position.start).trim();v&&g.push(v),T=k+1}else if(h(E))x++;else if(r&&x===0&&k>T&&te(E,c)&&Ji(m[k+1])){let v=o.slice(m[T].position.start,E.position.start).trim();v&&g.push(v),T=k}else if(a&&x===0&&k-1>T&&te(E,i)&&m[k+1]!==void 0&&te(m[k+1],s)){let v=m[k-1],b=o.slice(m[T].position.start,v.position.start).trim();b&&g.push(b),T=k-1}}if(T<m.length){let k=o.slice(m[T].position.start).trim();k&&g.push(k)}if(g.length<2)return null;let L=[],S=[];for(let k of g){let E;try{E=t.statement(k,e)}catch{return null}if(!E||E.kind!=="event-handler")return null;let v=E;L.push(v);let b=!v.body||v.body.length===0;S.push(b?.2:v.metadata?.confidence??.75)}return je(L,"then",{sourceLanguage:e,confidence:ut(S),sourceText:o})}function ut(o){return o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0}function Vn(o){let e=[];for(let t of o){let n=t.statements;t.kind==="compound"&&Array.isArray(n)?e.push(...n):e.push(t)}return e}function Rn(o,e,t,n,r){let i=r>0,s=i?0:Mn(t,r,e);if(s<0)return null;let a=t[s],l=a.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(l))return null;let{parameters:c,headerEnd:u}=An(o,a),d=i?r+1:t.findIndex(v=>v.position.start>=u);d<=s&&(d=s+1);let f=le(e,"init"),m=le(e,"end"),p=dt.map(v=>le(e,v)),h=v=>jt(v,p),y=v=>te(v,m),g=[],x=[],T=[],L=!1,S=0,k=d;for(let v=d;v<t.length;v++){let b=t[v];if(y(b)){if(S>0){S--;continue}if(v===k){L=!0;break}if(te(t[k],f)){let N=o.slice(t[k].position.end,b.position.start).trim();if(N)try{let C=Vn(n.body(N,e));x.push(...C),T.push(ut(C.map(z=>z.metadata?.confidence??.75)))}catch{T.push(0)}}else{let N=o.slice(t[k].position.start,b.position.start).trim();try{let C=n.statement(N,e);if(C&&C.kind==="event-handler"){let z=C;g.push(z);let M=!z.body||z.body.length===0;T.push(M?.2:z.metadata?.confidence??.75)}else T.push(0)}catch{T.push(0)}}k=v+1}else h(b)&&S++}if(g.length===0&&x.length===0)return null;let E=(L?1:.8)*ut(T);return hn(l,c,g,x.length>0?x:void 0,{sourceLanguage:e,confidence:E,sourceText:o})}function Xi(o,e,t,n){let r=Mn(t,0,e);if(r<0)return null;let i=t[r],s=i.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(s))return null;let{parameters:a,headerEnd:l}=An(o,i),c=t.findIndex(S=>S.position.start>=l);c<=r&&(c=r+1);let u=le(e,"end"),d=dt.map(S=>le(e,S)),f=S=>jt(S,d),m=S=>te(S,u),p=0,h=-1;for(let S=c;S<t.length;S++)if(m(t[S])){if(p===0){h=S;break}p--}else f(t[S])&&p++;let y=t[c]?.position.start??l,g=h>=0?t[h].position.start:o.length,x=o.slice(y,g).trim();if(!x)return null;let T;try{T=Vn(n.body(x,e))}catch{return null}if(T.length===0)return null;let L=ut(T.map(S=>S.metadata?.confidence??.75));return h<0&&(L*=.8),yn(s,a,T,{sourceLanguage:e,confidence:L,sourceText:o})}var Se={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Qi=Object.fromEntries(Object.entries(Se).map(([o,e])=>{let t={};for(let[n,r]of Object.entries(e))r in t||(t[r]=n);return[o,t]})),ea={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function In(o,e){return ea[e]?.has(o)?o:Qi[e]?.[o]??o}var pt=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);if(e.kind==="behavior")return this.renderBehavior(e,t);if(e.kind==="def")return this.renderDef(e,t);let n=wt(t,e.action);if(n.length===0)return this.renderExplicit(e);let r=this.findBestPattern(e,n);return r?this.renderWithPattern(e,r):this.renderExplicit(e)}renderCompound(e,t){if(e.statements.length>1&&e.statements.every(i=>i.kind==="event-handler")){let i=this.keyword(t,"end"),s=[];for(let a of e.statements)s.push(this.render(a,t),i);return s.join(`
1
+ "use strict";var LokaScriptSemanticTr=(()=>{var ht=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var Kn=Object.prototype.hasOwnProperty;var Fn=(o,e)=>{for(var t in e)ht(o,t,{get:e[t],enumerable:!0})},Un=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wn(e))!Kn.call(o,r)&&r!==t&&ht(o,r,{get:()=>e[r],enumerable:!(n=qn(e,r))||n.enumerable});return o};var Hn=o=>Un(ht({},"__esModule",{value:!0}),o);var ua={};Fn(ua,{ASTBuilder:()=>Oe,DEFAULT_CONFIDENCE_THRESHOLD:()=>Ft,HIGH_CONFIDENCE_THRESHOLD:()=>Ut,VERSION:()=>ia,buildAST:()=>Yt,canParse:()=>$t,createCommandNode:()=>H,createEventHandler:()=>me,createLiteral:()=>j,createPropertyPath:()=>ae,createReference:()=>Z,createSelector:()=>ne,fromExplicit:()=>Wt,getCommandMapper:()=>Me,getPatternsForLanguage:()=>Dn,getPatternsForLanguageAndCommand:()=>ca,getProfile:()=>Ze,getSupportedLanguages:()=>sa,getTokenizer:()=>Ye,isExplicitSyntax:()=>de,isLanguageSupported:()=>bt,parse:()=>Ae,parseAny:()=>Kt,parseExplicit:()=>Ne,registerCommandMapper:()=>vt,render:()=>Fe,renderExplicit:()=>Ue,toExplicit:()=>qt,tokenize:()=>la,turkishProfile:()=>ve,turkishTokenizer:()=>lt});var Ft=.5,Ut=.8;var Gn=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),Yn=new Set(["and","or","not","no"]),Zn=new Set(["true","false","null","undefined"]),Jn=new Set(["is","matches","match","contains","in"]),Xn=new Set(["next","previous","closest","first","last"]),Qn=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Ht(o){let e=[],t=0,n=1,r=1;function i(){if(e.length===0)return!0;let p=e[e.length-1];return p.type==="IDENTIFIER"&&Jn.has(p.value.toLowerCase())||p.type==="IDENTIFIER"&&Xn.has(p.value.toLowerCase())?!0:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(p.type)}function s(p=0){return o[t+p]??""}function a(){let p=o[t];return t++,p===`
2
+ `?(n++,r=1):r++,p}function l(){for(;t<o.length&&/\s/.test(o[t]);)a()}function c(p){let h="";for(;t<o.length&&p(o[t]);)h+=a();return h}function u(p){let h=p;for(a();t<o.length&&o[t]!==p;)o[t]==="\\"&&t+1<o.length&&(h+=a()),h+=a();return t<o.length&&(h+=a()),h}function d(){let p="`";for(a();t<o.length&&o[t]!=="`";)o[t]==="\\"&&t+1<o.length&&(p+=a()),p+=a();return t<o.length&&(p+=a()),p}function f(){let p="<";for(a();t<o.length&&(p+=a(),!p.endsWith("/>")););return p}function m(p,h,y){return{type:p,value:h,start:y,end:t,line:n,column:r-h.length}}for(;t<o.length&&(l(),!(t>=o.length));){let p=t,h=s();if(h==="'"&&s(1)==="s"&&!/\w/.test(s(2))){a(),a(),e.push(m("POSSESSIVE","'s",p));continue}if(h==='"'||h==="'"){let y=u(h);e.push(m("STRING",y,p));continue}if(h==="`"){let y=d();e.push(m("TEMPLATE_LITERAL",y,p));continue}if(h==="<"&&/[a-zA-Z.#\[]/.test(s(1))){let y=f();e.push(m("QUERY_SELECTOR",y,p));continue}if(h==="#"&&i()){a();let y=c(g=>/[\w-]/.test(g));e.push(m("ID_SELECTOR","#"+y,p));continue}if(h==="."&&/[a-zA-Z_-]/.test(s(1))&&i()){a();let y=c(g=>/[\w-]/.test(g));e.push(m("CLASS_SELECTOR","."+y,p));continue}if(h==="@"&&/[a-zA-Z_]/.test(s(1))){a();let y=c(g=>/[\w-]/.test(g));e.push(m("ATTRIBUTE_REF","@"+y,p));continue}if(h==="["&&i()){let y=s(1);if(y==="@"||/[a-zA-Z]/.test(y)){let g="";for(g+=a();t<o.length&&o[t]!=="]";)o[t]==='"'||o[t]==="'"?g+=u(o[t]):g+=a();t<o.length&&(g+=a()),e.push(m("ATTRIBUTE_SELECTOR",g,p));continue}}if(h==="["){a(),e.push(m("LBRACKET","[",p));continue}if(h==="]"){a(),e.push(m("RBRACKET","]",p));continue}if(/\d/.test(h)){let y=c(T=>/[\d.]/.test(T)),g=t,x=c(T=>/[a-zA-Z]/.test(T));Qn.has(x)?e.push(m("TIME_EXPRESSION",y+x,p)):(t=g,e.push(m("NUMBER",y,p)));continue}if(h==="("){a(),e.push(m("LPAREN","(",p));continue}if(h===")"){a(),e.push(m("RPAREN",")",p));continue}if(h==="{"){a(),e.push(m("LBRACE","{",p));continue}if(h==="}"){a(),e.push(m("RBRACE","}",p));continue}if(h===","){a(),e.push(m("COMMA",",",p));continue}if(h===":"){a(),e.push(m("COLON",":",p));continue}if(h==="."){a(),e.push(m("DOT",".",p));continue}if(h==="+"||h==="-"||h==="*"||h==="/"||h==="%"){a(),e.push(m("OPERATOR",h,p));continue}if(h==="="||h==="!"||h==="<"||h===">"){let y=a();s()==="="&&(y+=a()),e.push(m("COMPARISON",y,p));continue}if(/[a-zA-Z_$]/.test(h)){let y=c(x=>/[\w$]/.test(x)),g=y.toLowerCase();Gn.has(g)?e.push(m("CONTEXT_VAR",y,p)):Yn.has(g)?e.push(m("LOGICAL",y,p)):Zn.has(g)?e.push(m("BOOLEAN",y,p)):e.push(m("IDENTIFIER",y,p));continue}a()}return e.push(m("EOF","",t)),e}var er=new Set(["my","its","your"]),tr=new Set(["is","matches","match","contains","in","exists","does"]),nr=new Set(["next","previous","closest","first","last"]),Ge=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=Ht(e),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(e){return this.tokens[this.current+e]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(e){return this.peek().type===e}checkValue(e){return this.peek().value.toLowerCase()===e.toLowerCase()}match(...e){for(let t of e)if(this.check(t))return this.advance(),!0;return!1}parseExpression(){return this.parseOr()}parseOr(){let e=this.parseAnd();for(;this.checkValue("or");){let t=this.advance().value,n=this.parseAnd();e=this.createBinaryExpression(t,e,n)}return e}parseAnd(){let e=this.parseEquality();for(;this.checkValue("and");){let t=this.advance().value,n=this.parseEquality();e=this.createBinaryExpression(t,e,n)}return e}parseEquality(){let e=this.parseComparison();for(;;){let t;if(this.match("COMPARISON"))t=this.previous().value;else if(this.checkValue("is")||this.checkValue("matches")||this.checkValue("match")||this.checkValue("contains")||this.checkValue("in")){let r=this.advance().value;t=r.toLowerCase()==="match"?"matches":r}else break;if(t.toLowerCase()==="is"){if(this.checkValue("empty")){this.advance(),e=this.createPostfixUnary("is empty",e);continue}if(this.checkValue("not")&&this.peekAt(1).value.toLowerCase()==="empty"){this.advance(),this.advance(),e=this.createPostfixUnary("is not empty",e);continue}}let n=this.parseComparison();e=this.createBinaryExpression(t,e,n)}return e}parseComparison(){let e=this.parseAddition();for(;this.check("COMPARISON");){let t=this.advance().value,n=this.parseAddition();e=this.createBinaryExpression(t,e,n)}return e}parseAddition(){let e=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let t=this.advance().value,n=this.parseMultiplication();e=this.createBinaryExpression(t,e,n)}return e}parseMultiplication(){let e=this.parseUnary();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%";){let t=this.advance().value,n=this.parseUnary();e=this.createBinaryExpression(t,e,n)}return e}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let e=this.advance().value,t=this.parseUnary();return this.createUnaryExpression(e,t)}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let t=this.advance().value;e=this.createPossessiveExpression(e,t)}else break;else if(this.match("LPAREN")){let t=this.parseArguments();e=this.createCallExpression(e,t)}else if(this.match("LBRACKET")){let t=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");e=this.createPropertyAccess(e,t)}else if(e.type==="contextReference"&&er.has(e.contextType??"")&&this.check("IDENTIFIER")&&!tr.has(this.peek().value.toLowerCase())){let t=this.advance().value;e=this.createPropertyAccess(e,t)}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),e=this.createPostfixUnary("exists",e);else break;return e}parsePrimary(){let e=this.peek();if(this.match("NUMBER"))return this.createLiteral(parseFloat(e.value),"number",e);if(this.match("STRING")){let t=e.value.slice(1,-1);return this.createLiteral(t,"string",e)}if(this.match("BOOLEAN")){let t=e.value==="true"?!0:e.value==="false"?!1:e.value==="null"?null:void 0,n={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(t,n[e.value]??"string",e)}if(this.match("TEMPLATE_LITERAL"))return{type:"templateLiteral",value:e.value,start:e.start,end:e.end,line:e.line,column:e.column};if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(e);if(this.match("ID_SELECTOR"))return this.createSelector(e.value,"id",e);if(this.match("CLASS_SELECTOR"))return this.createSelector(e.value,"class",e);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(e.value,"attribute",e);if(this.match("ATTRIBUTE_REF"))return{type:"attributeAccess",attributeName:e.value.slice(1),start:e.start,end:e.end};if(this.match("QUERY_SELECTOR")){let t=e.value.slice(1,-2);return this.createSelector(t,"query",e)}if(this.match("CONTEXT_VAR"))return this.createContextReference(e.value,e);if(this.match("IDENTIFIER")){if(nr.has(e.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let t=this.advance(),n=t.type==="QUERY_SELECTOR"?t.value.slice(1,-2):t.value,r=t.type==="CLASS_SELECTOR"?"class":t.type==="ID_SELECTOR"?"id":"query";return{type:"callExpression",callee:this.createIdentifier(e.value,e),arguments:[this.createSelector(n,r,t)],start:e.start,end:t.end}}return this.createIdentifier(e.value,e)}if(this.match("LPAREN")){let t=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return t}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${e.value}`)}parseArguments(){let e=[];if(!this.check("RPAREN"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return e}parseArrayLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACKET"))do e.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return{type:"arrayLiteral",elements:e,start:t,end:this.previous().end}}parseObjectLiteral(){let e=[],t=this.previous().start;if(!this.check("RBRACE"))do{let n;if(this.check("STRING"))n=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER"))n=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let r=this.parseExpression();e.push({key:n,value:r})}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return{type:"objectLiteral",properties:e.map(n=>({type:"objectProperty",key:n.key,value:n.value})),start:t,end:this.previous().end}}parseTimeExpression(e){let t=e.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!t)throw new Error(`Invalid time expression: ${e.value}`);let n=parseFloat(t[1]),r=t[2].toLowerCase();return{type:"timeExpression",value:n,unit:r,raw:e.value,start:e.start,end:e.end,line:e.line,column:e.column}}createLiteral(e,t,n){return{type:"literal",value:e,dataType:t,raw:n.value,start:n.start,end:n.end,line:n.line,column:n.column}}createSelector(e,t,n){return{type:"selector",value:e,selector:e,selectorType:t,start:n.start,end:n.end,line:n.line,column:n.column}}createContextReference(e,t){return{type:"contextReference",contextType:e,name:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createIdentifier(e,t){return{type:"identifier",name:e,start:t.start,end:t.end,line:t.line,column:t.column}}createPropertyAccess(e,t){return{type:"propertyAccess",object:e,property:typeof t=="string"?t:t.type==="identifier"?t.name:"",start:e.start,end:this.previous().end}}createPossessiveExpression(e,t){return{type:"possessiveExpression",object:e,property:t,start:e.start,end:this.previous().end}}createBinaryExpression(e,t,n){return{type:"binaryExpression",operator:e,left:t,right:n,start:t.start,end:n.end}}createUnaryExpression(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!0,start:this.previous().start,end:t.end}}createPostfixUnary(e,t){return{type:"unaryExpression",operator:e,operand:t,prefix:!1,start:t.start,end:this.previous().end}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function yt(o){return new Ge().parse(o)}function Y(o,e){switch(o.type){case"literal":return rr(o);case"selector":return or(o,e);case"reference":return ir(o);case"property-path":return ar(o,e);case"expression":return sr(o);case"flag":return{type:"literal",value:o.enabled};default:let t=o;throw new Error(`Unknown semantic value type: ${t.type}`)}}function rr(o){let e={type:"literal",value:o.value};return o.dataType?{...e,dataType:o.dataType}:e}function or(o,e){return o.value.startsWith("@")&&/^[a-zA-Z_]/.test(o.value.slice(1))?{type:"attributeAccess",attributeName:o.value.slice(1)}:(e&&o.value.startsWith("*")&&/^[a-zA-Z-]/.test(o.value.slice(1))&&e.push(`Converted '${o.value}' to a CSS selector, but it looks like a CSS property name. CSS properties in commands like 'transition' should be literal strings, not selectors. Consider using expectedTypes: ['literal'] instead of ['literal', 'selector'] in the command schema.`),o.value.startsWith("<")?{type:"selector",value:o.value,selector:o.value,selectorType:o.selectorKind,raw:o.value}:{type:"selector",value:o.value,selector:o.value,selectorType:o.selectorKind})}function ir(o){return{type:"contextReference",contextType:o.value,name:o.value}}function ar(o,e){return{type:"propertyAccess",object:Y(o.object,e),property:o.property}}function sr(o){let e=yt(o.raw);return!e.success||!e.node?{type:"identifier",name:o.raw}:e.node}function gt(o,e){return o.roles.get(e)}function w(o,e,t){let n=gt(o,e);return n?Y(n,t):void 0}function P(o,e=[],t,n={}){let r={type:"command",name:o,args:e};return t&&Object.keys(t).length>0&&(r.modifiers=t),n.isBlocking&&(r.isBlocking=n.isBlocking),n.implicitTarget&&(r.implicitTarget=n.implicitTarget),n.semanticRoles&&Object.keys(n.semanticRoles).length>0&&(r.semanticRoles=n.semanticRoles),r}var lr={action:"toggle",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=w(o,"duration"),i=t?[t]:[],s={};return n&&(s.on=n),r&&(s.for=r),P("toggle",i,s)}},cr={action:"add",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("add",r,i)}},ur={action:"remove",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("remove",r,i)}},dr={action:"set",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"scope"),i=[],s={};return t&&i.push(t),n&&(s.to=n),r&&(s.on=r),P("set",i,s)}},pr={action:"show",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"duration"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.with=r),P("show",i,s)}},mr={action:"hide",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"duration"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.with=r),P("hide",i,s)}},fr={action:"increment",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"quantity"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.by=r),P("increment",i,s)}},hr={action:"decrement",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=w(o,"quantity"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.by=r),P("decrement",i,s)}},yr={action:"wait",toAST(o,e){let t=w(o,"event");if(t){let i={for:t},s=w(o,"source");return s&&(i.from=s),P("wait",[],i,{isBlocking:!0})}let n=w(o,"duration");return P("wait",n?[n]:[],void 0,{isBlocking:!0})}},gr={action:"log",toAST(o,e){let t=w(o,"patient"),n=[];return t&&n.push(t),P("log",n)}},vr={action:"put",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=gt(o,"manner")??gt(o,"method"),i=t?[t]:[],s={};if(n){let a=r?.type==="literal"?String(r.value):"into";s[a]=n}return P("put",i,s)}},kr={action:"fetch",toAST(o,e){let t=w(o,"source"),n=w(o,"method"),r=w(o,"responseType"),i=w(o,"patient"),s=t?[t]:[],a={};return n&&(a.with=n),r&&(a.as=r),i&&(a.body=i),P("fetch",s,a,{isBlocking:!0})}},Sr={action:"append",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("append",r,i)}},xr={action:"prepend",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.to=n),P("prepend",r,i)}},br={action:"trigger",toAST(o,e){let t=w(o,"event"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.on=n),P("trigger",r,i)}},wr={action:"send",toAST(o,e){let t=w(o,"event"),n=w(o,"destination"),r=w(o,"patient"),i=t?[t]:[],s={};return n&&(s.to=n),r&&(s.detail=r),P("send",i,s)}},Tr={action:"go",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=[],i={};return t&&r.push(t),n&&(i.to=n),P("go",r,i)}},Er={action:"transition",toAST(o,e){let t=w(o,"patient"),n=w(o,"goal"),r=w(o,"duration"),i=w(o,"destination"),s=t?[t]:[],a={};return n&&(a.to=n),r&&(a.over=r),i&&(a.on=i),P("transition",s,a)}},Lr={action:"focus",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i={},s=t??n;return s&&r.push(s),P("focus",r,i)}},Cr={action:"blur",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("blur",r)}},Nr={action:"get",toAST(o,e){let t=w(o,"source"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("get",r)}},Pr={action:"take",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("take",r,i)}},Rr={action:"call",toAST(o,e){let t=w(o,"patient");return P("call",t?[t]:[])}},Ar={action:"return",toAST(o,e){let t=w(o,"patient");return P("return",t?[t]:[])}},Mr={action:"halt",toAST(o,e){let t=o.roles.get("patient");return t?P("halt",[Y(t)]):P("halt",[])}},Or={action:"throw",toAST(o,e){let t=w(o,"patient");return P("throw",t?[t]:[])}},zr={action:"settle",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("settle",r,void 0,{isBlocking:!0})}},Vr={action:"swap",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=w(o,"destination"),i=w(o,"style"),s=[],a={};return t&&s.push(t),n&&s.push(n),r&&(a.on=r),i&&(a.with=i),P("swap",s,a)}},Ir={action:"morph",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=w(o,"patient"),i=[],s={},a=t??n;return a&&i.push(a),r&&(s.on=r),P("morph",i,s)}},_r={action:"clone",toAST(o,e){let t=w(o,"source"),n=w(o,"destination"),r=w(o,"patient"),i=[],s={},a=t??r;return a&&i.push(a),n&&(s.into=n),P("clone",i,s)}},jr={action:"make",toAST(o,e){let t=w(o,"patient");return P("make",t?[t]:[])}},Br={action:"measure",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=w(o,"source"),i=[],s={};t&&i.push(t);let a=n??r;return a&&(s.of=a),P("measure",i,s)}},Dr={action:"tell",toAST(o,e){let t=w(o,"destination"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("tell",r)}},$r={action:"js",toAST(o,e){let t=w(o,"patient");return P("js",t?[t]:[])}},qr={action:"async",toAST(o,e){return P("async",[])}},Wr={action:"if",toAST(o,e){let t=w(o,"condition");return P("if",t?[t]:[])}},Kr={action:"unless",toAST(o,e){let t=w(o,"condition");return P("unless",t?[t]:[])}},Fr={action:"repeat",toAST(o,e){let t=w(o,"quantity"),n=w(o,"patient"),r=[],i=t??n;return i&&r.push(i),P("repeat",r)}},Ur={action:"for",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.in=n),P("for",r,i)}},Hr={action:"while",toAST(o,e){let t=w(o,"condition");return P("while",t?[t]:[])}},Gr={action:"continue",toAST(o,e){return P("continue",[])}},Yr={action:"default",toAST(o,e){let t=w(o,"patient"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.to=n),P("default",r,i)}},Zr={action:"init",toAST(o,e){return P("init",[])}},Jr={action:"behavior",toAST(o,e){let t=w(o,"patient");return P("behavior",t?[t]:[])}},Xr={action:"install",toAST(o,e){let t=w(o,"patient"),n=w(o,"destination"),r=t?[t]:[],i={};return n&&(i.on=n),P("install",r,i)}},Qr={action:"on",toAST(o,e){let t=w(o,"event"),n=w(o,"source"),r=t?[t]:[],i={};return n&&(i.from=n),P("on",r,i)}},Gt=new Map([["toggle",lr],["add",cr],["remove",ur],["set",dr],["show",pr],["hide",mr],["increment",fr],["decrement",hr],["wait",yr],["log",gr],["put",vr],["fetch",kr],["append",Sr],["prepend",xr],["get",Nr],["take",Pr],["trigger",br],["send",wr],["on",Qr],["go",Tr],["transition",Er],["focus",Lr],["blur",Cr],["call",Rr],["return",Ar],["halt",Mr],["throw",Or],["settle",zr],["swap",Vr],["morph",Ir],["clone",_r],["measure",Br],["make",jr],["tell",Dr],["default",Yr],["js",$r],["async",qr],["if",Wr],["unless",Kr],["repeat",Fr],["for",Ur],["while",Hr],["continue",Gr],["init",Zr],["behavior",Jr],["install",Xr]]);function Me(o){return Gt.get(o)}function vt(o){Gt.set(o.action,o)}var Oe=class{constructor(e={}){this.warnings=[]}build(e){switch(e.kind){case"command":return this.buildCommand(e);case"event-handler":return this.buildEventHandler(e);case"conditional":return this.buildConditional(e);case"compound":return this.buildCompound(e);case"loop":return this.buildLoop(e);case"behavior":return this.buildBehavior(e);case"def":return this.buildDef(e);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildBehavior(e){let t=e.eventHandlers.map(r=>this.buildEventHandler(r)),n={type:"behavior",name:e.name,parameters:[...e.parameters],eventHandlers:t};return e.initBlock&&e.initBlock.length>0&&(n.initBlock={type:"initBlock",commands:e.initBlock.map(r=>this.build(r))}),n}buildDef(e){return{type:"def",name:e.name,params:[...e.parameters],body:e.body.map(t=>this.build(t))}}buildCommand(e){let t=Me(e.action),n;if(t){let r=t.toAST(e,this);if("ast"in r&&"warnings"in r){let i=r;this.warnings.push(...i.warnings),n=i.ast}else n=r}else n=this.buildGenericCommand(e);if(e.roles&&e.roles.size>0){let r={};for(let[i,s]of e.roles)r[i]=Y(s);Object.keys(r).length>0&&(n.semanticRoles=r)}return n}buildGenericCommand(e){let t=[],n={},r=["patient","source","quantity"],i=["destination","duration","method","style"];for(let a of r){let l=e.roles.get(a);l&&t.push(Y(l))}for(let a of i){let l=e.roles.get(a);if(l){let c=this.roleToModifierKey(a);n[c]=Y(l)}}let s={type:"command",name:e.action,args:t};return Object.keys(n).length>0?{...s,modifiers:n}:s}roleToModifierKey(e){return{destination:"on",duration:"for",source:"from",condition:"if",method:"via",style:"with"}[e]??e}buildEventHandler(e){let t=e.roles.get("event"),n="click",r,i=t?.type==="literal"?String(t.value):t?.type==="expression"?t.raw:t?.type==="reference"?t.value:void 0;i!==void 0&&(i.includes("|")||i.includes(" or ")?(r=i.split(/\s+or\s+|\|/).map(g=>g.trim()),n=r[0]):n=i);let s=e.body.map(g=>this.build(g)),a=e.roles.get("source"),l,c;a?.type==="selector"?(l=a.value,c=a.value):a?.type==="reference"?c=a.value:a?.type==="literal"&&(c=String(a.value));let u=e.roles.get("condition"),d=u?Y(u):void 0,f=e.roles.get("destination"),m=f?Y(f):void 0,p=e.eventModifiers,h=l;if(p?.from){let g=p.from;g.type==="selector"&&!l&&(h=g.value)}let y=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:n,commands:s,...r&&r.length>1?{events:r}:{},...h?{selector:h}:{},...c?{target:c}:{},...d?{condition:d}:{},...m?{watchTarget:m}:{},...y&&y.length>0?{args:y,params:y}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let n=Y(t),r=e.thenBranch.map(a=>this.build(a)),i=e.elseBranch?.map(a=>this.build(a)),s=[n,{type:"block",commands:r}];return i&&i.length>0&&s.push({type:"block",commands:i}),{type:"command",name:"if",args:s}}buildCompound(e){let t=e.statements.map(r=>this.build(r));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:t.every(r=>r.type==="eventHandler")?{type:"Program",statements:t}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(r=>this.build(r)),n=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let r=e.roles.get("quantity");r&&n.push(Y(r));break}case"for":{e.loopVariable&&n.push({type:"string",value:e.loopVariable});let r=e.roles.get("source");r&&n.push(Y(r));break}case"while":case"until":{let r=e.roles.get("condition");r&&n.push(Y(r));break}case"forever":break}return n.push({type:"block",commands:t}),{type:"command",name:"repeat",args:n}}buildBlock(e){return{type:"block",commands:e.map(n=>this.build(n))}}};function Yt(o){let e=new Oe;return{ast:e.build(o),warnings:e.warnings}}var ye=new Map,ge=new Map,ze=new Map;var Zt=null;function Xt(o,e){let t={...o};for(let n of Object.keys(e)){let r=e[n],i=o[n];r!==void 0&&(typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?t[n]=Xt(i,r):t[n]=r)}return t}function Qt(o,e){return Xt(o,e)}function kt(o){if(!o.extends)return o;let e=ge.get(o.extends);if(!e)return console.warn(`[Registry] Profile '${o.code}' extends '${o.extends}' but base is not registered. Make sure to import the base language before the variant.`),o;let t=kt(e);return Qt(t,o)}function St(o,e,t){ye.set(o,e),ge.set(o,t),ze.delete(o)}var Jt=new Map;function be(o){return o.split("-")[0]}function we(o){return o.includes("-")}function Ye(o){let e=ye.get(o);if(!e&&we(o)){let t=be(o);e=ye.get(t)}if(!e){let t=Array.from(ye.keys()).join(", ");throw new Error(`Language '${o}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${o}';`)}return e}function Ze(o){let e=ge.get(o);if(!e&&we(o)){let t=be(o);e=ge.get(t)}if(!e){let t=Array.from(ge.keys()).join(", ");throw new Error(`Language profile '${o}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${o}';`)}return kt(e)}function I(o){let e=ge.get(o);return!e&&we(o)&&(e=ge.get(be(o))),e?kt(e):void 0}function xt(){return Array.from(ye.keys())}function bt(o){return ye.has(o)?!0:we(o)?ye.has(be(o)):!1}function en(o,e){return Ye(e).tokenize(o)}function Q(o){let e=ze.get(o);if(!e&&we(o)&&(e=ze.get(be(o))),e)return e;let t=Jt.get(o);if(!t&&we(o)&&(t=Jt.get(be(o))),t)return ze.set(o,t),t;if(!Zt)throw new Error(`No patterns registered for language '${o}'. Either import the language module or set a pattern generator.`);let n=Ze(o),r=Zt(n);return ze.set(o,r),r}function wt(o,e){return Q(o).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}var ve={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:!0,markersOptional:!0,verb:{position:"end",suffixes:["mek","mak","yor","di","mi\u015F"],subjectDrop:!0},references:{me:"ben",it:"o",you:"sen",result:"sonu\xE7",event:"olay",target:"hedef",body:"g\xF6vde"},possessive:{marker:"\u0131n",markerPosition:"after-object",usePossessiveAdjectives:!0,specialForms:{me:"benim",it:"onun",you:"senin"},keywords:{benim:"me",senin:"you",onun:"it"}},roleMarkers:{patient:{primary:"i",alternatives:["\u0131","u","\xFC","yi","y\u0131","yu","y\xFC","ni","n\u0131","nu","n\xFC"],position:"after"},destination:{primary:"e",alternatives:["a","ye","ya","ne","na","de","da","te","ta","\u0131n","in","un","\xFCn","n\u0131n","nin","nun","n\xFCn"],position:"after"},source:{primary:"den",alternatives:["dan","ten","tan"],position:"after"},style:{primary:"le",alternatives:["la","yle","yla"],position:"after"},event:{primary:"i",alternatives:["\u0131","u","\xFC"],position:"after"}},keywords:{toggle:{primary:"de\u011Fi\u015Ftir",alternatives:["a\xE7/kapat"],normalized:"toggle"},add:{primary:"ekle",normalized:"add"},remove:{primary:"kald\u0131r",alternatives:["sil"],normalized:"remove"},put:{primary:"koy",normalized:"put"},append:{primary:"ili\u015Ftir",normalized:"append"},prepend:{primary:"ba\u015F\u0131naekle",normalized:"prepend"},take:{primary:"tut",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"klonla",normalized:"clone"},swap:{primary:"takas",normalized:"swap"},morph:{primary:"d\xF6n\xFC\u015Ft\xFCr",alternatives:["\u015Fekil de\u011Fi\u015Ftir"],normalized:"morph"},set:{primary:"ayarla",alternatives:["belirle"],normalized:"set"},get:{primary:"al",normalized:"get"},increment:{primary:"art\u0131r",normalized:"increment"},decrement:{primary:"azalt",normalized:"decrement"},log:{primary:"kaydet",normalized:"log"},show:{primary:"g\xF6ster",normalized:"show"},hide:{primary:"gizle",normalized:"hide"},transition:{primary:"ge\xE7i\u015F",normalized:"transition"},on:{primary:"\xFCzerinde",alternatives:["zaman"],normalized:"on"},trigger:{primary:"tetikle",normalized:"trigger"},send:{primary:"g\xF6nder",normalized:"send"},focus:{primary:"odak",alternatives:["odaklanma"],normalized:"focus"},blur:{primary:"bulan\u0131k",alternatives:["bulan\u0131kl\u0131k","bulanik"],normalized:"blur"},empty:{primary:"bo\u015Falt",alternatives:["bosalt","bo\u015F"],normalized:"empty"},open:{primary:"a\xE7",alternatives:["ac"],normalized:"open"},close:{primary:"kapat",normalized:"close"},select:{primary:"vurgula",normalized:"select"},clear:{primary:"temizle",normalized:"clear"},reset:{primary:"s\u0131f\u0131rla",alternatives:["sifirla"],normalized:"reset"},breakpoint:{primary:"kesme-noktas\u0131",alternatives:["kesme-noktasi"],normalized:"breakpoint"},click:{primary:"t\u0131klama",alternatives:["t\u0131kla","tiklama","t\u0131k","tik"],normalized:"click"},hover:{primary:"\xFCzerine gelme",alternatives:["\xFCzerinde gezinme"],normalized:"hover"},submit:{primary:"g\xF6nderme",normalized:"submit"},input:{primary:"giri\u015F",alternatives:["girdi","giris"],normalized:"input"},change:{primary:"de\u011Fi\u015Fiklik",alternatives:["de\u011Fi\u015Fim","degisim"],normalized:"change"},load:{primary:"y\xFCkle",normalized:"load"},go:{primary:"git",normalized:"go"},scroll:{primary:"kayd\u0131r",alternatives:["kaydir"],normalized:"scroll"},push:{primary:"itele",alternatives:["push"],normalized:"push"},replace:{primary:"de\u011Fi\u015Ftir_url",alternatives:["degistir_url"],normalized:"replace"},process:{primary:"i\u015Fle",alternatives:["isle"],normalized:"process"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},unless:{primary:"de\u011Filse",normalized:"unless"},when:{primary:"iken",alternatives:["durumunda","oldu\u011Funda"],normalized:"when"},where:{primary:"nerede",normalized:"where"},else:{primary:"yoksa",normalized:"else"},repeat:{primary:"tekrarla",normalized:"repeat"},for:{primary:"i\xE7in",normalized:"for"},while:{primary:"s\xFCresince",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"devam",normalized:"continue"},halt:{primary:"durdur",normalized:"halt"},throw:{primary:"f\u0131rlat",normalized:"throw"},call:{primary:"\xE7a\u011F\u0131r",normalized:"call"},return:{primary:"d\xF6n",normalized:"return"},then:{primary:"ard\u0131ndan",alternatives:["daha sonra","ardindan"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},or:{primary:"veya",normalized:"or"},not:{primary:"de\u011Fil",alternatives:["degil"],normalized:"not"},end:{primary:"son",alternatives:["biti\u015F","bitti"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asenkron",normalized:"async"},tell:{primary:"s\xF6yle",normalized:"tell"},default:{primary:"varsay\u0131lan",normalized:"default"},init:{primary:"ba\u015Flat",normalized:"init"},behavior:{primary:"davran\u0131\u015F",normalized:"behavior"},install:{primary:"kur",alternatives:["y\xFCklemek"],normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"dur",normalized:"break"},copy:{primary:"kopyala",normalized:"copy"},exit:{primary:"\xE7\u0131k",normalized:"exit"},pick:{primary:"se\xE7",normalized:"pick"},render:{primary:"render",normalized:"render"},into:{primary:"i\xE7ine",normalized:"into"},before:{primary:"\xF6nce",normalized:"before"},after:{primary:"sonra",normalized:"after"},until:{primary:"kadar",normalized:"until"},event:{primary:"olay",normalized:"event"},from:{primary:"den",alternatives:["dan"],normalized:"from"},connect:{primary:"ba\u011Flan",alternatives:["ba\u011Fla","ba\u011Flant\u0131"],normalized:"connect"},stream:{primary:"yay\u0131nla",alternatives:["ak\u0131t","ak\u0131\u015F"],normalized:"stream"},live:{primary:"canl\u0131",alternatives:["ger\xE7ek-zamanl\u0131"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"bind",normalized:"bind"},intercept:{primary:"yakala",alternatives:["araya-gir","intercept"],normalized:"intercept"},worker:{primary:"i\u015F\xE7i",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["olay-kayna\u011F\u0131"],normalized:"eventsource"}},eventHandler:{eventMarker:{primary:"da",alternatives:["de","ta","te"],position:"after"},temporalMarkers:["d\u0131\u011F\u0131nda","di\u011Finde"]}};function F(o,e){return e?{type:"literal",value:o,dataType:e}:{type:"literal",value:o}}function Ve(o,e){return e?{type:"selector",value:o,selectorKind:e}:{type:"selector",value:o}}function Te(o){return{type:"reference",value:o}}function Xe(o,e){return{type:"property-path",object:o,property:e}}function Tt(o,e=!0){return{type:"flag",name:o,enabled:e}}function nn(o,e,t){let n=e instanceof Map?e:new Map(Object.entries(e)),r={kind:"command",action:o,roles:n};return t?{...r,metadata:t}:r}function Et(o,e,t,n,r){let i=e instanceof Map?e:new Map(Object.entries(e));return{kind:"event-handler",action:o,roles:i,body:t,...r&&{eventModifiers:r},...n&&{metadata:n}}}function rn(o,e,t,n,r){let i=e instanceof Map?e:new Map(Object.entries(e));return{kind:"conditional",action:o,roles:i,thenBranch:t,...n&&{elseBranch:n},...r&&{metadata:r}}}function on(o,e,t,n,r,i,s){let a=e instanceof Map?e:new Map(Object.entries(e));return{kind:"loop",action:o,roles:a,loopVariant:t,body:n,...r&&{loopVariable:r},...i&&{indexVariable:i},...s&&{metadata:s}}}var Lt=new Set(["me","you","it","result","event","target","body"]);function Qe(o,e=Lt){return e.has(o)}var tn=new Set(["body","then","else","condition","loop-body","variable","catch","finally"]);function eo(o){let e=o.slice(1,-1),t=0;for(let n of e)if(n==="[")t++;else if(n==="]")t--;else if(t===0&&(n===" "||n===":"))return!0;return!1}function et(o,e={}){let t=o.trim(),n=e.collectDiagnostics===!0,r=[];if(!t.startsWith("[")||!t.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let i=t.slice(1,-1).trim();if(!i)throw new Error("Empty explicit statement");let s=no(i);if(s.length===0)throw new Error("No command specified in explicit statement");let a=s[0].toLowerCase(),l=new Map,c=e.referenceSet??Lt,u=e.schemaLookup?.getSchema(a),d=u?new Set(u.roles.map(m=>m.role)):null;for(let m=1;m<s.length;m++){let p=s[m];if(p.startsWith("+")||p.startsWith("~")){let L=p.startsWith("+"),S=p.slice(1);if(!S){if(n){r.push({severity:"error",code:"EMPTY_FLAG",message:`Empty flag name: "${p}"`,source:"schema"});continue}throw new Error(`Empty flag name: "${p}"`)}if(d&&!d.has(S)){if(n){r.push({severity:"error",code:"UNKNOWN_FLAG",message:`Unknown flag "${S}" for command "${a}"`,source:"schema",suggestions:[...d].map(k=>`+${k}`)}),l.set(S,Tt(S,L));continue}throw new Error(`Unknown flag "${S}" for command "${a}". Valid roles: ${[...d].join(", ")}`)}l.set(S,Tt(S,L));continue}let h=p.indexOf(":");if(h===-1){if(n){r.push({severity:"error",code:"INVALID_ROLE_FORMAT",message:`Invalid role format: "${p}". Expected role:value or +flag`,source:"schema"});continue}throw new Error(`Invalid role format: "${p}". Expected role:value or +flag`)}let y=p.slice(0,h);if(d&&!tn.has(y)&&!d.has(y))if(n)r.push({severity:"error",code:"UNKNOWN_ROLE",message:`Unknown role "${y}" for command "${a}"`,source:"schema",suggestions:[...d]});else throw new Error(`Unknown role "${y}" for command "${a}". Valid roles: ${[...d].join(", ")}`);let g=y,x=p.slice(h+1);if(tn.has(y)&&x.startsWith("[")&&eo(x)){let L=oo(p,h+1),S=p.slice(h+1,L+1);l.set(g,{type:"expression",raw:S});continue}let T=ro(x,c);l.set(g,T)}if(u&&a!=="on"){for(let m of u.roles)if(m.required&&!l.has(m.role)&&!m.default)if(n)r.push({severity:"error",code:"MISSING_REQUIRED_ROLE",message:`Missing required role "${m.role}" for command "${a}": ${m.description}`,source:"schema"});else throw new Error(`Missing required role "${m.role}" for command "${a}": ${m.description}`)}let f=m=>r.length===0?m:{...m,diagnostics:r};switch(a){case"on":{if(!l.get("event")){if(n)return r.push({severity:"error",code:"MISSING_EVENT_ROLE",message:"Event handler requires event role: [on event:click ...]",source:"schema"}),f(Et("on",l,[],{sourceLanguage:"explicit"}));throw new Error("Event handler requires event role: [on event:click ...]")}let p=Je(l,"body",e);return l.delete("body"),f(Et("on",l,p,{sourceLanguage:"explicit"}))}case"if":{let m=Je(l,"then",e),p=Je(l,"else",e);return l.delete("then"),l.delete("else"),f(rn(a,l,m,p.length>0?p:void 0,{sourceLanguage:"explicit"}))}case"repeat":{let m=Je(l,"loop-body",e),p=l.get("loop-variant"),h=l.get("variable"),y=l.get("index-variable");l.delete("loop-body"),l.delete("loop-variant"),l.delete("variable"),l.delete("index-variable");let g;p&&p.type==="literal"&&typeof p.value=="string"?g=p.value:l.has("quantity")?g="times":l.has("source")?g="for":l.has("condition")?g="while":g="forever";let x=h?.type==="literal"&&typeof h.value=="string"?h.value:h?.type==="expression"?h.raw:void 0,T=y?.type==="literal"&&typeof y.value=="string"?y.value:void 0;return f(on(a,l,g,m,x,T,{sourceLanguage:"explicit"}))}default:return f(nn(a,l,{sourceLanguage:"explicit"}))}}function de(o){let e=o.trim();return e.startsWith("[")&&e.endsWith("]")}function Je(o,e,t){let n=o.get(e);return n?n.type==="expression"?[et(n.raw,t)]:[]:[]}function to(o){if(o){if(o.startsWith("#"))return"id";if(o.startsWith("."))return"class";if(o.startsWith("["))return"attribute";if(o.startsWith("<")||o.startsWith("*"))return"element";if(/[>+~ ]/.test(o)&&o.length>1)return"complex"}}function no(o){let e=[],t="",n=!1,r="",i=0;for(let s=0;s<o.length;s++){let a=o[s];if(n){t+=a,a===r&&o[s-1]!=="\\"&&(n=!1);continue}if(a==='"'||a==="'"){n=!0,r=a,t+=a;continue}if(a==="["){i++,t+=a;continue}if(a==="]"){i--,t+=a;continue}if(a===" "&&i===0){t&&(e.push(t),t="");continue}t+=a}return t&&e.push(t),e}function ro(o,e){if(o.startsWith("#")||o.startsWith(".")||o.startsWith("[")||o.startsWith("@")||o.startsWith("*"))return Ve(o,to(o));if(o.startsWith('"')||o.startsWith("'"))return F(o.slice(1,-1),"string");if(o==="true")return F(!0,"boolean");if(o==="false")return F(!1,"boolean");let t=o.toLowerCase();if(Qe(t,e))return Te(t);let n=o.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(n){let r=parseFloat(n[1]);return n[2]?F(o,"duration"):F(r,"number")}return F(o)}function oo(o,e){let t=0;for(let n=e;n<o.length;n++)if(o[n]==="[")t++;else if(o[n]==="]"&&(t--,t===0))return n;return o.length-1}function ee(o){let e;if(o.kind==="compound"){let t=o;e=t.statements.map(n=>ee(n)).join(` ${t.chainType} `)}else e=io(o);return o.annotations&&o.annotations.length>0?o.annotations.map(n=>n.value!==void 0?`@${n.name}(${n.value})`:`@${n.name}`).join(" ")+" "+e:e}function io(o){let e=[o.action];for(let[t,n]of o.roles)n.type==="flag"?e.push(n.enabled?`+${n.name}`:`~${n.name}`):e.push(`${t}:${an(n)}`);if(o.kind==="event-handler"){let t=o;t.body&&t.body.length>0&&e.push(`body:${t.body.map(n=>ee(n)).join(" ")}`)}if(o.kind==="conditional"){let t=o;t.thenBranch&&t.thenBranch.length>0&&e.push(`then:${t.thenBranch.map(n=>ee(n)).join(" ")}`),t.elseBranch&&t.elseBranch.length>0&&e.push(`else:${t.elseBranch.map(n=>ee(n)).join(" ")}`)}if(o.kind==="loop"){let t=o;t.loopVariant&&e.push(`loop-variant:${t.loopVariant}`),t.loopVariable&&e.push(`variable:${t.loopVariable}`),t.indexVariable&&e.push(`index-variable:${t.indexVariable}`),t.body&&t.body.length>0&&e.push(`loop-body:${t.body.map(n=>ee(n)).join(" ")}`)}if(o.kind==="command"){let t=o;t.body&&t.body.length>0&&e.push(`body:${t.body.map(n=>ee(n)).join(" ")}`),t.catchBranch&&t.catchBranch.length>0&&e.push(`catch:${t.catchBranch.map(n=>ee(n)).join(" ")}`),t.finallyBranch&&t.finallyBranch.length>0&&e.push(`finally:${t.finallyBranch.map(n=>ee(n)).join(" ")}`),t.asyncVariant&&e.push(`async-variant:${t.asyncVariant}`),t.asyncBody&&t.asyncBody.length>0&&e.push(`async-body:${t.asyncBody.map(n=>ee(n)).join(" ")}`)}return`[${e.join(" ")}]`}function an(o){switch(o.type){case"literal":return typeof o.value=="string"?o.dataType==="string"||/\s/.test(o.value)?`"${o.value}"`:o.value:String(o.value);case"selector":return o.value;case"reference":return o.value;case"property-path":return`${an(o.object)}'s ${o.property}`;case"expression":return o.raw;case"flag":return o.name}}var ao=class{constructor(o){this.namespace=o,this.enabled=this.checkEnabled()}checkEnabled(){if(typeof process<"u"&&process.env){let o=process.env.DEBUG||"";return o==="*"||o.includes("framework:*")||o.includes(`framework:${this.namespace}`)}return!1}log(o,e,...t){if(!this.enabled)return;let n=`[framework:${this.namespace}]`,r=new Date().toISOString();switch(o){case"debug":console.debug(`${r} ${n} DEBUG:`,e,...t);break;case"info":console.info(`${r} ${n} INFO:`,e,...t);break;case"warn":console.warn(`${r} ${n} WARN:`,e,...t);break;case"error":console.error(`${r} ${n} ERROR:`,e,...t);break}}debug(o,...e){this.log("debug",o,...e)}info(o,...e){this.log("info",o,...e)}warn(o,...e){this.log("warn",o,...e)}error(o,...e){this.log("error",o,...e)}isEnabled(){return this.enabled}enable(){this.enabled=!0}disable(){this.enabled=!1}};function so(o){return new ao(o)}function Ee(o,e){return!e||e.length===0||e.includes(o)||e.includes("expression")?!0:o==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function lo(o,e){return o?.possessive?.keywords?.[e]}function sn(o){return!1}var Ie=class Le{constructor(){this.logger=so("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,n){let r=e.mark(),i=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let l=[];for(let c=0;c<10;c++){let u=e.peek(c);if(u)l.push({type:u.type,value:u.value,kind:u.kind});else break}this.logger.debug("Input tokens (first 10):",l),this.logger.debug("Profile code:",n?.code)}this.currentProfile=n,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,i);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(i.entries()).map(([l,c])=>[l,JSON.stringify(c)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(r),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-r.position,confidence:a}}matchBest(e,t,n){let r=[];for(let s of t){let a=e.mark(),l=this.matchPattern(e,s,n);l&&r.push(l),e.reset(a)}if(r.length===0)return null;r.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;if(l!==0)return l;let c=a.confidence-s.confidence;return Math.abs(c)>.001?c:a.consumedTokens-s.consumedTokens});let i=r[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n,r){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,l=null;for(let c=0;c<t.length;c++){let u=t[c];this.logger.debug(" >> Matching pattern token:",JSON.stringify(u,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),u.type==="role"&&u.greedy){let y=this.collectStopMarkers(t,c+1);if(r)for(let x of r)y.add(x);let g=[];for(;!e.isAtEnd();){let x=e.peek();if(!x||this.isStopMarker(x,y))break;g.push(x.value),e.advance()}if(g.length>0){n.set(u.role,{type:"expression",raw:g.join(" ")}),a=null,l=null;continue}else{if(u.optional)continue;return!1}}if(u.type==="group"){let y=this.collectStopMarkers(t,c+1);if(r)for(let x of r)y.add(x);if(this.matchGroupToken(e,u,n,y)){a=null,l=null;continue}if(this.isOptional(u))continue;return!1}let f=u.type==="role"&&u.optional===!0,m=f?e.mark():null;if(u.type==="role"&&!f){let y=c+1<t.length?t[c+1]:null;if(y?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(u))continue;if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),n.delete(l),a=null,l=null;let x=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Backtrack retry result:",x),x)continue}return!1}}}let h=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Match result:",h),h){f?(a=m,l=u.role):(a=null,l=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(u)){if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),n.delete(l),a=null,l=null;let y=this.matchPatternToken(e,u,n);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return!1}}return!0}matchPatternToken(e,t,n){switch(t.type){case"literal":return this.matchLiteralToken(e,t);case"role":return this.matchRoleToken(e,t,n);case"group":return this.matchGroupToken(e,t,n);default:return!1}}matchLiteralToken(e,t){let n=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",n?JSON.stringify({type:n.type,value:n.value,kind:n.kind}):"null"),!n)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),!1;let r=this.getMatchType(n,t.value);if(this.logger.debug(" >>> matchType for",n.value,"vs",t.value,":",r),r!=="none")return this.totalKeywordMatches++,r==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(n,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,n){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let r=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",r?JSON.stringify({value:r.value,kind:r.kind}):"null"),!r)return t.optional||!1;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(i.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,i),!0);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(s.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,s),!0);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(a.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,a),!0);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(l.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,l),!0);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Ee(c.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,c),!0);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",r?JSON.stringify({value:r.value,kind:r.kind}):"null");let u=this.tokenToSemanticValue(r);return this.logger.debug(" >>> tokenToSemanticValue returned:",u?JSON.stringify(u):"null"),u?(this.logger.debug(" >>> Validating type:",u.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!Ee(u.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||!1),t.optional||!1):(this.logger.debug(" >>> Type validation PASSED"),n.set(t.role,u),e.advance(),!0)):t.optional||!1}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=t.normalized||t.value,r=this.safeToLowerCase(n),i=lo(this.currentProfile,r);if(!i)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),Xe(Te(i),c)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<Le.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<Le.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<Le.MAX_METHOD_ARGS;){let f=e.peek();if(!f)break;if(f.kind==="punctuation"&&f.value===")"){if(u===0){e.advance();break}u--}if(f.kind==="punctuation"&&f.value==="("&&u++,f.kind==="punctuation"&&f.value===","){e.advance();continue}c.push(f.value),e.advance()}return{type:"expression",raw:`${s}(${c.join(", ")})`}}return{type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="punctuation"||r.value!=="'s")return e.reset(n),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(n),null):(e.advance(),Xe(Ve(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("."))return e.reset(n),null;let i=e.peek(1);i&&i.kind,e.advance();let s=r.value.slice(1);return Xe(Ve(t.value),s)}matchGroupToken(e,t,n,r){let i=e.mark(),s=new Set(n.keys());if(this.matchTokenSequence(e,t.tokens,n,r))return!0;e.reset(i);for(let c of n.keys())s.has(c)||n.delete(c);if(!t.optional)return!1;let l=this.getGroupLeadingMarker(t);if(l)for(let c=1;c<=Le.MAX_MARKER_SCAN;c++){let u=e.peek(c);if(!u)break;if((u.normalized||u.value).toLowerCase()===l){this.logger.debug(" >> MARKER SCAN: found",l,"at offset",c,"- skipping intervening tokens");for(let m=0;m<c;m++)e.advance();if(this.matchTokenSequence(e,t.tokens,n,r))return!0;e.reset(i);for(let m of n.keys())s.has(m)||n.delete(m);break}}return!0}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let n=new Set;for(let r=t;r<e.length;r++){let i=e[r];if(i.type==="literal"){if(n.add(i.value.toLowerCase()),i.alternatives)for(let s of i.alternatives)n.add(s.toLowerCase());break}if(i.type==="group"){for(let s of i.tokens)if(s.type==="literal"){if(n.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)n.add(a.toLowerCase());break}if(!i.optional)break}}return n}isStopMarker(e,t){return t.size===0?!1:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case"selector":return Ve(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=e.normalized||e.value,n=this.safeToLowerCase(t);return sn(n)?Te(n):F(e.normalized||e.value);case"identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Te(e.value);let r=this.safeToLowerCase(e.value);return sn(r)?Te(r):{type:"expression",raw:e.value};case"url":return F(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let r=e.slice(1,-1);return F(r,"string")}if(e==="true")return F(!0,"boolean");if(e==="false")return F(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let r=parseFloat(t[1]);return t[2]?F(e,"duration"):F(r,"number")}let n=parseFloat(e);return isNaN(n)?F(e,"string"):F(n,"number")}applyExtractionRules(e,t){for(let[n,r]of Object.entries(e.extraction))t.has(n)||(r.value!==void 0?t.set(n,{type:"literal",value:r.value}):r.default&&t.set(n,r.default))}isOptional(e){return e.type!=="literal"&&e.optional===!0}calculateConfidence(e,t){let n=0,r=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")r+=1,t.has(c.role)&&(n+=1);else if(c.type==="group"){for(let u of c.tokens)if(u.type==="role"){let d=i(u.role),f=.8;r+=f,t.has(u.role)?n+=f:d&&(n+=f*.6)}}let s=r>0?n/r:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c)}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(t.value))return .15;if(t.alternatives){for(let r of t.alternatives)if(n.has(r))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,r={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[i,s]of t.entries()){let a=r[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?n+=.1:n-=.1}}return Math.max(-.1,Math.min(.1,n))}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=this.safeToLowerCase(t.value);if(Le.ENGLISH_NOISE_WORDS.has(n)){let r=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(r)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let r=e.peek();if(!r||r.kind!=="event-modifier")break;let i=r.metadata;if(!i)break;switch(n=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return n?t:void 0}};Ie.MAX_MARKER_SCAN=3;Ie.MAX_PROPERTY_DEPTH=10;Ie.MAX_METHOD_ARGS=20;Ie.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var co=Ie,Ua=new co;var Ct=class{constructor(){this.name="string-literal"}canExtract(o,e){let t=o[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(o,e){let t=o[e];if(t==="\u201C"){let i=1;for(;e+i<o.length;){if(o[e+i]==="\u201D")return i++,{value:o.substring(e,e+i),length:i};i++}return null}if(t==="\u2018"){let i=1;for(;e+i<o.length;){if(o[e+i]==="\u2019")return i++,{value:o.substring(e,e+i),length:i};i++}return null}let n=1,r=!1;for(;e+n<o.length;){let i=o[e+n];if(r){r=!1,n++;continue}if(i==="\\"){r=!0,n++;continue}if(i===t)return n++,{value:o.substring(e,e+n),length:n};n++}return null}},Nt=class{constructor(){this.name="number"}canExtract(o,e){return/\d/.test(o[e])}extract(o,e){let t=0,n=!1;for(;e+t<o.length;){let s=o[e+t];if(/\d/.test(s))t++;else if(s==="."&&!n)n=!0,t++;else break}if(t===0)return null;let r=o.substring(e,e+t),i=e+t;if(i<o.length){let s=o.slice(i),a=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let c of a)if(s.startsWith(c.pattern))return{value:r+c.suffix,length:t+c.pattern.length,metadata:{hasTimeUnit:!0}};if(s.startsWith("ms"))return{value:r+"ms",length:t+2,metadata:{hasTimeUnit:!0}};let l=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let c of l)if(s.startsWith(c.pattern))return{value:r+c.suffix,length:t+1,metadata:{hasTimeUnit:!0}};if(/^[smh](?![a-zA-Z])/.test(s))return{value:r+s[0],length:t+1,metadata:{hasTimeUnit:!0}}}return{value:r,length:t}}};function uo(o){return"setContext"in o&&typeof o.setContext=="function"}function po(o){let e={language:o.language,direction:o.direction,lookupKeyword:o.lookupKeyword.bind(o),isKeyword:o.isKeyword.bind(o),isKeywordStart:o.isKeywordStart.bind(o),...o.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:o.isKeywordStartAtBoundary.bind(o)}:{}};return o.normalizer?{...e,normalizer:o.normalizer}:e}var X=class{constructor(o,e){this.pos=0,this.tokens=o,this.language=e}peek(o=0){let e=this.pos+o;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return{position:this.pos}}reset(o){this.pos=o.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(o){let e=[];for(;!this.isAtEnd()&&o(this.peek());)e.push(this.advance());return e}skipWhile(o){for(;!this.isAtEnd()&&o(this.peek());)this.advance()}};function B(o,e){return{start:o,end:e}}function D(o,e,t,n){if(typeof o=="object"){let{value:i,kind:s,position:a,normalized:l,stem:c,stemConfidence:u,metadata:d}=o;return{value:i,kind:s,position:a,...l!==void 0&&{normalized:l},...c!==void 0&&{stem:c},...u!==void 0&&{stemConfidence:u},...d!==void 0&&{metadata:d}}}let r=o;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof n=="string")return{value:r,kind:e,position:t,normalized:n};if(n){let{normalized:i,stem:s,stemConfidence:a,metadata:l}=n;return{value:r,kind:e,position:t,...i!==void 0&&{normalized:i},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...l!==void 0&&{metadata:l}}}return{value:r,kind:e,position:t}}function pe(o){return/\s/.test(o)}function tt(o){return o==="#"||o==="."||o==="["||o==="@"||o==="*"||o==="<"}function nt(o){return o==='"'||o==="'"||o==="`"||o==="\u300C"||o==="\u300D"}function ie(o){return/\d/.test(o)}function rt(o){return/[a-zA-Z]/.test(o)}function W(o){return/[a-zA-Z0-9_-]/.test(o)}function ln(o,e){if(e>=o.length)return null;let t=o[e];if(!tt(t))return null;let n=e,r="";if(t==="#"||t==="."){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null;if(n<o.length&&o[n]==="."&&t==="#"){let s=n+1;for(;s<o.length&&W(o[s]);)s++;if(s<o.length&&o[s]==="(")return r}}else if(t==="["){let i=1,s=!1,a=null,l=!1;for(r+=o[n++];n<o.length&&i>0;){let c=o[n];r+=c,l?l=!1:c==="\\"?l=!0:s?c===a&&(s=!1,a=null):c==='"'||c==="'"||c==="`"?(s=!0,a=c):c==="["?i++:c==="]"&&i--,n++}if(i!==0)return null}else if(t==="@"){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null}else if(t==="*"){for(r+=o[n++];n<o.length&&W(o[n]);)r+=o[n++];if(r.length<=1)return null}else if(t==="<"){if(r+=o[n++],n>=o.length||!rt(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++];for(;n<o.length;){let i=o[n];if(i==="."){if(r+=o[n++],n>=o.length||!W(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++]}else if(i==="#"){if(r+=o[n++],n>=o.length||!W(o[n]))return null;for(;n<o.length&&W(o[n]);)r+=o[n++]}else if(i==="["){let s=1,a=!1,l=null,c=!1;for(r+=o[n++];n<o.length&&s>0;){let u=o[n];r+=u,c?c=!1:u==="\\"?c=!0:a?u===l&&(a=!1,l=null):u==='"'||u==="'"||u==="`"?(a=!0,l=u):u==="["?s++:u==="]"&&s--,n++}if(s!==0)return null}else break}for(;n<o.length&&pe(o[n]);)r+=o[n++];if(n<o.length&&o[n]==="/")for(r+=o[n++];n<o.length&&pe(o[n]);)r+=o[n++];if(n>=o.length||o[n]!==">")return null;r+=o[n++]}return r||null}function mo(o,e){if(e>=o.length||o[e]!=="'"||e+1>=o.length||o[e+1].toLowerCase()!=="s")return!1;if(e+2>=o.length)return!0;let n=o[e+2];return pe(n)||n==="*"||!W(n)}function cn(o,e){if(e>=o.length)return null;let t=o[e];if(!nt(t)||t==="'"&&mo(o,e))return null;let r={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!r)return null;let i=e+1,s=t,a=!1;for(;i<o.length;){let l=o[i];if(s+=l,a)a=!1;else if(l==="\\")a=!0;else if(l===r)return s;i++}return s}function un(o,e){if(e>=o.length)return!1;let t=o[e],n=o[e+1]||"",r=o[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(r)||t==="."&&(n==="/"||n==="."&&r==="/"))return!0;let i=o.slice(e,e+8).toLowerCase();return!!(i.startsWith("http://")||i.startsWith("https://"))}function dn(o,e){if(!un(o,e))return null;let t=e,n="",r=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<o.length;){let i=o[t];if(i==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=i,t++;t<o.length&&/[a-zA-Z0-9_-]/.test(o[t]);)n+=o[t++];break}if(r.test(i))n+=i,t++;else break}return n.length<2?null:n}function pn(o,e){if(e>=o.length)return null;let t=o[e];if(!ie(t)&&t!=="-"&&t!=="+")return null;let n=e,r="";if((o[n]==="-"||o[n]==="+")&&(r+=o[n++]),n>=o.length||!ie(o[n]))return null;for(;n<o.length&&ie(o[n]);)r+=o[n++];if(n<o.length&&o[n]===".")for(r+=o[n++];n<o.length&&ie(o[n]);)r+=o[n++];return n<o.length&&(o.slice(n,n+2)==="ms"?r+="ms":(o[n]==="s"||o[n]==="m"||o[n]==="h")&&(r+=o[n])),r}var fo=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];var Ja=new Set(fo),ho=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]),yo=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],mn=class fn{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[]}getExtraKeywordEntries(){return this.rawExtraEntries}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){uo(e)&&e.setContext(po(this)),this.extractors.push(e)}registerExtractors(e){for(let t of e)this.registerExtractor(t)}clearExtractors(){this.extractors=[]}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&pe(e[n]);)n++;if(n>=e.length)break;let r=this.tryMultiWordKeyword(e,n);if(r){t.push(r),n=r.position.end;continue}let i=!1;for(let s of this.extractors)if(s.canExtract(e,n)){let a=s.extract(e,n);if(a){let l=a.metadata?.normalized,c=a.metadata?.stem,u=a.metadata?.stemConfidence,d={};if(a.metadata)for(let[m,p]of Object.entries(a.metadata))m!=="normalized"&&m!=="stem"&&m!=="stemConfidence"&&(d[m]=p);let f={};l&&(f.normalized=l),c&&(f.stem=c),u!==void 0&&(f.stemConfidence=u),Object.keys(d).length>0&&(f.metadata=d),t.push(D(a.value,this.classifyToken(a.value),B(n,n+a.length),Object.keys(f).length>0?f:void 0)),n+=a.length,i=!0;break}}if(!i){let s=e[n],a=this.classifyUnknownChar(s);t.push(D(s,a,B(n,n+1))),n++}}return new X(t,this.language)}classifyUnknownChar(e){return"()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,n){if(e[t]!==".")return!1;let r=n[n.length-1],i=r&&r.position.end<t;if(r&&!i&&(r.kind==="identifier"||r.kind==="keyword"||r.kind==="selector"))return n.push(D(".","operator",B(t,t+1))),!0;let l=t+1;for(;l<e.length&&W(e[l]);)l++;return l<e.length&&e[l]==="("?(n.push(D(".","operator",B(t,t+1))),!0):!1}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(this.rawExtraEntries=t,e.keywords){for(let[r,i]of Object.entries(e.keywords))if(n.set(i.primary,{native:i.primary,normalized:i.normalized||r}),i.alternatives)for(let s of i.alternatives)n.set(s,{native:s,normalized:i.normalized||r})}if(e.references){for(let[r,i]of Object.entries(e.references))n.set(i,{native:i,normalized:r});for(let r of Object.keys(e.references))n.has(r)||n.set(r,{native:r,normalized:r})}if(e.roleMarkers){for(let[r,i]of Object.entries(e.roleMarkers))if(i.primary&&n.set(i.primary,{native:i.primary,normalized:r}),i.alternatives)for(let s of i.alternatives)n.set(s,{native:s,normalized:r})}if(e.possessive?.keywords)for(let[r,i]of Object.entries(e.possessive.keywords))n.set(r,{native:r,normalized:i});for(let r of yo)n.has(r)||n.set(r,{native:r,normalized:r});for(let r of t)n.set(r.native,r);this.profileKeywords=Array.from(n.values()).sort((r,i)=>i.native.length-r.native.length),this.multiWordKeywords=this.profileKeywords.filter(r=>r.native.includes(" ")&&!ho.has(r.normalized)),this.profileKeywordMap=new Map;for(let r of this.profileKeywords){this.profileKeywordMap.set(r.native.toLowerCase(),r);let i=this.removeDiacritics(r.native);i!==r.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),r)}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let n of this.profileKeywords)if(e.slice(t).startsWith(n.native))return D(n.native,"keyword",B(t,t+n.native.length),n.normalized);return null}tryMultiWordKeyword(e,t,n=r=>/[\p{L}\p{N}_]/u.test(r)){if(this.multiWordKeywords.length===0)return null;let r=e.slice(t);for(let i of this.multiWordKeywords){if(!r.startsWith(i.native))continue;let s=e[t+i.native.length];if(!(s!==void 0&&n(s)))return D(i.native,"keyword",B(t,t+i.native.length),i.normalized)}return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(r=>n.startsWith(r.native))}isKeywordStartAtBoundary(e,t,n=r=>/[\p{L}\p{N}_]/u.test(r)){let r=e.slice(t);return this.profileKeywords.some(i=>{if(!r.startsWith(i.native))return!1;let s=e[t+i.native.length];return s===void 0||!n(s)})}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,n){let r=this.tryNormalize(e);if(!r)return null;let i=this.lookupKeyword(r.stem);if(!i)return null;let s={normalized:i.normalized,stem:r.stem,stemConfidence:r.confidence};return D(e,"keyword",B(t,n),s)}trySelector(e,t){let n=ln(e,t);return n?D(n,"selector",B(t,t+n.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let n=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let r=n[0].replace(/(\s|\.)$/,""),i=r.slice(1).split("(")[0],s=n[1];return{...D(r,"event-modifier",B(t,t+r.length)),metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let n=cn(e,t);return n?D(n,"literal",B(t,t+n.length)):null}tryNumber(e,t){let n=pn(e,t);return n?D(n,"literal",B(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,r=!1){let i=t;if(r)for(;i<e.length&&pe(e[i]);)i++;let s=e.slice(i);for(let a of n){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let u=s[a.length]||"";if(W(u))continue}return{suffix:a.suffix,endPos:i+a.length}}}return null}parseBaseNumber(e,t,n=!0){let r=t,i="";if(n&&(e[r]==="-"||e[r]==="+")&&(i+=e[r++]),r>=e.length||!ie(e[r]))return null;for(;r<e.length&&ie(e[r]);)i+=e[r++];if(r<e.length&&e[r]===".")for(i+=e[r++];r<e.length&&ie(e[r]);)i+=e[r++];return!i||i==="-"||i==="+"?null:{number:i,endPos:r}}tryNumberWithTimeUnits(e,t,n,r={}){let{allowSign:i=!0,skipWhitespace:s=!1}=r,a=this.parseBaseNumber(e,t,i);if(!a)return null;let{number:l,endPos:c}=a,u=[...n,...fn.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,c,u,s);return d&&(l+=d.suffix,c=d.endPos),D(l,"literal",B(t,c))}tryUrl(e,t){let n=dn(e,t);return n?D(n,"url",B(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!W(e[t+1]))return null;let n=t+1;for(;n<e.length&&W(e[n]);)n++;let r=e.slice(t,n);return D(r,"identifier",B(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return D(n,"operator",B(t,t+2));let r=e[t];return["<",">","!","+","-","*","/","="].includes(r)?D(r,"operator",B(t,t+1)):["(",")","{","}",",",";",":"].includes(r)?D(r,"punctuation",B(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let r of n)if(e.slice(t,t+r.length)===r)return D(r,"particle",B(t,t+r.length));return null}};mn.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:!0},{pattern:"m",suffix:"m",length:1,checkBoundary:!0,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:!0}];var _e=mn;function Pt(o){return{stem:o,confidence:1}}function ot(o,e,t){return t?{stem:o,confidence:e,metadata:t}:{stem:o,confidence:e}}function ne(o){let e="complex";return o.startsWith("#")&&!o.includes(" ")?e="id":o.startsWith(".")&&!o.includes(" ")?e="class":o.startsWith("[")&&o.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(o)&&(e="element"),{type:"selector",value:o,selectorKind:e}}function j(o,e){let t={type:"literal",value:o};return e!==void 0?{type:"literal",value:o,dataType:e}:t}function ke(o){return Qe(o)}function Z(o){return{type:"reference",value:o}}function ae(o,e){return{type:"property-path",object:o,property:e}}function H(o,e,t){let n={kind:"command",action:o,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function me(o,e,t,n,r,i){let s=new Map;s.set("event",o);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),r!==void 0&&r.length>0&&(a.parameterNames=r),i!==void 0&&i.length>0&&(a.additionalEvents=i),a}function hn(o,e,t,n,r){let i={kind:"behavior",action:"behavior",roles:new Map,name:o,parameters:e,eventHandlers:t};return n!==void 0&&n.length>0&&(i.initBlock=n),r!==void 0&&(i.metadata=r),i}function yn(o,e,t,n){let r={kind:"def",action:"def",roles:new Map,name:o,parameters:e,body:t};return n!==void 0&&(r.metadata=n),r}function je(o,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:o,chainType:e};return t!==void 0&&(n.metadata=t),n}function gn(o,e,t,n){let r=new Map;r.set("condition",o);let i={kind:"conditional",action:"if",roles:r,thenBranch:e};return t!==void 0&&(i.elseBranch=t),n!==void 0&&(i.metadata=n),i}function Be(o,e){return!e||e.length===0||e.includes(o)||e.includes("expression")?!0:o==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):o==="expression"?e.some(t=>["selector","reference","expression"].includes(t)):!1}var go={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:!0,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},vo={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:!0,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},ko={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},So={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"},markerVariants:{en:["before","after"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},xo={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:!0,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"patient",description:"The value to set",required:!0,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},bo={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:!0,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},wo={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},To={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Eo={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Lo={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},Co={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:!0,bareKeyword:!0,roles:[]},No={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Po={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:!0,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:!1,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Ro={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:!0,roles:[{role:"event",description:"The event to handle",required:!0,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ao={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Mo={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Oo={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:!1,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:!1,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},zo={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Vo={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:!1,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Io={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},_o={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:!0,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},jo={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Bo={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:!1,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Do={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:!0,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},$o={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:!0,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},qo={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:!1,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Wo={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ko={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Fo={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},Uo={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate",required:!0,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Ho={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:!0,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Go={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},Yo={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:!0,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:!0,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:!1,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:!1,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Zo={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The iteration variable",required:!0,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},Jo={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:!0,roles:[{role:"condition",description:"The condition to check",required:!0,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Xo={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Qo={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""},markerOptional:{en:!0},markerVariants:{he:["\u05D0\u05EA"],zh:["\u628A"]}}]},ei={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:!0,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:!1,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:!1,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ti={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:!1,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},ni={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ri={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},oi={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ii={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},ai={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},si={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},li={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:!1,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ci={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},ui={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:!0},di={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:!0,expectedTypes:["expression","reference"],markerOptional:{he:!0,zh:!0},svoPosition:1,sovPosition:1}]},pi={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:!1,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},mi={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The JavaScript code to execute",required:!1,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},fi={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:!0,roles:[]},hi={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:!0,roles:[{role:"destination",description:"The element to tell",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},yi={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:!0,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:!0,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},gi={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[]},vi={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:!0,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ki={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Si={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:!1,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:!1,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},xi={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:!1,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:!0,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{role:"patient",description:"The content to swap in (optional for delete)",required:!1,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528"}}]},bi={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to morph",required:!0,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:!0,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},wi={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:!1,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Ti={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Ei={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:!0,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Li={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:!0},Ci={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:!0,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:!1,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Ni={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},vn={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},Pi={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Ri={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:vn}]},Ai={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:!0,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:vn}]},Mi={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:!0,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Pi}]},Oi={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:!0,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:!1,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},Ce={toggle:go,add:vo,remove:ko,put:So,set:xo,show:No,hide:Po,on:Ro,trigger:Ao,wait:Mo,fetch:Oo,increment:zo,decrement:Vo,append:Io,prepend:_o,log:jo,get:Bo,take:Do,make:$o,halt:qo,settle:Wo,throw:Ko,send:Fo,if:Uo,unless:Ho,else:Go,repeat:Yo,for:Zo,while:Jo,continue:Xo,go:Qo,scroll:Ni,push:Ri,replace:Ai,process:Mi,transition:ei,clone:ti,focus:ni,blur:ri,empty:oi,open:ii,close:ai,select:si,clear:li,reset:ci,breakpoint:ui,call:di,return:pi,js:mi,async:fi,tell:hi,default:yi,init:gi,behavior:vi,install:ki,measure:Si,swap:xi,morph:bi,beep:wi,break:Ti,copy:Ei,exit:Li,pick:Ci,render:Oi,bind:bo,live:wo,eventsource:To,socket:Eo,worker:Lo,intercept:Co,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:!0,roles:[]}};function re(o){return Ce[o]}function ce(o,e){let t=o.possessive?.keywords?.[e];if(t)return t;let n=o.possessive?.specialForms;if(n){for(let[r,i]of Object.entries(n))if(i===e)return r}}var kn=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:!0,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:!0,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:!0,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:!0,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:!0,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:!0,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function Rt(o,e,t,n){let r=kn.find(s=>s.lang===o);if(!r)return!1;let i=(s,a)=>(s??"").toLowerCase()===a.toLowerCase();return i(e,r.end)&&i(t,r.at)&&i(n,r.of)}function Sn(o,e){let t=kn.find(r=>r.lang===o);if(!t)return!1;let n=e.toLowerCase();return n===t.at.toLowerCase()||n===t.of.toLowerCase()||n===t.end.toLowerCase()}var xn=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]),zi={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]},At=class{calculate(e){return this.calculateWithBreakdown(e).final}calculateWithBreakdown(e){let t=this.scoreRoleCoverage(e),n=this.scoreStemPenalty(e),r=this.scoreLanguageBoost(e),i=this.scoreLanguageAdjustment(e),s=t;return s=Math.max(.5,s+n),s=Math.min(1,s+r),s=Math.max(0,Math.min(1,s+i)),{roleCoverage:t,stemPenalty:n,languageBoost:r,languageAdjustment:i,final:s}}scoreRoleCoverage(e){let{pattern:t,captured:n}=e,r=0,i=0,s=a=>t.extraction?.[a]?.default!==void 0;for(let a of t.template.tokens)if(a.type==="role")i+=1,n.has(a.role)&&(r+=1);else if(a.type==="group")for(let l of a.tokens)l.type==="role"&&(i+=.8,n.has(l.role)?r+=.8:s(l.role)&&(r+=.8*.6));return i>0?r/i:1}scoreStemPenalty(e){let{stemMatchCount:t,totalKeywordMatches:n}=e;return t<=0||n<=0?0:-(t/n)*.15}scoreLanguageBoost(e){let{pattern:t}=e;if(t.language!=="ar")return 0;let n=t.template.tokens[0];return!n||n.type!=="literal"?0:xn.has(n.value)||n.alternatives?.some(r=>xn.has(r))?.15:0}scoreLanguageAdjustment(e){let{pattern:t,captured:n}=e;if(t.language!=="ar")return 0;let r=0;for(let[i,s]of n.entries()){let a=zi[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;l&&typeof l.prepositionValue=="string"&&(a.includes(l.prepositionValue)?r+=.1:r-=.1)}return Math.max(-.1,Math.min(.1,r))}},bn=new At;var Vi=new Set(Object.values(Ce).filter(o=>o.bareKeyword===!0).map(o=>o.action)),A=class A{constructor(e){this.matchCache=new Map;this.stemMatchCount=0;this.totalKeywordMatches=0;this.confidenceModel=e??bn}matchPattern(e,t){let n=e.mark(),r=new Map;if(this.currentProfile=I(t.language),this.currentPatternCommand=t.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,r))return e.reset(n),null;let s=this.confidenceModel.calculate({pattern:t,captured:r,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,r),{pattern:t,captured:r,consumedTokens:e.position()-n.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let n=[],r=e.position();for(let s of t){let a=e.mark(),l=`${r}:${s.id}`,c;this.matchCache.has(l)?c=this.matchCache.get(l):(c=this.matchPattern(e,s),this.matchCache.set(l,c)),c&&n.push(c),e.reset(a)}if(n.length===0)return null;n.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;return l!==0?l:a.confidence-s.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n,r){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=0;for(let l=0;l<t.length;l++){let c=t[l];a>0&&c.type==="literal"&&this.tryConsumeEventSourceClause(e,n,c);let u=this.matchPatternToken(e,c,n,t[l+1]??r);if(a=c.type==="role"&&c.role==="event"?2:Math.max(0,a-1),!u){if(this.isOptional(c))continue;return!1}}return!0}tryConsumeEventSourceClause(e,t,n){if(t.has("source"))return;let r=e.peek(),i=e.peek(1);if(!r||!i||this.patternTokenWouldMatch(n,r))return;let s=this.currentProfile?.roleMarkers?.source,a=c=>{if(c.kind!=="particle"&&c.kind!=="keyword")return!1;if((c.normalized??"").toLowerCase()==="source")return!0;if(!s)return!1;let u=c.value.toLowerCase();return s.primary?.toLowerCase()===u?!0:!!s.alternatives?.some(d=>d.toLowerCase()===u)},l=s?.position;if(l!=="after"&&a(r)&&i.kind==="selector"){e.advance();let c=this.tokenToSemanticValue(e.advance());c&&t.set("source",c);return}if(l==="after"&&r.kind==="selector"&&a(i)){let c=this.tokenToSemanticValue(r);e.advance(),e.advance(),c&&t.set("source",c)}}matchPatternToken(e,t,n,r){switch(t.type){case"literal":return this.matchLiteralToken(e,t);case"role":return this.matchRoleToken(e,t,n,r);case"group":return this.matchGroupToken(e,t,n,r);default:return!1}}matchLiteralToken(e,t){let n=e.peek();if(!n)return!1;let r=this.getMatchType(n,t.value);if(r!=="none")return this.totalKeywordMatches++,r==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(n,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),!0}for(let i of[t.value,...t.alternatives??[]])for(let s of["-","_"])if(i.includes(s)&&this.tryMatchShatteredCompound(e,i,s))return this.totalKeywordMatches++,!0;return!1}tryFoldHyphenActionKeyword(e){let t=this.currentProfile;if(!t)return null;let n=e.mark(),r=[];for(;;){let s=e.peek();if(!s||s.kind!=="identifier"&&s.kind!=="keyword")break;r.push(s.value),e.advance();let a=e.peek();if(!a||a.value!=="-")break;e.advance(),r.push("-")}if(r.length<3||r[r.length-1]==="-")return e.reset(n),null;let i=r.join("").toLowerCase();for(let[s,a]of Object.entries(t.keywords))if(a.primary.toLowerCase()===i||a.alternatives?.some(l=>l.toLowerCase()===i))return j(s);return e.reset(n),null}tryMatchShatteredCompound(e,t,n){let r=t.split(n);if(r.length<2||r.some(s=>s.length===0))return!1;let i=e.mark();for(let s=0;s<r.length;s++){if(s>0){let l=e.peek();if(!l||l.value!==n)return e.reset(i),!1;e.advance()}let a=e.peek();if(!a||a.kind!=="identifier"&&a.kind!=="keyword"&&a.kind!=="particle"||a.value.toLowerCase()!==r[s].toLowerCase())return e.reset(i),!1;e.advance()}return!0}matchRoleToken(e,t,n,r){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||!1;if(t.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return n.set(t.role,g),!0}if(t.role==="event"&&this.currentPatternCommand==="on"){if(!A.tokenLooksLikeEvent(i))return t.optional||!1;let g=(i.normalized??i.value).toLowerCase();if(A.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(ce(this.currentProfile,i.value)??ce(this.currentProfile,g))!==void 0||i.value.includes("?."))return t.optional||!1}if(t.role==="event"){let g=(i.normalized??i.value).toLowerCase();if(A.STRUCTURAL_NEVER_EVENT.has(g))return t.optional||!1}if(t.role==="duration"){let g=(i.normalized??i.value).toLowerCase();if(A.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return t.optional||!1}if(t.optional&&r===void 0&&t.role!=="event"&&t.role!=="action"&&i.kind==="keyword"&&(i.normalized??i.value).toLowerCase()in Ce)return!0;let s=this.tryMatchPositionalExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(s.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,s),!0);let a=this.tryMatchCaretScopeExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(a.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,a),!0);if(t.role!=="event"&&(!t.expectedTypes||t.expectedTypes.includes("expression"))){let g=this.tryMatchOperatorRunExpression(e);if(g)return n.set(t.role,g),!0}if(t.expectedTypes?.includes("property-path")){let g=this.tryMatchOfPossessiveExpression(e);if(g)return n.set(t.role,g),!0;let x=this.tryMatchPostNominalPossessiveExpression(e);if(x)return n.set(t.role,x),!0}let l=this.tryMatchPossessiveExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,l),!0);let c=this.tryMatchMethodCallExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,c),!0);let d=t.role==="event"&&this.currentPatternCommand==="on"||A.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(d)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(d.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,d),!0);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(f.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,f),!0);let m=t.role!=="condition",p=this.tryMatchPropertyAccessExpression(e,m);if(p)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(p.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,p),!0);let h=this.tryMatchSelectorPropertyExpression(e);if(h)return t.expectedTypes&&t.expectedTypes.length>0&&!Be(h.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,h),!0);if(i.kind==="identifier"&&i.value==="{"&&(!t.expectedTypes?.length||t.expectedTypes.includes("literal"))){let g=this.tryMatchBraceRunLiteral(e);if(g)return n.set(t.role,g),!0}let y=this.tokenToSemanticValue(i);if(!y)return t.optional||!1;if(t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(y.type)){let g=y.type==="selector"&&String(y.value).startsWith("@"),x=t.expectedTypes.some(T=>T==="expression"||T==="reference");if(!(g&&x))return t.optional||!1}if(n.set(t.role,y),e.advance(),t.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in y&&(n.set(t.role,j(`${String(y.value)}${g.value}`)),e.advance());let x=e.peek();if(x&&(x.kind==="particle"||x.kind==="keyword")&&(x.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(r,x)){let T=e.peek(1);if(T&&(T.kind==="selector"||T.kind==="identifier")){e.advance();let L=this.tokenToSemanticValue(e.advance());L&&!n.has("source")&&n.set("source",L)}}}return!0}patternTokenWouldMatch(e,t){return e?e.type==="literal"?this.getMatchType(t,e.value)!=="none"?!0:!!e.alternatives?.some(n=>this.getMatchType(t,n)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],t):!1:!1}tryMatchPositionalExpression(e){let t=e.peek();if(!t)return null;let n=(t.normalized??t.value).toLowerCase();if(!A.POSITIONAL_KEYWORDS.has(n)&&!A.POSITIONAL_KEYWORDS.has(t.value.toLowerCase()))return null;let r=e.mark(),i=[t.normalized??t.value];e.advance();let s=e.peek();if(!s||s.kind!=="selector")return e.reset(r),null;i.push(s.value),e.advance();let a=0;for(;a++<8;){let u=e.peek();if(u&&u.kind==="selector"&&u.value.startsWith("."))i.push(u.value),e.advance();else break}let l=e.peek(),c=e.peek(1);return l&&c&&c.kind==="selector"&&(l.kind==="keyword"||l.kind==="particle"||l.kind==="identifier")&&!A.POSITIONAL_KEYWORDS.has((l.normalized??l.value).toLowerCase())&&!A.COMMAND_ACTION_KEYWORDS.has((l.normalized??l.value).toLowerCase())&&(i.push(l.normalized??l.value,c.value),e.advance(),e.advance()),{type:"expression",raw:i.join(" ")}}tryMatchCaretScopeExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!t.value.startsWith("^"))return null;let n=e.peek(1),r=e.peek(2),i=(n?.normalized??"").toLowerCase(),s=!!n&&(n.value.toLowerCase()==="on"||i==="destination"||i==="on");return!n||!r||r.kind!=="selector"||!s?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${t.value} on ${r.value}`})}isOfPossessiveMarker(e){let t=e.value.toLowerCase(),n=(e.normalized??"").toLowerCase();if(t==="of"||t==="ng"||n==="of"||n==="source")return!0;let r=this.currentProfile?.code?A.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return!!r&&r.has(t)}tryMatchOperatorRunExpression(e){let t=e.mark(),n=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(t),null;let r=1;for(;;){let s=e.peek();if(!s||!A.RUN_OPERATORS.has(s.value))break;let a=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(a);break}r++}if(r<2)return e.reset(t),null;let i=e.tokens.slice(n,e.position()).map(s=>s.value).join(" ");return{type:"expression",raw:i,value:i}}tryConsumeRunOperand(e){let t=e.peek();if(!t)return!1;if(t.value==="("){let n=e.mark(),r=0;for(;!e.isAtEnd();){let i=e.advance();if(i.value==="(")r++;else if(i.value===")"&&(r--,r===0))return!0}return e.reset(n),!1}return this.tryMatchPossessiveExpression(e)?!0:(t.kind==="literal"||t.kind==="identifier"||t.kind==="selector"||t.kind==="keyword")&&!A.RUN_OPERATORS.has(t.value)&&t.value!==")"?(e.advance(),!0):!1}tryMatchOfPossessiveExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||!this.isOfPossessiveMarker(r))return e.reset(n),null;e.advance();let i=e.peek();return!i||i.kind!=="selector"?(e.reset(n),null):(e.advance(),ae(ne(i.value),t.value))}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=[t.value,t.normalized].filter(Boolean),r;for(let l of n)if(r=ce(this.currentProfile,l)??ce(this.currentProfile,l.toLowerCase()),r)break;if(!r)return null;let i=e.mark();e.advance();let s=this.currentProfile.possessive?.connectors;if(s&&s.length>0){let l=e.peek();if(l){let c=l.value.toLowerCase(),u=(l.normalized??"").toLowerCase();s.some(d=>d.toLowerCase()===c||d.toLowerCase()===u)&&e.advance()}}let a=e.peek();if(!a||Sn(this.currentProfile.code,a.value))return e.reset(i),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)&&!(a.normalized&&this.isStructuralKeyword(a.normalized))&&!(a.normalized&&this.isRoleMarkerConcept(a.normalized))||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();if(u&&u.value.startsWith("(")){let d="",f=0,m=0;for(;!e.isAtEnd()&&m++<A.MAX_METHOD_ARGS+2;){let p=e.peek();if(!p)break;d+=p.value,e.advance();for(let h of p.value)h==="("?f++:h===")"&&f--;if(f<=0)break}c+=d}return ae(Z(r),c)}return e.reset(i),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let t=d=>{for(let f of[d.value,d.normalized].filter(Boolean))if(ce(this.currentProfile,f)??ce(this.currentProfile,f.toLowerCase()))return!0;return!1},n=e.peek();if(!n)return null;let r=n.kind==="selector"&&n.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(n.value);if(!(n.kind==="identifier"&&!this.isStructuralKeyword(n.value)&&!(n.normalized&&this.isStructuralKeyword(n.normalized))&&!(n.normalized&&this.isRoleMarkerConcept(n.normalized))||n.kind==="selector"&&(n.value.startsWith("*")||n.value.startsWith("@"))||r)||t(n))return null;let s=e.mark(),a=n.value;r&&(a=a.substring(1)),e.advance();let l=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();if(!c)return e.reset(s),null;let u;for(let d of[c.value,c.normalized].filter(Boolean))if(u=ce(this.currentProfile,d)??ce(this.currentProfile,d.toLowerCase()),u)break;return u?(e.advance(),ae(Z(u),l)):(e.reset(s),null)}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return!1;let t=e.value;if(/[/#@*]/.test(t)||t.startsWith('"')||t.startsWith("'")||t.startsWith("`"))return!1;let n=e.normalized?.toLowerCase();return!(n&&Vi.has(n))}tryMatchBraceRunLiteral(e){let t=e.peek();if(!t||t.kind!=="identifier"||t.value!=="{")return null;let n=e.mark();e.advance();let r=["{"],i=1,s=0;for(;!e.isAtEnd()&&s++<A.MAX_BRACE_RUN_TOKENS;){let a=e.advance();if(!a)break;if(a.value==="{")i++;else if(a.value==="}"&&(i--,i===0))return r.push("}"),j(r.join(" "));r.push(a.value)}return e.reset(n),null}tryMatchBareCallExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(t.value))return null;let n=e.peek(1);if(!n||n.value!=="(")return null;let r=e.mark();e.advance(),e.advance();let i=[],s=!1,a=0;for(;!e.isAtEnd()&&a++<A.MAX_METHOD_ARGS+2;){let l=e.peek();if(!l)break;if(l.value===")"){e.advance(),s=!0;break}if(l.value===","){e.advance();continue}i.push(l.value),e.advance()}return s?{type:"expression",raw:`${t.value}(${i.join(", ")})`}:(e.reset(r),null)}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="operator"||r.value!==".")return e.reset(n),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(n),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<A.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e,t=!0){let n=e.peek();if(!n||n.kind!=="identifier"&&n.kind!=="keyword")return null;let r=e.mark();e.advance();let i=n.value.toLowerCase(),s=e.peek();if((n.kind==="identifier"||A.PROPERTY_ACCESS_BASES.has(i))&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value)){let m=n.value,p=[],h=0;for(;h<A.MAX_PROPERTY_DEPTH;){let x=e.peek();if(x&&x.kind==="selector"&&/^\.[a-zA-Z_]/.test(x.value))m+=`.${x.value.slice(1)}`,p.push(x.value.slice(1)),e.advance(),h++;else break}let y=e.peek(),g=!!y&&y.value.startsWith("(");if(t&&!g&&p.length>0&&ke(i))return ae(Z(i),p.join("."));if(g){let x=e.mark(),T=[],L=0,S=!1;for(;!e.isAtEnd();){let k=e.peek();if(!k)break;if(k.value==="(")L++;else if(k.value===")"){if(T.push(k.value),e.advance(),L--,L===0&&(S=!0),S)break;continue}T.push(k.value),e.advance()}S?m+=T.join(""):e.reset(x)}return{type:"expression",raw:m}}let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(r),null;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")return e.reset(r),null;e.advance();let c=`${n.value}.${l.value}`,u=1;for(;!e.isAtEnd()&&u<A.MAX_PROPERTY_DEPTH;){let m=e.peek();if(!m||m.kind!=="operator"||m.value!==".")break;e.advance();let p=e.peek();if(!p||p.kind!=="identifier")break;e.advance(),c+=`.${p.value}`,u++}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let m=[],p=0;for(;!e.isAtEnd()&&m.length<A.MAX_METHOD_ARGS;){let y=e.peek();if(!y)break;if(y.kind==="punctuation"&&y.value===")"){if(p===0){e.advance();break}p--}if(y.kind==="punctuation"&&y.value==="("&&p++,y.kind==="punctuation"&&y.value===","){e.advance();continue}m.push(y.value),e.advance()}return{type:"expression",raw:`${c}(${m.join(", ")})`}}let f=n.value.toLowerCase();if(t&&ke(f)){let m=c.split(".").slice(1).join(".");return ae(Z(f),m)}return{type:"expression",raw:c}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let r=e.peek(),i=this.currentProfile?.possessive?.marker?.replace(/^-/,""),s=!!r&&r.kind==="punctuation"&&r.value==="'s",a=!!r&&r.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",l=(()=>{if(!this.currentPatternCommand||(r?.normalized??"").toLowerCase()!=="source")return!1;let f=Ce[this.currentPatternCommand];return!!f&&f.roles.some(m=>m.role==="source")})(),c=!!r&&!!i&&i!=="'s"&&r.value===i&&(r.kind==="particle"||r.kind==="punctuation")&&!l;if(!s&&!c&&!a)return e.reset(n),null;e.advance(),a&&e.advance();let u=e.peek();return!u||!(u.kind==="identifier"||(s||a)&&(u.kind==="selector"||u.kind==="keyword"))?(e.reset(n),null):(e.advance(),ae(ne(t.value),u.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("."))return e.reset(n),null;let i=e.peek(1);i&&i.kind,e.advance();let s=r.value.slice(1);return ae(ne(t.value),s)}matchGroupToken(e,t,n,r){let i=e.mark(),s=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n,r)){e.reset(i);for(let l of n.keys())s.has(l)||n.delete(l);return t.optional||!1}return!0}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case"selector":return ne(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return ke(t)?Z(t):j(e.normalized||e.value);case"identifier":if(e.value.startsWith("@"))return ne(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return Z(e.value);let n=e.value.toLowerCase();return ke(n)?Z(n):{type:"expression",raw:e.value};case"url":return j(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let r=e.slice(1,-1);return j(r,"string")}if(e==="true")return j(!0,"boolean");if(e==="false")return j(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let r=parseFloat(t[1]);return t[2]?j(e,"duration"):j(r,"number")}let n=parseFloat(e);return isNaN(n)?j(e,"string"):j(n,"number")}applyExtractionRules(e,t){for(let[n,r]of Object.entries(e.extraction))t.has(n)||(r.value!==void 0?t.set(n,{type:"literal",value:r.value}):r.default&&t.set(n,r.default))}isOptional(e){return e.type!=="literal"&&e.optional===!0}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=t.value.toLowerCase();if(A.ENGLISH_NOISE_WORDS.has(n)){let r=e.mark();e.advance();let i=e.peek();if(i&&(i.kind==="selector"||i.kind==="identifier"))return;let s=e.peek(1);if(i&&i.kind==="keyword"&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value))return;let a=i?(i.normalized??i.value).toLowerCase():"";if(i&&A.POSITIONAL_OR_SCOPE_KEYWORDS.has(a))return;let l=e.peek(1),c=l?(l.normalized??l.value).toLowerCase():"",u=this.currentProfile?.wordOrder!=="SOV"&&A.COMMAND_ACTION_KEYWORDS.has(c),d=!l||l.kind==="particle"||A.CLAUSE_BOUNDARY_KEYWORDS.has(c)||u;if(i&&i.kind==="keyword"&&this.currentProfile?.code!=="en"&&ke(a)&&d||i&&i.kind==="keyword"&&this.currentProfile?.code==="en"&&ke(a))return;e.reset(r)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let r=e.peek();if(!r||r.kind!=="event-modifier")break;let i=r.metadata;if(!i)break;switch(n=!0,i.modifierName){case"once":t.once=!0;break;case"debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case"throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case"queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance()}return n?t:void 0}};A.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]),A.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]),A.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]),A.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]),A.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(Ce).map(e=>e.toLowerCase())),A.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]),A.OF_POSSESSIVE_MARKERS={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin"])},A.RUN_OPERATORS=new Set(["+","-","*","/"]),A.MAX_BRACE_RUN_TOKENS=64,A.MAX_PROPERTY_DEPTH=10,A.MAX_METHOD_ARGS=20,A.DECLARATION_COMMANDS=new Set(["behavior","def","install"]),A.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Mt=A,se=new Mt;var Ii=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],it=class{constructor(e=Ii){this.name="operator";this.operators=[...e].sort((t,n)=>n.length-t.length)}canExtract(e,t){return this.operators.some(n=>e.startsWith(n,t))}extract(e,t){for(let n of this.operators)if(e.startsWith(n,t))return{value:n,length:n.length};return null}},_i="()[]{},:;",at=class{constructor(e=_i){this.punctuation=e;this.name="punctuation"}canExtract(e,t){return this.punctuation.includes(e[t])}extract(e,t){let n=e[t];return this.punctuation.includes(n)?{value:n,length:1}:null}};function Ot(o,e){let t=o[e];if(t==="#"){let n=o.slice(e).match(/^#[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="."){let n=o.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(n)return n[0];let r=o.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="@"){let n=o.slice(e).match(/^@[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="*"){let n=o.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return n?n[0]:null}if(t==="["){let n=0,r=e;for(;r<o.length;){if(o[r]==="["&&n++,o[r]==="]"&&(n--,n===0))return o.slice(e,r+1);r++}return null}if(t==="<"){let n=o.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return n?n[0]:null}return null}var De=class{constructor(){this.name="css-selector"}canExtract(e,t){let n=e[t];return n==="#"||n==="."||n==="["||n==="<"?!0:n==="@"||n==="*"?Ot(e,t)!==null:!1}extract(e,t){let n=Ot(e,t);return n?{value:n,length:n.length,metadata:{type:"css-selector"}}:null}};var $e=class{constructor(){this.name="event-modifier"}canExtract(e,t){if(e[t]!==".")return!1;let n=e.slice(t);return/^\.(once|prevent|stop|debounce|throttle|queue)/.test(n)}extract(e,t){let n=e.slice(t).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!n)return null;let r=n[0],i=r.slice(1).split("(")[0],s=n[1];return{value:r,length:r.length,metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}};function wn(o,e){let t=o.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let n=t.match(/^https?:\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("//")){let n=t.match(/^\/\/[^\s]*/);return n?n[0]:null}if(t.startsWith("./")||t.startsWith("../")){let n=t.match(/^\.\.?\/[^\s]*/);return n?n[0]:null}if(t.startsWith("/")){let n=t.match(/^\/[^\s]*/);return n?n[0]:null}return null}var qe=class{constructor(){this.name="url"}canExtract(e,t){let n=e.slice(t);return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("//")||n.startsWith("./")||n.startsWith("../")||n.startsWith("/")}extract(e,t){let n=wn(e,t);return n?{value:n,length:n.length,metadata:{type:"url"}}:null}};var We=class{constructor(){this.name="variable-ref"}canExtract(e,t){let n=e[t];return(n===":"||n==="$"||n==="^")&&t+1<e.length&&/[a-zA-Z_]/.test(e[t+1])}extract(e,t){if(!this.canExtract(e,t))return null;let n=1;for(;t+n<e.length&&/[a-zA-Z0-9_]/.test(e[t+n]);)n++;return{value:e.substring(t,t+n),length:n,metadata:{type:"variable-reference"}}}};function st(o){let e=o.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?!0:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(o)}var ji=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),Bi=new Set(["de","da","te","ta","den","dan","ten","tan","e","a","ye","ya","i","\u0131","u","\xFC","in","\u0131n","un","\xFCn","le","la","yle","yla"]),zt=class{constructor(){this.name="turkish-keyword"}setContext(e){this.context=e}canExtract(e,t){return st(e[t])}extract(e,t){if(!this.context)throw new Error("TurkishKeywordExtractor: context not set");let n=t,r=12;for(let f=Math.min(r,e.length-n);f>=2;f--){let m=e.slice(n,n+f);if(n+f<e.length&&st(e[n+f]))continue;let p=!0;for(let y=0;y<m.length;y++)if(!st(m[y])){p=!1;break}if(!p)continue;let h=this.context.lookupKeyword(m);if(h)return{value:m,length:f,metadata:{normalized:h.normalized!==h.native?h.normalized:void 0}};if(this.context.normalizer){let y=this.context.normalizer.normalize(m);if(y.stem!==m&&y.confidence>=.7){let g=this.context.lookupKeyword(y.stem);if(g)return{value:m,length:f,metadata:{normalized:g.normalized,stem:y.stem,stemConfidence:y.confidence}}}}}let i="",s=t;for(;s<e.length&&st(e[s]);)i+=e[s],s++;for(let f=i.length;f>=2&&!(f<i.length);f--){let m=i.substring(0,f),p=this.context.lookupKeyword(m);if(p)return{value:m,length:f,metadata:{normalized:p.normalized!==p.native?p.normalized:void 0}}}if(!i||!i)return null;if(ji.has(i.toLowerCase()))return{value:i,length:s-n,metadata:{postpositionValue:i.toLowerCase()}};if(Bi.has(i.toLowerCase()))return{value:i,length:s-n,metadata:{caseSuffixValue:i.toLowerCase()}};let a=this.context.lookupKeyword(i),l=a&&a.normalized!==a.native?a.normalized:void 0,c,u,d;if(!a&&this.context.normalizer){let f=this.context.normalizer.normalize(i);if(f.stem!==i&&f.confidence>=.7){let m=this.context.lookupKeyword(f.stem);m&&(c=m.normalized,u=f.stem,d=f.confidence)}}return{value:i,length:s-n,metadata:{normalized:l||c,stem:u,stemConfidence:d}}}};function Tn(){return new zt}function En(){return[new qe,new $e,new We,new De]}function Di(o){let e=o.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?!0:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(o)}function $i(o){for(let e of o)if(Di(e))return!0;return!1}function Vt(o){return"a\u0131ouAIOU".includes(o)}function Ln(o){return"ei\xF6\xFCE\u0130\xD6\xDC".includes(o)}function Cn(o){return Vt(o)||Ln(o)}function qi(o){for(let e=o.length-1;e>=0;e--)if(Cn(o[e]))return o[e];return null}function Wi(o,e){let t=qi(o);if(!t)return!0;let n=e.split("").find(r=>Cn(r));return n?Vt(t)?Vt(n):Ln(n):!0}var Ki=[{pattern:"iyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorsunuz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorsun",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyoruz",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"iyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"uyorum",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"iyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"uyorlar",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"eceksiniz",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaks\u0131n\u0131z",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"eceksin",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaks\u0131n",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"ece\u011Fiz",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"aca\u011F\u0131z",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"ece\u011Fim",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"aca\u011F\u0131m",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"ecekler",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"acaklar",confidence:.82,conjugationType:"future",minStemLength:2},{pattern:"mi\u015Fsiniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Fs\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fs\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fsunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fsin",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Fs\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fs\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fsun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fiz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Fum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mi\u015Fler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015Flar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015Fler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"mu\u015Flar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"diniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tiniz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131n\u0131z",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCn\xFCz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tunuz",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"diler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131lar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dular",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tiler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131lar",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCler",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tular",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"din",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tin",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131n",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCn",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tun",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\u0131k",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"d\xFCk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"duk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tik",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\u0131k",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"t\xFCk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"tuk",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"dim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"dum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tim",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\u0131m",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\xFCm",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tum",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"iyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u0131yor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\xFCyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"uyor",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"ecek",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"acak",confidence:.85,conjugationType:"future",minStemLength:2},{pattern:"mi\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\u0131\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"m\xFC\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mu\u015F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"di",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\u0131",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"d\xFC",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"du",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"ti",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\u0131",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"t\xFC",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"tu",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"mek",confidence:.88,conjugationType:"dictionary",minStemLength:2},{pattern:"mak",confidence:.88,conjugationType:"dictionary",minStemLength:2},{pattern:"eyelim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"ayal\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"eyim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"ay\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"elim",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"al\u0131m",confidence:.82,conjugationType:"optative",minStemLength:2},{pattern:"melisiniz",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131s\u0131n\u0131z",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"melisin",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131s\u0131n",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meliyiz",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131y\u0131z",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meliyim",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131y\u0131m",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"meliler",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131lar",confidence:.82,conjugationType:"necessitative",minStemLength:2},{pattern:"meli",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"mal\u0131",confidence:.85,conjugationType:"necessitative",minStemLength:2},{pattern:"ebiliyor",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"abiliyor",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"ebilir",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"abilir",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"ebildi",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"abildi",confidence:.82,conjugationType:"potential",minStemLength:2},{pattern:"ebilmek",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"abilmek",confidence:.85,conjugationType:"potential",minStemLength:2},{pattern:"iniz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"\u0131n\u0131z",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"\xFCn\xFCz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"unuz",confidence:.82,conjugationType:"imperative",minStemLength:2},{pattern:"in",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"\u0131n",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"\xFCn",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"un",confidence:.8,conjugationType:"imperative",minStemLength:2},{pattern:"ildi",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\u0131ld\u0131",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\xFCld\xFC",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"uldu",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ilir",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\u0131l\u0131r",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"\xFCl\xFCr",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"ulur",confidence:.82,conjugationType:"passive",minStemLength:2},{pattern:"tirmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"t\u0131rmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"t\xFCrmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"turmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"dirmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"d\u0131rmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"d\xFCrmek",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"durmak",confidence:.82,conjugationType:"causative",minStemLength:2},{pattern:"miyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyorsunuz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyorsun",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"muyoruz",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"miyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"muyorum",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"miyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\u0131yor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"m\xFCyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"muyor",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"medi",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"mad\u0131",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"me",confidence:.75,conjugationType:"negative",minStemLength:3},{pattern:"ma",confidence:.75,conjugationType:"negative",minStemLength:3}],Ke=class{constructor(){this.language="tr"}isNormalizable(e){return!(!$i(e)||e.length<3)}normalize(e){let t=e.toLowerCase();for(let n of Ki)if(t.endsWith(n.pattern)){let r=t.slice(0,-n.pattern.length),i=n.minStemLength??2;if(r.length<i)continue;if(!Wi(r,n.pattern)){let a=n.confidence*.9,l={removedSuffixes:[n.pattern]};return n.conjugationType&&(l.conjugationType=n.conjugationType),ot(r,a,l)}let s={removedSuffixes:[n.pattern]};return n.conjugationType&&(s.conjugationType=n.conjugationType),ot(r,n.confidence,s)}return Pt(e)}},Ks=new Ke;var Fi=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","boyunca"]),Ui=new Set(["de","da","te","ta","den","dan","ten","tan","e","a","ye","ya","i","\u0131","u","\xFC","in","\u0131n","un","\xFCn","le","la","yle","yla"]),Hi=[{native:"do\u011Fru",normalized:"true"},{native:"dogru",normalized:"true"},{native:"yanl\u0131\u015F",normalized:"false"},{native:"yanlis",normalized:"false"},{native:"null",normalized:"null"},{native:"bo\u015F",normalized:"null"},{native:"bos",normalized:"null"},{native:"tan\u0131ms\u0131z",normalized:"undefined"},{native:"tanimsiz",normalized:"undefined"},{native:"ilk",normalized:"first"},{native:"son",normalized:"last"},{native:"sonuncu",normalized:"last"},{native:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"enyak\u0131n",normalized:"closest"},{native:"enyakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{native:"farebas",normalized:"mousedown"},{native:"fareb\u0131rak",normalized:"mouseup"},{native:"farebirak",normalized:"mouseup"},{native:"kayd\u0131r",normalized:"scroll"},{native:"kaydir",normalized:"scroll"},{native:"tu\u015F_bas",normalized:"keydown"},{native:"tus_bas",normalized:"keydown"},{native:"tu\u015F_b\u0131rak",normalized:"keyup"},{native:"tus_birak",normalized:"keyup"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"}],It=class extends _e{constructor(){super();this.language="tr";this.direction="ltr";this.initializeKeywordsFromProfile(ve,Hi),this.setNormalizer(new Ke),this.registerExtractors(En()),this.registerExtractor(new Ct),this.registerExtractor(new Nt),this.registerExtractor(Tn()),this.registerExtractor(new it),this.registerExtractor(new at)}classifyToken(t){let n=t.toLowerCase();return Fi.has(n)||Ui.has(n)?"particle":this.isKeyword(n)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(t)?"operator":"identifier"}},lt=new It;function G(o,e){return en(o,e)}function ct(){return xt()}var dt=["if","unless","repeat","for","while"];function le(o,e){let t=new Set([e]),r=I(o)?.keywords?.[e];if(r){r.primary&&t.add(r.primary.toLowerCase());for(let i of r.alternatives??[])t.add(i.toLowerCase())}return t}function te(o,e){return e.has(o.value.toLowerCase())?!0:o.normalized?e.has(o.normalized.toLowerCase()):!1}var Yi=new Set(dt);function jt(o,e){let t=o.normalized?.toLowerCase();return t?Yi.has(t):e.some(n=>te(o,n))}var Nn=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Zi=new Set(["destination","source","style","patient","on","from","to"]);function Ji(o){if(!o||o.kind==="selector")return!1;let e=(o.normalized??o.value).toLowerCase(),t=o.value.toLowerCase();return!(Nn.has(e)||Nn.has(t)||Zi.has(e))}var Pn=new Set(["ja","ko"]);function _t(o){let e=new Set;o?.primary&&e.add(o.primary.toLowerCase());for(let t of o?.alternatives??[])e.add(t.toLowerCase());return e}function An(o,e){let t=[],n=e.position.end,r=o.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(r){n=e.position.end+r[0].length;for(let i of r[1].split(/[,،、]/)){let s=i.trim();s&&t.push(s)}}return{parameters:t,headerEnd:n}}function Mn(o,e,t){let n=e+1;if(n>=o.length)return-1;let r=_t(I(t)?.roleMarkers?.patient);return r.size>0&&te(o[n],r)&&n++,n<o.length?n:-1}function On(o,e,t){if(!I(e))return null;let n=le(e,"behavior"),r=le(e,"def"),i=o.toLowerCase(),s=[...n].some(u=>i.includes(u)),a=/\bdef\b/.test(i)||[...r].some(u=>u!=="def"&&i.includes(u));if(!s&&!a)return null;let l=G(o,e).tokens;if(l.length<2)return null;if(te(l[0],n))return Rn(o,e,l,t,0);let c=l.findIndex((u,d)=>d>0&&te(u,n));return c>0&&/^[A-Z][A-Za-z0-9_]*$/.test(l[0].value)?Rn(o,e,l,t,c):te(l[0],r)?Xi(o,e,l,t):null}function zn(o,e,t){let n=I(e);if(!n)return null;let r=n.wordOrder!=="SOV",i=Pn.has(e)?_t(n.roleMarkers?.event):new Set,s=Pn.has(e)?_t(n.keywords?.on):new Set,a=i.size>0&&s.size>0,l=le(e,"end"),c=le(e,"on"),u=o.toLowerCase(),d=[...l].some(k=>u.includes(k)),f=(r||a)&&(()=>{let k=0;for(let E of c)if(E){for(let v=u.indexOf(E);v>=0;v=u.indexOf(E,v+E.length))if(++k>=2)return!0}return!1})();if(!d&&!f)return null;let m=G(o,e).tokens;if(m.length<2)return null;let p=dt.map(k=>le(e,k)),h=k=>jt(k,p),y=k=>te(k,l),g=[],x=0,T=0;for(let k=0;k<m.length;k++){let E=m[k];if(y(E)){if(x>0){x--;continue}let v=o.slice(m[T].position.start,E.position.start).trim();v&&g.push(v),T=k+1}else if(h(E))x++;else if(r&&x===0&&k>T&&te(E,c)&&Ji(m[k+1])){let v=o.slice(m[T].position.start,E.position.start).trim();v&&g.push(v),T=k}else if(a&&x===0&&k-1>T&&te(E,i)&&m[k+1]!==void 0&&te(m[k+1],s)){let v=m[k-1],b=o.slice(m[T].position.start,v.position.start).trim();b&&g.push(b),T=k-1}}if(T<m.length){let k=o.slice(m[T].position.start).trim();k&&g.push(k)}if(g.length<2)return null;let L=[],S=[];for(let k of g){let E;try{E=t.statement(k,e)}catch{return null}if(!E||E.kind!=="event-handler")return null;let v=E;L.push(v);let b=!v.body||v.body.length===0;S.push(b?.2:v.metadata?.confidence??.75)}return je(L,"then",{sourceLanguage:e,confidence:ut(S),sourceText:o})}function ut(o){return o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0}function Vn(o){let e=[];for(let t of o){let n=t.statements;t.kind==="compound"&&Array.isArray(n)?e.push(...n):e.push(t)}return e}function Rn(o,e,t,n,r){let i=r>0,s=i?0:Mn(t,r,e);if(s<0)return null;let a=t[s],l=a.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(l))return null;let{parameters:c,headerEnd:u}=An(o,a),d=i?r+1:t.findIndex(v=>v.position.start>=u);d<=s&&(d=s+1);let f=le(e,"init"),m=le(e,"end"),p=dt.map(v=>le(e,v)),h=v=>jt(v,p),y=v=>te(v,m),g=[],x=[],T=[],L=!1,S=0,k=d;for(let v=d;v<t.length;v++){let b=t[v];if(y(b)){if(S>0){S--;continue}if(v===k){L=!0;break}if(te(t[k],f)){let N=o.slice(t[k].position.end,b.position.start).trim();if(N)try{let C=Vn(n.body(N,e));x.push(...C),T.push(ut(C.map(z=>z.metadata?.confidence??.75)))}catch{T.push(0)}}else{let N=o.slice(t[k].position.start,b.position.start).trim();try{let C=n.statement(N,e);if(C&&C.kind==="event-handler"){let z=C;g.push(z);let M=!z.body||z.body.length===0;T.push(M?.2:z.metadata?.confidence??.75)}else T.push(0)}catch{T.push(0)}}k=v+1}else h(b)&&S++}if(g.length===0&&x.length===0)return null;let E=(L?1:.8)*ut(T);return hn(l,c,g,x.length>0?x:void 0,{sourceLanguage:e,confidence:E,sourceText:o})}function Xi(o,e,t,n){let r=Mn(t,0,e);if(r<0)return null;let i=t[r],s=i.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(s))return null;let{parameters:a,headerEnd:l}=An(o,i),c=t.findIndex(S=>S.position.start>=l);c<=r&&(c=r+1);let u=le(e,"end"),d=dt.map(S=>le(e,S)),f=S=>jt(S,d),m=S=>te(S,u),p=0,h=-1;for(let S=c;S<t.length;S++)if(m(t[S])){if(p===0){h=S;break}p--}else f(t[S])&&p++;let y=t[c]?.position.start??l,g=h>=0?t[h].position.start:o.length,x=o.slice(y,g).trim();if(!x)return null;let T;try{T=Vn(n.body(x,e))}catch{return null}if(T.length===0)return null;let L=ut(T.map(S=>S.metadata?.confidence??.75));return h<0&&(L*=.8),yn(s,a,T,{sourceLanguage:e,confidence:L,sourceText:o})}var Se={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Qi=Object.fromEntries(Object.entries(Se).map(([o,e])=>{let t={};for(let[n,r]of Object.entries(e))r in t||(t[r]=n);return[o,t]})),ea={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function In(o,e){return ea[e]?.has(o)?o:Qi[e]?.[o]??o}var pt=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);if(e.kind==="behavior")return this.renderBehavior(e,t);if(e.kind==="def")return this.renderDef(e,t);let n=wt(t,e.action);if(n.length===0)return this.renderExplicit(e);let r=this.findBestPattern(e,n);return r?this.renderWithPattern(e,r):this.renderExplicit(e)}renderCompound(e,t){if(e.statements.length>1&&e.statements.every(i=>i.kind==="event-handler")){let i=this.keyword(t,"end"),s=[];for(let a of e.statements)s.push(this.render(a,t),i);return s.join(`
3
3
  `)}let n=e.statements.map(i=>this.render(i,t)),r=this.getChainWord(e.chainType,t);return n.join(` ${r} `)}keyword(e,t){return I(e)?.keywords?.[t]?.primary??t}renderBlockHeader(e,t,n){return n.length>0?`${e} ${t}(${n.join(", ")})`:`${e} ${t}`}renderBehavior(e,t){let n=this.keyword(t,"end"),r=[this.renderBlockHeader(this.keyword(t,"behavior"),e.name,e.parameters)];for(let i of e.eventHandlers)r.push(` ${this.render(i,t)}`,` ${n}`);if(e.initBlock&&e.initBlock.length>0){r.push(` ${this.keyword(t,"init")}`);for(let i of e.initBlock)r.push(` ${this.render(i,t)}`);r.push(` ${n}`)}return r.push(n),r.join(`
4
4
  `)}renderDef(e,t){let n=[this.renderBlockHeader(this.keyword(t,"def"),e.name,e.parameters)];for(let r of e.body)n.push(` ${this.render(r,t)}`);return n.push(this.keyword(t,"end")),n.join(`
5
- `)}getChainWord(e,t){let n=I(t);return n?.keywords?n.keywords[e]?.primary??e:e}renderExplicit(e){return ee(e)}supportedLanguages(){return ct()}findBestPattern(e,t){let n=t;if(e.kind==="event-handler"){let i=t.filter(s=>!/-event-/i.test(s.id));i.length>0&&(n=i)}let r=n.map(i=>{let s=i.priority;for(let a of i.template.tokens)a.type==="role"&&(e.roles.has(a.role)?s+=10:a.optional||(s-=50));return/-at-end|-at-start|-before$|-after$/i.test(i.id)&&(s-=30),i.language==="en"&&((i.id.includes("standard")||i.id.includes("en-source"))&&(s+=20),(i.id.includes("-when")||i.id.includes("-if")||i.id.includes("-upon"))&&(s-=15)),{pattern:i,score:s}});return r.sort((i,s)=>s.score-i.score),r.length>0?r[0].pattern:null}renderWithPattern(e,t){let n=[],r=t.language;for(let i of t.template.tokens){let s=this.renderPatternToken(i,e,r);s!==null&&n.push(s)}if(e.kind==="event-handler"){let i=e;if(i.body&&i.body.length>0){let s=i.body.map(a=>this.render(a,r));n.push(s.join(" "))}}return n.join(" ")}renderPatternToken(e,t,n){switch(e.type){case"literal":return e.value;case"role":{let r=t.roles.get(e.role);return r?e.role==="event"&&t.kind==="event-handler"?this.renderEventName(r,n):this.valueToNaturalString(r,n):(e.optional,null)}case"group":{if(!e.tokens.filter(a=>a.type==="role"&&!a.optional).every(a=>t.roles.has(a.role))&&e.optional)return null;if(e.optional&&e.tokens.find(l=>l.type==="role"&&l.role==="destination")){let l=t.roles.get("destination");if(l?.type==="reference"&&l.value==="me")return null}if(e.optional&&e.tokens.find(l=>l.type==="role"&&l.role==="quantity")){let l=t.roles.get("quantity");if(l?.type==="literal"&&Number(l.value)===1)return null}let i=[],s=!1;for(let a of e.tokens){let l=this.renderPatternToken(a,t,n);l!==null&&(i.push(l),a.type==="role"&&(s=!0))}return e.optional&&!s?null:i.length>0?i.join(" "):null}default:return null}}renderEventName(e,t){if(e.type!=="literal"||typeof e.value!="string")return this.valueToNaturalString(e,t);let n=e.value,r=i=>i.includes(":")?i:In(i,t);return n.includes(" or ")?n.split(" or ").map(i=>r(i.trim())).join(" or "):r(n)}valueToNaturalString(e,t="en"){switch(e.type){case"literal":return typeof e.value=="string"&&e.dataType==="string"?`"${e.value}"`:String(e.value);case"selector":return e.value;case"reference":return this.renderReference(e,t);case"property-path":return this.renderPropertyPath(e,t);case"expression":return e.raw;case"flag":return e.name}}renderReference(e,t){let n=I(t);return n?.references?n.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let n=I(t),r=e.property,i=e.object.type==="reference"?e.object.value:null;if(n?.possessive?.specialForms&&i){let a=n.possessive.specialForms[i];if(a){let{markerPosition:l,usePossessiveAdjectives:c}=n.possessive;return c&&l==="after-object"?`${r} ${a}`:`${a} ${r}`}}let s=this.valueToNaturalString(e.object,t);if(n?.possessive){let{marker:a,markerPosition:l,usePossessiveAdjectives:c}=n.possessive;if(c&&i&&l==="after-object")return`${r} ${s}`;if(a)switch(l){case"between":return n.usesSpaces?`${s}${a} ${r}`:`${s}${a}${r}`;case"after-object":return`${s}${a} ${r}`;case"before-property":return`${s} ${a} ${r}`}}return t==="en"||!n?.possessive?s==="me"?`my ${r}`:s==="it"?`its ${r}`:`${s}'s ${r}`:`${s} ${r}`}},Bt=new pt;function Fe(o,e){return Bt.render(o,e)}function Ue(o){return Bt.renderExplicit(o)}var ta={getSchema:re};function Ne(o){return et(o,{schemaLookup:ta})}var Pe=new Set(["if","unless","while","repeat","for"]),na=new Set(["then","end","else","if","unless","while","for","repeat","and"]),ra=new Set(["first","last","next","previous","random","closest"]),Re=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),He=class extends Error{constructor(e,t,n,r){super(e),this.name="SemanticParseError",this.language=t,this.input=n,this.diagnostics=r}};function D(o,e,t){return{message:o,severity:e,source:"semantic-parser",...t&&{code:t}}}function J(o,e){return e.length===0?o:{...o,diagnostics:e}}function _n(o){if(o.length>=2){let e=o[0];if((e==='"'||e==="'")&&o.endsWith(e))return o.slice(1,-1)}return o}var oa=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function jn(o,e){if(!o||typeof o!="object")return o;if(o.action&&o.roles instanceof Map){let n=re(o.action),r=n?.primaryRole;if(n&&r&&r!=="patient"&&!n.roles.some(i=>i.role==="patient")&&o.roles.has("patient")&&!o.roles.has(r)){let i=o.roles,s=i.get("patient");s!==void 0&&(i.delete("patient"),i.set(r,s))}if(o.action==="tell"){let i=o.roles,s=i.get("patient"),a=i.get("destination");s&&(s.type==="selector"||s.type==="reference")&&(!a||a.type==="literal")&&(i.delete("patient"),i.set("destination",s))}if(o.action==="transition"){let i=o.roles,s=i.get("destination");s&&s.type==="literal"&&!i.has("goal")&&(i.delete("destination"),i.set("goal",s));let a=i.get("patient");a&&a.type==="literal"&&typeof a.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(a.value)&&i.set("patient",{type:"expression",raw:a.value})}if(o.action==="morph"){let i=o.roles,s=i.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(s.value)&&i.set("patient",{type:"expression",raw:s.value})}if(o.action==="wait"){let i=o.roles;if(!i.has("event")){let s=i.get("duration"),a=s?.type==="expression"?s.raw:s?.type==="literal"?s.value:void 0;typeof a=="string"&&Re.has(a.toLowerCase())&&(i.delete("duration"),i.set("event",{type:"literal",value:a,dataType:"string"}))}}if(o.kind==="command"&&o.action!=="on"){let i=o.roles,s=i.get("event");if(s&&s.type==="expression"){let a=s.raw;typeof a=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(a)&&i.set("event",{type:"literal",value:a,dataType:"string"})}}if(e?.size){let i=o.roles;for(let s of["destination","source"]){let a=i.get(s);a&&a.type==="literal"&&typeof a.value=="string"&&e.has(a.value)&&i.set(s,{type:"expression",raw:a.value})}}}let t=o;for(let n of oa){let r=t[n];if(Array.isArray(r))for(let i of r)jn(i,e)}return o}var R=class R{constructor(){this.parseDepth=0;this.boundIdentifiers=new Set}parse(e,t){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return jn(this.parseInternal(e,t),this.boundIdentifiers)}finally{this.parseDepth--}}registerBoundIdentifiers(e){let t=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!t)return;let n=e.roles.get(t);n?.type==="expression"&&typeof n.raw=="string"&&/^[A-Za-z_]\w*$/.test(n.raw)&&this.boundIdentifiers.add(n.raw)}parseInternal(e,t){let n=On(e,t,{statement:(v,b)=>this.parse(v,b),body:(v,b)=>this.parseStatements(v,b)});if(n)return n;let r=zn(e,t,{statement:(v,b)=>this.parse(v,b),body:(v,b)=>this.parseStatements(v,b)});if(r)return r;let{modifiers:i,remainingInput:s}=this.extractStandaloneModifiers(e,t),a=s||e,c=this.stripAsyncModifier(a,t).remainingInput??a,d=this.stripDoNotThrowModifier(c,t).remainingInput??c,f=[],m=G(d,t),p=Q(t);if(p.length===0)throw new He(`No patterns available for language: ${t}`,t,d,[D(`No patterns registered for language '${t}'`,"error","no-patterns")]);let h=[...p].sort((v,b)=>b.priority-v.priority);{let v=m.tokens;if(I(t)?.wordOrder==="VSO"&&v.length>=4&&v[0]?.normalized==="source"){let b=v.findIndex(N=>N.normalized==="on");if(b>=2&&b+1<v.length){let N=d.slice(v[0].position.start,v[b].position.start).trim(),C=v[b+1].position.end,z=d.slice(v[b].position.start,C)+" "+N+d.slice(C);if(z!==d)try{let M=this.parse(z,t);if(M&&M.kind==="event-handler"){let O=i?this.applyModifiers(M,i):M;return J(O,f)}}catch{}}}}{let v=m.tokens;for(let b=1;b<v.length-1;b++){let N=v[b],C=N.value,z=(N.normalized??N.value).toLowerCase();if(!(z==="or"||R.OR_KEYWORDS.has(C)||R.OR_KEYWORDS.has(z)))continue;let O=v[b+1],_=(O.normalized??O.value).toLowerCase();if(!R.KNOWN_EVENTS.has(_))break;let V=b+1,K=v[b+2];K&&K.kind==="selector"&&K.value.startsWith("[")&&(V=b+2);let U=v[b].position.start,fe=v[V].position.end,oe=(d.slice(0,U).trimEnd()+" "+d.slice(fe).trimStart()).trim();if(oe&&oe!==d)try{let he=this.parse(oe,t);if(he&&he.kind==="event-handler"){he.additionalEvents=[{type:"literal",value:_}];let ft=i?this.applyModifiers(he,i):he;return J(ft,f)}}catch{}break}}let y=h.filter(v=>v.command==="on"),g=m.mark(),x=se.matchBest(m,y);if(x){f.push(D(`event pattern matched: ${x.pattern.id} (confidence: ${x.confidence.toFixed(2)})`,"info","pattern-match"));let v=!1;if(/^event-[a-z]+-bare$/.test(x.pattern.id)){let b=x.captured.get("event"),N=(b?.raw??b?.value??"").toString().toLowerCase(),C=Se[t],z=R.KNOWN_EVENTS.has(N)||!!C&&Object.keys(C).some(M=>M.toLowerCase()===N);if(N&&!z){let M=this.trySOVEventExtraction(d,t,h);if(M){f.push(D(`bare-event mis-anchor on "${N}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let O=i?this.applyModifiers(M,i):M;return J(O,f)}if(b?.type==="reference"||b?.type==="expression"){m.reset(g);let O=h.filter(V=>V.command!=="on"),_=se.matchBest(m,O);m.reset(g),_&&_.pattern.command!=="on"?(v=!0,f.push(D(`bare-event mis-anchor on reference "${N}" rejected; command ${_.pattern.command} preferred`,"info","stage-bare-event-guard"))):se.matchBest(m,y)}}}if(!v){let b=this.buildEventHandler(x,m,t),N=i?this.applyModifiers(b,i):b;return J(N,f)}}f.push(D(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let T=this.tryTrailingEventExtraction(d,t,h);if(T){f.push(D("trailing event extraction succeeded","info","stage-trailing-event"));let v=i?this.applyModifiers(T,i):T;return J(v,f)}let L=h.filter(v=>v.command!=="on"),S=se.matchBest(m,L);if(S){if(Pe.has(S.pattern.command)){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push(D(`SOV event extraction preferred over bare ${S.pattern.command} command`,"info","stage-sov-loop"));let N=i?this.applyModifiers(v,i):v;return J(N,f)}let b=this.tryMidStreamEventExtraction(d,t,h);if(b){f.push(D(`mid-stream event extraction preferred over bare ${S.pattern.command} command`,"info","stage-midstream-loop"));let N=i?this.applyModifiers(b,i):b;return J(N,f)}}else if(R.KNOWN_EVENTS.has(S.pattern.command)&&this.hasSOVEventMarkerHead(d,t)){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push(D(`SOV event extraction preferred over command-homonym event ${S.pattern.command}`,"info","stage-sov-homonym"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}else if(I(t)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(d,t,h);if(v){f.push(D(`mid-stream event extraction preferred over bare ${S.pattern.command} command`,"info","stage-midstream-cmd"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}if(S.consumedTokens<m.tokens.length&&I(t)?.wordOrder==="SOV"){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push(D(`SOV event extraction preferred over partial ${S.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}return f.push(D(`command pattern matched: ${S.pattern.id} (confidence: ${S.confidence.toFixed(2)})`,"info","pattern-match")),J(this.buildCommand(S,t),f)}if(f.push(D(`command patterns: ${L.length} tried, no match`,"info","stage-command")),!d.includes(`
6
- `)&&I(t)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(d,t,h);if(v){f.push(D("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}let k=this.trySOVEventExtraction(d,t,h);if(k){f.push(D("SOV event extraction succeeded","info","stage-sov"));let v=i?this.applyModifiers(k,i):k;return J(v,f)}f.push(D("SOV event extraction: no event keyword found","info","stage-sov"));let E=this.tryCompoundCommandParsing(m,L,t);if(E)return f.push(D("compound command parsing succeeded","info","stage-compound")),J(E,f);throw f.push(D("compound parsing: no then-keywords or no command matches","info","stage-compound")),f.push(D(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new He(`Could not parse input in ${t}: ${d}`,t,d,f)}parseStatements(e,t){let n=G(e,t),r=Q(t).filter(i=>i.command!=="on").sort((i,s)=>s.priority-i.priority);return this.parseBodyWithClauses(n,r,t)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return ct()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,s]of e.captured)n[i]=s;let r=H(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(r),r}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let r=e.captured.get("event");if(!r)throw new Error("Event handler pattern matched but no event captured");let i=se.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,n),a=r;s.length>0&&r.type==="literal"&&(a={type:"literal",value:[String(r.value),...s.map(d=>String("value"in d?d.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let u=t.tokens,d=-1;for(let f=t.position()-1;f>=0;f--){let m=u[f],p=(m.normalized??m.value).toLowerCase();if(this.isIfKeyword(p,n)){d=f;break}}if(d>=0){let f=Q(n).filter(y=>y.command!=="on").sort((y,g)=>g.priority-y.priority),m=new X(u.slice(d),n),p=this.parseBodyWithClauses(m,f,n);if(p.some(y=>y.kind==="conditional")||p.length===1&&p[0]?.kind==="compound"&&p[0].statements.some(y=>y.kind==="conditional")){for(;!t.isAtEnd();)t.advance();return me(a,p,i,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}}}if(c&&c.type==="literal"){let u=c.value,d={};for(let[L,S]of e.captured)L!=="event"&&L!=="action"&&L!=="continues"&&(d[L]=S);if(u==="repeat"){let L=t.peek(),S=E=>(E.normalized??E.value).toLowerCase();if(L&&L.kind==="keyword"&&S(L)==="forever")d.loopType={type:"literal",value:"forever"},delete d.patient,t.advance();else if(L&&L.kind==="keyword"&&S(L)==="event"){t.advance();let E=t.peek();if(E)for(d.event={type:"literal",value:S(E)},d.loopType={type:"literal",value:"until-event"},delete d.patient;!t.isAtEnd();){let v=t.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,n)||this.isEndKeyword(v.value,n)))break;t.advance()}}let k=d.patient;k&&k.type==="reference"&&k.value==="me"&&delete d.patient}let f=H(u,d,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(f),!Pe.has(u)||u==="repeat"){let L=e.pattern.id.includes("verb-first"),S=t.tokens,k=t.position(),E=b=>b.kind==="conjunction"||b.kind==="keyword"&&(this.isThenKeyword(b.value,n)||this.isEndKeyword(b.value,n)),v=-1;for(let b=k-1;b>=0;b--){let N=S[b];if(E(N))break;if((N.normalized??N.value).toLowerCase()===u){v=b;break}}if(v>=0){let b=k;for(;b<S.length&&!E(S[b]);)b++;let N=S.slice(v,b),C=N;if(L){let z=String(r.value??"").toLowerCase(),M=N.findIndex(O=>(O.normalized??O.value).toLowerCase()===z);if(M<0)C=null;else{let O=N[M-1],_=O&&O.kind==="keyword"&&O.normalized?.toLowerCase()==="on"?M-1:M;C=[...N.slice(0,_),...N.slice(M+1)]}}if(C&&C.length>1){let z=Q(n).filter(q=>q.command!=="on").sort((q,ue)=>ue.priority-q.priority),M=this.parseClause(C,z,n),O=M[0],_=q=>q!==null&&typeof q=="object"&&typeof q.type=="string"?q.type:typeof q,V=re(u),K=V?.primaryRole,U=q=>q==="patient"&&K&&K!=="patient"&&!V?.roles.some(ue=>ue.role==="patient")?K:q,fe=(q,ue)=>{if(!Pe.has(u)||!V)return!1;let xe=V.roles.find(Dn=>Dn.role===U(q));return xe?xe.expectedTypes.length>0&&!xe.expectedTypes.includes(_(ue)):!0},oe=!!O&&O.kind==="command"&&Object.entries(d).every(([q,ue])=>{if(fe(q,ue))return!0;let xe=O.roles.get(U(q));return xe!==void 0&&_(xe)===_(ue)}),he=O?.metadata?.patternId??"",ft=!Pe.has(u)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(he);if(M.length===1&&O&&O.kind==="command"&&O.action===u&&oe&&ft&&O.roles.size>Object.keys(d).length)for(f=O;t.position()<b;)t.advance()}}}if(!Pe.has(u)){let L=f;if(re(u)?.roles.some(C=>C.role==="quantity"&&!C.required)&&!L.roles.has("quantity")){let C=t.peek();C&&/^-?\d+(\.\d+)?$/.test(C.value)&&(f=H(u,{...Object.fromEntries(L.roles),quantity:{type:"literal",value:parseFloat(C.value),dataType:"number"}},L.metadata),t.advance())}let k=f;if(re(u)?.roles.some(C=>C.role==="duration"&&!C.required)&&!k.roles.has("duration")){let C=t.peek();C&&/^\d+(\.\d+)?(ms|s)$/i.test(C.value)&&(f=H(u,{...Object.fromEntries(k.roles),duration:{type:"literal",value:C.value,dataType:"string"}},k.metadata),t.advance(),this.consumeForPostposition(t,n))}let v=f,b=re(u);if(b?.roles.find(C=>C.role==="responseType"&&!C.required)&&!v.roles.has("responseType")){let C=V=>typeof V=="string"&&R.RESPONSE_TYPE_WORDS.has(V.toLowerCase()),z=(V,K)=>{let U=Object.fromEntries(v.roles);K&&delete U.destination,U.responseType={type:"expression",raw:V},f=H(u,U,v.metadata)},M=v.roles.get("destination"),O=b?.roles.find(V=>V.role==="destination"),_=M?.raw??M?.value;if(M&&O&&!O.expectedTypes.includes(M.type)&&C(_))z(_,!0);else{let V=t.peek();V&&C(V.value)&&(z(V.value,!1),t.advance())}}if(u==="wait"){let C=f;if(!C.roles.has("event")){let z=t.peek();if(z&&Re.has(z.value.toLowerCase())){let M=Object.fromEntries(C.roles),O=M.duration;O&&O.type!=="literal"&&O.type!=="expression"&&delete M.duration;let _=M.patient;_&&_.type==="reference"&&_.value==="me"&&delete M.patient,M.event={type:"literal",value:z.value,dataType:"string"},f=H(u,M,C.metadata),t.advance(),this.consumeForPostposition(t,n)}}}}let m=e.captured.get("continues"),p=m?.type==="literal"&&m.value==="then",h=t.peek(),y=!!h&&this.isThenKeyword(h.value,n),x=Pe.has(u)&&!!h&&!this.isEndKeyword(h.value,n),T=!!h&&!this.isEndKeyword(h.value,n);if(p||y||x||T){let L=Q(n).filter(E=>E.command!=="on").sort((E,v)=>v.priority-E.priority),S=Q(n).filter(E=>E.id.startsWith("grammar-")&&E.id.includes("-continuation")).sort((E,v)=>v.priority-E.priority),k=this.parseBodyWithGrammarPatterns(t,L,S,n);k.length>0?l=[f,...k]:l=[f]}else l=[f]}else{let u=Q(n).filter(d=>d.command!=="on").sort((d,f)=>f.priority-d.priority);l=this.parseBodyWithClauses(t,u,n)}return me(a,l,i,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,n){let r=[],i=[],s=0,a=[];for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(i.length===0){let p=this.consumeJsBlock(e,n);if(p){r.push(p);continue}let h=this.tryParseConditionalBlock(e,t,n);if(h){r.push(h);continue}}let c=l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,n),u=i[i.length-1],d=e.peek(1),f=u?.value.toLowerCase()==="at"&&d?.value.toLowerCase()==="of"||Rt(n,l.value,u?.value,d?.value),m=l.kind==="keyword"&&this.isEndKeyword(l.value,n)&&!f;if(m&&s>0){s--,a.pop(),i.push(l),e.advance();continue}if(c&&a.includes("if")){i.push(l),e.advance();continue}if(c){if(i.length>0){let p=this.parseClause(i,t,n);r.push(...p),i.length=0,s=p.filter(h=>{let y=h;return(y.action==="for"||y.action==="repeat"||y.action==="while")&&(!Array.isArray(y.body)||y.body.length===0)}).length,a.length=0;for(let h=0;h<s;h++)a.push("other")}e.advance();continue}if(m){e.advance();let p=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,n)||this.isEndKeyword(h.value,n)))break;p.push(h),e.advance()}if(p.length>0){let h=i.length>0?this.parseClause(i,t,n):[];h.length===0&&i.length>0?r.push(...this.parseClause([...i,...p],t,n)):(r.push(...h),r.push(...this.parseClause(p,t,n)))}else if(i.length>0){let h=this.parseClause(i,t,n);r.push(...h)}i.length=0;break}if(l.kind==="keyword"){let p=(l.normalized??l.value).toLowerCase();(this.isIfKeyword(p,n)||this.isUnlessKeyword(p,n)||p==="while"||p==="for"||p==="repeat")&&(s++,a.push(this.isIfKeyword(p,n)?"if":"other"))}i.push(l),e.advance()}if(i.length>0){let l=this.parseClause(i,t,n);r.push(...l)}this.foldFrontedWhileIntoRepeat(r,n);for(let l=r.length-1;l>=0;l--){let c=r[l];c.kind==="command"&&c.action==="for"&&(!(c.roles instanceof Map)||c.roles.size===0)&&(!Array.isArray(c.body)||c.body.length===0)&&r.splice(l,1)}return r.length>1?[je(r,"then",{sourceLanguage:n})]:r}foldFrontedWhileIntoRepeat(e,t){for(let n=0;n+1<e.length;n++){let r=e[n],i=e[n+1];if(r.kind!=="command"||r.action!=="while"||i.kind!=="command"||i.action!=="repeat")continue;let s=r.roles.get("condition");if(!s||i.roles.has("condition")||Array.isArray(r.body)||Array.isArray(i.body))continue;let a=new Map(i.roles);a.set("condition",s),a.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(n,2,{...i,roles:a,metadata:{...i.metadata,sourceLanguage:t,patternId:`repeat-${t}-fronted-while-fold`,confidence:Math.max(i.metadata?.confidence??0,r.metadata?.confidence??0)}})}}parseClause(e,t,n){if(e.length===0)return[];let r=null,i=e,s=e[e.length-1];if(s&&e.length>=2){let y=(s.normalized??s.value).toLowerCase();this.isUnlessKeyword(y,n)&&(r="unless",i=e.slice(0,-1))}let a=null;if(r&&i.length>=3){let y=I(n),g=y?R.buildVerbLookup(y):null;if(g)for(let x=1;x<i.length-1;x++){let T=i[x],L=g.get(T.value.toLowerCase())??(T.normalized?g.get(T.normalized.toLowerCase()):void 0);if(L&&!R.CONDITION_OPERATORS.has(L)){a=i.slice(0,x),i=i.slice(x);break}}}let l=new X(i,n),c=[],u=0,d=[],f=a,m=()=>{if(d.length===0)return;let y=d.slice();if(d.length=0,r&&c.length===0&&f===null){f=y;return}let g=y[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let T of this.parseSOVClauseByVerbAnchoring(y,n)){let L=T.action,S=T.roles;L&&re(L)&&S instanceof Map&&S.size>0&&c.push(T)}};for(;!l.isAtEnd();){let y=l.peek(),g=!!y&&y.normalized?.toLowerCase()==="repeat",x=l.mark(),T=se.matchBest(l,t);if(g&&T&&T.pattern.command!=="repeat"){l.reset(x),m(),c.push(H("repeat",{},{sourceLanguage:n,confidence:.6})),u++,l.advance();continue}if(T&&T.pattern.command==="if"){let L=l.mark(),S=d.length;for(l.reset(x);!l.isAtEnd();){let E=l.peek();if(!E||this.isIfKeyword((E.normalized??E.value).toLowerCase(),n))break;d.push(E),l.advance()}let k=this.tryParseConditionalBlock(l,t,n);if(k){m(),c.push(k),u++;continue}d.length=S,l.reset(L)}if(T){m();let L=this.buildCommand(T,n);c.push(L),u++,this.tryAttachTrailingRole(l,L,n)}else{let L=l.peek();L&&L.normalized?.toLowerCase()==="repeat"?(m(),c.push(H("repeat",{},{sourceLanguage:n,confidence:.6})),u++):L&&d.push(L),l.advance()}}m();let p=c;if(u===0){let y=this.parseSOVClauseByVerbAnchoring(i,n);y.length>0&&(p=y)}let h=f;return r&&p.length>0&&h&&h.length>0?[H(r,{condition:{type:"expression",raw:this.joinTokenText(h)}},{sourceLanguage:n,patternId:`${r}-${n}-trailing-guard`,confidence:.85}),...p]:p}tryAttachTrailingRole(e,t,n){let r=re(t.action);if(!r)return;let i=I(n);if(!i)return;let s=t.roles,a=(c,u)=>{if(!c)return!1;if(c.kind==="selector")return!0;let d=(c.normalized??c.value).toLowerCase();return na.has(d)?!1:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="window"||this.boundIdentifiers.has(c.value)?!0:u?!1:c.kind==="identifier"||c.kind==="reference"},l=[{role:"source",strict:!1},{role:"destination",strict:!0}];for(let{role:c,strict:u}of l){if(!r.roles.some(y=>y.role===c))continue;let d=i.roleMarkers?.[c];if(!d)continue;let f=s.get(c);if(f&&!(f.type==="reference"&&f.value==="me"))continue;let m=y=>{if(!y||y.kind!=="particle"&&y.kind!=="keyword")return!1;let g=y.value.toLowerCase();return d.primary?.toLowerCase()===g?!0:u?!1:(y.normalized??"").toLowerCase()===c?!0:!!d.alternatives?.some(x=>x.toLowerCase()===g)},p=e.peek(),h=e.peek(1);if(!p||!h)return;if(u&&d.position==="after"){let y=e.peek(2),g=(p.normalized??p.value).toLowerCase();if(ra.has(g)&&h.kind==="selector"&&m(y)){s.set(c,{type:"expression",raw:`${g} ${h.value}`}),e.advance(),e.advance(),e.advance();return}}if(d.position==="after"){if(a(p,u)&&m(h)){let y=this.tokenToSemanticValue(p);e.advance(),e.advance(),y&&s.set(c,y);return}}else if(m(p)&&a(h,u)){e.advance();let y=this.tokenToSemanticValue(e.advance());y&&s.set(c,y);return}}}static buildVerbLookup(e){let t=new Map;for(let[n,r]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(n)&&(t.set(r.primary.toLowerCase(),n),r.alternatives))for(let i of r.alternatives)t.set(i.toLowerCase(),n);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[n,r]of Object.entries(e.roleMarkers)){if(!r)continue;if((n!=="event"||!t.has(r.primary))&&t.set(r.primary,n),r.alternatives)for(let s of r.alternatives)t.has(s)||t.set(s,n)}return t}parseSOVClauseByVerbAnchoring(e,t){let n=I(t);if(!n||n.wordOrder!=="SOV")return[];let r=R.buildVerbLookup(n),i=R.buildMarkerToRoleLookup(n),s=[],a=0;for(;a<e.length;){let l=-1,c="";for(let p=a;p<e.length;p++){let h=e[p];if(i.has(h.value))continue;let y=r.get(h.value.toLowerCase()),g=h.normalized?r.get(h.normalized.toLowerCase()):void 0,x=y||g;if(x){l=p,c=x;break}}if(l===-1)break;let u=e.slice(a,l),d=e.length;for(let p=l+1;p<e.length;p++){let h=e[p];if(h.kind==="conjunction"||this.isThenKeyword(h.value,t)){d=p;break}if(p>l+1&&!i.has(h.value)&&(r.get(h.value.toLowerCase())||(h.normalized?r.get(h.normalized.toLowerCase()):void 0))){d=p;break}}let f=e.slice(l+1,d),m=this.extractRolesFromMarkedTokens(u,f,i,c,t);if(s.push(H(c,m,{sourceLanguage:t,confidence:.7})),a=d,a<e.length){let p=e[a];(p.kind==="conjunction"||this.isThenKeyword(p.value,t))&&a++}}return s}extractRolesFromMarkedTokens(e,t,n,r,i){let s={},a=l=>{let c=[];for(let u of l){let d=n.get(u.value);if(d&&u.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c);if(f){let m=this.mapRoleForCommand(d,r,s);m&&(s[m]=f)}c=[]}else c.push(u)}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!s.duration&&re(r)?.roles.some(d=>d.role==="duration"))s.duration={type:"literal",value:c[0].value,dataType:"string"};else{let d=this.tokensToSemanticValue(c);d&&(s.patient?s.destination||(s.destination=d):s.patient=d)}};return a(e),a(t),s}mapRoleForCommand(e,t,n){return n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(i=>i.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(i=>i.value).join(""),r=t[0];return r.kind==="selector"||r.value.startsWith("#")||r.value.startsWith(".")||r.value.startsWith("@")||r.value.startsWith("*")?ne(n):r.kind==="literal"||r.value.startsWith('"')||r.value.startsWith("'")?j(_n(n),"string"):r.kind==="reference"?Z(n):j(n)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return ne(t);if(t.startsWith('"')||t.startsWith("'"))return j(_n(t),"string");if(/^-?\d+(\.\d+)?$/.test(t))return j(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return j(!0);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return j(!1);let n=e.normalized?.toLowerCase();return n==="me"||n==="it"||n==="you"||n==="result"||n==="body"?Z(n):e.kind==="reference"?Z(e.normalized||"me"):j(t)}parseBodyWithGrammarPatterns(e,t,n,r){let i=[],s=[],a=!1,l=()=>{!a&&s.length>0&&i.push(...this.parseSOVClauseByVerbAnchoring(s,r)),s=[],a=!1},c=0,u=()=>{let d=0;for(let f of i){let m=f;(m.action==="for"||m.action==="repeat"||m.action==="while")&&(!Array.isArray(m.body)||m.body.length===0)&&d++}return d-c};for(;!e.isAtEnd();){let d=e.peek();if(d&&this.isThenKeyword(d.value,r)){l(),e.advance();continue}if(d&&this.isEndKeyword(d.value,r)){let m=e.peek(-1),p=e.peek(1);if(!Rt(r,d.value,m?.value,p?.value)){if(l(),u()>0){c++,e.advance();continue}e.advance();break}}if(d&&!a&&this.isIfKeyword((d.normalized??d.value).toLowerCase(),r)){l();let m=this.tryParseConditionalBlock(e,t,r);if(m){i.push(m),a=!0;continue}}let f=!1;if(n.length>0){let m=se.matchBest(e,n);if(m){let p=m.pattern.command,h={};for(let[x,T]of m.captured)x!=="event"&&x!=="action"&&x!=="continues"&&(h[x]=T);let y=H(p,h,{sourceLanguage:r,patternId:m.pattern.id});i.push(y),f=!0,a=!0;let g=m.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then")continue}}if(!f){let m=e.mark(),p=se.matchBest(e,t);if(p){if(p.pattern.command==="if"){let y=e.mark();for(e.reset(m);!e.isAtEnd();){let x=e.peek();if(!x||this.isIfKeyword((x.normalized??x.value).toLowerCase(),r))break;e.advance()}let g=this.tryParseConditionalBlock(e,t,r);if(g){l(),i.push(g),a=!0;continue}e.reset(y)}let h=this.buildCommand(p,r);i.push(h),this.tryAttachTrailingRole(e,h,r),f=!0,a=!0}}f||(d&&s.push(d),e.advance())}l();for(let d=i.length-1;d>=0;d--){let f=i[d];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&i.splice(d,1)}return i}tryCompoundCommandParsing(e,t,n){let r=e.tokens,i=r.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,n)),s=r.some(c=>this.isElseKeyword(c.value,n));if(!i&&!s)return null;let a=new X(r,n),l=this.parseBodyWithClauses(a,t,n);return l.length===0?null:l.length===1?l[0]:je(l,"then",{sourceLanguage:n,confidence:.65})}matchEventMarkerPhrase(e,t,n){let r=R.SOV_EVENT_MARKER_PHRASES[n];if(!r)return 0;for(let i of r)if(i.every((s,a)=>e[t+a]?.value===s))return i.length;return 0}hasSOVEventMarkerHead(e,t){let n=R.SOV_EVENT_MARKERS[t];if(n===void 0)return!1;let{tokens:r}=G(e,t),i=Se[t],s=new Set;if(i)for(let a of Object.keys(i))s.add(a.toLowerCase());for(let a=0;a<r.length;a++){let l=r[a],c=l.value.toLowerCase(),u=l.normalized?.toLowerCase();if(!(!!u&&(R.KNOWN_EVENTS.has(u)||Re.has(u))||R.KNOWN_EVENTS.has(c)||Re.has(c)||s.has(c)))continue;let f=this.matchEventParamPhrase(r,a+1).len,m=r[a+1+f];if(m&&(m.kind==="particle"||m.kind==="keyword")&&n.has(m.value)||this.matchEventMarkerPhrase(r,a+1+f,t)>0)return!0}return!1}matchEventParamPhrase(e,t){if(e[t]?.value!=="(")return{len:0,names:[]};let n=[];for(let r=t+1;r<e.length;r++){let i=e[r].value;if(i===")")return{len:r-t+1,names:n};if(i!==","){if(e[r].kind!=="identifier")break;n.push(i)}}return{len:0,names:[]}}isStrippableSourceRef(e,t){if(!e)return!1;let n=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(n==="me"||n==="i"||n==="it"))return!0;let r=e.value.toLowerCase();return t.has(r)||!!n&&t.has(n)}tryTrailingEventExtraction(e,t,n){let r=G(e,t).tokens;if(r.length<3)return null;let i=Se[t],s=new Set;if(i)for(let T of Object.keys(i))s.add(T.toLowerCase());let a=r.length-2,l=r[a];if(!(l.kind==="keyword"&&l.normalized?.toLowerCase()==="on"))return null;let u=r[r.length-1],d=u.value.toLowerCase(),f=u.normalized?.toLowerCase();if(!(!!f&&R.KNOWN_EVENTS.has(f)||R.KNOWN_EVENTS.has(d)||s.has(d)))return null;let p=f&&R.KNOWN_EVENTS.has(f)?f:i?.[d]??d,h=r.slice(0,a);if(h.length===0)return null;let y=n.filter(T=>T.command!=="on"),g=new X(h,t),x=this.parseBodyWithClauses(g,y,t);return x.length===0?null:me({type:"literal",value:p},x,void 0,{sourceLanguage:t,confidence:.75})}tryMidStreamEventExtraction(e,t,n){let r=G(e,t).tokens;if(r.length<3)return null;let i=Se[t],s=new Set;if(i)for(let a of Object.keys(i))s.add(a.toLowerCase());for(let a=0;a<r.length-1;a++){let l=r[a];if(!(l.kind==="keyword"&&l.normalized?.toLowerCase()==="on"))continue;let u=r[a+1],d=u.value.toLowerCase(),f=u.normalized?.toLowerCase();if(!(!!f&&R.KNOWN_EVENTS.has(f)||R.KNOWN_EVENTS.has(d)||s.has(d)))continue;let p=f&&R.KNOWN_EVENTS.has(f)?f:i?.[d]??d,h=r.filter((T,L)=>L!==a&&L!==a+1);if(h.length===0)return null;let y=n.filter(T=>T.command!=="on"),g=new X(h,t),x=this.parseBodyWithClauses(g,y,t);return x.length===0?null:me({type:"literal",value:p},x,void 0,{sourceLanguage:t,confidence:.75})}return null}trySOVEventExtraction(e,t,n){let r=R.SOV_EVENT_MARKERS[t];if(!r)return null;let s=G(e,t).tokens,a=Se[t],l=new Set;if(a)for(let S of Object.keys(a))l.add(S.toLowerCase());let c=R.SOV_SOURCE_MARKERS[t],u=-1,d="",f="",m=1,p=[];for(let S=0;S<s.length;S++){let k=s[S],E=k.value.toLowerCase(),v=E,b="",N=E.indexOf("[");N>0&&(v=E.slice(0,N),b=k.value.slice(N));let C=k.normalized?.toLowerCase(),z=C&&(R.KNOWN_EVENTS.has(C)||Re.has(C)),M=l.has(E)||l.has(v),O=R.KNOWN_EVENTS.has(v)||Re.has(v);if(z||M||O){let _=s[S-1];if(_&&(_.normalized??_.value).toLowerCase()==="event")continue;let V;z?V=C:M?V=a?.[E]??a?.[v]??v:V=v;let K=this.matchEventParamPhrase(s,S+1);if(r.size>0){let U=1+K.len,fe=s[S+U];fe&&fe.kind==="selector"&&fe.value.startsWith("[")&&(U+=1);let oe=s[S+U];if(oe&&(oe.kind==="particle"||oe.kind==="keyword")&&r.has(oe.value)){u=S,d=V,f=b||(U===K.len+2?s[S+U-1].value:""),m=U+1,p=K.names;break}}else{u=S,d=V,f=b,m=1+K.len+this.matchEventMarkerPhrase(s,S+1+K.len,t),p=K.names;break}}}if(u===-1){let S=new Set(n.filter(k=>k.command!=="on").map(k=>k.command));for(let k=0;k<s.length;k++){let E=s[k];if(E.kind==="identifier")if(r.size>0){let v=1,b=s[k+1];b&&b.kind==="selector"&&b.value.startsWith("[")&&(v=2);let N=s[k+v];if(N&&(N.kind==="particle"||N.kind==="keyword")&&r.has(N.value)){u=k,d=E.value,f=v===2?s[k+1].value:"",m=v+1;break}}else{let v=this.matchEventMarkerPhrase(s,k+1,t);if(v>0){u=k,d=E.value,f="",m=1+v;break}let b=s[k+1];if(b&&b.kind==="keyword"&&b.normalized!=null&&S.has(b.normalized)){u=k,d=E.value,f="",m=1;break}}}}if(u===-1)return null;let h=new Set;for(let S=u;S<u+m;S++)h.add(S);if(c){let S=u+m;if(S<s.length){let k=s[S];if((k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value))h.add(S);else if(this.isStrippableSourceRef(k,c.windowTokens)){let E=s[S+1];E&&(E.kind==="particle"||E.kind==="keyword")&&c.markers.has(E.value)&&(h.add(S),h.add(S+1))}}if(u>=2){let k=s[u-1];(k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value)&&this.isStrippableSourceRef(s[u-2],c.windowTokens)&&(h.add(u-2),h.add(u-1))}for(let k=0;k<u;k++){let E=s[k],v=E.value.toLowerCase(),b=E.normalized?.toLowerCase();if(c.windowTokens.has(v)||b&&c.windowTokens.has(b)){h.add(k);break}}}let y=s.filter((S,k)=>!h.has(k));if(y.length===0)return null;let g=n.filter(S=>S.command!=="on"),x=new X(y,t),T=this.parseBodyWithClauses(x,g,t);if(T.length===0)return null;let L={sourceLanguage:t,confidence:.75};return f&&(L.keyFilter=f),me({type:"literal",value:d},T,void 0,L,p)}profileKeywordMatches(e,t,n){let r=I(e)?.keywords?.[t];return r?r.primary?.toLowerCase()===n?!0:!!r.alternatives?.some(i=>i.toLowerCase()===n):!1}consumeForPostposition(e,t){let n=e.peek();if(!n)return;let r=(n.normalized??"").toLowerCase(),i=I(t)?.keywords?.for;(r==="for"||n.value===i?.primary||(i?.alternatives??[]).includes(n.value))&&e.advance()}isThenKeyword(e,t){let n=e.toLowerCase(),i={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[t];return i?i.has(n):n==="then"||this.profileKeywordMatches(t,"then",n)}isElseKeyword(e,t){let n=e.toLowerCase();return n==="else"?!0:this.profileKeywordMatches(t,"else",n)}isEndKeyword(e,t){let n=e.toLowerCase(),i={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])}[t];return i?n==="end"||i.has(n):n==="end"||this.profileKeywordMatches(t,"end",n)}isJsKeyword(e){let t=(e.normalized??e.value).toLowerCase();return t==="js"||this.profileKeywordMatches("en","js",t)}consumeJsBlock(e,t){let n=e.peek();if(!n||!this.isJsKeyword(n))return null;let r=e.mark(),i=[];e.advance();let s=!1;for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(e.advance(),this.isEndKeyword(l.value,t)){s=!0;break}i.push(l)}if(!s)return e.reset(r),null;let a=i.map(l=>l.value).join(" ").trim();return H("js",{patient:{type:"expression",raw:a||"()"}},{sourceLanguage:t,patternId:`js-opaque-${t}`,confidence:1})}isIfKeyword(e,t){let n=e.toLowerCase();return n==="if"?!0:this.profileKeywordMatches(t,"if",n)}isUnlessKeyword(e,t){let n=e.toLowerCase();return n==="unless"?!0:this.profileKeywordMatches(t,"unless",n)}isBlockEndToken(e,t,n){return this.isEndKeyword(e.value,n)?!0:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?!1:!(t&&t.kind==="selector")}tryParseConditionalBlock(e,t,n){let r=e.peek();if(!r)return null;let i=(r.normalized??r.value).toLowerCase();if(!this.isIfKeyword(i,n))return null;let s=e.mark();e.advance();let a=[],l=0;for(;!e.isAtEnd();){let k=e.peek();if(!k)break;let E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)){l++,a.push(k),e.advance();continue}if(this.isBlockEndToken(k,e.peek(1)??void 0,n)){if(l===0){e.advance();break}l--,a.push(k),e.advance();continue}a.push(k),e.advance()}if(a.length===0)return e.reset(s),null;let c=I(n),u=c?.wordOrder==="SOV"?R.buildVerbLookup(c):null,d=0,f=0,m=[],p=!1;for(;d<a.length;d++){let k=a[d],E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)?f++:this.isBlockEndToken(k,a[d+1],n)&&f--,f===0&&this.isThenKeyword(k.value,n)){p=!0,d++;break}if(f===0&&m.length>0){let v=(a[d-1].normalized??a[d-1].value).toLowerCase(),b=a[d-1].value.toLowerCase(),N=(k.normalized??k.value).toLowerCase(),C=R.CONDITION_COPULAS.has(v)||R.CONDITION_COPULAS_SURFACE.has(b)&&R.CONDITION_PREDICATES.has(N),z=u!==null&&u.has(k.value.toLowerCase())&&!R.CONDITION_PREDICATES.has(N);if(!R.CONDITION_OPERATORS.has(N)&&(!C||z)&&(this.tokensBeginCommand(a.slice(d),t,n)||this.sovCommandStartsAt(a.slice(d),u)))break}m.push(k)}if(m.length===0)return e.reset(s),null;let h=[],y=[],g=!1,x=0;for(;d<a.length;d++){let k=a[d],E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)?x++:this.isBlockEndToken(k,a[d+1],n)&&x--,x===0&&!g&&this.isElseKeyword(k.value,n)){g=!0;continue}(g?y:h).push(k)}let T={type:"expression",raw:this.joinTokenText(m)},L=this.parseBranch(h,t,n),S=y.length>0?this.parseBranch(y,t,n):void 0;return L.length===0&&(!S||S.length===0)?(e.reset(s),null):gn(T,L,S,{sourceLanguage:n,patternId:`conditional-${n}-folded`,confidence:1})}joinTokenText(e){return e.map(t=>t.kind==="keyword"?t.normalized??t.value:t.value).join(" ").trim()}tokensBeginCommand(e,t,n){if(e.length===0)return!1;let r=new X(e,n);return se.matchBest(r,t)!==null}sovCommandStartsAt(e,t){if(!t)return!1;let n=a=>t.has(a.value.toLowerCase())||!!a.normalized&&t.has(a.normalized.toLowerCase()),r=a=>a.kind==="identifier"||a.kind==="selector"||a.kind==="literal"||a.kind==="reference",i=0,s=0;for(;i+1<e.length;){let a=e[i],l=e[i+1];if(!r(a)||l.kind!=="particle")break;s+=1,i+=2;let c=e[i];if(s>=1&&c&&n(c))return!0}return!1}parseBranch(e,t,n){if(e.length===0)return[];let r=new X(e,n),i=this.parseBodyWithClauses(r,t,n);return i.length===1&&i[0]?.kind==="compound"?i[0].statements:i}extractStandaloneModifiers(e,t){let r=G(e,t).tokens;if(r.length===0)return{modifiers:null,remainingInput:null};let s=r[0].value.toLowerCase(),a=R.STANDALONE_MODIFIERS[s];if(!a)return{modifiers:null,remainingInput:null};let l={},c=1;if(a==="once")l.once=!0;else{let m=1;if(m<r.length){let p=r[m];(p.kind==="keyword"||p.kind==="particle")&&(m++,c++)}if(m<r.length){let p=r[m];if(p.kind==="literal"){let h=p.value.match(/^(\d+)(ms|s|m)?$/);if(h){let y=parseInt(h[1],10),g=h[2]||"ms";g==="s"?y*=1e3:g==="m"&&(y*=6e4),l[a]=y,c=m+1}}}l[a]||(l[a]=a==="debounce"?300:100)}let u=r.slice(c);if(u.length===0)return{modifiers:null,remainingInput:null};let d=u[0].position.start,f=e.slice(d);return{modifiers:l,remainingInput:f}}stripAsyncModifier(e,t){let n=I(t)?.keywords?.async,r=new Set(["async"]);n?.primary&&r.add(n.primary.toLowerCase()),n?.alternatives?.forEach(c=>r.add(c.toLowerCase()));let i=G(e,t).tokens,s=i.findIndex(c=>r.has(c.value.toLowerCase()));if(s===-1)return{remainingInput:null};let a=i[s],l=(e.slice(0,a.position.start)+e.slice(a.position.end)).replace(/\s{2,}/g," ").trim();return l.length===0?{remainingInput:null}:{remainingInput:l}}stripDoNotThrowModifier(e,t){let n=G(e,t).tokens;for(let r=0;r<n.length-1;r++){if(n[r].value.toLowerCase()!=="do")continue;let i=-1;for(let c=r+1;c<=r+5&&c<n.length;c++){let u=n[c];if(u.normalized?.toLowerCase()==="throw"){i=c;break}let d=u.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(i===-1)continue;let s=n[r].position.start,a=n[i].position.end,l=(e.slice(0,s)+e.slice(a)).replace(/\s{2,}/g," ").trim();return l.length===0?{remainingInput:null}:{remainingInput:l}}return{remainingInput:null}}applyModifiers(e,t){return{...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let n=[];for(;;){let r=e.mark(),i=e.peek();if(!i)break;let s=(i.normalized||i.value).toLowerCase();if(!R.OR_KEYWORDS.has(s)){e.reset(r);break}e.advance();let a=e.peek();if(!a){e.reset(r);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),n.push({type:"literal",value:l})}return n}};R.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]),R.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]),R.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])},R.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]},R.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}},R.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]),R.CONDITION_COPULAS_SURFACE=new Set(["est","\u0435\u0441\u0442\u044C","\u0454","\xE9","ay","\u0647\u0648","adalah","\u0E40\u0E1B\u0E47\u0E19","\u09B9\u09AF\u09BC","\u0939\u0948","dir","kanqa"]),R.CONDITION_PREDICATES=new Set(["empty","null","undefined"]),R.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]),R.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},R.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var mt=R,$t=new mt;function Ae(o,e){return $t.parse(o,e)}function Dt(o,e){return $t.canParse(o,e)}function qt(o,e){if(de(o))return o;let t=Ae(o,e);return Ue(t)}function Wt(o,e){let t=Ne(o);return Fe(t,e)}function Kt(o,e){return de(o)?Ne(o):Ae(o,e)}St("tr",lt,ve);var ia="1.0.0-tr",aa=["tr"];function sa(){return[...aa]}function Bn(o){if(o!=="tr")throw new Error(`Language not supported in this bundle: ${o}. Supported: tr`)}function la(o,e){return Bn(e),[...G(o,e).tokens]}function $n(o){return Bn(o),Q(o)}function ca(o,e){return $n(o).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}return Hn(ua);})();
5
+ `)}getChainWord(e,t){let n=I(t);return n?.keywords?n.keywords[e]?.primary??e:e}renderExplicit(e){return ee(e)}supportedLanguages(){return ct()}findBestPattern(e,t){let n=t;if(e.kind==="event-handler"){let i=t.filter(s=>!/-event-/i.test(s.id));i.length>0&&(n=i)}let r=n.map(i=>{let s=i.priority;for(let a of i.template.tokens)a.type==="role"&&(e.roles.has(a.role)?s+=10:a.optional||(s-=50));return/-at-end|-at-start|-before$|-after$/i.test(i.id)&&(s-=30),i.language==="en"&&((i.id.includes("standard")||i.id.includes("en-source"))&&(s+=20),(i.id.includes("-when")||i.id.includes("-if")||i.id.includes("-upon"))&&(s-=15)),{pattern:i,score:s}});return r.sort((i,s)=>s.score-i.score),r.length>0?r[0].pattern:null}renderWithPattern(e,t){let n=[],r=t.language;for(let i of t.template.tokens){let s=this.renderPatternToken(i,e,r);s!==null&&n.push(s)}if(e.kind==="event-handler"){let i=e;if(i.body&&i.body.length>0){let s=i.body.map(a=>this.render(a,r));n.push(s.join(" "))}}return n.join(" ")}renderPatternToken(e,t,n){switch(e.type){case"literal":return e.value;case"role":{let r=t.roles.get(e.role);return r?e.role==="event"&&t.kind==="event-handler"?this.renderEventName(r,n):this.valueToNaturalString(r,n):(e.optional,null)}case"group":{if(!e.tokens.filter(a=>a.type==="role"&&!a.optional).every(a=>t.roles.has(a.role))&&e.optional)return null;if(e.optional&&e.tokens.find(l=>l.type==="role"&&l.role==="destination")){let l=t.roles.get("destination");if(l?.type==="reference"&&l.value==="me")return null}if(e.optional&&e.tokens.find(l=>l.type==="role"&&l.role==="quantity")){let l=t.roles.get("quantity");if(l?.type==="literal"&&Number(l.value)===1)return null}let i=[],s=!1;for(let a of e.tokens){let l=this.renderPatternToken(a,t,n);l!==null&&(i.push(l),a.type==="role"&&(s=!0))}return e.optional&&!s?null:i.length>0?i.join(" "):null}default:return null}}renderEventName(e,t){if(e.type!=="literal"||typeof e.value!="string")return this.valueToNaturalString(e,t);let n=e.value,r=i=>i.includes(":")?i:In(i,t);return n.includes(" or ")?n.split(" or ").map(i=>r(i.trim())).join(" or "):r(n)}valueToNaturalString(e,t="en"){switch(e.type){case"literal":return typeof e.value=="string"&&e.dataType==="string"?`"${e.value}"`:String(e.value);case"selector":return e.value;case"reference":return this.renderReference(e,t);case"property-path":return this.renderPropertyPath(e,t);case"expression":return e.raw;case"flag":return e.name}}renderReference(e,t){let n=I(t);return n?.references?n.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let n=I(t),r=e.property,i=e.object.type==="reference"?e.object.value:null;if(n?.possessive?.specialForms&&i){let a=n.possessive.specialForms[i];if(a){let{markerPosition:l,usePossessiveAdjectives:c}=n.possessive;return c&&l==="after-object"?`${r} ${a}`:`${a} ${r}`}}let s=this.valueToNaturalString(e.object,t);if(n?.possessive){let{marker:a,markerPosition:l,usePossessiveAdjectives:c}=n.possessive;if(c&&i&&l==="after-object")return`${r} ${s}`;if(a)switch(l){case"between":return n.usesSpaces?`${s}${a} ${r}`:`${s}${a}${r}`;case"after-object":return`${s}${a} ${r}`;case"before-property":return`${s} ${a} ${r}`}}return t==="en"||!n?.possessive?s==="me"?`my ${r}`:s==="it"?`its ${r}`:`${s}'s ${r}`:`${s} ${r}`}},Bt=new pt;function Fe(o,e){return Bt.render(o,e)}function Ue(o){return Bt.renderExplicit(o)}var ta={getSchema:re};function Ne(o){return et(o,{schemaLookup:ta})}var Pe=new Set(["if","unless","while","repeat","for"]),na=new Set(["then","end","else","if","unless","while","for","repeat","and"]),ra=new Set(["first","last","next","previous","random","closest"]),Re=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),He=class extends Error{constructor(e,t,n,r){super(e),this.name="SemanticParseError",this.language=t,this.input=n,this.diagnostics=r}};function $(o,e,t){return{message:o,severity:e,source:"semantic-parser",...t&&{code:t}}}function J(o,e){return e.length===0?o:{...o,diagnostics:e}}function _n(o){if(o.length>=2){let e=o[0];if((e==='"'||e==="'")&&o.endsWith(e))return o.slice(1,-1)}return o}var oa=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function jn(o,e){if(!o||typeof o!="object")return o;if(o.action&&o.roles instanceof Map){let n=re(o.action),r=n?.primaryRole;if(n&&r&&r!=="patient"&&!n.roles.some(i=>i.role==="patient")&&o.roles.has("patient")&&!o.roles.has(r)){let i=o.roles,s=i.get("patient");s!==void 0&&(i.delete("patient"),i.set(r,s))}if(o.action==="tell"){let i=o.roles,s=i.get("patient"),a=i.get("destination");s&&(s.type==="selector"||s.type==="reference")&&(!a||a.type==="literal")&&(i.delete("patient"),i.set("destination",s))}if(o.action==="transition"){let i=o.roles,s=i.get("destination");s&&s.type==="literal"&&!i.has("goal")&&(i.delete("destination"),i.set("goal",s));let a=i.get("patient");a&&a.type==="literal"&&typeof a.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(a.value)&&i.set("patient",{type:"expression",raw:a.value})}if(o.action==="morph"){let i=o.roles,s=i.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(s.value)&&i.set("patient",{type:"expression",raw:s.value})}if(o.action==="wait"){let i=o.roles;if(!i.has("event")){let s=i.get("duration"),a=s?.type==="expression"?s.raw:s?.type==="literal"?s.value:void 0;typeof a=="string"&&Re.has(a.toLowerCase())&&(i.delete("duration"),i.set("event",{type:"literal",value:a,dataType:"string"}))}}if(o.kind==="command"&&o.action!=="on"){let i=o.roles,s=i.get("event");if(s&&s.type==="expression"){let a=s.raw;typeof a=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(a)&&i.set("event",{type:"literal",value:a,dataType:"string"})}}if(e?.size){let i=o.roles;for(let s of["destination","source"]){let a=i.get(s);a&&a.type==="literal"&&typeof a.value=="string"&&e.has(a.value)&&i.set(s,{type:"expression",raw:a.value})}}}let t=o;for(let n of oa){let r=t[n];if(Array.isArray(r))for(let i of r)jn(i,e)}return o}var R=class R{constructor(){this.parseDepth=0;this.boundIdentifiers=new Set}parse(e,t){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return jn(this.parseInternal(e,t),this.boundIdentifiers)}finally{this.parseDepth--}}registerBoundIdentifiers(e){let t=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!t)return;let n=e.roles.get(t);n?.type==="expression"&&typeof n.raw=="string"&&/^[A-Za-z_]\w*$/.test(n.raw)&&this.boundIdentifiers.add(n.raw)}parseInternal(e,t){let n=On(e,t,{statement:(v,b)=>this.parse(v,b),body:(v,b)=>this.parseStatements(v,b)});if(n)return n;let r=zn(e,t,{statement:(v,b)=>this.parse(v,b),body:(v,b)=>this.parseStatements(v,b)});if(r)return r;let{modifiers:i,remainingInput:s}=this.extractStandaloneModifiers(e,t),a=s||e,c=this.stripAsyncModifier(a,t).remainingInput??a,d=this.stripDoNotThrowModifier(c,t).remainingInput??c,f=[],m=G(d,t),p=Q(t);if(p.length===0)throw new He(`No patterns available for language: ${t}`,t,d,[$(`No patterns registered for language '${t}'`,"error","no-patterns")]);let h=[...p].sort((v,b)=>b.priority-v.priority);{let v=m.tokens;if(I(t)?.wordOrder==="VSO"&&v.length>=4&&v[0]?.normalized==="source"){let b=v.findIndex(N=>N.normalized==="on");if(b>=2&&b+1<v.length){let N=d.slice(v[0].position.start,v[b].position.start).trim(),C=v[b+1].position.end,z=d.slice(v[b].position.start,C)+" "+N+d.slice(C);if(z!==d)try{let M=this.parse(z,t);if(M&&M.kind==="event-handler"){let O=i?this.applyModifiers(M,i):M;return J(O,f)}}catch{}}}}{let v=m.tokens;for(let b=1;b<v.length-1;b++){let N=v[b],C=N.value,z=(N.normalized??N.value).toLowerCase();if(!(z==="or"||R.OR_KEYWORDS.has(C)||R.OR_KEYWORDS.has(z)))continue;let O=v[b+1],_=(O.normalized??O.value).toLowerCase();if(!R.KNOWN_EVENTS.has(_))break;let V=b+1,K=v[b+2];K&&K.kind==="selector"&&K.value.startsWith("[")&&(V=b+2);let U=v[b].position.start,fe=v[V].position.end,oe=(d.slice(0,U).trimEnd()+" "+d.slice(fe).trimStart()).trim();if(oe&&oe!==d)try{let he=this.parse(oe,t);if(he&&he.kind==="event-handler"){he.additionalEvents=[{type:"literal",value:_}];let ft=i?this.applyModifiers(he,i):he;return J(ft,f)}}catch{}break}}let y=h.filter(v=>v.command==="on"),g=m.mark(),x=se.matchBest(m,y);if(x){f.push($(`event pattern matched: ${x.pattern.id} (confidence: ${x.confidence.toFixed(2)})`,"info","pattern-match"));let v=!1;if(/^event-[a-z]+-bare$/.test(x.pattern.id)){let b=x.captured.get("event"),N=(b?.raw??b?.value??"").toString().toLowerCase(),C=Se[t],z=R.KNOWN_EVENTS.has(N)||!!C&&Object.keys(C).some(M=>M.toLowerCase()===N);if(N&&!z){let M=this.trySOVEventExtraction(d,t,h);if(M){f.push($(`bare-event mis-anchor on "${N}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let O=i?this.applyModifiers(M,i):M;return J(O,f)}if(b?.type==="reference"||b?.type==="expression"){m.reset(g);let O=h.filter(V=>V.command!=="on"),_=se.matchBest(m,O);m.reset(g),_&&_.pattern.command!=="on"?(v=!0,f.push($(`bare-event mis-anchor on reference "${N}" rejected; command ${_.pattern.command} preferred`,"info","stage-bare-event-guard"))):se.matchBest(m,y)}}}if(!v){let b=this.buildEventHandler(x,m,t),N=i?this.applyModifiers(b,i):b;return J(N,f)}}f.push($(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let T=this.tryTrailingEventExtraction(d,t,h);if(T){f.push($("trailing event extraction succeeded","info","stage-trailing-event"));let v=i?this.applyModifiers(T,i):T;return J(v,f)}let L=h.filter(v=>v.command!=="on"),S=se.matchBest(m,L);if(S){if(Pe.has(S.pattern.command)){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push($(`SOV event extraction preferred over bare ${S.pattern.command} command`,"info","stage-sov-loop"));let N=i?this.applyModifiers(v,i):v;return J(N,f)}let b=this.tryMidStreamEventExtraction(d,t,h);if(b){f.push($(`mid-stream event extraction preferred over bare ${S.pattern.command} command`,"info","stage-midstream-loop"));let N=i?this.applyModifiers(b,i):b;return J(N,f)}}else if(R.KNOWN_EVENTS.has(S.pattern.command)&&this.hasSOVEventMarkerHead(d,t)){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push($(`SOV event extraction preferred over command-homonym event ${S.pattern.command}`,"info","stage-sov-homonym"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}else if(I(t)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(d,t,h);if(v){f.push($(`mid-stream event extraction preferred over bare ${S.pattern.command} command`,"info","stage-midstream-cmd"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}if(S.consumedTokens<m.tokens.length&&I(t)?.wordOrder==="SOV"){let v=this.trySOVEventExtraction(d,t,h);if(v){f.push($(`SOV event extraction preferred over partial ${S.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}return f.push($(`command pattern matched: ${S.pattern.id} (confidence: ${S.confidence.toFixed(2)})`,"info","pattern-match")),J(this.buildCommand(S,t),f)}if(f.push($(`command patterns: ${L.length} tried, no match`,"info","stage-command")),!d.includes(`
6
+ `)&&I(t)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(d,t,h);if(v){f.push($("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let b=i?this.applyModifiers(v,i):v;return J(b,f)}}let k=this.trySOVEventExtraction(d,t,h);if(k){f.push($("SOV event extraction succeeded","info","stage-sov"));let v=i?this.applyModifiers(k,i):k;return J(v,f)}f.push($("SOV event extraction: no event keyword found","info","stage-sov"));let E=this.tryCompoundCommandParsing(m,L,t);if(E)return f.push($("compound command parsing succeeded","info","stage-compound")),J(E,f);throw f.push($("compound parsing: no then-keywords or no command matches","info","stage-compound")),f.push($(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new He(`Could not parse input in ${t}: ${d}`,t,d,f)}parseStatements(e,t){let n=G(e,t),r=Q(t).filter(i=>i.command!=="on").sort((i,s)=>s.priority-i.priority);return this.parseBodyWithClauses(n,r,t)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return ct()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,s]of e.captured)n[i]=s;let r=H(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(r),r}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let r=e.captured.get("event");if(!r)throw new Error("Event handler pattern matched but no event captured");let i=se.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,n),a=r;s.length>0&&r.type==="literal"&&(a={type:"literal",value:[String(r.value),...s.map(d=>String("value"in d?d.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let u=t.tokens,d=-1;for(let f=t.position()-1;f>=0;f--){let m=u[f],p=(m.normalized??m.value).toLowerCase();if(this.isIfKeyword(p,n)){d=f;break}}if(d>=0){let f=Q(n).filter(y=>y.command!=="on").sort((y,g)=>g.priority-y.priority),m=new X(u.slice(d),n),p=this.parseBodyWithClauses(m,f,n);if(p.some(y=>y.kind==="conditional")||p.length===1&&p[0]?.kind==="compound"&&p[0].statements.some(y=>y.kind==="conditional")){for(;!t.isAtEnd();)t.advance();return me(a,p,i,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}}}if(c&&c.type==="literal"){let u=c.value,d={};for(let[L,S]of e.captured)L!=="event"&&L!=="action"&&L!=="continues"&&(d[L]=S);if(u==="repeat"){let L=t.peek(),S=E=>(E.normalized??E.value).toLowerCase();if(L&&L.kind==="keyword"&&S(L)==="forever")d.loopType={type:"literal",value:"forever"},delete d.patient,t.advance();else if(L&&L.kind==="keyword"&&S(L)==="event"){t.advance();let E=t.peek();if(E)for(d.event={type:"literal",value:S(E)},d.loopType={type:"literal",value:"until-event"},delete d.patient;!t.isAtEnd();){let v=t.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,n)||this.isEndKeyword(v.value,n)))break;t.advance()}}let k=d.patient;k&&k.type==="reference"&&k.value==="me"&&delete d.patient}let f=H(u,d,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(f),!Pe.has(u)||u==="repeat"){let L=e.pattern.id.includes("verb-first"),S=t.tokens,k=t.position(),E=b=>b.kind==="conjunction"||b.kind==="keyword"&&(this.isThenKeyword(b.value,n)||this.isEndKeyword(b.value,n)),v=-1;for(let b=k-1;b>=0;b--){let N=S[b];if(E(N))break;if((N.normalized??N.value).toLowerCase()===u){v=b;break}}if(v>=0){let b=k;for(;b<S.length&&!E(S[b]);)b++;let N=S.slice(v,b),C=N;if(L){let z=String(r.value??"").toLowerCase(),M=N.findIndex(O=>(O.normalized??O.value).toLowerCase()===z);if(M<0)C=null;else{let O=N[M-1],_=O&&O.kind==="keyword"&&O.normalized?.toLowerCase()==="on"?M-1:M;C=[...N.slice(0,_),...N.slice(M+1)]}}if(C&&C.length>1){let z=Q(n).filter(q=>q.command!=="on").sort((q,ue)=>ue.priority-q.priority),M=this.parseClause(C,z,n),O=M[0],_=q=>q!==null&&typeof q=="object"&&typeof q.type=="string"?q.type:typeof q,V=re(u),K=V?.primaryRole,U=q=>q==="patient"&&K&&K!=="patient"&&!V?.roles.some(ue=>ue.role==="patient")?K:q,fe=(q,ue)=>{if(!Pe.has(u)||!V)return!1;let xe=V.roles.find($n=>$n.role===U(q));return xe?xe.expectedTypes.length>0&&!xe.expectedTypes.includes(_(ue)):!0},oe=!!O&&O.kind==="command"&&Object.entries(d).every(([q,ue])=>{if(fe(q,ue))return!0;let xe=O.roles.get(U(q));return xe!==void 0&&_(xe)===_(ue)}),he=O?.metadata?.patternId??"",ft=!Pe.has(u)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(he);if(M.length===1&&O&&O.kind==="command"&&O.action===u&&oe&&ft&&O.roles.size>Object.keys(d).length)for(f=O;t.position()<b;)t.advance()}}}if(!Pe.has(u)){let L=f;if(re(u)?.roles.some(C=>C.role==="quantity"&&!C.required)&&!L.roles.has("quantity")){let C=t.peek();C&&/^-?\d+(\.\d+)?$/.test(C.value)&&(f=H(u,{...Object.fromEntries(L.roles),quantity:{type:"literal",value:parseFloat(C.value),dataType:"number"}},L.metadata),t.advance())}let k=f;if(re(u)?.roles.some(C=>C.role==="duration"&&!C.required)&&!k.roles.has("duration")){let C=t.peek();C&&/^\d+(\.\d+)?(ms|s)$/i.test(C.value)&&(f=H(u,{...Object.fromEntries(k.roles),duration:{type:"literal",value:C.value,dataType:"string"}},k.metadata),t.advance(),this.consumeForPostposition(t,n))}let v=f,b=re(u);if(b?.roles.find(C=>C.role==="responseType"&&!C.required)&&!v.roles.has("responseType")){let C=V=>typeof V=="string"&&R.RESPONSE_TYPE_WORDS.has(V.toLowerCase()),z=(V,K)=>{let U=Object.fromEntries(v.roles);K&&delete U.destination,U.responseType={type:"expression",raw:V},f=H(u,U,v.metadata)},M=v.roles.get("destination"),O=b?.roles.find(V=>V.role==="destination"),_=M?.raw??M?.value;if(M&&O&&!O.expectedTypes.includes(M.type)&&C(_))z(_,!0);else{let V=t.peek();V&&C(V.value)&&(z(V.value,!1),t.advance())}}if(u==="wait"){let C=f;if(!C.roles.has("event")){let z=t.peek();if(z&&Re.has(z.value.toLowerCase())){let M=Object.fromEntries(C.roles),O=M.duration;O&&O.type!=="literal"&&O.type!=="expression"&&delete M.duration;let _=M.patient;_&&_.type==="reference"&&_.value==="me"&&delete M.patient,M.event={type:"literal",value:z.value,dataType:"string"},f=H(u,M,C.metadata),t.advance(),this.consumeForPostposition(t,n)}}}}let m=e.captured.get("continues"),p=m?.type==="literal"&&m.value==="then",h=t.peek(),y=!!h&&this.isThenKeyword(h.value,n),x=Pe.has(u)&&!!h&&!this.isEndKeyword(h.value,n),T=!!h&&!this.isEndKeyword(h.value,n);if(p||y||x||T){let L=Q(n).filter(E=>E.command!=="on").sort((E,v)=>v.priority-E.priority),S=Q(n).filter(E=>E.id.startsWith("grammar-")&&E.id.includes("-continuation")).sort((E,v)=>v.priority-E.priority),k=this.parseBodyWithGrammarPatterns(t,L,S,n);k.length>0?l=[f,...k]:l=[f]}else l=[f]}else{let u=Q(n).filter(d=>d.command!=="on").sort((d,f)=>f.priority-d.priority);l=this.parseBodyWithClauses(t,u,n)}return me(a,l,i,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,n){let r=[],i=[],s=0,a=[];for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(i.length===0){let p=this.consumeJsBlock(e,n);if(p){r.push(p);continue}let h=this.tryParseConditionalBlock(e,t,n);if(h){r.push(h);continue}}let c=l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,n),u=i[i.length-1],d=e.peek(1),f=u?.value.toLowerCase()==="at"&&d?.value.toLowerCase()==="of"||Rt(n,l.value,u?.value,d?.value),m=l.kind==="keyword"&&this.isEndKeyword(l.value,n)&&!f;if(m&&s>0){s--,a.pop(),i.push(l),e.advance();continue}if(c&&a.includes("if")){i.push(l),e.advance();continue}if(c){if(i.length>0){let p=this.parseClause(i,t,n);r.push(...p),i.length=0,s=p.filter(h=>{let y=h;return(y.action==="for"||y.action==="repeat"||y.action==="while")&&(!Array.isArray(y.body)||y.body.length===0)}).length,a.length=0;for(let h=0;h<s;h++)a.push("other")}e.advance();continue}if(m){e.advance();let p=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,n)||this.isEndKeyword(h.value,n)))break;p.push(h),e.advance()}if(p.length>0){let h=i.length>0?this.parseClause(i,t,n):[];h.length===0&&i.length>0?r.push(...this.parseClause([...i,...p],t,n)):(r.push(...h),r.push(...this.parseClause(p,t,n)))}else if(i.length>0){let h=this.parseClause(i,t,n);r.push(...h)}i.length=0;break}if(l.kind==="keyword"){let p=(l.normalized??l.value).toLowerCase();(this.isIfKeyword(p,n)||this.isUnlessKeyword(p,n)||p==="while"||p==="for"||p==="repeat")&&(s++,a.push(this.isIfKeyword(p,n)?"if":"other"))}i.push(l),e.advance()}if(i.length>0){let l=this.parseClause(i,t,n);r.push(...l)}this.foldFrontedWhileIntoRepeat(r,n);for(let l=r.length-1;l>=0;l--){let c=r[l];c.kind==="command"&&c.action==="for"&&(!(c.roles instanceof Map)||c.roles.size===0)&&(!Array.isArray(c.body)||c.body.length===0)&&r.splice(l,1)}return r.length>1?[je(r,"then",{sourceLanguage:n})]:r}foldFrontedWhileIntoRepeat(e,t){for(let n=0;n+1<e.length;n++){let r=e[n],i=e[n+1];if(r.kind!=="command"||r.action!=="while"||i.kind!=="command"||i.action!=="repeat")continue;let s=r.roles.get("condition");if(!s||i.roles.has("condition")||Array.isArray(r.body)||Array.isArray(i.body))continue;let a=new Map(i.roles);a.set("condition",s),a.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(n,2,{...i,roles:a,metadata:{...i.metadata,sourceLanguage:t,patternId:`repeat-${t}-fronted-while-fold`,confidence:Math.max(i.metadata?.confidence??0,r.metadata?.confidence??0)}})}}parseClause(e,t,n){if(e.length===0)return[];let r=null,i=e,s=e[e.length-1];if(s&&e.length>=2){let y=(s.normalized??s.value).toLowerCase();this.isUnlessKeyword(y,n)&&(r="unless",i=e.slice(0,-1))}let a=null;if(r&&i.length>=3){let y=I(n),g=y?R.buildVerbLookup(y):null;if(g)for(let x=1;x<i.length-1;x++){let T=i[x],L=g.get(T.value.toLowerCase())??(T.normalized?g.get(T.normalized.toLowerCase()):void 0);if(L&&!R.CONDITION_OPERATORS.has(L)){a=i.slice(0,x),i=i.slice(x);break}}}let l=new X(i,n),c=[],u=0,d=[],f=a,m=()=>{if(d.length===0)return;let y=d.slice();if(d.length=0,r&&c.length===0&&f===null){f=y;return}let g=y[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let T of this.parseSOVClauseByVerbAnchoring(y,n)){let L=T.action,S=T.roles;L&&re(L)&&S instanceof Map&&S.size>0&&c.push(T)}};for(;!l.isAtEnd();){let y=l.peek(),g=!!y&&y.normalized?.toLowerCase()==="repeat",x=l.mark(),T=se.matchBest(l,t);if(g&&T&&T.pattern.command!=="repeat"){l.reset(x),m(),c.push(H("repeat",{},{sourceLanguage:n,confidence:.6})),u++,l.advance();continue}if(T&&T.pattern.command==="if"){let L=l.mark(),S=d.length;for(l.reset(x);!l.isAtEnd();){let E=l.peek();if(!E||this.isIfKeyword((E.normalized??E.value).toLowerCase(),n))break;d.push(E),l.advance()}let k=this.tryParseConditionalBlock(l,t,n);if(k){m(),c.push(k),u++;continue}d.length=S,l.reset(L)}if(T){m();let L=this.buildCommand(T,n);c.push(L),u++,this.tryAttachTrailingRole(l,L,n)}else{let L=l.peek();L&&L.normalized?.toLowerCase()==="repeat"?(m(),c.push(H("repeat",{},{sourceLanguage:n,confidence:.6})),u++):L&&d.push(L),l.advance()}}m();let p=c;if(u===0){let y=this.parseSOVClauseByVerbAnchoring(i,n);y.length>0&&(p=y)}let h=f;return r&&p.length>0&&h&&h.length>0?[H(r,{condition:{type:"expression",raw:this.joinTokenText(h)}},{sourceLanguage:n,patternId:`${r}-${n}-trailing-guard`,confidence:.85}),...p]:p}tryAttachTrailingRole(e,t,n){let r=re(t.action);if(!r)return;let i=I(n);if(!i)return;let s=t.roles,a=(c,u)=>{if(!c)return!1;if(c.kind==="selector")return!0;let d=(c.normalized??c.value).toLowerCase();return na.has(d)?!1:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="window"||this.boundIdentifiers.has(c.value)?!0:u?!1:c.kind==="identifier"||c.kind==="reference"},l=[{role:"source",strict:!1},{role:"destination",strict:!0}];for(let{role:c,strict:u}of l){if(!r.roles.some(y=>y.role===c))continue;let d=i.roleMarkers?.[c];if(!d)continue;let f=s.get(c);if(f&&!(f.type==="reference"&&f.value==="me"))continue;let m=y=>{if(!y||y.kind!=="particle"&&y.kind!=="keyword")return!1;let g=y.value.toLowerCase();return d.primary?.toLowerCase()===g?!0:u?!1:(y.normalized??"").toLowerCase()===c?!0:!!d.alternatives?.some(x=>x.toLowerCase()===g)},p=e.peek(),h=e.peek(1);if(!p||!h)return;if(u&&d.position==="after"){let y=e.peek(2),g=(p.normalized??p.value).toLowerCase();if(ra.has(g)&&h.kind==="selector"&&m(y)){s.set(c,{type:"expression",raw:`${g} ${h.value}`}),e.advance(),e.advance(),e.advance();return}}if(d.position==="after"){if(a(p,u)&&m(h)){let y=this.tokenToSemanticValue(p);e.advance(),e.advance(),y&&s.set(c,y);return}}else if(m(p)&&a(h,u)){e.advance();let y=this.tokenToSemanticValue(e.advance());y&&s.set(c,y);return}}}static buildVerbLookup(e){let t=new Map;for(let[n,r]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(n)&&(t.set(r.primary.toLowerCase(),n),r.alternatives))for(let i of r.alternatives)t.set(i.toLowerCase(),n);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[n,r]of Object.entries(e.roleMarkers)){if(!r)continue;if((n!=="event"||!t.has(r.primary))&&t.set(r.primary,n),r.alternatives)for(let s of r.alternatives)t.has(s)||t.set(s,n)}return t}parseSOVClauseByVerbAnchoring(e,t){let n=I(t);if(!n||n.wordOrder!=="SOV")return[];let r=R.buildVerbLookup(n),i=R.buildMarkerToRoleLookup(n),s=[],a=0;for(;a<e.length;){let l=-1,c="";for(let p=a;p<e.length;p++){let h=e[p];if(i.has(h.value))continue;let y=r.get(h.value.toLowerCase()),g=h.normalized?r.get(h.normalized.toLowerCase()):void 0,x=y||g;if(x){l=p,c=x;break}}if(l===-1)break;let u=e.slice(a,l),d=e.length;for(let p=l+1;p<e.length;p++){let h=e[p];if(h.kind==="conjunction"||this.isThenKeyword(h.value,t)){d=p;break}if(p>l+1&&!i.has(h.value)&&(r.get(h.value.toLowerCase())||(h.normalized?r.get(h.normalized.toLowerCase()):void 0))){d=p;break}}let f=e.slice(l+1,d),m=this.extractRolesFromMarkedTokens(u,f,i,c,t);if(s.push(H(c,m,{sourceLanguage:t,confidence:.7})),a=d,a<e.length){let p=e[a];(p.kind==="conjunction"||this.isThenKeyword(p.value,t))&&a++}}return s}extractRolesFromMarkedTokens(e,t,n,r,i){let s={},a=l=>{let c=[];for(let u of l){let d=n.get(u.value);if(d&&u.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c);if(f){let m=this.mapRoleForCommand(d,r,s);m&&(s[m]=f)}c=[]}else c.push(u)}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!s.duration&&re(r)?.roles.some(d=>d.role==="duration"))s.duration={type:"literal",value:c[0].value,dataType:"string"};else{let d=this.tokensToSemanticValue(c);d&&(s.patient?s.destination||(s.destination=d):s.patient=d)}};return a(e),a(t),s}mapRoleForCommand(e,t,n){return n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(i=>i.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(i=>i.value).join(""),r=t[0];return r.kind==="selector"||r.value.startsWith("#")||r.value.startsWith(".")||r.value.startsWith("@")||r.value.startsWith("*")?ne(n):r.kind==="literal"||r.value.startsWith('"')||r.value.startsWith("'")?j(_n(n),"string"):r.kind==="reference"?Z(n):j(n)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return ne(t);if(t.startsWith('"')||t.startsWith("'"))return j(_n(t),"string");if(/^-?\d+(\.\d+)?$/.test(t))return j(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return j(!0);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return j(!1);let n=e.normalized?.toLowerCase();return n==="me"||n==="it"||n==="you"||n==="result"||n==="body"?Z(n):e.kind==="reference"?Z(e.normalized||"me"):j(t)}parseBodyWithGrammarPatterns(e,t,n,r){let i=[],s=[],a=!1,l=()=>{!a&&s.length>0&&i.push(...this.parseSOVClauseByVerbAnchoring(s,r)),s=[],a=!1},c=0,u=()=>{let d=0;for(let f of i){let m=f;(m.action==="for"||m.action==="repeat"||m.action==="while")&&(!Array.isArray(m.body)||m.body.length===0)&&d++}return d-c};for(;!e.isAtEnd();){let d=e.peek();if(d&&this.isThenKeyword(d.value,r)){l(),e.advance();continue}if(d&&this.isEndKeyword(d.value,r)){let m=e.peek(-1),p=e.peek(1);if(!Rt(r,d.value,m?.value,p?.value)){if(l(),u()>0){c++,e.advance();continue}e.advance();break}}if(d&&!a&&this.isIfKeyword((d.normalized??d.value).toLowerCase(),r)){l();let m=this.tryParseConditionalBlock(e,t,r);if(m){i.push(m),a=!0;continue}}let f=!1;if(n.length>0){let m=se.matchBest(e,n);if(m){let p=m.pattern.command,h={};for(let[x,T]of m.captured)x!=="event"&&x!=="action"&&x!=="continues"&&(h[x]=T);let y=H(p,h,{sourceLanguage:r,patternId:m.pattern.id});i.push(y),f=!0,a=!0;let g=m.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then")continue}}if(!f){let m=e.mark(),p=se.matchBest(e,t);if(p){if(p.pattern.command==="if"){let y=e.mark();for(e.reset(m);!e.isAtEnd();){let x=e.peek();if(!x||this.isIfKeyword((x.normalized??x.value).toLowerCase(),r))break;e.advance()}let g=this.tryParseConditionalBlock(e,t,r);if(g){l(),i.push(g),a=!0;continue}e.reset(y)}let h=this.buildCommand(p,r);i.push(h),this.tryAttachTrailingRole(e,h,r),f=!0,a=!0}}f||(d&&s.push(d),e.advance())}l();for(let d=i.length-1;d>=0;d--){let f=i[d];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&i.splice(d,1)}return i}tryCompoundCommandParsing(e,t,n){let r=e.tokens,i=r.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,n)),s=r.some(c=>this.isElseKeyword(c.value,n));if(!i&&!s)return null;let a=new X(r,n),l=this.parseBodyWithClauses(a,t,n);return l.length===0?null:l.length===1?l[0]:je(l,"then",{sourceLanguage:n,confidence:.65})}matchEventMarkerPhrase(e,t,n){let r=R.SOV_EVENT_MARKER_PHRASES[n];if(!r)return 0;for(let i of r)if(i.every((s,a)=>e[t+a]?.value===s))return i.length;return 0}hasSOVEventMarkerHead(e,t){let n=R.SOV_EVENT_MARKERS[t];if(n===void 0)return!1;let{tokens:r}=G(e,t),i=Se[t],s=new Set;if(i)for(let a of Object.keys(i))s.add(a.toLowerCase());for(let a=0;a<r.length;a++){let l=r[a],c=l.value.toLowerCase(),u=l.normalized?.toLowerCase();if(!(!!u&&(R.KNOWN_EVENTS.has(u)||Re.has(u))||R.KNOWN_EVENTS.has(c)||Re.has(c)||s.has(c)))continue;let f=this.matchEventParamPhrase(r,a+1).len,m=r[a+1+f];if(m&&(m.kind==="particle"||m.kind==="keyword")&&n.has(m.value)||this.matchEventMarkerPhrase(r,a+1+f,t)>0)return!0}return!1}matchEventParamPhrase(e,t){if(e[t]?.value!=="(")return{len:0,names:[]};let n=[];for(let r=t+1;r<e.length;r++){let i=e[r].value;if(i===")")return{len:r-t+1,names:n};if(i!==","){if(e[r].kind!=="identifier")break;n.push(i)}}return{len:0,names:[]}}isStrippableSourceRef(e,t){if(!e)return!1;let n=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(n==="me"||n==="i"||n==="it"))return!0;let r=e.value.toLowerCase();return t.has(r)||!!n&&t.has(n)}tryTrailingEventExtraction(e,t,n){let r=G(e,t).tokens;if(r.length<3)return null;let i=Se[t],s=new Set;if(i)for(let T of Object.keys(i))s.add(T.toLowerCase());let a=r.length-2,l=r[a];if(!(l.kind==="keyword"&&l.normalized?.toLowerCase()==="on"))return null;let u=r[r.length-1],d=u.value.toLowerCase(),f=u.normalized?.toLowerCase();if(!(!!f&&R.KNOWN_EVENTS.has(f)||R.KNOWN_EVENTS.has(d)||s.has(d)))return null;let p=f&&R.KNOWN_EVENTS.has(f)?f:i?.[d]??d,h=r.slice(0,a);if(h.length===0)return null;let y=n.filter(T=>T.command!=="on"),g=new X(h,t),x=this.parseBodyWithClauses(g,y,t);return x.length===0?null:me({type:"literal",value:p},x,void 0,{sourceLanguage:t,confidence:.75})}tryMidStreamEventExtraction(e,t,n){let r=G(e,t).tokens;if(r.length<3)return null;let i=Se[t],s=new Set;if(i)for(let a of Object.keys(i))s.add(a.toLowerCase());for(let a=0;a<r.length-1;a++){let l=r[a];if(!(l.kind==="keyword"&&l.normalized?.toLowerCase()==="on"))continue;let u=r[a+1],d=u.value.toLowerCase(),f=u.normalized?.toLowerCase();if(!(!!f&&R.KNOWN_EVENTS.has(f)||R.KNOWN_EVENTS.has(d)||s.has(d)))continue;let p=f&&R.KNOWN_EVENTS.has(f)?f:i?.[d]??d,h=r.filter((T,L)=>L!==a&&L!==a+1);if(h.length===0)return null;let y=n.filter(T=>T.command!=="on"),g=new X(h,t),x=this.parseBodyWithClauses(g,y,t);return x.length===0?null:me({type:"literal",value:p},x,void 0,{sourceLanguage:t,confidence:.75})}return null}trySOVEventExtraction(e,t,n){let r=R.SOV_EVENT_MARKERS[t];if(!r)return null;let s=G(e,t).tokens,a=Se[t],l=new Set;if(a)for(let S of Object.keys(a))l.add(S.toLowerCase());let c=R.SOV_SOURCE_MARKERS[t],u=-1,d="",f="",m=1,p=[];for(let S=0;S<s.length;S++){let k=s[S],E=k.value.toLowerCase(),v=E,b="",N=E.indexOf("[");N>0&&(v=E.slice(0,N),b=k.value.slice(N));let C=k.normalized?.toLowerCase(),z=C&&(R.KNOWN_EVENTS.has(C)||Re.has(C)),M=l.has(E)||l.has(v),O=R.KNOWN_EVENTS.has(v)||Re.has(v);if(z||M||O){let _=s[S-1];if(_&&(_.normalized??_.value).toLowerCase()==="event")continue;let V;z?V=C:M?V=a?.[E]??a?.[v]??v:V=v;let K=this.matchEventParamPhrase(s,S+1);if(r.size>0){let U=1+K.len,fe=s[S+U];fe&&fe.kind==="selector"&&fe.value.startsWith("[")&&(U+=1);let oe=s[S+U];if(oe&&(oe.kind==="particle"||oe.kind==="keyword")&&r.has(oe.value)){u=S,d=V,f=b||(U===K.len+2?s[S+U-1].value:""),m=U+1,p=K.names;break}}else{u=S,d=V,f=b,m=1+K.len+this.matchEventMarkerPhrase(s,S+1+K.len,t),p=K.names;break}}}if(u===-1){let S=new Set(n.filter(k=>k.command!=="on").map(k=>k.command));for(let k=0;k<s.length;k++){let E=s[k];if(E.kind==="identifier")if(r.size>0){let v=1,b=s[k+1];b&&b.kind==="selector"&&b.value.startsWith("[")&&(v=2);let N=s[k+v];if(N&&(N.kind==="particle"||N.kind==="keyword")&&r.has(N.value)){u=k,d=E.value,f=v===2?s[k+1].value:"",m=v+1;break}}else{let v=this.matchEventMarkerPhrase(s,k+1,t);if(v>0){u=k,d=E.value,f="",m=1+v;break}let b=s[k+1];if(b&&b.kind==="keyword"&&b.normalized!=null&&S.has(b.normalized)){u=k,d=E.value,f="",m=1;break}}}}if(u===-1)return null;let h=new Set;for(let S=u;S<u+m;S++)h.add(S);if(c){let S=u+m;if(S<s.length){let k=s[S];if((k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value))h.add(S);else if(this.isStrippableSourceRef(k,c.windowTokens)){let E=s[S+1];E&&(E.kind==="particle"||E.kind==="keyword")&&c.markers.has(E.value)&&(h.add(S),h.add(S+1))}}if(u>=2){let k=s[u-1];(k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value)&&this.isStrippableSourceRef(s[u-2],c.windowTokens)&&(h.add(u-2),h.add(u-1))}for(let k=0;k<u;k++){let E=s[k],v=E.value.toLowerCase(),b=E.normalized?.toLowerCase();if(c.windowTokens.has(v)||b&&c.windowTokens.has(b)){h.add(k);break}}}let y=s.filter((S,k)=>!h.has(k));if(y.length===0)return null;let g=n.filter(S=>S.command!=="on"),x=new X(y,t),T=this.parseBodyWithClauses(x,g,t);if(T.length===0)return null;let L={sourceLanguage:t,confidence:.75};return f&&(L.keyFilter=f),me({type:"literal",value:d},T,void 0,L,p)}profileKeywordMatches(e,t,n){let r=I(e)?.keywords?.[t];return r?r.primary?.toLowerCase()===n?!0:!!r.alternatives?.some(i=>i.toLowerCase()===n):!1}consumeForPostposition(e,t){let n=e.peek();if(!n)return;let r=(n.normalized??"").toLowerCase(),i=I(t)?.keywords?.for;(r==="for"||n.value===i?.primary||(i?.alternatives??[]).includes(n.value))&&e.advance()}isThenKeyword(e,t){let n=e.toLowerCase(),i={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[t];return i?i.has(n):n==="then"||this.profileKeywordMatches(t,"then",n)}isElseKeyword(e,t){let n=e.toLowerCase();return n==="else"?!0:this.profileKeywordMatches(t,"else",n)}isEndKeyword(e,t){let n=e.toLowerCase(),i={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])}[t];return i?n==="end"||i.has(n):n==="end"||this.profileKeywordMatches(t,"end",n)}isJsKeyword(e){let t=(e.normalized??e.value).toLowerCase();return t==="js"||this.profileKeywordMatches("en","js",t)}consumeJsBlock(e,t){let n=e.peek();if(!n||!this.isJsKeyword(n))return null;let r=e.mark(),i=[];e.advance();let s=!1;for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(e.advance(),this.isEndKeyword(l.value,t)){s=!0;break}i.push(l)}if(!s)return e.reset(r),null;let a=i.map(l=>l.value).join(" ").trim();return H("js",{patient:{type:"expression",raw:a||"()"}},{sourceLanguage:t,patternId:`js-opaque-${t}`,confidence:1})}isIfKeyword(e,t){let n=e.toLowerCase();return n==="if"?!0:this.profileKeywordMatches(t,"if",n)}isUnlessKeyword(e,t){let n=e.toLowerCase();return n==="unless"?!0:this.profileKeywordMatches(t,"unless",n)}isBlockEndToken(e,t,n){return this.isEndKeyword(e.value,n)?!0:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?!1:!(t&&t.kind==="selector")}tryParseConditionalBlock(e,t,n){let r=e.peek();if(!r)return null;let i=(r.normalized??r.value).toLowerCase();if(!this.isIfKeyword(i,n))return null;let s=e.mark();e.advance();let a=[],l=0;for(;!e.isAtEnd();){let k=e.peek();if(!k)break;let E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)){l++,a.push(k),e.advance();continue}if(this.isBlockEndToken(k,e.peek(1)??void 0,n)){if(l===0){e.advance();break}l--,a.push(k),e.advance();continue}a.push(k),e.advance()}if(a.length===0)return e.reset(s),null;let c=I(n),u=c?.wordOrder==="SOV"?R.buildVerbLookup(c):null,d=0,f=0,m=[],p=!1;for(;d<a.length;d++){let k=a[d],E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)?f++:this.isBlockEndToken(k,a[d+1],n)&&f--,f===0&&this.isThenKeyword(k.value,n)){p=!0,d++;break}if(f===0&&m.length>0){let v=(a[d-1].normalized??a[d-1].value).toLowerCase(),b=a[d-1].value.toLowerCase(),N=(k.normalized??k.value).toLowerCase(),C=R.CONDITION_COPULAS.has(v)||R.CONDITION_COPULAS_SURFACE.has(b)&&R.CONDITION_PREDICATES.has(N),z=u!==null&&u.has(k.value.toLowerCase())&&!R.CONDITION_PREDICATES.has(N);if(!R.CONDITION_OPERATORS.has(N)&&(!C||z)&&(this.tokensBeginCommand(a.slice(d),t,n)||this.sovCommandStartsAt(a.slice(d),u)))break}m.push(k)}if(m.length===0)return e.reset(s),null;let h=[],y=[],g=!1,x=0;for(;d<a.length;d++){let k=a[d],E=(k.normalized??k.value).toLowerCase();if(this.isIfKeyword(E,n)||this.isUnlessKeyword(E,n)?x++:this.isBlockEndToken(k,a[d+1],n)&&x--,x===0&&!g&&this.isElseKeyword(k.value,n)){g=!0;continue}(g?y:h).push(k)}let T={type:"expression",raw:this.joinTokenText(m)},L=this.parseBranch(h,t,n),S=y.length>0?this.parseBranch(y,t,n):void 0;return L.length===0&&(!S||S.length===0)?(e.reset(s),null):gn(T,L,S,{sourceLanguage:n,patternId:`conditional-${n}-folded`,confidence:1})}joinTokenText(e){return e.map(t=>t.kind==="keyword"?t.normalized??t.value:t.value).join(" ").trim()}tokensBeginCommand(e,t,n){if(e.length===0)return!1;let r=new X(e,n);return se.matchBest(r,t)!==null}sovCommandStartsAt(e,t){if(!t)return!1;let n=a=>t.has(a.value.toLowerCase())||!!a.normalized&&t.has(a.normalized.toLowerCase()),r=a=>a.kind==="identifier"||a.kind==="selector"||a.kind==="literal"||a.kind==="reference",i=0,s=0;for(;i+1<e.length;){let a=e[i],l=e[i+1];if(!r(a)||l.kind!=="particle")break;s+=1,i+=2;let c=e[i];if(s>=1&&c&&n(c))return!0}return!1}parseBranch(e,t,n){if(e.length===0)return[];let r=new X(e,n),i=this.parseBodyWithClauses(r,t,n);return i.length===1&&i[0]?.kind==="compound"?i[0].statements:i}extractStandaloneModifiers(e,t){let r=G(e,t).tokens;if(r.length===0)return{modifiers:null,remainingInput:null};let s=r[0].value.toLowerCase(),a=R.STANDALONE_MODIFIERS[s];if(!a)return{modifiers:null,remainingInput:null};let l={},c=1;if(a==="once")l.once=!0;else{let m=1;if(m<r.length){let p=r[m];(p.kind==="keyword"||p.kind==="particle")&&(m++,c++)}if(m<r.length){let p=r[m];if(p.kind==="literal"){let h=p.value.match(/^(\d+)(ms|s|m)?$/);if(h){let y=parseInt(h[1],10),g=h[2]||"ms";g==="s"?y*=1e3:g==="m"&&(y*=6e4),l[a]=y,c=m+1}}}l[a]||(l[a]=a==="debounce"?300:100)}let u=r.slice(c);if(u.length===0)return{modifiers:null,remainingInput:null};let d=u[0].position.start,f=e.slice(d);return{modifiers:l,remainingInput:f}}stripAsyncModifier(e,t){let n=I(t)?.keywords?.async,r=new Set(["async"]);n?.primary&&r.add(n.primary.toLowerCase()),n?.alternatives?.forEach(c=>r.add(c.toLowerCase()));let i=G(e,t).tokens,s=i.findIndex(c=>r.has(c.value.toLowerCase()));if(s===-1)return{remainingInput:null};let a=i[s],l=(e.slice(0,a.position.start)+e.slice(a.position.end)).replace(/\s{2,}/g," ").trim();return l.length===0?{remainingInput:null}:{remainingInput:l}}stripDoNotThrowModifier(e,t){let n=G(e,t).tokens;for(let r=0;r<n.length-1;r++){if(n[r].value.toLowerCase()!=="do")continue;let i=-1;for(let c=r+1;c<=r+5&&c<n.length;c++){let u=n[c];if(u.normalized?.toLowerCase()==="throw"){i=c;break}let d=u.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(i===-1)continue;let s=n[r].position.start,a=n[i].position.end,l=(e.slice(0,s)+e.slice(a)).replace(/\s{2,}/g," ").trim();return l.length===0?{remainingInput:null}:{remainingInput:l}}return{remainingInput:null}}applyModifiers(e,t){return{...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let n=[];for(;;){let r=e.mark(),i=e.peek();if(!i)break;let s=(i.normalized||i.value).toLowerCase();if(!R.OR_KEYWORDS.has(s)){e.reset(r);break}e.advance();let a=e.peek();if(!a){e.reset(r);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),n.push({type:"literal",value:l})}return n}};R.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]),R.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]),R.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])},R.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]},R.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}},R.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]),R.CONDITION_COPULAS_SURFACE=new Set(["est","\u0435\u0441\u0442\u044C","\u0454","\xE9","ay","\u0647\u0648","adalah","\u0E40\u0E1B\u0E47\u0E19","\u09B9\u09AF\u09BC","\u0939\u0948","dir","kanqa"]),R.CONDITION_PREDICATES=new Set(["empty","null","undefined"]),R.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]),R.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},R.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var mt=R,Dt=new mt;function Ae(o,e){return Dt.parse(o,e)}function $t(o,e){return Dt.canParse(o,e)}function qt(o,e){if(de(o))return o;let t=Ae(o,e);return Ue(t)}function Wt(o,e){let t=Ne(o);return Fe(t,e)}function Kt(o,e){return de(o)?Ne(o):Ae(o,e)}St("tr",lt,ve);var ia="1.0.0-tr",aa=["tr"];function sa(){return[...aa]}function Bn(o){if(o!=="tr")throw new Error(`Language not supported in this bundle: ${o}. Supported: tr`)}function la(o,e){return Bn(e),[...G(o,e).tokens]}function Dn(o){return Bn(o),Q(o)}function ca(o,e){return Dn(o).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}return Hn(ua);})();