@lokascript/semantic 1.0.0 → 1.1.0

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 (162) hide show
  1. package/dist/browser-ar.ar.global.js +2 -2
  2. package/dist/browser-core.core.global.js +2 -2
  3. package/dist/browser-de.de.global.js +2 -2
  4. package/dist/browser-east-asian.east-asian.global.js +2 -2
  5. package/dist/browser-en-tr.en-tr.global.js +2 -2
  6. package/dist/browser-en.en.global.js +2 -2
  7. package/dist/browser-es-en.es-en.global.js +2 -2
  8. package/dist/browser-es.es.global.js +2 -2
  9. package/dist/browser-fr.fr.global.js +2 -2
  10. package/dist/browser-id.id.global.js +2 -2
  11. package/dist/browser-ja.ja.global.js +2 -2
  12. package/dist/browser-ko.ko.global.js +2 -2
  13. package/dist/browser-lazy.lazy.global.js +2 -2
  14. package/dist/browser-priority.priority.global.js +2 -2
  15. package/dist/browser-pt.pt.global.js +2 -2
  16. package/dist/browser-qu.qu.global.js +2 -2
  17. package/dist/browser-sw.sw.global.js +2 -2
  18. package/dist/browser-tr.tr.global.js +2 -2
  19. package/dist/browser-western.western.global.js +2 -2
  20. package/dist/browser-zh.zh.global.js +2 -2
  21. package/dist/browser.global.js +2 -2
  22. package/dist/browser.global.js.map +1 -1
  23. package/dist/index.cjs +13042 -17462
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +49 -5
  26. package/dist/index.d.ts +49 -5
  27. package/dist/index.js +14044 -18464
  28. package/dist/index.js.map +1 -1
  29. package/dist/languages/ar.d.ts +1 -1
  30. package/dist/languages/ar.js +31 -44
  31. package/dist/languages/ar.js.map +1 -1
  32. package/dist/languages/de.d.ts +1 -1
  33. package/dist/languages/de.js +14 -2
  34. package/dist/languages/de.js.map +1 -1
  35. package/dist/languages/en.d.ts +1 -1
  36. package/dist/languages/en.js +558 -12
  37. package/dist/languages/en.js.map +1 -1
  38. package/dist/languages/es.d.ts +1 -1
  39. package/dist/languages/es.js +16 -0
  40. package/dist/languages/es.js.map +1 -1
  41. package/dist/languages/fr.d.ts +1 -1
  42. package/dist/languages/fr.js +14 -2
  43. package/dist/languages/fr.js.map +1 -1
  44. package/dist/languages/id.d.ts +1 -1
  45. package/dist/languages/id.js +14 -2
  46. package/dist/languages/id.js.map +1 -1
  47. package/dist/languages/ja.d.ts +1 -1
  48. package/dist/languages/ja.js +18 -3
  49. package/dist/languages/ja.js.map +1 -1
  50. package/dist/languages/ko.d.ts +8 -1
  51. package/dist/languages/ko.js +75 -43
  52. package/dist/languages/ko.js.map +1 -1
  53. package/dist/languages/pt.d.ts +1 -1
  54. package/dist/languages/pt.js +17 -0
  55. package/dist/languages/pt.js.map +1 -1
  56. package/dist/languages/qu.d.ts +12 -1
  57. package/dist/languages/qu.js +77 -2
  58. package/dist/languages/qu.js.map +1 -1
  59. package/dist/languages/sw.d.ts +1 -1
  60. package/dist/languages/sw.js.map +1 -1
  61. package/dist/languages/tr.d.ts +9 -1
  62. package/dist/languages/tr.js +96 -72
  63. package/dist/languages/tr.js.map +1 -1
  64. package/dist/languages/zh.d.ts +1 -1
  65. package/dist/languages/zh.js +16 -0
  66. package/dist/languages/zh.js.map +1 -1
  67. package/dist/{types-C4dcj53L.d.ts → types-BY3Id07j.d.ts} +20 -5
  68. package/package.json +20 -29
  69. package/src/generators/command-schemas.ts +21 -10
  70. package/src/generators/event-handler-generator.ts +50 -44
  71. package/src/generators/language-profiles.ts +6 -0
  72. package/src/generators/pattern-generator.ts +883 -1
  73. package/src/generators/profiles/arabic.ts +19 -3
  74. package/src/generators/profiles/bengali.ts +12 -1
  75. package/src/generators/profiles/chinese.ts +15 -0
  76. package/src/generators/profiles/french.ts +12 -1
  77. package/src/generators/profiles/german.ts +12 -1
  78. package/src/generators/profiles/hebrew.ts +148 -0
  79. package/src/generators/profiles/hindi.ts +12 -1
  80. package/src/generators/profiles/index.ts +2 -0
  81. package/src/generators/profiles/indonesian.ts +12 -1
  82. package/src/generators/profiles/italian.ts +16 -0
  83. package/src/generators/profiles/japanese.ts +11 -2
  84. package/src/generators/profiles/korean.ts +15 -1
  85. package/src/generators/profiles/polish.ts +12 -0
  86. package/src/generators/profiles/portuguese.ts +16 -0
  87. package/src/generators/profiles/russian.ts +11 -0
  88. package/src/generators/profiles/spanish.ts +15 -0
  89. package/src/generators/profiles/spanishMexico.ts +176 -0
  90. package/src/generators/profiles/thai.ts +11 -0
  91. package/src/generators/profiles/turkish.ts +49 -7
  92. package/src/generators/profiles/types.ts +21 -5
  93. package/src/generators/profiles/ukrainian.ts +11 -0
  94. package/src/generators/profiles/vietnamese.ts +11 -0
  95. package/src/language-building-schema.ts +111 -0
  96. package/src/languages/_all.ts +5 -1
  97. package/src/languages/es-MX.ts +32 -0
  98. package/src/languages/he.ts +15 -0
  99. package/src/parser/pattern-matcher.ts +10 -1
  100. package/src/parser/semantic-parser.ts +3 -0
  101. package/src/patterns/add/ar.ts +3 -59
  102. package/src/patterns/add/index.ts +5 -1
  103. package/src/patterns/add/ja.ts +3 -81
  104. package/src/patterns/add/ko.ts +3 -62
  105. package/src/patterns/add/qu.ts +69 -0
  106. package/src/patterns/add/tr.ts +3 -59
  107. package/src/patterns/builders.ts +1 -0
  108. package/src/patterns/decrement/tr.ts +3 -36
  109. package/src/patterns/event-handler/ar.ts +3 -139
  110. package/src/patterns/event-handler/he.ts +15 -0
  111. package/src/patterns/event-handler/index.ts +5 -1
  112. package/src/patterns/event-handler/ja.ts +3 -106
  113. package/src/patterns/event-handler/ko.ts +3 -121
  114. package/src/patterns/event-handler/ms.ts +45 -20
  115. package/src/patterns/event-handler/tr.ts +3 -158
  116. package/src/patterns/get/ar.ts +3 -37
  117. package/src/patterns/get/ja.ts +3 -41
  118. package/src/patterns/get/ko.ts +3 -41
  119. package/src/patterns/grammar-transformed/ja.ts +3 -1701
  120. package/src/patterns/grammar-transformed/ko.ts +3 -1299
  121. package/src/patterns/grammar-transformed/tr.ts +3 -1055
  122. package/src/patterns/hide/ar.ts +3 -55
  123. package/src/patterns/hide/ja.ts +3 -57
  124. package/src/patterns/hide/ko.ts +3 -57
  125. package/src/patterns/hide/tr.ts +3 -53
  126. package/src/patterns/increment/tr.ts +3 -40
  127. package/src/patterns/put/ar.ts +3 -62
  128. package/src/patterns/put/ja.ts +3 -63
  129. package/src/patterns/put/ko.ts +3 -55
  130. package/src/patterns/put/tr.ts +3 -55
  131. package/src/patterns/remove/ar.ts +3 -59
  132. package/src/patterns/remove/index.ts +5 -1
  133. package/src/patterns/remove/ja.ts +3 -62
  134. package/src/patterns/remove/ko.ts +3 -66
  135. package/src/patterns/remove/qu.ts +69 -0
  136. package/src/patterns/remove/tr.ts +3 -66
  137. package/src/patterns/set/ar.ts +3 -72
  138. package/src/patterns/set/ja.ts +3 -74
  139. package/src/patterns/set/ko.ts +3 -73
  140. package/src/patterns/set/tr.ts +3 -95
  141. package/src/patterns/show/ar.ts +3 -55
  142. package/src/patterns/show/ja.ts +3 -57
  143. package/src/patterns/show/ko.ts +3 -61
  144. package/src/patterns/show/tr.ts +3 -53
  145. package/src/patterns/take/ar.ts +3 -39
  146. package/src/patterns/toggle/ar.ts +3 -49
  147. package/src/patterns/toggle/index.ts +5 -1
  148. package/src/patterns/toggle/ja.ts +3 -144
  149. package/src/patterns/toggle/ko.ts +3 -101
  150. package/src/patterns/toggle/qu.ts +90 -0
  151. package/src/patterns/toggle/tr.ts +3 -76
  152. package/src/registry.ts +179 -15
  153. package/src/tokenizers/arabic.ts +13 -46
  154. package/src/tokenizers/bengali.ts +2 -16
  155. package/src/tokenizers/he.ts +542 -0
  156. package/src/tokenizers/index.ts +1 -0
  157. package/src/tokenizers/japanese.ts +3 -1
  158. package/src/tokenizers/korean.ts +104 -48
  159. package/src/tokenizers/ms.ts +3 -0
  160. package/src/tokenizers/quechua.ts +101 -2
  161. package/src/tokenizers/turkish.ts +64 -69
  162. package/src/types.ts +13 -0
@@ -1,2 +1,2 @@
1
- "use strict";var LokaScriptSemanticTr=(()=>{var de=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var st=(r,e)=>{for(var t in e)de(r,t,{get:e[t],enumerable:!0})},ct=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ot(e))!at.call(r,i)&&i!==t&&de(r,i,{get:()=>e[i],enumerable:!(n=it(e,i))||n.enumerable});return r};var lt=r=>ct(de({},"__esModule",{value:!0}),r);var Rn={};st(Rn,{ASTBuilder:()=>X,DEFAULT_CONFIDENCE_THRESHOLD:()=>ze,HIGH_CONFIDENCE_THRESHOLD:()=>et,SemanticAnalyzerImpl:()=>Z,VERSION:()=>Ln,buildAST:()=>Ye,canParse:()=>ke,createCommandNode:()=>R,createEventHandler:()=>K,createLiteral:()=>v,createPropertyPath:()=>B,createReference:()=>w,createSelector:()=>z,createSemanticAnalyzer:()=>Je,fromExplicit:()=>Ee,getCommandMapper:()=>G,getPatternsForLanguage:()=>rt,getPatternsForLanguageAndCommand:()=>zn,getProfile:()=>fe,getSupportedLanguages:()=>wn,getTokenizer:()=>me,isExplicitSyntax:()=>$,isLanguageSupported:()=>Ae,parse:()=>W,parseAny:()=>Le,parseExplicit:()=>V,registerCommandMapper:()=>we,render:()=>q,renderExplicit:()=>H,shouldUseSemanticResult:()=>tt,toExplicit:()=>be,tokenize:()=>Cn,turkishProfile:()=>A,turkishTokenizer:()=>oe});var I=new Map,J=new Map,Y=new Map;var Re=null;function Pe(r,e,t){I.set(r,e),J.set(r,t),Y.delete(r)}var ut=new Map;function me(r){let e=I.get(r);if(!e){let t=Array.from(I.keys()).join(", ");throw new Error(`Language '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return e}function fe(r){let e=J.get(r);if(!e){let t=Array.from(J.keys()).join(", ");throw new Error(`Language profile '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return e}function Me(r){return I.get(r)}function _(r){return J.get(r)}function ee(){return Array.from(I.keys())}function Ae(r){return I.has(r)}function je(r,e){return me(e).tokenize(r)}function L(r){let e=Y.get(r);if(e)return e;let t=ut.get(r);if(t)return Y.set(r,t),t;if(!Re)throw new Error(`No patterns registered for language '${r}'. Either import the language module or set a pattern generator.`);let n=fe(r),i=Re(n);return Y.set(r,i),i}function Ve(r,e){return L(r).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}var P=class{constructor(e,t){this.pos=0;this.tokens=e,this.language=t}peek(e=0){let t=this.pos+e;return t<0||t>=this.tokens.length?null:this.tokens[t]}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(e){this.pos=e.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(e){let t=[];for(;!this.isAtEnd()&&e(this.peek());)t.push(this.advance());return t}skipWhile(e){for(;!this.isAtEnd()&&e(this.peek());)this.advance()}};function x(r,e){return{start:r,end:e}}function T(r,e,t,n){if(typeof n=="string")return{value:r,kind:e,position:t,normalized:n};if(n){let{normalized:i,stem:o,stemConfidence:a}=n,s={value:r,kind:e,position:t};return i!==void 0&&(s.normalized=i),o!==void 0&&(s.stem=o,a!==void 0&&(s.stemConfidence=a)),s}return{value:r,kind:e,position:t}}function M(r){return/\s/.test(r)}function ne(r){return r==="#"||r==="."||r==="["||r==="@"||r==="*"||r==="<"}function re(r){return r==='"'||r==="'"||r==="`"||r==="\u300C"||r==="\u300D"}function N(r){return/\d/.test(r)}function Oe(r){return/[a-zA-Z]/.test(r)}function b(r){return/[a-zA-Z0-9_-]/.test(r)}function ge(r){let e=n=>r.test(n);return{isLetter:e,isIdentifierChar:n=>e(n)||/[0-9_-]/.test(n)}}function Ie(r,e){if(e>=r.length)return null;let t=r[e];if(!ne(t))return null;let n=e,i="";if(t==="#"||t==="."){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null;if(n<r.length&&r[n]==="."&&t==="#"){let a=n+1;for(;a<r.length&&b(r[a]);)a++;if(a<r.length&&r[a]==="(")return i}}else if(t==="["){let o=1,a=!1,s=null,u=!1;for(i+=r[n++];n<r.length&&o>0;){let c=r[n];i+=c,u?u=!1:c==="\\"?u=!0:a?c===s&&(a=!1,s=null):c==='"'||c==="'"||c==="`"?(a=!0,s=c):c==="["?o++:c==="]"&&o--,n++}if(o!==0)return null}else if(t==="@"){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="*"){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="<"){if(i+=r[n++],n>=r.length||!Oe(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++];for(;n<r.length;){let o=r[n];if(o==="."){if(i+=r[n++],n>=r.length||!b(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++]}else if(o==="#"){if(i+=r[n++],n>=r.length||!b(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++]}else if(o==="["){let a=1,s=!1,u=null,c=!1;for(i+=r[n++];n<r.length&&a>0;){let m=r[n];i+=m,c?c=!1:m==="\\"?c=!0:s?m===u&&(s=!1,u=null):m==='"'||m==="'"||m==="`"?(s=!0,u=m):m==="["?a++:m==="]"&&a--,n++}if(a!==0)return null}else break}for(;n<r.length&&M(r[n]);)i+=r[n++];if(n<r.length&&r[n]==="/")for(i+=r[n++];n<r.length&&M(r[n]);)i+=r[n++];if(n>=r.length||r[n]!==">")return null;i+=r[n++]}return i||null}function pt(r,e){if(e>=r.length||r[e]!=="'"||e+1>=r.length||r[e+1].toLowerCase()!=="s")return!1;if(e+2>=r.length)return!0;let n=r[e+2];return M(n)||n==="*"||!b(n)}function _e(r,e){if(e>=r.length)return null;let t=r[e];if(!re(t)||t==="'"&&pt(r,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,a=t,s=!1;for(;o<r.length;){let u=r[o];if(a+=u,s)s=!1;else if(u==="\\")s=!0;else if(u===i)return a;o++}return a}function ie(r,e){if(e>=r.length)return!1;let t=r[e],n=r[e+1]||"",i=r[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(n==="/"||n==="."&&i==="/"))return!0;let o=r.slice(e,e+8).toLowerCase();return!!(o.startsWith("http://")||o.startsWith("https://"))}function Be(r,e){if(!ie(r,e))return null;let t=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<r.length;){let o=r[t];if(o==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=o,t++;t<r.length&&/[a-zA-Z0-9_-]/.test(r[t]);)n+=r[t++];break}if(i.test(o))n+=o,t++;else break}return n.length<2?null:n}function Ke(r,e){if(e>=r.length)return null;let t=r[e];if(!N(t)&&t!=="-"&&t!=="+")return null;let n=e,i="";if((r[n]==="-"||r[n]==="+")&&(i+=r[n++]),n>=r.length||!N(r[n]))return null;for(;n<r.length&&N(r[n]);)i+=r[n++];if(n<r.length&&r[n]===".")for(i+=r[n++];n<r.length&&N(r[n]);)i+=r[n++];return n<r.length&&(r.slice(n,n+2)==="ms"?i+="ms":(r[n]==="s"||r[n]==="m"||r[n]==="h")&&(i+=r[n])),i}var te=class te{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(n.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let a of o.alternatives)n.set(a,{native:a,normalized:o.normalized||i})}if(e.references)for(let[i,o]of Object.entries(e.references))n.set(o,{native:o,normalized:i});if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&n.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let a of o.alternatives)n.set(a,{native:a,normalized:i})}for(let i of t)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i)}}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 T(n.native,"keyword",x(t,t+n.native.length),n.normalized);return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(i=>n.startsWith(i.native))}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 i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let a={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return T(e,"keyword",x(t,n),a)}trySelector(e,t){let n=Ie(e,t);return n?T(n,"selector",x(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 i=n[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],a=n[1];return{...T(i,"event-modifier",x(t,t+i.length)),metadata:{modifierName:o,value:a?o==="queue"?a:parseInt(a,10):void 0}}}tryString(e,t){let n=_e(e,t);return n?T(n,"literal",x(t,t+n.length)):null}tryNumber(e,t){let n=Ke(e,t);return n?T(n,"literal",x(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,i=!1){let o=t;if(i)for(;o<e.length&&M(e[o]);)o++;let a=e.slice(o);for(let s of n){let u=a.slice(0,s.length);if(s.caseInsensitive?u.toLowerCase()===s.pattern.toLowerCase():u===s.pattern){if(s.notFollowedBy&&(a[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let m=a[s.length]||"";if(b(m))continue}return{suffix:s.suffix,endPos:o+s.length}}}return null}parseBaseNumber(e,t,n=!0){let i=t,o="";if(n&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!N(e[i]))return null;for(;i<e.length&&N(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&N(e[i]);)o+=e[i++];return!o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,n,i={}){let{allowSign:o=!0,skipWhitespace:a=!1}=i,s=this.parseBaseNumber(e,t,o);if(!s)return null;let{number:u,endPos:c}=s,m=[...n,...te.STANDARD_TIME_UNITS],S=this.tryMatchTimeUnit(e,c,m,a);return S&&(u+=S.suffix,c=S.endPos),T(u,"literal",x(t,c))}tryUrl(e,t){let n=Be(e,t);return n?T(n,"url",x(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!b(e[t+1]))return null;let n=t+1;for(;n<e.length&&b(e[n]);)n++;let i=e.slice(t,n);return T(i,"identifier",x(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return T(n,"operator",x(t,t+2));let i=e[t];return["<",">","!","+","-","*","/","="].includes(i)?T(i,"operator",x(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?T(i,"punctuation",x(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let i of n)if(e.slice(t,t+i.length)===i)return T(i,"particle",x(t,t+i.length));return null}};te.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 U=te;function $e(r){return{stem:r,confidence:1}}function he(r,e,t){return t?{stem:r,confidence:e,metadata:t}:{stem:r,confidence:e}}function dt(r){let e=r.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(r)}function mt(r){for(let e of r)if(dt(e))return!0;return!1}function ye(r){return"a\u0131ouAIOU".includes(r)}function We(r){return"ei\xF6\xFCE\u0130\xD6\xDC".includes(r)}function Ue(r){return ye(r)||We(r)}function ft(r){for(let e=r.length-1;e>=0;e--)if(Ue(r[e]))return r[e];return null}function gt(r,e){let t=ft(r);if(!t)return!0;let n=e.split("").find(i=>Ue(i));return n?ye(t)?ye(n):We(n):!0}var ht=[{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}],F=class{constructor(){this.language="tr"}isNormalizable(e){return!(!mt(e)||e.length<3)}normalize(e){let t=e.toLowerCase();for(let n of ht)if(t.endsWith(n.pattern)){let i=t.slice(0,-n.pattern.length),o=n.minStemLength??2;if(i.length<o)continue;if(!gt(i,n.pattern)){let s=n.confidence*.9,u={removedSuffixes:[n.pattern]};return n.conjugationType&&(u.conjugationType=n.conjugationType),he(i,s,u)}let a={removedSuffixes:[n.pattern]};return n.conjugationType&&(a.conjugationType=n.conjugationType),he(i,n.confidence,a)}return $e(e)}},On=new F;var A={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",direction:"ltr",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:!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:"",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"],position:"after"},destination:{primary:"e",alternatives:["a","de","da","te","ta"],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:"ekle",normalized:"append"},take:{primary:"al",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"kopyala",normalized:"clone"},swap:{primary:"de\u011Fi\u015Ftir",alternatives:["takas"],normalized:"swap"},morph:{primary:"d\xF6n\xFC\u015Ft\xFCr",alternatives:["\u015Fekil de\u011Fi\u015Ftir"],normalized:"morph"},set:{primary:"ayarla",alternatives:["yap","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:["oldu\u011Funda","zaman"],normalized:"on"},trigger:{primary:"tetikle",normalized:"trigger"},send:{primary:"g\xF6nder",normalized:"send"},focus:{primary:"odak",normalized:"focus"},blur:{primary:"bulan\u0131k",normalized:"blur"},go:{primary:"git",normalized:"go"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},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:"iken",normalized:"while"},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:"sonra",alternatives:["ard\u0131ndan","daha sonra"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},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:"y\xFCkle",normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},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"}}};var{isLetter:Fe}=ge(/[a-zA-ZçÇğĞıİöÖşŞüÜ]/),De=new Set(["ile","i\xE7in","kadar","gibi","sonra","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),yt=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"]),St=[{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:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"en_yak\u0131n",normalized:"closest"},{native:"en_yakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"t\u0131klama",normalized:"click"},{native:"tiklama",normalized:"click"},{native:"t\u0131k",normalized:"click"},{native:"tik",normalized:"click"},{native:"giri\u015F",normalized:"input"},{native:"giris",normalized:"input"},{native:"de\u011Fi\u015Fim",normalized:"change"},{native:"degisim",normalized:"change"},{native:"odak",normalized:"focus"},{native:"bulan\u0131k",normalized:"blur"},{native:"bulanik",normalized:"blur"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{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:"ben",normalized:"me"},{native:"benim",normalized:"my"},{native:"o",normalized:"it"},{native:"onun",normalized:"its"},{native:"sonu\xE7",normalized:"result"},{native:"sonuc",normalized:"result"},{native:"olay",normalized:"event"},{native:"hedef",normalized:"target"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"},{native:"ve",normalized:"and"},{native:"veya",normalized:"or"},{native:"de\u011Fil",normalized:"not"},{native:"degil",normalized:"not"},{native:"\xFCzerinde",normalized:"on"},{native:"uzerinde",normalized:"on"},{native:"oldu\u011Funda",normalized:"on"},{native:"oldugunda",normalized:"on"},{native:"ekle",normalized:"add"},{native:"de\u011Fi\u015Ftir",normalized:"toggle"},{native:"de\u011Fistir",normalized:"toggle"},{native:"kaldir",normalized:"remove"},{native:"yerlestir",normalized:"put"},{native:"olustur",normalized:"make"},{native:"artir",normalized:"increment"},{native:"yazdir",normalized:"log"},{native:"goster",normalized:"show"},{native:"gecis",normalized:"transition"},{native:"atesle",normalized:"trigger"},{native:"gonder",normalized:"send"},{native:"bulaniklastir",normalized:"blur"},{native:"odak_kaldir",normalized:"blur"},{native:"yonlendir",normalized:"go"},{native:"cek",normalized:"fetch"},{native:"yerles",normalized:"settle"},{native:"eger",normalized:"if"},{native:"degilse",normalized:"else"},{native:"firlat",normalized:"throw"},{native:"cagir",normalized:"call"},{native:"don",normalized:"return"},{native:"dondur",normalized:"return"},{native:"eszamansiz",normalized:"async"},{native:"soyle",normalized:"tell"},{native:"varsayilan",normalized:"default"},{native:"baslat",normalized:"init"},{native:"basla",normalized:"init"},{native:"davranis",normalized:"behavior"},{native:"yukle",normalized:"install"},{native:"olc",normalized:"measure"},{native:"icine",normalized:"into"},{native:"once",normalized:"before"},{native:"icin",normalized:"for"},{native:"al",normalized:"get"},{native:"yap",normalized:"set"},{native:"o_zaman",normalized:"then"},{native:"bitir",normalized:"end"},{native:"-den",normalized:"from"},{native:"-dan",normalized:"from"}],vt=[{pattern:"milisaniye",suffix:"ms",length:10,caseInsensitive:!0},{pattern:"dakika",suffix:"m",length:6,caseInsensitive:!0},{pattern:"saniye",suffix:"s",length:6,caseInsensitive:!0},{pattern:"saat",suffix:"h",length:4,caseInsensitive:!0},{pattern:"dk",suffix:"m",length:2,checkBoundary:!0},{pattern:"sa",suffix:"h",length:2,checkBoundary:!0}],Se=class extends U{constructor(){super();this.language="tr";this.direction="ltr";this.initializeKeywordsFromProfile(A,St),this.normalizer=new F}tokenize(t){let n=[],i=0;for(;i<t.length;){if(M(t[i])){i++;continue}if(ne(t[i])){let a=this.tryEventModifier(t,i);if(a){n.push(a),i=a.position.end;continue}let s=this.trySelector(t,i);if(s){n.push(s),i=s.position.end;continue}}if(re(t[i])){let a=this.tryString(t,i);if(a){n.push(a),i=a.position.end;continue}}if(ie(t,i)){let a=this.tryUrl(t,i);if(a){n.push(a),i=a.position.end;continue}}if(N(t[i])){let a=this.extractTurkishNumber(t,i);if(a){n.push(a),i=a.position.end;continue}}let o=this.tryVariableRef(t,i);if(o){n.push(o),i=o.position.end;continue}if(Fe(t[i])){let a=this.extractTurkishWord(t,i);if(a){n.push(a),i=a.position.end;continue}}i++}return new P(n,"tr")}classifyToken(t){let n=t.toLowerCase();return De.has(n)||yt.has(n)?"particle":this.isKeyword(n)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":"identifier"}extractTurkishWord(t,n){let i=n,o="";for(;i<t.length&&(Fe(t[i])||t[i]==="_");)o+=t[i++];if(!o)return null;let a=o.toLowerCase(),s=this.lookupKeyword(a);if(s)return T(o,"keyword",x(n,i),s.normalized);if(De.has(a))return T(o,"particle",x(n,i));let u=this.tryMorphKeywordMatch(a,n,i);return u||T(o,"identifier",x(n,i))}extractTurkishNumber(t,n){return this.tryNumberWithTimeUnits(t,n,vt,{allowSign:!1,skipWhitespace:!0})}},oe=new Se;Pe("tr",oe,A);function qe(r){return Me(r)}function ae(r,e){return je(r,e)}function se(){return ee()}function z(r){let e="complex";return r.startsWith("#")&&!r.includes(" ")?e="id":r.startsWith(".")&&!r.includes(" ")?e="class":r.startsWith("[")&&r.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(r)&&(e="element"),{type:"selector",value:r,selectorKind:e}}function v(r,e){let t={type:"literal",value:r};return e!==void 0?{type:"literal",value:r,dataType:e}:t}function w(r){return{type:"reference",value:r}}function B(r,e){return{type:"property-path",object:r,property:e}}function R(r,e,t){let n={kind:"command",action:r,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function K(r,e,t,n,i){let o=new Map;o.set("event",r);let a={kind:"event-handler",action:"on",roles:o,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),i!==void 0&&i.length>0&&(a.parameterNames=i),a}function He(r,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:r,chainType:e};return t!==void 0&&(n.metadata=t),n}function ve(r,e){return!e||e.length===0||e.includes(r)||e.includes("expression")?!0:r==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function Ge(r,e){return r.possessive?.keywords?.[e]}var C=class C{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(e,t){let n=e.mark(),i=new Map;if(this.currentProfile=_(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(n),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-n.position,confidence:a}}matchBest(e,t){let n=[];for(let o of t){let a=e.mark(),s=this.matchPattern(e,o);s&&n.push(s),e.reset(a)}if(n.length===0)return null;n.sort((o,a)=>{let s=a.pattern.priority-o.pattern.priority;return s!==0?s:a.confidence-o.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n){if(this.currentProfile?.code==="ar")for(;e.peek()?.kind==="conjunction";)e.advance();for(let i of t)if(!this.matchPatternToken(e,i,n)){if(this.isOptional(i))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(!n)return!1;let i=this.getMatchType(n,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let o of t.alternatives){let a=this.getMatchType(n,o);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,n){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||!1;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,o),!0);let a=this.tryMatchMethodCallExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(a.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,a),!0);let s=this.tryMatchPossessiveSelectorExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!ve(s.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,s),!0);let u=this.tryMatchPropertyAccessExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(u.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,u),!0);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!ve(c.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,c),!0);let m=this.tokenToSemanticValue(i);return!m||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(m.type)?t.optional||!1:(n.set(t.role,m),e.advance(),!0)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=(t.normalized||t.value).toLowerCase(),i=Ge(this.currentProfile,n);if(!i)return null;let o=e.mark();e.advance();let a=e.peek();return a&&(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*"))?(e.advance(),B(w(i),a.value)):(e.reset(o),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 i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="(")return e.reset(n),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<C.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}s.push(c.value),e.advance()}return{type:"expression",raw:`${t.value}.${o.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let a=`${t.value}.${o.value}`,s=1;for(;!e.isAtEnd()&&s<C.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let m=e.peek();if(!m||m.kind!=="identifier")break;e.advance(),a+=`.${m.value}`,s++}let u=e.peek();if(u&&u.kind==="punctuation"&&u.value==="("){e.advance();let c=[],m=0;for(;!e.isAtEnd()&&c.length<C.MAX_METHOD_ARGS;){let y=e.peek();if(!y)break;if(y.kind==="punctuation"&&y.value===")"){if(m===0){e.advance();break}m--}if(y.kind==="punctuation"&&y.value==="("&&m++,y.kind==="punctuation"&&y.value===","){e.advance();continue}c.push(y.value),e.advance()}return{type:"expression",raw:`${a}(${c.join(", ")})`}}return{type:"expression",raw:a}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return!o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),B(z(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let a=i.value.slice(1);return B(z(t.value),a)}matchGroupToken(e,t,n){let i=e.mark(),o=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n)){e.reset(i);for(let s of n.keys())o.has(s)||n.delete(s);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 z(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(t)?w(t):v(e.normalized||e.value);case"identifier":if(e.value.startsWith(":"))return w(e.value);let n=e.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(n)?w(n):{type:"expression",raw:e.value};case"url":return v(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return v(i,"string")}if(e==="true")return v(!0,"boolean");if(e==="false")return v(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?v(e,"duration"):v(i,"number")}let n=parseFloat(e);return isNaN(n)?v(e,"string"):v(n,"number")}applyExtractionRules(e,t){for(let[n,i]of Object.entries(e.extraction))!t.has(n)&&i.default&&t.set(n,i.default)}isOptional(e){return e.optional===!0}calculateConfidence(e,t){let n=0,i=0,o=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")i+=1,t.has(c.role)&&(n+=1);else if(c.type==="group"){for(let m of c.tokens)if(m.type==="role"){let S=o(m.role),y=.8;i+=y,t.has(m.role)?n+=y:S&&(n+=y*.6)}}let a=i>0?n/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;a=Math.max(.5,a-c)}let s=this.calculateVSOConfidenceBoost(e);a=Math.min(1,a+s);let u=this.arabicPrepositionDisambiguation(e,t);return a=Math.max(0,Math.min(1,a+u)),a}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 i of t.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,i={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[o,a]of t.entries()){let s=i[o];if(!s||s.length===0)continue;let u=a.metadata;if(u&&typeof u.prepositionValue=="string"){let c=u.prepositionValue;s.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=t.value.toLowerCase();if(C.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=!0,o.modifierName){case"once":t.once=!0;break;case"debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case"throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case"queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance()}return n?t:void 0}};C.MAX_PROPERTY_DEPTH=10,C.MAX_METHOD_ARGS=20,C.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var D=C,j=new D;var ce=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);let n=Ve(t,e.action);if(n.length===0)return this.renderExplicit(e);let i=this.findBestPattern(e,n);return i?this.renderWithPattern(e,i):this.renderExplicit(e)}renderCompound(e,t){let n=e.statements.map(o=>this.render(o,t)),i=this.getChainWord(e.chainType,t);return n.join(` ${i} `)}getChainWord(e,t){let n=_(t);return n?.keywords?n.keywords[e]?.primary??e:e}renderExplicit(e){if(e.kind==="compound"){let n=e;return n.statements.map(o=>this.renderExplicit(o)).join(` ${n.chainType} `)}let t=[e.action];for(let[n,i]of e.roles)t.push(`${n}:${this.valueToString(i)}`);if(e.kind==="event-handler"){let n=e;if(n.body&&n.body.length>0){let i=n.body.map(o=>this.renderExplicit(o));t.push(`body:${i.join(" ")}`)}}return`[${t.join(" ")}]`}supportedLanguages(){return se()}findBestPattern(e,t){let n=t.map(i=>{let o=i.priority;for(let a of i.template.tokens)a.type==="role"&&(e.roles.has(a.role)?o+=10:a.optional||(o-=50));return i.language==="en"&&((i.id.includes("standard")||i.id.includes("en-source"))&&(o+=20),(i.id.includes("-when")||i.id.includes("-if")||i.id.includes("-upon"))&&(o-=15)),{pattern:i,score:o}});return n.sort((i,o)=>o.score-i.score),n.length>0?n[0].pattern:null}renderWithPattern(e,t){let n=[],i=t.language;for(let o of t.template.tokens){let a=this.renderPatternToken(o,e,i);a!==null&&n.push(a)}if(e.kind==="event-handler"){let o=e;if(o.body&&o.body.length>0){let a=o.body.map(s=>this.render(s,i));n.push(a.join(" "))}}return n.join(" ")}renderPatternToken(e,t,n){switch(e.type){case"literal":return e.value;case"role":{let i=t.roles.get(e.role);return i?this.valueToNaturalString(i,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(s=>s.type==="role"&&s.role==="destination")){let s=t.roles.get("destination");if(s?.type==="reference"&&s.value==="me")return null}let o=[];for(let a of e.tokens){let s=this.renderPatternToken(a,t,n);s!==null&&o.push(s)}return o.length>0?o.join(" "):null}default:return null}}valueToString(e){switch(e.type){case"literal":return typeof e.value=="string"?e.dataType==="string"||/\s/.test(e.value)?`"${e.value}"`:e.value:String(e.value);case"selector":return e.value;case"reference":return e.value;case"property-path":return`${this.valueToString(e.object)}'s ${e.property}`;case"expression":return e.raw}}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}}renderReference(e,t){let n=_(t);return n?.references?n.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let n=_(t),i=e.property,o=e.object.type==="reference"?e.object.value:null;if(n?.possessive?.specialForms&&o){let s=n.possessive.specialForms[o];if(s){let{markerPosition:u,usePossessiveAdjectives:c}=n.possessive;return c&&u==="after-object"?`${i} ${s}`:`${s} ${i}`}}let a=this.valueToNaturalString(e.object,t);if(n?.possessive){let{marker:s,markerPosition:u,usePossessiveAdjectives:c}=n.possessive;if(c&&o&&u==="after-object")return`${i} ${a}`;if(s)switch(u){case"between":return n.usesSpaces?`${a}${s} ${i}`:`${a}${s}${i}`;case"after-object":return`${a}${s} ${i}`;case"before-property":return`${a} ${s} ${i}`}}return t==="en"||!n?.possessive?a==="me"?`my ${i}`:a==="it"?`its ${i}`:`${a}'s ${i}`:`${a} ${i}`}},xe=new ce;function q(r,e){return xe.render(r,e)}function H(r){return xe.renderExplicit(r)}function V(r){let e=r.trim();if(!e.startsWith("[")||!e.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let t=e.slice(1,-1).trim();if(!t)throw new Error("Empty explicit statement");let n=xt(t);if(n.length===0)throw new Error("No command specified in explicit statement");let i=n[0].toLowerCase(),o=new Map;for(let s=1;s<n.length;s++){let u=n[s],c=u.indexOf(":");if(c===-1)throw new Error(`Invalid role format: "${u}". Expected role:value`);let m=u.slice(0,c),S=u.slice(c+1);if(m==="body"&&S.startsWith("[")){let h=kt(u,c+1),p=u.slice(c+1,h+1);o.set(m,{type:"expression",raw:p});continue}let y=Tt(S);o.set(m,y)}if(i==="on"){let s=o.get("event");if(!s)throw new Error("Event handler requires event role: [on event:click ...]");let u=o.get("body"),c=[];return u&&u.type==="expression"&&c.push(V(u.raw)),o.delete("body"),K(s,c,void 0,{sourceLanguage:"explicit"})}let a={};for(let[s,u]of o)a[s]=u;return R(i,a,{sourceLanguage:"explicit"})}function xt(r){let e=[],t="",n=!1,i="",o=0;for(let a=0;a<r.length;a++){let s=r[a];if(n){t+=s,s===i&&r[a-1]!=="\\"&&(n=!1);continue}if(s==='"'||s==="'"){n=!0,i=s,t+=s;continue}if(s==="["){o++,t+=s;continue}if(s==="]"){o--,t+=s;continue}if(s===" "&&o===0){t&&(e.push(t),t="");continue}t+=s}return t&&e.push(t),e}function Tt(r){if(r.startsWith("#")||r.startsWith(".")||r.startsWith("[")||r.startsWith("@")||r.startsWith("*"))return z(r);if(r.startsWith('"')||r.startsWith("'")){let t=r.slice(1,-1);return v(t,"string")}if(r==="true")return v(!0,"boolean");if(r==="false")return v(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(r.toLowerCase()))return w(r.toLowerCase());let e=r.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let t=parseFloat(e[1]);return e[2]?v(r,"duration"):v(t,"number")}return v(r,"string")}function kt(r,e){let t=0;for(let n=e;n<r.length;n++)if(r[n]==="[")t++;else if(r[n]==="]"&&(t--,t===0))return n;return r.length-1}function $(r){let e=r.trim();return e.startsWith("[")&&e.endsWith("]")}var le=class{parse(e,t){let n=ae(e,t),i=L(t);if(i.length===0)throw new Error(`No patterns available for language: ${t}`);let o=[...i].sort((m,S)=>S.priority-m.priority),a=o.filter(m=>m.command==="on"),s=j.matchBest(n,a);if(s)return this.buildEventHandler(s,n,t);let u=o.filter(m=>m.command!=="on"),c=j.matchBest(n,u);if(c)return this.buildCommand(c,t);throw new Error(`Could not parse input in ${t}: ${e}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return se()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,o]of e.captured)n[i]=o;return R(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id})}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=j.extractEventModifiers(t),a,s=e.captured.get("action");if(s&&s.type==="literal"){let u=s.value,c={};for(let[y,h]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(c[y]=h);let m=R(u,c,{sourceLanguage:n,patternId:e.pattern.id}),S=e.captured.get("continues");if(S&&S.type==="literal"&&S.value==="then"){let y=L(n).filter(d=>d.command!=="on").sort((d,g)=>g.priority-d.priority),h=L(n).filter(d=>d.id.startsWith("grammar-")&&d.id.includes("-continuation")).sort((d,g)=>g.priority-d.priority),p=this.parseBodyWithGrammarPatterns(t,y,h,n);p.length>0?a=[m,...p]:a=[m]}else a=[m]}else{let u=L(n).filter(c=>c.command!=="on").sort((c,m)=>m.priority-c.priority);a=this.parseBodyWithClauses(t,u,n)}return K(i,a,o,{sourceLanguage:n,patternId:e.pattern.id})}parseBodyWithClauses(e,t,n){let i=[],o=[];for(;!e.isAtEnd();){let a=e.peek();if(!a)break;let s=a.kind==="conjunction"||a.kind==="keyword"&&this.isThenKeyword(a.value,n),u=a.kind==="keyword"&&this.isEndKeyword(a.value,n);if(s){if(o.length>0){let c=this.parseClause(o,t,n);i.push(...c),o.length=0}e.advance();continue}if(u){if(o.length>0){let c=this.parseClause(o,t,n);i.push(...c)}e.advance();break}o.push(a),e.advance()}if(o.length>0){let a=this.parseClause(o,t,n);i.push(...a)}return i.length>1?[He(i,"then",{sourceLanguage:n})]:i}parseClause(e,t,n){if(e.length===0)return[];let i=new P(e,n),o=[];for(;!i.isAtEnd();){let a=j.matchBest(i,t);a?o.push(this.buildCommand(a,n)):i.advance()}return o}parseBodyWithGrammarPatterns(e,t,n,i){let o=[];for(;!e.isAtEnd();){let a=e.peek();if(a&&this.isThenKeyword(a.value,i)){e.advance();continue}if(a&&this.isEndKeyword(a.value,i)){e.advance();break}let s=!1;if(n.length>0){let u=j.matchBest(e,n);if(u){let c=u.pattern.command,m={};for(let[h,p]of u.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(m[h]=p);let S=R(c,m,{sourceLanguage:i,patternId:u.pattern.id});o.push(S),s=!0;let y=u.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!s){let u=j.matchBest(e,t);u&&(o.push(this.buildCommand(u,i)),s=!0)}s||e.advance()}return o}isThenKeyword(e,t){let n={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"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta"]),sw:new Set(["kisha","halafu","baadaye"])};return(n[t]||n.en).has(e.toLowerCase())}isEndKeyword(e,t){let n={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\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","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return(n[t]||n.en).has(e.toLowerCase())}},Te=new le;function W(r,e){return Te.parse(r,e)}function ke(r,e){return Te.canParse(r,e)}function be(r,e){if($(r))return r;let t=W(r,e);return H(t)}function Ee(r,e){let t=V(r);return q(t,e)}function Le(r,e){return $(r)?V(r):W(r,e)}var bt=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),Et=new Set(["and","or","not","no"]),Lt=new Set(["true","false","null","undefined"]),Nt=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Xe(r){let e=[],t=0,n=1,i=1;function o(){if(e.length===0)return!0;let p=e[e.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(p.type)}function a(p=0){return r[t+p]??""}function s(){let p=r[t];return t++,p===`
2
- `?(n++,i=1):i++,p}function u(){for(;t<r.length&&/\s/.test(r[t]);)s()}function c(p){let d="";for(;t<r.length&&p(r[t]);)d+=s();return d}function m(p){let d=p;for(s();t<r.length&&r[t]!==p;)r[t]==="\\"&&t+1<r.length&&(d+=s()),d+=s();return t<r.length&&(d+=s()),d}function S(){let p="`";for(s();t<r.length&&r[t]!=="`";)r[t]==="\\"&&t+1<r.length&&(p+=s()),p+=s();return t<r.length&&(p+=s()),p}function y(){let p="<";for(s();t<r.length&&(p+=s(),!p.endsWith("/>")););return p}function h(p,d,g){return{type:p,value:d,start:g,end:t,line:n,column:i-d.length}}for(;t<r.length&&(u(),!(t>=r.length));){let p=t,d=a();if(d==="'"&&a(1)==="s"&&!/\w/.test(a(2))){s(),s(),e.push(h("POSSESSIVE","'s",p));continue}if(d==='"'||d==="'"){let g=m(d);e.push(h("STRING",g,p));continue}if(d==="`"){let g=S();e.push(h("TEMPLATE_LITERAL",g,p));continue}if(d==="<"&&/[a-zA-Z.#\[]/.test(a(1))){let g=y();e.push(h("QUERY_SELECTOR",g,p));continue}if(d==="#"&&o()){s();let g=c(k=>/[\w-]/.test(k));e.push(h("ID_SELECTOR","#"+g,p));continue}if(d==="."&&/[a-zA-Z_-]/.test(a(1))&&o()){s();let g=c(k=>/[\w-]/.test(k));e.push(h("CLASS_SELECTOR","."+g,p));continue}if(d==="["&&o()){let g=a(1);if(g==="@"||/[a-zA-Z]/.test(g)){let k="";for(k+=s();t<r.length&&r[t]!=="]";)r[t]==='"'||r[t]==="'"?k+=m(r[t]):k+=s();t<r.length&&(k+=s()),e.push(h("ATTRIBUTE_SELECTOR",k,p));continue}}if(d==="["){s(),e.push(h("LBRACKET","[",p));continue}if(d==="]"){s(),e.push(h("RBRACKET","]",p));continue}if(/\d/.test(d)){let g=c(pe=>/[\d.]/.test(pe)),k=t,Q=c(pe=>/[a-zA-Z]/.test(pe));Nt.has(Q)?e.push(h("TIME_EXPRESSION",g+Q,p)):(t=k,e.push(h("NUMBER",g,p)));continue}if(d==="("){s(),e.push(h("LPAREN","(",p));continue}if(d===")"){s(),e.push(h("RPAREN",")",p));continue}if(d==="{"){s(),e.push(h("LBRACE","{",p));continue}if(d==="}"){s(),e.push(h("RBRACE","}",p));continue}if(d===","){s(),e.push(h("COMMA",",",p));continue}if(d===":"){s(),e.push(h("COLON",":",p));continue}if(d==="."){s(),e.push(h("DOT",".",p));continue}if(d==="+"||d==="-"||d==="*"||d==="/"||d==="%"){s(),e.push(h("OPERATOR",d,p));continue}if(d==="="||d==="!"||d==="<"||d===">"){let g=s();a()==="="&&(g+=s()),e.push(h("COMPARISON",g,p));continue}if(/[a-zA-Z_$]/.test(d)){let g=c(Q=>/[\w$]/.test(Q)),k=g.toLowerCase();bt.has(k)?e.push(h("CONTEXT_VAR",g,p)):Et.has(k)?e.push(h("LOGICAL",g,p)):Lt.has(k)?e.push(h("BOOLEAN",g,p)):e.push(h("IDENTIFIER",g,p));continue}s()}return e.push(h("EOF","",t)),e}var ue=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=Xe(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}}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(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let t=this.previous().value,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 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;return this.createLiteral(t,e.value,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("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"))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 i=this.parseExpression();e.push({key:n,value:i})}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]),i=t[2].toLowerCase();return{type:"timeExpression",value:n,unit:i,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.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}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function Ne(r){return new ue().parse(r)}function E(r,e){switch(r.type){case"literal":return wt(r);case"selector":return Ct(r,e);case"reference":return zt(r);case"property-path":return Rt(r,e);case"expression":return Pt(r);default:let t=r;throw new Error(`Unknown semantic value type: ${t.type}`)}}function wt(r){let e={type:"literal",value:r.value};return r.dataType?{...e,dataType:r.dataType}:e}function Ct(r,e){return e&&r.value.startsWith("*")&&/^[a-zA-Z-]/.test(r.value.slice(1))&&e.push(`Converted '${r.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.`),{type:"selector",value:r.value,selector:r.value,selectorType:r.selectorKind}}function zt(r){return{type:"contextReference",contextType:r.value,name:r.value}}function Rt(r,e){return{type:"propertyAccess",object:E(r.object,e),property:r.property}}function Pt(r){let e=Ne(r.raw);return!e.success||!e.node?{type:"identifier",name:r.raw}:e.node}function Ze(r,e){return r.roles.get(e)}function l(r,e,t){let n=Ze(r,e);return n?E(n,t):void 0}function f(r,e=[],t,n={}){let i={type:"command",name:r,args:e};return t&&Object.keys(t).length>0&&(i.modifiers=t),n.isBlocking&&(i.isBlocking=n.isBlocking),n.implicitTarget&&(i.implicitTarget=n.implicitTarget),i}var Mt={action:"toggle",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=l(r,"duration"),o=t?[t]:[],a={};return n&&(a.on=n),i&&(a.for=i),f("toggle",o,a)}},At={action:"add",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("add",i,o)}},jt={action:"remove",toAST(r,e){let t=l(r,"patient"),n=l(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("remove",i,o)}},Vt={action:"set",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=[],o={};return t&&i.push(t),n&&(o.to=n),f("set",i,o)}},Ot={action:"show",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=l(r,"duration"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.with=i),f("show",o,a)}},It={action:"hide",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=l(r,"duration"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.with=i),f("hide",o,a)}},_t={action:"increment",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=l(r,"quantity"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.by=i),f("increment",o,a)}},Bt={action:"decrement",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=l(r,"quantity"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.by=i),f("decrement",o,a)}},Kt={action:"wait",toAST(r,e){let t=l(r,"duration");return f("wait",t?[t]:[],void 0,{isBlocking:!0})}},$t={action:"log",toAST(r,e){let t=l(r,"patient"),n=[];return t&&n.push(t),f("log",n)}},Wt={action:"put",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=Ze(r,"method"),o=t?[t]:[],a={};if(n){let s=i?.type==="literal"?String(i.value):"into";a[s]=n}return f("put",o,a)}},Ut={action:"fetch",toAST(r,e){let t=l(r,"source"),n=l(r,"method"),i=l(r,"responseType"),o=l(r,"patient"),a=t?[t]:[],s={};return n&&(s.with=n),i&&(s.as=i),o&&(s.body=o),f("fetch",a,s,{isBlocking:!0})}},Ft={action:"append",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("append",i,o)}},Dt={action:"prepend",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("prepend",i,o)}},qt={action:"trigger",toAST(r,e){let t=l(r,"event"),n=l(r,"destination"),i=t?[t]:[],o={};return n&&(o.on=n),f("trigger",i,o)}},Ht={action:"send",toAST(r,e){let t=l(r,"event"),n=l(r,"destination"),i=l(r,"patient"),o=t?[t]:[],a={};return n&&(a.to=n),i&&(a.detail=i),f("send",o,a)}},Gt={action:"go",toAST(r,e){let t=l(r,"source"),n=l(r,"destination"),i=[],o={};return t&&i.push(t),n&&(o.to=n),f("go",i,o)}},Xt={action:"transition",toAST(r,e){let t=l(r,"patient"),n=l(r,"goal"),i=l(r,"duration"),o=l(r,"destination"),a=t?[t]:[],s={};return n&&(s.to=n),i&&(s.over=i),o&&(s.on=o),f("transition",a,s)}},Zt={action:"focus",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=[],o={},a=t??n;return a&&i.push(a),f("focus",i,o)}},Qt={action:"blur",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("blur",i)}},Yt={action:"get",toAST(r,e){let t=l(r,"source"),n=l(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("get",i)}},Jt={action:"take",toAST(r,e){let t=l(r,"patient"),n=l(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("take",i,o)}},en={action:"call",toAST(r,e){let t=l(r,"patient");return f("call",t?[t]:[])}},tn={action:"return",toAST(r,e){let t=l(r,"patient");return f("return",t?[t]:[])}},nn={action:"halt",toAST(r,e){return f("halt",[])}},rn={action:"throw",toAST(r,e){let t=l(r,"patient");return f("throw",t?[t]:[])}},on={action:"settle",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("settle",i,void 0,{isBlocking:!0})}},an={action:"swap",toAST(r,e){let t=l(r,"patient"),n=l(r,"source"),i=l(r,"destination"),o=l(r,"style"),a=[],s={};return t&&a.push(t),n&&a.push(n),i&&(s.on=i),o&&(s.with=o),f("swap",a,s)}},sn={action:"morph",toAST(r,e){let t=l(r,"source"),n=l(r,"destination"),i=l(r,"patient"),o=[],a={},s=t??i;return s&&o.push(s),n&&(a.on=n),f("morph",o,a)}},cn={action:"clone",toAST(r,e){let t=l(r,"source"),n=l(r,"destination"),i=l(r,"patient"),o=[],a={},s=t??i;return s&&o.push(s),n&&(a.into=n),f("clone",o,a)}},ln={action:"make",toAST(r,e){let t=l(r,"patient");return f("make",t?[t]:[])}},un={action:"measure",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=l(r,"source"),o=[],a={};t&&o.push(t);let s=n??i;return s&&(a.of=s),f("measure",o,a)}},pn={action:"tell",toAST(r,e){let t=l(r,"destination"),n=l(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("tell",i)}},dn={action:"js",toAST(r,e){let t=l(r,"patient");return f("js",t?[t]:[])}},mn={action:"async",toAST(r,e){return f("async",[])}},fn={action:"if",toAST(r,e){let t=l(r,"condition");return f("if",t?[t]:[])}},gn={action:"unless",toAST(r,e){let t=l(r,"condition");return f("unless",t?[t]:[])}},hn={action:"repeat",toAST(r,e){let t=l(r,"quantity"),n=l(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("repeat",i)}},yn={action:"for",toAST(r,e){let t=l(r,"patient"),n=l(r,"source"),i=t?[t]:[],o={};return n&&(o.in=n),f("for",i,o)}},Sn={action:"while",toAST(r,e){let t=l(r,"condition");return f("while",t?[t]:[])}},vn={action:"continue",toAST(r,e){return f("continue",[])}},xn={action:"default",toAST(r,e){let t=l(r,"patient"),n=l(r,"source"),i=t?[t]:[],o={};return n&&(o.to=n),f("default",i,o)}},Tn={action:"init",toAST(r,e){return f("init",[])}},kn={action:"behavior",toAST(r,e){let t=l(r,"patient");return f("behavior",t?[t]:[])}},bn={action:"install",toAST(r,e){let t=l(r,"patient"),n=l(r,"destination"),i=t?[t]:[],o={};return n&&(o.on=n),f("install",i,o)}},En={action:"on",toAST(r,e){let t=l(r,"event"),n=l(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("on",i,o)}},Qe=new Map([["toggle",Mt],["add",At],["remove",jt],["set",Vt],["show",Ot],["hide",It],["increment",_t],["decrement",Bt],["wait",Kt],["log",$t],["put",Wt],["fetch",Ut],["append",Ft],["prepend",Dt],["get",Yt],["take",Jt],["trigger",qt],["send",Ht],["on",En],["go",Gt],["transition",Xt],["focus",Zt],["blur",Qt],["call",en],["return",tn],["halt",nn],["throw",rn],["settle",on],["swap",an],["morph",sn],["clone",cn],["measure",un],["make",ln],["tell",pn],["default",xn],["js",dn],["async",mn],["if",fn],["unless",gn],["repeat",hn],["for",yn],["while",Sn],["continue",vn],["init",Tn],["behavior",kn],["install",bn]]);function G(r){return Qe.get(r)}function we(r){Qe.set(r.action,r)}var X=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);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildCommand(e){let t=G(e.action);if(t){let n=t.toAST(e,this);if("ast"in n&&"warnings"in n){let i=n;return this.warnings.push(...i.warnings),i.ast}else return n}return this.buildGenericCommand(e)}buildGenericCommand(e){let t=[],n={},i=["patient","source","quantity"],o=["destination","duration","method","style"];for(let s of i){let u=e.roles.get(s);u&&t.push(E(u))}for(let s of o){let u=e.roles.get(s);if(u){let c=this.roleToModifierKey(s);n[c]=E(u)}}let a={type:"command",name:e.action,args:t};return Object.keys(n).length>0?{...a,modifiers:n}:a}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,i;if(t?.type==="literal"){let g=String(t.value);g.includes("|")||g.includes(" or ")?(i=g.split(/\s+or\s+|\|/).map(k=>k.trim()),n=i[0]):n=g}else t?.type==="reference"?n=t.value:n="click";let o=e.body.map(g=>this.build(g)),a=e.roles.get("source"),s,u;a?.type==="selector"?(s=a.value,u=a.value):a?.type==="reference"?u=a.value:a?.type==="literal"&&(u=String(a.value));let c=e.roles.get("condition"),m=c?E(c):void 0,S=e.roles.get("destination"),y=S?E(S):void 0,h=e.eventModifiers,p=s;if(h?.from){let g=h.from;g.type==="selector"&&!s&&(p=g.value)}let d=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:n,commands:o,...i&&i.length>1?{events:i}:{},...p?{selector:p}:{},...u?{target:u}:{},...m?{condition:m}:{},...y?{watchTarget:y}:{},...d&&d.length>0?{args:d,params:d}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let n=E(t),i=e.thenBranch.map(s=>this.build(s)),o=e.elseBranch?.map(s=>this.build(s)),a=[n,{type:"block",commands:i}];return o&&o.length>0&&a.push({type:"block",commands:o}),{type:"command",name:"if",args:a}}buildCompound(e){let t=e.statements.map(i=>this.build(i));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(i=>this.build(i)),n=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let i=e.roles.get("quantity");i&&n.push(E(i));break}case"for":{e.loopVariable&&n.push({type:"string",value:e.loopVariable});let i=e.roles.get("source");i&&n.push(E(i));break}case"while":case"until":{let i=e.roles.get("condition");i&&n.push(E(i));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 Ye(r){let e=new X;return{ast:e.build(r),warnings:e.warnings}}var O=class{constructor(e={}){this.cache=new Map,this.config={maxSize:e.maxSize??1e3,ttlMs:e.ttlMs??0,enabled:e.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(e,t){return`${t}:${e}`}isExpired(e){return this.config.ttlMs===0?!1:Date.now()-e.createdAt>this.config.ttlMs}evictLRU(){let e=this.cache.keys().next().value;e!==void 0&&(this.cache.delete(e),this.stats.evictions++)}get(e,t){if(!this.config.enabled){this.stats.misses++;return}let n=this.makeKey(e,t),i=this.cache.get(n);if(!i){this.stats.misses++;return}if(this.isExpired(i)){this.cache.delete(n),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(n),i.lastAccessed=Date.now(),this.cache.set(n,i),this.stats.hits++,i.result}set(e,t,n){if(!this.config.enabled||n.confidence===0)return;let i=this.makeKey(e,t),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:n,createdAt:o,lastAccessed:o})}has(e,t){if(!this.config.enabled)return!1;let n=this.makeKey(e,t),i=this.cache.get(n);return i?this.isExpired(i)?(this.cache.delete(n),this.stats.expirations++,!1):!0:!1}delete(e,t){let n=this.makeKey(e,t);return this.cache.delete(n)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let e=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:e>0?this.stats.hits/e:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(e){if(e.maxSize!==void 0)for(this.config.maxSize=e.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();e.ttlMs!==void 0&&(this.config.ttlMs=e.ttlMs),e.enabled!==void 0&&(this.config.enabled=e.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},Ce=new O;var Z=class{constructor(e={}){this.patternMatcher=new D,this.languages=new Set(ee()),e.cache===!1?this.cache=new O({enabled:!1}):this.cache=e.cache?new O(e.cache):Ce}analyze(e,t){if(!this.supportsLanguage(t))return{confidence:0,errors:[`Language '${t}' is not supported for semantic parsing`]};let n=this.cache.get(e,t);if(n)return n;let i=this.analyzeUncached(e,t);return this.cache.set(e,t,i),i}analyzeUncached(e,t){try{let n=qe(t);if(!n)return{confidence:0,errors:[`No tokenizer available for language '${t}'`]};let i=n.tokenize(e),o=L(t);if(o.length===0)return{confidence:0,errors:[`No patterns available for language '${t}'`]};let a=this.patternMatcher.matchBest(i,o);if(!a)return{confidence:0,errors:["No pattern matched the input"]};let s=this.buildSemanticNode(a);return{confidence:a.confidence,command:{name:a.pattern.command,roles:a.captured},node:s,tokensConsumed:a.consumedTokens}}catch(n){return{confidence:0,errors:[n instanceof Error?n.message:String(n)]}}}supportsLanguage(e){return this.languages.has(e)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(e){this.cache.configure(e)}buildSemanticNode(e){return{kind:"command",action:e.pattern.command,roles:e.captured,metadata:{patternId:e.pattern.id}}}};function Je(r){return new Z(r)}var ze=.5,et=.8;function tt(r,e=ze){return r.confidence>=e&&r.command!==void 0}var Ln="1.0.0-tr",Nn=["tr"];function wn(){return[...Nn]}function nt(r){if(r!=="tr")throw new Error(`Language not supported in this bundle: ${r}. Supported: tr`)}function Cn(r,e){return nt(e),[...ae(r,e).tokens]}function rt(r){return nt(r),L(r)}function zn(r,e){return rt(r).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}return lt(Rn);})();
1
+ "use strict";var LokaScriptSemanticTr=(()=>{var fe=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var mt=(r,e)=>{for(var t in e)fe(r,t,{get:e[t],enumerable:!0})},ft=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of pt(e))!dt.call(r,i)&&i!==t&&fe(r,i,{get:()=>e[i],enumerable:!(n=ut(e,i))||n.enumerable});return r};var gt=r=>ft(fe({},"__esModule",{value:!0}),r);var Vn={};mt(Vn,{ASTBuilder:()=>J,DEFAULT_CONFIDENCE_THRESHOLD:()=>Ae,HIGH_CONFIDENCE_THRESHOLD:()=>at,SemanticAnalyzerImpl:()=>ee,VERSION:()=>Rn,buildAST:()=>it,canParse:()=>Ne,createCommandNode:()=>M,createEventHandler:()=>U,createLiteral:()=>v,createPropertyPath:()=>W,createReference:()=>C,createSelector:()=>z,createSemanticAnalyzer:()=>ot,fromExplicit:()=>Ce,getCommandMapper:()=>Y,getPatternsForLanguage:()=>lt,getPatternsForLanguageAndCommand:()=>jn,getProfile:()=>ye,getSupportedLanguages:()=>Mn,getTokenizer:()=>he,isExplicitSyntax:()=>F,isLanguageSupported:()=>Be,parse:()=>D,parseAny:()=>Pe,parseExplicit:()=>B,registerCommandMapper:()=>ze,render:()=>Z,renderExplicit:()=>Q,shouldUseSemanticResult:()=>st,toExplicit:()=>we,tokenize:()=>An,turkishProfile:()=>I,turkishTokenizer:()=>se});var w=new Map,A=new Map,q=new Map;var je=null;function Oe(r,e){let t={...r};for(let n of Object.keys(e)){let i=e[n],o=r[n];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[n]=Oe(o,i):t[n]=i)}return t}function ht(r,e){return Oe(r,e)}function ge(r){if(!r.extends)return r;let e=A.get(r.extends);if(!e)return console.warn(`[Registry] Profile '${r.code}' extends '${r.extends}' but base is not registered. Make sure to import the base language before the variant.`),r;let t=ge(e);return ht(t,r)}function Ie(r,e,t){w.set(r,e),A.set(r,t),q.delete(r)}var Ve=new Map;function j(r){return r.split("-")[0]}function V(r){return r.includes("-")}function he(r){let e=w.get(r);if(!e&&V(r)){let t=j(r);e=w.get(t)}if(!e){let t=Array.from(w.keys()).join(", ");throw new Error(`Language '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return e}function ye(r){let e=A.get(r);if(!e&&V(r)){let t=j(r);e=A.get(t)}if(!e){let t=Array.from(A.keys()).join(", ");throw new Error(`Language profile '${r}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${r}';`)}return ge(e)}function _e(r){let e=w.get(r);return!e&&V(r)&&(e=w.get(j(r))),e}function $(r){let e=A.get(r);return!e&&V(r)&&(e=A.get(j(r))),e?ge(e):void 0}function ne(){return Array.from(w.keys())}function Be(r){return w.has(r)?!0:V(r)?w.has(j(r)):!1}function Ke(r,e){return he(e).tokenize(r)}function L(r){let e=q.get(r);if(!e&&V(r)&&(e=q.get(j(r))),e)return e;let t=Ve.get(r);if(!t&&V(r)&&(t=Ve.get(j(r))),t)return q.set(r,t),t;if(!je)throw new Error(`No patterns registered for language '${r}'. Either import the language module or set a pattern generator.`);let n=ye(r),i=je(n);return q.set(r,i),i}function $e(r,e){return L(r).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}var O=class{constructor(e,t){this.pos=0;this.tokens=e,this.language=t}peek(e=0){let t=this.pos+e;return t<0||t>=this.tokens.length?null:this.tokens[t]}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(e){this.pos=e.position}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(e){let t=[];for(;!this.isAtEnd()&&e(this.peek());)t.push(this.advance());return t}skipWhile(e){for(;!this.isAtEnd()&&e(this.peek());)this.advance()}};function x(r,e){return{start:r,end:e}}function T(r,e,t,n){if(typeof n=="string")return{value:r,kind:e,position:t,normalized:n};if(n){let{normalized:i,stem:o,stemConfidence:a}=n,s={value:r,kind:e,position:t};return i!==void 0&&(s.normalized=i),o!==void 0&&(s.stem=o,a!==void 0&&(s.stemConfidence=a)),s}return{value:r,kind:e,position:t}}function R(r){return/\s/.test(r)}function ie(r){return r==="#"||r==="."||r==="["||r==="@"||r==="*"||r==="<"}function oe(r){return r==='"'||r==="'"||r==="`"||r==="\u300C"||r==="\u300D"}function N(r){return/\d/.test(r)}function We(r){return/[a-zA-Z]/.test(r)}function b(r){return/[a-zA-Z0-9_-]/.test(r)}function Se(r){let e=n=>r.test(n);return{isLetter:e,isIdentifierChar:n=>e(n)||/[0-9_-]/.test(n)}}function Ue(r,e){if(e>=r.length)return null;let t=r[e];if(!ie(t))return null;let n=e,i="";if(t==="#"||t==="."){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null;if(n<r.length&&r[n]==="."&&t==="#"){let a=n+1;for(;a<r.length&&b(r[a]);)a++;if(a<r.length&&r[a]==="(")return i}}else if(t==="["){let o=1,a=!1,s=null,c=!1;for(i+=r[n++];n<r.length&&o>0;){let l=r[n];i+=l,c?c=!1:l==="\\"?c=!0:a?l===s&&(a=!1,s=null):l==='"'||l==="'"||l==="`"?(a=!0,s=l):l==="["?o++:l==="]"&&o--,n++}if(o!==0)return null}else if(t==="@"){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="*"){for(i+=r[n++];n<r.length&&b(r[n]);)i+=r[n++];if(i.length<=1)return null}else if(t==="<"){if(i+=r[n++],n>=r.length||!We(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++];for(;n<r.length;){let o=r[n];if(o==="."){if(i+=r[n++],n>=r.length||!b(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++]}else if(o==="#"){if(i+=r[n++],n>=r.length||!b(r[n]))return null;for(;n<r.length&&b(r[n]);)i+=r[n++]}else if(o==="["){let a=1,s=!1,c=null,l=!1;for(i+=r[n++];n<r.length&&a>0;){let m=r[n];i+=m,l?l=!1:m==="\\"?l=!0:s?m===c&&(s=!1,c=null):m==='"'||m==="'"||m==="`"?(s=!0,c=m):m==="["?a++:m==="]"&&a--,n++}if(a!==0)return null}else break}for(;n<r.length&&R(r[n]);)i+=r[n++];if(n<r.length&&r[n]==="/")for(i+=r[n++];n<r.length&&R(r[n]);)i+=r[n++];if(n>=r.length||r[n]!==">")return null;i+=r[n++]}return i||null}function yt(r,e){if(e>=r.length||r[e]!=="'"||e+1>=r.length||r[e+1].toLowerCase()!=="s")return!1;if(e+2>=r.length)return!0;let n=r[e+2];return R(n)||n==="*"||!b(n)}function Fe(r,e){if(e>=r.length)return null;let t=r[e];if(!oe(t)||t==="'"&&yt(r,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,a=t,s=!1;for(;o<r.length;){let c=r[o];if(a+=c,s)s=!1;else if(c==="\\")s=!0;else if(c===i)return a;o++}return a}function ae(r,e){if(e>=r.length)return!1;let t=r[e],n=r[e+1]||"",i=r[e+2]||"";if(t==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||t==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(n==="/"||n==="."&&i==="/"))return!0;let o=r.slice(e,e+8).toLowerCase();return!!(o.startsWith("http://")||o.startsWith("https://"))}function De(r,e){if(!ae(r,e))return null;let t=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<r.length;){let o=r[t];if(o==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=o,t++;t<r.length&&/[a-zA-Z0-9_-]/.test(r[t]);)n+=r[t++];break}if(i.test(o))n+=o,t++;else break}return n.length<2?null:n}function qe(r,e){if(e>=r.length)return null;let t=r[e];if(!N(t)&&t!=="-"&&t!=="+")return null;let n=e,i="";if((r[n]==="-"||r[n]==="+")&&(i+=r[n++]),n>=r.length||!N(r[n]))return null;for(;n<r.length&&N(r[n]);)i+=r[n++];if(n<r.length&&r[n]===".")for(i+=r[n++];n<r.length&&N(r[n]);)i+=r[n++];return n<r.length&&(r.slice(n,n+2)==="ms"?i+="ms":(r[n]==="s"||r[n]==="m"||r[n]==="h")&&(i+=r[n])),i}var re=class re{constructor(){this.profileKeywords=[];this.profileKeywordMap=new Map}initializeKeywordsFromProfile(e,t=[]){let n=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(n.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let a of o.alternatives)n.set(a,{native:a,normalized:o.normalized||i})}if(e.references)for(let[i,o]of Object.entries(e.references))n.set(o,{native:o,normalized:i});if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&n.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let a of o.alternatives)n.set(a,{native:a,normalized:i})}for(let i of t)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i)}}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 T(n.native,"keyword",x(t,t+n.native.length),n.normalized);return null}isKeywordStart(e,t){let n=e.slice(t);return this.profileKeywords.some(i=>n.startsWith(i.native))}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 i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let a={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return T(e,"keyword",x(t,n),a)}trySelector(e,t){let n=Ue(e,t);return n?T(n,"selector",x(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 i=n[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],a=n[1];return{...T(i,"event-modifier",x(t,t+i.length)),metadata:{modifierName:o,value:a?o==="queue"?a:parseInt(a,10):void 0}}}tryString(e,t){let n=Fe(e,t);return n?T(n,"literal",x(t,t+n.length)):null}tryNumber(e,t){let n=qe(e,t);return n?T(n,"literal",x(t,t+n.length)):null}tryMatchTimeUnit(e,t,n,i=!1){let o=t;if(i)for(;o<e.length&&R(e[o]);)o++;let a=e.slice(o);for(let s of n){let c=a.slice(0,s.length);if(s.caseInsensitive?c.toLowerCase()===s.pattern.toLowerCase():c===s.pattern){if(s.notFollowedBy&&(a[s.length]||"")===s.notFollowedBy)continue;if(s.checkBoundary){let m=a[s.length]||"";if(b(m))continue}return{suffix:s.suffix,endPos:o+s.length}}}return null}parseBaseNumber(e,t,n=!0){let i=t,o="";if(n&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!N(e[i]))return null;for(;i<e.length&&N(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&N(e[i]);)o+=e[i++];return!o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,n,i={}){let{allowSign:o=!0,skipWhitespace:a=!1}=i,s=this.parseBaseNumber(e,t,o);if(!s)return null;let{number:c,endPos:l}=s,m=[...n,...re.STANDARD_TIME_UNITS],S=this.tryMatchTimeUnit(e,l,m,a);return S&&(c+=S.suffix,l=S.endPos),T(c,"literal",x(t,l))}tryUrl(e,t){let n=De(e,t);return n?T(n,"url",x(t,t+n.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!b(e[t+1]))return null;let n=t+1;for(;n<e.length&&b(e[n]);)n++;let i=e.slice(t,n);return T(i,"identifier",x(t,n))}tryOperator(e,t){let n=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return T(n,"operator",x(t,t+2));let i=e[t];return["<",">","!","+","-","*","/","="].includes(i)?T(i,"operator",x(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?T(i,"punctuation",x(t,t+1)):null}tryMultiCharParticle(e,t,n){for(let i of n)if(e.slice(t,t+i.length)===i)return T(i,"particle",x(t,t+i.length));return null}};re.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 H=re;function He(r){return{stem:r,confidence:1}}function xe(r,e,t){return t?{stem:r,confidence:e,metadata:t}:{stem:r,confidence:e}}function St(r){let e=r.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(r)}function xt(r){for(let e of r)if(St(e))return!0;return!1}function Te(r){return"a\u0131ouAIOU".includes(r)}function Ge(r){return"ei\xF6\xFCE\u0130\xD6\xDC".includes(r)}function Xe(r){return Te(r)||Ge(r)}function Tt(r){for(let e=r.length-1;e>=0;e--)if(Xe(r[e]))return r[e];return null}function vt(r,e){let t=Tt(r);if(!t)return!0;let n=e.split("").find(i=>Xe(i));return n?Te(t)?Te(n):Ge(n):!0}var kt=[{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}],G=class{constructor(){this.language="tr"}isNormalizable(e){return!(!xt(e)||e.length<3)}normalize(e){let t=e.toLowerCase();for(let n of kt)if(t.endsWith(n.pattern)){let i=t.slice(0,-n.pattern.length),o=n.minStemLength??2;if(i.length<o)continue;if(!vt(i,n.pattern)){let s=n.confidence*.9,c={removedSuffixes:[n.pattern]};return n.conjugationType&&(c.conjugationType=n.conjugationType),xe(i,s,c)}let a={removedSuffixes:[n.pattern]};return n.conjugationType&&(a.conjugationType=n.conjugationType),xe(i,n.confidence,a)}return He(e)}},$n=new G;var I={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",direction:"ltr",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:!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:"",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:"ekle",normalized:"append"},take:{primary:"tut",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"kopyala",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:["yap","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:["oldu\u011Funda","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"],normalized:"blur"},click:{primary:"t\u0131klama",alternatives:["t\u0131kla"],normalized:"click"},hover:{primary:"\xFCzerine gelme",alternatives:["\xFCzerinde gezinme"],normalized:"hover"},submit:{primary:"g\xF6nderme",alternatives:["g\xF6nder"],normalized:"submit"},input:{primary:"giri\u015F",alternatives:["girdi"],normalized:"input"},change:{primary:"de\u011Fi\u015Fiklik",alternatives:["de\u011Fi\u015Fim"],normalized:"change"},go:{primary:"git",normalized:"go"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},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:"iken",normalized:"while"},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:"sonra",alternatives:["ard\u0131ndan","daha sonra"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},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:"y\xFCkle",normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},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"}},eventHandler:{eventMarker:{primary:"da",alternatives:["de","ta","te"],position:"after"},temporalMarkers:["d\u0131\u011F\u0131nda","di\u011Finde"]}};var{isLetter:ve}=Se(/[a-zA-ZçÇğĞıİöÖşŞüÜ]/),Ze=new Set(["ile","i\xE7in","kadar","gibi","sonra","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),Qe=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"]),bt=[{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:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"en_yak\u0131n",normalized:"closest"},{native:"en_yakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"t\u0131klama",normalized:"click"},{native:"tiklama",normalized:"click"},{native:"t\u0131k",normalized:"click"},{native:"tik",normalized:"click"},{native:"giri\u015F",normalized:"input"},{native:"giris",normalized:"input"},{native:"de\u011Fi\u015Fim",normalized:"change"},{native:"degisim",normalized:"change"},{native:"odak",normalized:"focus"},{native:"bulan\u0131k",normalized:"blur"},{native:"bulanik",normalized:"blur"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{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:"benim",normalized:"my"},{native:"onun",normalized:"its"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"},{native:"ve",normalized:"and"},{native:"veya",normalized:"or"},{native:"de\u011Fil",normalized:"not"},{native:"degil",normalized:"not"}],Et=[{pattern:"milisaniye",suffix:"ms",length:10,caseInsensitive:!0},{pattern:"dakika",suffix:"m",length:6,caseInsensitive:!0},{pattern:"saniye",suffix:"s",length:6,caseInsensitive:!0},{pattern:"saat",suffix:"h",length:4,caseInsensitive:!0},{pattern:"dk",suffix:"m",length:2,checkBoundary:!0},{pattern:"sa",suffix:"h",length:2,checkBoundary:!0}],ke=class extends H{constructor(){super();this.language="tr";this.direction="ltr";this.initializeKeywordsFromProfile(I,bt),this.normalizer=new G}tokenize(t){let n=[],i=0;for(;i<t.length;){if(R(t[i])){i++;continue}if(ie(t[i])){let s=this.tryEventModifier(t,i);if(s){n.push(s),i=s.position.end;continue}let c=this.trySelector(t,i);if(c){n.push(c),i=c.position.end;continue}}if(oe(t[i])){let s=this.tryString(t,i);if(s){n.push(s),i=s.position.end;continue}}if(ae(t,i)){let s=this.tryUrl(t,i);if(s){n.push(s),i=s.position.end;continue}}if(N(t[i])){let s=this.extractTurkishNumber(t,i);if(s){n.push(s),i=s.position.end;continue}}let o=this.tryVariableRef(t,i);if(o){n.push(o),i=o.position.end;continue}let a=this.tryMultiWordPhrase(t,i);if(a){n.push(a),i=a.position.end;continue}if(ve(t[i])){let s=this.extractTurkishWord(t,i);if(s){n.push(s),i=s.position.end;continue}}i++}return new O(n,"tr")}classifyToken(t){let n=t.toLowerCase();return Ze.has(n)||Qe.has(n)?"particle":this.isKeyword(n)?"keyword":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":"identifier"}tryMultiWordPhrase(t,n){for(let i of this.profileKeywords){if(!i.native.includes(" "))continue;let o=i.native;if(t.slice(n,n+o.length).toLowerCase()===o.toLowerCase()){let s=n+o.length;if(s>=t.length||R(t[s])||!ve(t[s]))return T(t.slice(n,n+o.length),"keyword",x(n,s),i.normalized)}}return null}extractTurkishWord(t,n){let i=n,o="";for(;i<t.length&&(ve(t[i])||t[i]==="_");)o+=t[i++];if(!o)return null;let a=o.toLowerCase();if(Qe.has(a))return T(o,"particle",x(n,i));if(Ze.has(a))return T(o,"particle",x(n,i));let s=this.lookupKeyword(a);if(s)return T(o,"keyword",x(n,i),s.normalized);let c=this.tryMorphKeywordMatch(a,n,i);return c||T(o,"identifier",x(n,i))}extractTurkishNumber(t,n){return this.tryNumberWithTimeUnits(t,n,Et,{allowSign:!1,skipWhitespace:!0})}},se=new ke;Ie("tr",se,I);function Ye(r){return _e(r)}function ce(r,e){return Ke(r,e)}function le(){return ne()}function z(r){let e="complex";return r.startsWith("#")&&!r.includes(" ")?e="id":r.startsWith(".")&&!r.includes(" ")?e="class":r.startsWith("[")&&r.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(r)&&(e="element"),{type:"selector",value:r,selectorKind:e}}function v(r,e){let t={type:"literal",value:r};return e!==void 0?{type:"literal",value:r,dataType:e}:t}function C(r){return{type:"reference",value:r}}function W(r,e){return{type:"property-path",object:r,property:e}}function M(r,e,t){let n={kind:"command",action:r,roles:new Map(Object.entries(e))};return t!==void 0?{...n,metadata:t}:n}function U(r,e,t,n,i){let o=new Map;o.set("event",r);let a={kind:"event-handler",action:"on",roles:o,body:e};return t!==void 0&&(a.eventModifiers=t),n!==void 0&&(a.metadata=n),i!==void 0&&i.length>0&&(a.parameterNames=i),a}function Je(r,e="then",t){let n={kind:"compound",action:"compound",roles:new Map,statements:r,chainType:e};return t!==void 0&&(n.metadata=t),n}function be(r,e){return!e||e.length===0||e.includes(r)||e.includes("expression")?!0:r==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):!1}function et(r,e){return r.possessive?.keywords?.[e]}var P=class P{constructor(){this.stemMatchCount=0;this.totalKeywordMatches=0}matchPattern(e,t){let n=e.mark(),i=new Map;if(this.currentProfile=$(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(n),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-n.position,confidence:a}}matchBest(e,t){let n=[];for(let o of t){let a=e.mark(),s=this.matchPattern(e,o);s&&n.push(s),e.reset(a)}if(n.length===0)return null;n.sort((o,a)=>{let s=a.pattern.priority-o.pattern.priority;return s!==0?s:a.confidence-o.confidence});let i=n[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,n){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let a of t)if(!this.matchPatternToken(e,a,n)){if(this.isOptional(a))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(!n)return!1;let i=this.getMatchType(n,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),!0;if(t.alternatives)for(let o of t.alternatives){let a=this.getMatchType(n,o);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),!0}return!1}matchRoleToken(e,t,n){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||!1;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,o),!0);let a=this.tryMatchMethodCallExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(a.type)&&!t.expectedTypes.includes("expression")?t.optional||!1:(n.set(t.role,a),!0);let s=this.tryMatchPossessiveSelectorExpression(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 c=this.tryMatchPropertyAccessExpression(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 l=this.tryMatchSelectorPropertyExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!be(l.type,t.expectedTypes)?t.optional||!1:(n.set(t.role,l),!0);let m=this.tokenToSemanticValue(i);return!m||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(m.type)?t.optional||!1:(n.set(t.role,m),e.advance(),!0)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let n=(t.normalized||t.value).toLowerCase(),i=et(this.currentProfile,n);if(!i)return null;let o=e.mark();e.advance();let a=e.peek();return a&&(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*"))?(e.advance(),W(C(i),a.value)):(e.reset(o),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 i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="(")return e.reset(n),null;e.advance();let s=[];for(;!e.isAtEnd()&&s.length<P.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}s.push(l.value),e.advance()}return{type:"expression",raw:`${t.value}.${o.value}(${s.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(n),null;e.advance();let a=`${t.value}.${o.value}`,s=1;for(;!e.isAtEnd()&&s<P.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let m=e.peek();if(!m||m.kind!=="identifier")break;e.advance(),a+=`.${m.value}`,s++}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let l=[],m=0;for(;!e.isAtEnd()&&l.length<P.MAX_METHOD_ARGS;){let y=e.peek();if(!y)break;if(y.kind==="punctuation"&&y.value===")"){if(m===0){e.advance();break}m--}if(y.kind==="punctuation"&&y.value==="("&&m++,y.kind==="punctuation"&&y.value===","){e.advance();continue}l.push(y.value),e.advance()}return{type:"expression",raw:`${a}(${l.join(", ")})`}}return{type:"expression",raw:a}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let o=e.peek();return!o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(n),null):(e.advance(),W(z(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let o=e.peek(1);o&&o.kind,e.advance();let a=i.value.slice(1);return W(z(t.value),a)}matchGroupToken(e,t,n){let i=e.mark(),o=new Set(n.keys());if(!this.matchTokenSequence(e,t.tokens,n)){e.reset(i);for(let s of n.keys())o.has(s)||n.delete(s);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 z(e.value);case"literal":return this.parseLiteralValue(e.value);case"keyword":let t=(e.normalized||e.value).toLowerCase();return["me","you","it","result","event","target","body"].includes(t)?C(t):v(e.normalized||e.value);case"identifier":if(e.value.startsWith(":"))return C(e.value);let n=e.value.toLowerCase();return["me","you","it","result","event","target","body"].includes(n)?C(n):{type:"expression",raw:e.value};case"url":return v(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return v(i,"string")}if(e==="true")return v(!0,"boolean");if(e==="false")return v(!1,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?v(e,"duration"):v(i,"number")}let n=parseFloat(e);return isNaN(n)?v(e,"string"):v(n,"number")}applyExtractionRules(e,t){for(let[n,i]of Object.entries(e.extraction))!t.has(n)&&i.default&&t.set(n,i.default)}isOptional(e){return e.optional===!0}calculateConfidence(e,t){let n=0,i=0,o=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")i+=1,t.has(l.role)&&(n+=1);else if(l.type==="group"){for(let m of l.tokens)if(m.type==="role"){let S=o(m.role),y=.8;i+=y,t.has(m.role)?n+=y:S&&(n+=y*.6)}}let a=i>0?n/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;a=Math.max(.5,a-l)}let s=this.calculateVSOConfidenceBoost(e);a=Math.min(1,a+s);let c=this.arabicPrepositionDisambiguation(e,t);return a=Math.max(0,Math.min(1,a+c)),a}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 i of t.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let n=0,i={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[o,a]of t.entries()){let s=i[o];if(!s||s.length===0)continue;let c=a.metadata;if(c&&typeof c.prepositionValue=="string"){let l=c.prepositionValue;s.includes(l)?n+=.1:n-=.1}}return Math.max(-.1,Math.min(.1,n))}skipNoiseWords(e){let t=e.peek();if(!t)return;let n=t.value.toLowerCase();if(P.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i)}n==="class"&&e.advance()}extractEventModifiers(e){let t={},n=!1;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(n=!0,o.modifierName){case"once":t.once=!0;break;case"debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case"throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case"queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance()}return n?t:void 0}};P.MAX_PROPERTY_DEPTH=10,P.MAX_METHOD_ARGS=20,P.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var X=P,_=new X;var ue=class{render(e,t){if(e.kind==="compound")return this.renderCompound(e,t);let n=$e(t,e.action);if(n.length===0)return this.renderExplicit(e);let i=this.findBestPattern(e,n);return i?this.renderWithPattern(e,i):this.renderExplicit(e)}renderCompound(e,t){let n=e.statements.map(o=>this.render(o,t)),i=this.getChainWord(e.chainType,t);return n.join(` ${i} `)}getChainWord(e,t){let n=$(t);return n?.keywords?n.keywords[e]?.primary??e:e}renderExplicit(e){if(e.kind==="compound"){let n=e;return n.statements.map(o=>this.renderExplicit(o)).join(` ${n.chainType} `)}let t=[e.action];for(let[n,i]of e.roles)t.push(`${n}:${this.valueToString(i)}`);if(e.kind==="event-handler"){let n=e;if(n.body&&n.body.length>0){let i=n.body.map(o=>this.renderExplicit(o));t.push(`body:${i.join(" ")}`)}}return`[${t.join(" ")}]`}supportedLanguages(){return le()}findBestPattern(e,t){let n=t.map(i=>{let o=i.priority;for(let a of i.template.tokens)a.type==="role"&&(e.roles.has(a.role)?o+=10:a.optional||(o-=50));return i.language==="en"&&((i.id.includes("standard")||i.id.includes("en-source"))&&(o+=20),(i.id.includes("-when")||i.id.includes("-if")||i.id.includes("-upon"))&&(o-=15)),{pattern:i,score:o}});return n.sort((i,o)=>o.score-i.score),n.length>0?n[0].pattern:null}renderWithPattern(e,t){let n=[],i=t.language;for(let o of t.template.tokens){let a=this.renderPatternToken(o,e,i);a!==null&&n.push(a)}if(e.kind==="event-handler"){let o=e;if(o.body&&o.body.length>0){let a=o.body.map(s=>this.render(s,i));n.push(a.join(" "))}}return n.join(" ")}renderPatternToken(e,t,n){switch(e.type){case"literal":return e.value;case"role":{let i=t.roles.get(e.role);return i?this.valueToNaturalString(i,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(s=>s.type==="role"&&s.role==="destination")){let s=t.roles.get("destination");if(s?.type==="reference"&&s.value==="me")return null}let o=[];for(let a of e.tokens){let s=this.renderPatternToken(a,t,n);s!==null&&o.push(s)}return o.length>0?o.join(" "):null}default:return null}}valueToString(e){switch(e.type){case"literal":return typeof e.value=="string"?e.dataType==="string"||/\s/.test(e.value)?`"${e.value}"`:e.value:String(e.value);case"selector":return e.value;case"reference":return e.value;case"property-path":return`${this.valueToString(e.object)}'s ${e.property}`;case"expression":return e.raw}}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}}renderReference(e,t){let n=$(t);return n?.references?n.references[e.value]??e.value:e.value}renderPropertyPath(e,t){let n=$(t),i=e.property,o=e.object.type==="reference"?e.object.value:null;if(n?.possessive?.specialForms&&o){let s=n.possessive.specialForms[o];if(s){let{markerPosition:c,usePossessiveAdjectives:l}=n.possessive;return l&&c==="after-object"?`${i} ${s}`:`${s} ${i}`}}let a=this.valueToNaturalString(e.object,t);if(n?.possessive){let{marker:s,markerPosition:c,usePossessiveAdjectives:l}=n.possessive;if(l&&o&&c==="after-object")return`${i} ${a}`;if(s)switch(c){case"between":return n.usesSpaces?`${a}${s} ${i}`:`${a}${s}${i}`;case"after-object":return`${a}${s} ${i}`;case"before-property":return`${a} ${s} ${i}`}}return t==="en"||!n?.possessive?a==="me"?`my ${i}`:a==="it"?`its ${i}`:`${a}'s ${i}`:`${a} ${i}`}},Ee=new ue;function Z(r,e){return Ee.render(r,e)}function Q(r){return Ee.renderExplicit(r)}function B(r){let e=r.trim();if(!e.startsWith("[")||!e.endsWith("]"))throw new Error("Explicit syntax must be wrapped in brackets: [command role:value ...]");let t=e.slice(1,-1).trim();if(!t)throw new Error("Empty explicit statement");let n=Lt(t);if(n.length===0)throw new Error("No command specified in explicit statement");let i=n[0].toLowerCase(),o=new Map;for(let s=1;s<n.length;s++){let c=n[s],l=c.indexOf(":");if(l===-1)throw new Error(`Invalid role format: "${c}". Expected role:value`);let m=c.slice(0,l),S=c.slice(l+1);if(m==="body"&&S.startsWith("[")){let h=wt(c,l+1),p=c.slice(l+1,h+1);o.set(m,{type:"expression",raw:p});continue}let y=Nt(S);o.set(m,y)}if(i==="on"){let s=o.get("event");if(!s)throw new Error("Event handler requires event role: [on event:click ...]");let c=o.get("body"),l=[];return c&&c.type==="expression"&&l.push(B(c.raw)),o.delete("body"),U(s,l,void 0,{sourceLanguage:"explicit"})}let a={};for(let[s,c]of o)a[s]=c;return M(i,a,{sourceLanguage:"explicit"})}function Lt(r){let e=[],t="",n=!1,i="",o=0;for(let a=0;a<r.length;a++){let s=r[a];if(n){t+=s,s===i&&r[a-1]!=="\\"&&(n=!1);continue}if(s==='"'||s==="'"){n=!0,i=s,t+=s;continue}if(s==="["){o++,t+=s;continue}if(s==="]"){o--,t+=s;continue}if(s===" "&&o===0){t&&(e.push(t),t="");continue}t+=s}return t&&e.push(t),e}function Nt(r){if(r.startsWith("#")||r.startsWith(".")||r.startsWith("[")||r.startsWith("@")||r.startsWith("*"))return z(r);if(r.startsWith('"')||r.startsWith("'")){let t=r.slice(1,-1);return v(t,"string")}if(r==="true")return v(!0,"boolean");if(r==="false")return v(!1,"boolean");if(["me","you","it","result","event","target","body"].includes(r.toLowerCase()))return C(r.toLowerCase());let e=r.match(/^(-?\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let t=parseFloat(e[1]);return e[2]?v(r,"duration"):v(t,"number")}return v(r,"string")}function wt(r,e){let t=0;for(let n=e;n<r.length;n++)if(r[n]==="[")t++;else if(r[n]==="]"&&(t--,t===0))return n;return r.length-1}function F(r){let e=r.trim();return e.startsWith("[")&&e.endsWith("]")}var pe=class{parse(e,t){let n=ce(e,t),i=L(t);if(i.length===0)throw new Error(`No patterns available for language: ${t}`);let o=[...i].sort((m,S)=>S.priority-m.priority),a=o.filter(m=>m.command==="on"),s=_.matchBest(n,a);if(s)return this.buildEventHandler(s,n,t);let c=o.filter(m=>m.command!=="on"),l=_.matchBest(n,c);if(l)return this.buildCommand(l,t);throw new Error(`Could not parse input in ${t}: ${e}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return!1}}supportedLanguages(){return le()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let n={};for(let[i,o]of e.captured)n[i]=o;return M(e.pattern.command,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=_.extractEventModifiers(t),a,s=e.captured.get("action");if(s&&s.type==="literal"){let c=s.value,l={};for(let[y,h]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(l[y]=h);let m=M(c,l,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence}),S=e.captured.get("continues");if(S&&S.type==="literal"&&S.value==="then"){let y=L(n).filter(d=>d.command!=="on").sort((d,g)=>g.priority-d.priority),h=L(n).filter(d=>d.id.startsWith("grammar-")&&d.id.includes("-continuation")).sort((d,g)=>g.priority-d.priority),p=this.parseBodyWithGrammarPatterns(t,y,h,n);p.length>0?a=[m,...p]:a=[m]}else a=[m]}else{let c=L(n).filter(l=>l.command!=="on").sort((l,m)=>m.priority-l.priority);a=this.parseBodyWithClauses(t,c,n)}return U(i,a,o,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,n){let i=[],o=[];for(;!e.isAtEnd();){let a=e.peek();if(!a)break;let s=a.kind==="conjunction"||a.kind==="keyword"&&this.isThenKeyword(a.value,n),c=a.kind==="keyword"&&this.isEndKeyword(a.value,n);if(s){if(o.length>0){let l=this.parseClause(o,t,n);i.push(...l),o.length=0}e.advance();continue}if(c){if(o.length>0){let l=this.parseClause(o,t,n);i.push(...l)}e.advance();break}o.push(a),e.advance()}if(o.length>0){let a=this.parseClause(o,t,n);i.push(...a)}return i.length>1?[Je(i,"then",{sourceLanguage:n})]:i}parseClause(e,t,n){if(e.length===0)return[];let i=new O(e,n),o=[];for(;!i.isAtEnd();){let a=_.matchBest(i,t);a?o.push(this.buildCommand(a,n)):i.advance()}return o}parseBodyWithGrammarPatterns(e,t,n,i){let o=[];for(;!e.isAtEnd();){let a=e.peek();if(a&&this.isThenKeyword(a.value,i)){e.advance();continue}if(a&&this.isEndKeyword(a.value,i)){e.advance();break}let s=!1;if(n.length>0){let c=_.matchBest(e,n);if(c){let l=c.pattern.command,m={};for(let[h,p]of c.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(m[h]=p);let S=M(l,m,{sourceLanguage:i,patternId:c.pattern.id});o.push(S),s=!0;let y=c.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!s){let c=_.matchBest(e,t);c&&(o.push(this.buildCommand(c,i)),s=!0)}s||e.advance()}return o}isThenKeyword(e,t){let n={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"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),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"]),qu:new Set(["chaymantataq","hinaspa","chaymanta"]),sw:new Set(["kisha","halafu","baadaye"])};return(n[t]||n.en).has(e.toLowerCase())}isEndKeyword(e,t){let n={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\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","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return(n[t]||n.en).has(e.toLowerCase())}},Le=new pe;function D(r,e){return Le.parse(r,e)}function Ne(r,e){return Le.canParse(r,e)}function we(r,e){if(F(r))return r;let t=D(r,e);return Q(t)}function Ce(r,e){let t=B(r);return Z(t,e)}function Pe(r,e){return F(r)?B(r):D(r,e)}var Ct=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),Pt=new Set(["and","or","not","no"]),Rt=new Set(["true","false","null","undefined"]),zt=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function tt(r){let e=[],t=0,n=1,i=1;function o(){if(e.length===0)return!0;let p=e[e.length-1];return["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(p.type)}function a(p=0){return r[t+p]??""}function s(){let p=r[t];return t++,p===`
2
+ `?(n++,i=1):i++,p}function c(){for(;t<r.length&&/\s/.test(r[t]);)s()}function l(p){let d="";for(;t<r.length&&p(r[t]);)d+=s();return d}function m(p){let d=p;for(s();t<r.length&&r[t]!==p;)r[t]==="\\"&&t+1<r.length&&(d+=s()),d+=s();return t<r.length&&(d+=s()),d}function S(){let p="`";for(s();t<r.length&&r[t]!=="`";)r[t]==="\\"&&t+1<r.length&&(p+=s()),p+=s();return t<r.length&&(p+=s()),p}function y(){let p="<";for(s();t<r.length&&(p+=s(),!p.endsWith("/>")););return p}function h(p,d,g){return{type:p,value:d,start:g,end:t,line:n,column:i-d.length}}for(;t<r.length&&(c(),!(t>=r.length));){let p=t,d=a();if(d==="'"&&a(1)==="s"&&!/\w/.test(a(2))){s(),s(),e.push(h("POSSESSIVE","'s",p));continue}if(d==='"'||d==="'"){let g=m(d);e.push(h("STRING",g,p));continue}if(d==="`"){let g=S();e.push(h("TEMPLATE_LITERAL",g,p));continue}if(d==="<"&&/[a-zA-Z.#\[]/.test(a(1))){let g=y();e.push(h("QUERY_SELECTOR",g,p));continue}if(d==="#"&&o()){s();let g=l(k=>/[\w-]/.test(k));e.push(h("ID_SELECTOR","#"+g,p));continue}if(d==="."&&/[a-zA-Z_-]/.test(a(1))&&o()){s();let g=l(k=>/[\w-]/.test(k));e.push(h("CLASS_SELECTOR","."+g,p));continue}if(d==="["&&o()){let g=a(1);if(g==="@"||/[a-zA-Z]/.test(g)){let k="";for(k+=s();t<r.length&&r[t]!=="]";)r[t]==='"'||r[t]==="'"?k+=m(r[t]):k+=s();t<r.length&&(k+=s()),e.push(h("ATTRIBUTE_SELECTOR",k,p));continue}}if(d==="["){s(),e.push(h("LBRACKET","[",p));continue}if(d==="]"){s(),e.push(h("RBRACKET","]",p));continue}if(/\d/.test(d)){let g=l(me=>/[\d.]/.test(me)),k=t,te=l(me=>/[a-zA-Z]/.test(me));zt.has(te)?e.push(h("TIME_EXPRESSION",g+te,p)):(t=k,e.push(h("NUMBER",g,p)));continue}if(d==="("){s(),e.push(h("LPAREN","(",p));continue}if(d===")"){s(),e.push(h("RPAREN",")",p));continue}if(d==="{"){s(),e.push(h("LBRACE","{",p));continue}if(d==="}"){s(),e.push(h("RBRACE","}",p));continue}if(d===","){s(),e.push(h("COMMA",",",p));continue}if(d===":"){s(),e.push(h("COLON",":",p));continue}if(d==="."){s(),e.push(h("DOT",".",p));continue}if(d==="+"||d==="-"||d==="*"||d==="/"||d==="%"){s(),e.push(h("OPERATOR",d,p));continue}if(d==="="||d==="!"||d==="<"||d===">"){let g=s();a()==="="&&(g+=s()),e.push(h("COMPARISON",g,p));continue}if(/[a-zA-Z_$]/.test(d)){let g=l(te=>/[\w$]/.test(te)),k=g.toLowerCase();Ct.has(k)?e.push(h("CONTEXT_VAR",g,p)):Pt.has(k)?e.push(h("LOGICAL",g,p)):Rt.has(k)?e.push(h("BOOLEAN",g,p)):e.push(h("IDENTIFIER",g,p));continue}s()}return e.push(h("EOF","",t)),e}var de=class{constructor(){this.tokens=[];this.current=0}parse(e){try{return this.tokens=tt(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}}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(;this.match("COMPARISON")||this.checkValue("is")||this.checkValue("matches")||this.checkValue("contains")||this.checkValue("in");){let t=this.previous().value,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 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;return this.createLiteral(t,e.value,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("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"))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 i=this.parseExpression();e.push({key:n,value:i})}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]),i=t[2].toLowerCase();return{type:"timeExpression",value:n,unit:i,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.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}}createCallExpression(e,t){return{type:"callExpression",callee:e,arguments:t,start:e.start,end:this.previous().end}}};function Re(r){return new de().parse(r)}function E(r,e){switch(r.type){case"literal":return Mt(r);case"selector":return At(r,e);case"reference":return jt(r);case"property-path":return Vt(r,e);case"expression":return Ot(r);default:let t=r;throw new Error(`Unknown semantic value type: ${t.type}`)}}function Mt(r){let e={type:"literal",value:r.value};return r.dataType?{...e,dataType:r.dataType}:e}function At(r,e){return e&&r.value.startsWith("*")&&/^[a-zA-Z-]/.test(r.value.slice(1))&&e.push(`Converted '${r.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.`),{type:"selector",value:r.value,selector:r.value,selectorType:r.selectorKind}}function jt(r){return{type:"contextReference",contextType:r.value,name:r.value}}function Vt(r,e){return{type:"propertyAccess",object:E(r.object,e),property:r.property}}function Ot(r){let e=Re(r.raw);return!e.success||!e.node?{type:"identifier",name:r.raw}:e.node}function nt(r,e){return r.roles.get(e)}function u(r,e,t){let n=nt(r,e);return n?E(n,t):void 0}function f(r,e=[],t,n={}){let i={type:"command",name:r,args:e};return t&&Object.keys(t).length>0&&(i.modifiers=t),n.isBlocking&&(i.isBlocking=n.isBlocking),n.implicitTarget&&(i.implicitTarget=n.implicitTarget),i}var It={action:"toggle",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=u(r,"duration"),o=t?[t]:[],a={};return n&&(a.on=n),i&&(a.for=i),f("toggle",o,a)}},_t={action:"add",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("add",i,o)}},Bt={action:"remove",toAST(r,e){let t=u(r,"patient"),n=u(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("remove",i,o)}},Kt={action:"set",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=[],o={};return t&&i.push(t),n&&(o.to=n),f("set",i,o)}},$t={action:"show",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=u(r,"duration"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.with=i),f("show",o,a)}},Wt={action:"hide",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=u(r,"duration"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.with=i),f("hide",o,a)}},Ut={action:"increment",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=u(r,"quantity"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.by=i),f("increment",o,a)}},Ft={action:"decrement",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=u(r,"quantity"),o=[],a={},s=t??n;return s&&o.push(s),i&&(a.by=i),f("decrement",o,a)}},Dt={action:"wait",toAST(r,e){let t=u(r,"duration");return f("wait",t?[t]:[],void 0,{isBlocking:!0})}},qt={action:"log",toAST(r,e){let t=u(r,"patient"),n=[];return t&&n.push(t),f("log",n)}},Ht={action:"put",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=nt(r,"method"),o=t?[t]:[],a={};if(n){let s=i?.type==="literal"?String(i.value):"into";a[s]=n}return f("put",o,a)}},Gt={action:"fetch",toAST(r,e){let t=u(r,"source"),n=u(r,"method"),i=u(r,"responseType"),o=u(r,"patient"),a=t?[t]:[],s={};return n&&(s.with=n),i&&(s.as=i),o&&(s.body=o),f("fetch",a,s,{isBlocking:!0})}},Xt={action:"append",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("append",i,o)}},Zt={action:"prepend",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=t?[t]:[],o={};return n&&(o.to=n),f("prepend",i,o)}},Qt={action:"trigger",toAST(r,e){let t=u(r,"event"),n=u(r,"destination"),i=t?[t]:[],o={};return n&&(o.on=n),f("trigger",i,o)}},Yt={action:"send",toAST(r,e){let t=u(r,"event"),n=u(r,"destination"),i=u(r,"patient"),o=t?[t]:[],a={};return n&&(a.to=n),i&&(a.detail=i),f("send",o,a)}},Jt={action:"go",toAST(r,e){let t=u(r,"source"),n=u(r,"destination"),i=[],o={};return t&&i.push(t),n&&(o.to=n),f("go",i,o)}},en={action:"transition",toAST(r,e){let t=u(r,"patient"),n=u(r,"goal"),i=u(r,"duration"),o=u(r,"destination"),a=t?[t]:[],s={};return n&&(s.to=n),i&&(s.over=i),o&&(s.on=o),f("transition",a,s)}},tn={action:"focus",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=[],o={},a=t??n;return a&&i.push(a),f("focus",i,o)}},nn={action:"blur",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("blur",i)}},rn={action:"get",toAST(r,e){let t=u(r,"source"),n=u(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("get",i)}},on={action:"take",toAST(r,e){let t=u(r,"patient"),n=u(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("take",i,o)}},an={action:"call",toAST(r,e){let t=u(r,"patient");return f("call",t?[t]:[])}},sn={action:"return",toAST(r,e){let t=u(r,"patient");return f("return",t?[t]:[])}},cn={action:"halt",toAST(r,e){return f("halt",[])}},ln={action:"throw",toAST(r,e){let t=u(r,"patient");return f("throw",t?[t]:[])}},un={action:"settle",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("settle",i,void 0,{isBlocking:!0})}},pn={action:"swap",toAST(r,e){let t=u(r,"patient"),n=u(r,"source"),i=u(r,"destination"),o=u(r,"style"),a=[],s={};return t&&a.push(t),n&&a.push(n),i&&(s.on=i),o&&(s.with=o),f("swap",a,s)}},dn={action:"morph",toAST(r,e){let t=u(r,"source"),n=u(r,"destination"),i=u(r,"patient"),o=[],a={},s=t??i;return s&&o.push(s),n&&(a.on=n),f("morph",o,a)}},mn={action:"clone",toAST(r,e){let t=u(r,"source"),n=u(r,"destination"),i=u(r,"patient"),o=[],a={},s=t??i;return s&&o.push(s),n&&(a.into=n),f("clone",o,a)}},fn={action:"make",toAST(r,e){let t=u(r,"patient");return f("make",t?[t]:[])}},gn={action:"measure",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=u(r,"source"),o=[],a={};t&&o.push(t);let s=n??i;return s&&(a.of=s),f("measure",o,a)}},hn={action:"tell",toAST(r,e){let t=u(r,"destination"),n=u(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("tell",i)}},yn={action:"js",toAST(r,e){let t=u(r,"patient");return f("js",t?[t]:[])}},Sn={action:"async",toAST(r,e){return f("async",[])}},xn={action:"if",toAST(r,e){let t=u(r,"condition");return f("if",t?[t]:[])}},Tn={action:"unless",toAST(r,e){let t=u(r,"condition");return f("unless",t?[t]:[])}},vn={action:"repeat",toAST(r,e){let t=u(r,"quantity"),n=u(r,"patient"),i=[],o=t??n;return o&&i.push(o),f("repeat",i)}},kn={action:"for",toAST(r,e){let t=u(r,"patient"),n=u(r,"source"),i=t?[t]:[],o={};return n&&(o.in=n),f("for",i,o)}},bn={action:"while",toAST(r,e){let t=u(r,"condition");return f("while",t?[t]:[])}},En={action:"continue",toAST(r,e){return f("continue",[])}},Ln={action:"default",toAST(r,e){let t=u(r,"patient"),n=u(r,"source"),i=t?[t]:[],o={};return n&&(o.to=n),f("default",i,o)}},Nn={action:"init",toAST(r,e){return f("init",[])}},wn={action:"behavior",toAST(r,e){let t=u(r,"patient");return f("behavior",t?[t]:[])}},Cn={action:"install",toAST(r,e){let t=u(r,"patient"),n=u(r,"destination"),i=t?[t]:[],o={};return n&&(o.on=n),f("install",i,o)}},Pn={action:"on",toAST(r,e){let t=u(r,"event"),n=u(r,"source"),i=t?[t]:[],o={};return n&&(o.from=n),f("on",i,o)}},rt=new Map([["toggle",It],["add",_t],["remove",Bt],["set",Kt],["show",$t],["hide",Wt],["increment",Ut],["decrement",Ft],["wait",Dt],["log",qt],["put",Ht],["fetch",Gt],["append",Xt],["prepend",Zt],["get",rn],["take",on],["trigger",Qt],["send",Yt],["on",Pn],["go",Jt],["transition",en],["focus",tn],["blur",nn],["call",an],["return",sn],["halt",cn],["throw",ln],["settle",un],["swap",pn],["morph",dn],["clone",mn],["measure",gn],["make",fn],["tell",hn],["default",Ln],["js",yn],["async",Sn],["if",xn],["unless",Tn],["repeat",vn],["for",kn],["while",bn],["continue",En],["init",Nn],["behavior",wn],["install",Cn]]);function Y(r){return rt.get(r)}function ze(r){rt.set(r.action,r)}var J=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);default:throw new Error(`Unknown semantic node kind: ${e.kind}`)}}buildCommand(e){let t=Y(e.action);if(t){let n=t.toAST(e,this);if("ast"in n&&"warnings"in n){let i=n;return this.warnings.push(...i.warnings),i.ast}else return n}return this.buildGenericCommand(e)}buildGenericCommand(e){let t=[],n={},i=["patient","source","quantity"],o=["destination","duration","method","style"];for(let s of i){let c=e.roles.get(s);c&&t.push(E(c))}for(let s of o){let c=e.roles.get(s);if(c){let l=this.roleToModifierKey(s);n[l]=E(c)}}let a={type:"command",name:e.action,args:t};return Object.keys(n).length>0?{...a,modifiers:n}:a}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,i;if(t?.type==="literal"){let g=String(t.value);g.includes("|")||g.includes(" or ")?(i=g.split(/\s+or\s+|\|/).map(k=>k.trim()),n=i[0]):n=g}else t?.type==="reference"?n=t.value:n="click";let o=e.body.map(g=>this.build(g)),a=e.roles.get("source"),s,c;a?.type==="selector"?(s=a.value,c=a.value):a?.type==="reference"?c=a.value:a?.type==="literal"&&(c=String(a.value));let l=e.roles.get("condition"),m=l?E(l):void 0,S=e.roles.get("destination"),y=S?E(S):void 0,h=e.eventModifiers,p=s;if(h?.from){let g=h.from;g.type==="selector"&&!s&&(p=g.value)}let d=e.parameterNames?[...e.parameterNames]:void 0;return{type:"eventHandler",event:n,commands:o,...i&&i.length>1?{events:i}:{},...p?{selector:p}:{},...c?{target:c}:{},...m?{condition:m}:{},...y?{watchTarget:y}:{},...d&&d.length>0?{args:d,params:d}:{}}}buildConditional(e){let t=e.roles.get("condition");if(!t)throw new Error("Conditional node missing condition");let n=E(t),i=e.thenBranch.map(s=>this.build(s)),o=e.elseBranch?.map(s=>this.build(s)),a=[n,{type:"block",commands:i}];return o&&o.length>0&&a.push({type:"block",commands:o}),{type:"command",name:"if",args:a}}buildCompound(e){let t=e.statements.map(i=>this.build(i));return t.length===1?t[0]:t.length===0?{type:"block",commands:[]}:{type:"CommandSequence",commands:t}}buildLoop(e){let t=e.body.map(i=>this.build(i)),n=[{type:"identifier",name:e.loopVariant}];switch(e.loopVariant){case"times":{let i=e.roles.get("quantity");i&&n.push(E(i));break}case"for":{e.loopVariable&&n.push({type:"string",value:e.loopVariable});let i=e.roles.get("source");i&&n.push(E(i));break}case"while":case"until":{let i=e.roles.get("condition");i&&n.push(E(i));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 it(r){let e=new J;return{ast:e.build(r),warnings:e.warnings}}var K=class{constructor(e={}){this.cache=new Map,this.config={maxSize:e.maxSize??1e3,ttlMs:e.ttlMs??0,enabled:e.enabled??!0},this.stats={hits:0,misses:0,evictions:0,expirations:0}}makeKey(e,t){return`${t}:${e}`}isExpired(e){return this.config.ttlMs===0?!1:Date.now()-e.createdAt>this.config.ttlMs}evictLRU(){let e=this.cache.keys().next().value;e!==void 0&&(this.cache.delete(e),this.stats.evictions++)}get(e,t){if(!this.config.enabled){this.stats.misses++;return}let n=this.makeKey(e,t),i=this.cache.get(n);if(!i){this.stats.misses++;return}if(this.isExpired(i)){this.cache.delete(n),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(n),i.lastAccessed=Date.now(),this.cache.set(n,i),this.stats.hits++,i.result}set(e,t,n){if(!this.config.enabled||n.confidence===0)return;let i=this.makeKey(e,t),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:n,createdAt:o,lastAccessed:o})}has(e,t){if(!this.config.enabled)return!1;let n=this.makeKey(e,t),i=this.cache.get(n);return i?this.isExpired(i)?(this.cache.delete(n),this.stats.expirations++,!1):!0:!1}delete(e,t){let n=this.makeKey(e,t);return this.cache.delete(n)}clear(){this.cache.clear()}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0}}getStats(){let e=this.stats.hits+this.stats.misses;return{hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:e>0?this.stats.hits/e:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(e){if(e.maxSize!==void 0)for(this.config.maxSize=e.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();e.ttlMs!==void 0&&(this.config.ttlMs=e.ttlMs),e.enabled!==void 0&&(this.config.enabled=e.enabled)}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1}getConfig(){return{...this.config}}},Me=new K;var ee=class{constructor(e={}){this.patternMatcher=new X,this.languages=new Set(ne()),e.cache===!1?this.cache=new K({enabled:!1}):this.cache=e.cache?new K(e.cache):Me}analyze(e,t){if(!this.supportsLanguage(t))return{confidence:0,errors:[`Language '${t}' is not supported for semantic parsing`]};let n=this.cache.get(e,t);if(n)return n;let i=this.analyzeUncached(e,t);return this.cache.set(e,t,i),i}analyzeUncached(e,t){try{let n=Ye(t);if(!n)return{confidence:0,errors:[`No tokenizer available for language '${t}'`]};let i=n.tokenize(e),o=L(t);if(o.length===0)return{confidence:0,errors:[`No patterns available for language '${t}'`]};let a=this.patternMatcher.matchBest(i,o);if(!a)return{confidence:0,errors:["No pattern matched the input"]};let s=this.buildSemanticNode(a);return{confidence:a.confidence,command:{name:a.pattern.command,roles:a.captured},node:s,tokensConsumed:a.consumedTokens}}catch(n){return{confidence:0,errors:[n instanceof Error?n.message:String(n)]}}}supportsLanguage(e){return this.languages.has(e)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear()}configureCache(e){this.cache.configure(e)}buildSemanticNode(e){return{kind:"command",action:e.pattern.command,roles:e.captured,metadata:{patternId:e.pattern.id}}}};function ot(r){return new ee(r)}var Ae=.5,at=.8;function st(r,e=Ae){return r.confidence>=e&&r.command!==void 0}var Rn="1.0.0-tr",zn=["tr"];function Mn(){return[...zn]}function ct(r){if(r!=="tr")throw new Error(`Language not supported in this bundle: ${r}. Supported: tr`)}function An(r,e){return ct(e),[...ce(r,e).tokens]}function lt(r){return ct(r),L(r)}function jn(r,e){return lt(r).filter(t=>t.command===e).sort((t,n)=>n.priority-t.priority)}return gt(Vn);})();