@hyperscript-tools/multilingual 2.7.2 → 2.8.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 (31) hide show
  1. package/dist/hyperscript-i18n-ar.global.js +5 -5
  2. package/dist/hyperscript-i18n-bn.global.js +5 -5
  3. package/dist/hyperscript-i18n-de.global.js +5 -5
  4. package/dist/hyperscript-i18n-east-asian.global.js +5 -5
  5. package/dist/hyperscript-i18n-en.global.js +7 -7
  6. package/dist/hyperscript-i18n-es.global.js +5 -5
  7. package/dist/hyperscript-i18n-fr.global.js +5 -5
  8. package/dist/hyperscript-i18n-he.global.js +5 -5
  9. package/dist/hyperscript-i18n-hi.global.js +5 -5
  10. package/dist/hyperscript-i18n-id.global.js +5 -5
  11. package/dist/hyperscript-i18n-it.global.js +5 -5
  12. package/dist/hyperscript-i18n-ja.global.js +5 -5
  13. package/dist/hyperscript-i18n-ko.global.js +5 -5
  14. package/dist/hyperscript-i18n-ms.global.js +5 -5
  15. package/dist/hyperscript-i18n-pl.global.js +5 -5
  16. package/dist/hyperscript-i18n-pt.global.js +5 -5
  17. package/dist/hyperscript-i18n-qu.global.js +5 -5
  18. package/dist/hyperscript-i18n-ru.global.js +5 -5
  19. package/dist/hyperscript-i18n-slavic.global.js +5 -5
  20. package/dist/hyperscript-i18n-south-asian.global.js +5 -5
  21. package/dist/hyperscript-i18n-southeast-asian.global.js +5 -5
  22. package/dist/hyperscript-i18n-sw.global.js +5 -5
  23. package/dist/hyperscript-i18n-th.global.js +5 -5
  24. package/dist/hyperscript-i18n-tl.global.js +5 -5
  25. package/dist/hyperscript-i18n-tr.global.js +5 -5
  26. package/dist/hyperscript-i18n-uk.global.js +5 -5
  27. package/dist/hyperscript-i18n-vi.global.js +5 -5
  28. package/dist/hyperscript-i18n-western.global.js +5 -5
  29. package/dist/hyperscript-i18n-zh.global.js +5 -5
  30. package/dist/hyperscript-i18n.global.js +28 -27
  31. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function re(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function Me(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Be(i){return {type:"reference",value:i}}function _e(i,e){return {type:"property-path",object:i,property:e}}var lr=new Set(["me","you","it","result","event","target","body"]);function He(i,e=lr){return e.has(i)}var pt=class{constructor(i){this.namespace=i,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let i=process.env.DEBUG||"";return i==="*"||i.includes("framework:*")||i.includes(`framework:${this.namespace}`)}return false}log(i,e,...r){if(!this.enabled)return;let t=`[framework:${this.namespace}]`,n=new Date().toISOString();switch(i){case "debug":console.debug(`${n} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${t} WARN:`,e,...r);break;case "error":console.error(`${n} ${t} ERROR:`,e,...r);break}}debug(i,...e){this.log("debug",i,...e);}info(i,...e){this.log("info",i,...e);}warn(i,...e){this.log("warn",i,...e);}error(i,...e){this.log("error",i,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function dt(i){return new pt(i)}function ke(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ft(i,e){return i?.possessive?.keywords?.[e]}var Le=class be{constructor(){this.logger=dt("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,t){let n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let m=e.peek(l);if(m)s.push({type:m.type,value:m.value,kind:m.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",t?.code);}this.currentProfile=t,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:u}}matchBest(e,r,t){let n=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&n.push(s),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let m=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(m,null,2));let c=e.peek();if(this.logger.debug(" >> Current input token:",c?JSON.stringify({type:c.type,value:c.value,kind:c.kind}):"EOF"),m.type==="role"&&m.greedy){let h=this.collectStopMarkers(r,l+1);if(n)for(let b of n)h.add(b);let E=[];for(;!e.isAtEnd();){let b=e.peek();if(!b||this.isStopMarker(b,h))break;E.push(b.value),e.advance();}if(E.length>0){t.set(m.role,{type:"expression",raw:E.join(" ")}),u=null,s=null;continue}else {if(m.optional)continue;return false}}if(m.type==="group"){let h=this.collectStopMarkers(r,l+1);if(n)for(let b of n)h.add(b);if(this.matchGroupToken(e,m,t,h)){u=null,s=null;continue}if(this.isOptional(m))continue;return false}let p=m.type==="role"&&m.optional===true,d=p?e.mark():null;if(m.type==="role"&&!p){let h=l+1<r.length?r[l+1]:null;if(h?.type==="literal"){let E=e.peek();if(E&&this.getMatchType(E,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(m))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let b=this.matchPatternToken(e,m,t);if(this.logger.debug(" >> Backtrack retry result:",b),b)continue}return false}}}let y=this.matchPatternToken(e,m,t);if(this.logger.debug(" >> Match result:",y),y){p?(u=d,s=m.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(m)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let h=this.matchPatternToken(e,m,t);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let n=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(t,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(a.type,r.expectedTypes)?r.optional||false:(t.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(s.type,r.expectedTypes)?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let m=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",m?JSON.stringify(m):"null"),m?(this.logger.debug(" >>> Validating type:",m.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!ke(m.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),t.set(r.role,m),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=r.normalized||r.value,n=this.safeToLowerCase(t),a=ft(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let m=e.peek();return m?.kind==="literal"&&m.value.startsWith("(")&&(l+=m.value,e.advance()),_e(Be(a),l)}return 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 r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<be.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}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${a.value}`,u=1;for(;!e.isAtEnd()&&u<be.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(),o+=`.${m.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],m=0;for(;!e.isAtEnd()&&l.length<be.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(m===0){e.advance();break}m--;}if(p.kind==="punctuation"&&p.value==="("&&m++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(t),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(t),null):(e.advance(),_e(Me(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(t),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return _e(Me(r.value),o)}matchGroupToken(e,r,t,n){let a=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,n))return true;e.reset(a);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=be.MAX_MARKER_SCAN;l++){let m=e.peek(l);if(!m)break;if((m.normalized||m.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,t,n))return true;e.reset(a);for(let d of t.keys())o.has(d)||t.delete(d);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let t=new Set;for(let n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(t.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)t.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!a.optional)break}}return t}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return Me(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return re(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Be(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return re(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return re(n,"string")}if(e==="true")return re(true,"boolean");if(e==="false")return re(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?re(e,"duration"):re(n,"number")}let t=parseFloat(e);return isNaN(t)?re(e,"string"):re(t,"number")}applyExtractionRules(e,r){for(let[t,n]of Object.entries(e.extraction))r.has(t)||(n.value!==void 0?r.set(t,{type:"literal",value:n.value}):n.default&&r.set(t,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let m of l.tokens)if(m.type==="role"){let c=a(m.role),p=.8;n+=p,r.has(m.role)?t+=p:c&&(t+=p*.6);}}let o=n>0?t/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let t=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(t.has(r.value))return .15;if(r.alternatives){for(let n of r.alternatives)if(t.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,n={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[a,o]of r.entries()){let u=n[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if(be.ENGLISH_NOISE_WORDS.has(t)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(t=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return t?r:void 0}};Le.MAX_MARKER_SCAN=3;Le.MAX_PROPERTY_DEPTH=10;Le.MAX_METHOD_ARGS=20;Le.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var yt=Le;new yt;var pr=class{constructor(){this.name="string-literal";}canExtract(i,e){let r=i[e];return r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(i,e){let r=i[e];if(r==="\u201C"){let a=1;for(;e+a<i.length;){if(i[e+a]==="\u201D")return a++,{value:i.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<i.length;){if(i[e+a]==="\u2019")return a++,{value:i.substring(e,e+a),length:a};a++;}return null}let t=1,n=false;for(;e+t<i.length;){let a=i[e+t];if(n){n=false,t++;continue}if(a==="\\"){n=true,t++;continue}if(a===r)return t++,{value:i.substring(e,e+t),length:t};t++;}return null}},dr=class{constructor(){this.name="number";}canExtract(i,e){return /\d/.test(i[e])}extract(i,e){let r=0,t=false;for(;e+r<i.length;){let o=i[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let n=i.substring(e,e+r),a=e+r;if(a<i.length){let o=i.slice(a),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function ht(i){return "setContext"in i&&typeof i.setContext=="function"}function vt(i){let e={language:i.language,direction:i.direction,lookupKeyword:i.lookupKeyword.bind(i),isKeyword:i.isKeyword.bind(i),isKeywordStart:i.isKeywordStart.bind(i),...i.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:i.isKeywordStartAtBoundary.bind(i)}:{}};return i.normalizer?{...e,normalizer:i.normalizer}:e}var te=class{constructor(i,e){this.pos=0,this.tokens=i,this.language=e;}peek(i=0){let e=this.pos+i;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(i){this.pos=i.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(i){let e=[];for(;!this.isAtEnd()&&i(this.peek());)e.push(this.advance());return e}skipWhile(i){for(;!this.isAtEnd()&&i(this.peek());)this.advance();}};function I(i,e){return {start:i,end:e}}function j(i,e,r,t){if(typeof i=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:m,metadata:c}=i;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...m!==void 0&&{stemConfidence:m},...c!==void 0&&{metadata:c}}}let n=i;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:n,kind:e,position:r,normalized:t};if(t){let{normalized:a,stem:o,stemConfidence:u,metadata:s}=t;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function Fe(i){return /\s/.test(i)}function gt(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function Et(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function pe(i){return /\d/.test(i)}function zt(i){return /[a-zA-Z]/.test(i)}function W(i){return /[a-zA-Z0-9_-]/.test(i)}function kt(i,e){if(e>=i.length)return null;let r=i[e];if(!gt(r))return null;let t=e,n="";if(r==="#"||r==="."){for(n+=i[t++];t<i.length&&W(i[t]);)n+=i[t++];if(n.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let o=t+1;for(;o<i.length&&W(i[o]);)o++;if(o<i.length&&i[o]==="(")return n}}else if(r==="["){let a=1,o=false,u=null,s=false;for(n+=i[t++];t<i.length&&a>0;){let l=i[t];n+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,t++;}if(a!==0)return null}else if(r==="@"){for(n+=i[t++];t<i.length&&W(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="*"){for(n+=i[t++];t<i.length&&W(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="<"){if(n+=i[t++],t>=i.length||!zt(i[t]))return null;for(;t<i.length&&W(i[t]);)n+=i[t++];for(;t<i.length;){let a=i[t];if(a==="."){if(n+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)n+=i[t++];}else if(a==="#"){if(n+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)n+=i[t++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(n+=i[t++];t<i.length&&o>0;){let m=i[t];n+=m,l?l=false:m==="\\"?l=true:u?m===s&&(u=false,s=null):m==='"'||m==="'"||m==="`"?(u=true,s=m):m==="["?o++:m==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<i.length&&Fe(i[t]);)n+=i[t++];if(t<i.length&&i[t]==="/")for(n+=i[t++];t<i.length&&Fe(i[t]);)n+=i[t++];if(t>=i.length||i[t]!==">")return null;n+=i[t++];}return n||null}function bt(i,e){if(e>=i.length||i[e]!=="'"||e+1>=i.length||i[e+1].toLowerCase()!=="s")return false;if(e+2>=i.length)return true;let t=i[e+2];return Fe(t)||t==="*"||!W(t)}function wt(i,e){if(e>=i.length)return null;let r=i[e];if(!Et(r)||r==="'"&&bt(i,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,u=false;for(;a<i.length;){let s=i[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===n)return o;a++;}return o}function Ct(i,e){if(e>=i.length)return false;let r=i[e],t=i[e+1]||"",n=i[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(t==="/"||t==="."&&n==="/"))return true;let a=i.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function At(i,e){if(!Ct(i,e))return null;let r=e,t="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<i.length;){let a=i[r];if(a==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=a,r++;r<i.length&&/[a-zA-Z0-9_-]/.test(i[r]);)t+=i[r++];break}if(n.test(a))t+=a,r++;else break}return t.length<2?null:t}function St(i,e){if(e>=i.length)return null;let r=i[e];if(!pe(r)&&r!=="-"&&r!=="+")return null;let t=e,n="";if((i[t]==="-"||i[t]==="+")&&(n+=i[t++]),t>=i.length||!pe(i[t]))return null;for(;t<i.length&&pe(i[t]);)n+=i[t++];if(t<i.length&&i[t]===".")for(n+=i[t++];t<i.length&&pe(i[t]);)n+=i[t++];return t<i.length&&(i.slice(t,t+2)==="ms"?n+="ms":(i[t]==="s"||i[t]==="m"||i[t]==="h")&&(n+=i[t])),n}var Dt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Dt);var xt=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]),Tt=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],fr=class yr{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[];}getExtraKeywordEntries(){return this.rawExtraEntries}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){ht(e)&&e.setContext(vt(this)),this.extractors.push(e);}registerExtractors(e){for(let r of e)this.registerExtractor(r);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let r=[],t=0;for(;t<e.length;){for(;t<e.length&&Fe(e[t]);)t++;if(t>=e.length)break;let n=this.tryMultiWordKeyword(e,t);if(n){r.push(n),t=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,t)){let u=o.extract(e,t);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,m=u.metadata?.stemConfidence,c={};if(u.metadata)for(let[d,f]of Object.entries(u.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(c[d]=f);let p={};s&&(p.normalized=s),l&&(p.stem=l),m!==void 0&&(p.stemConfidence=m),Object.keys(c).length>0&&(p.metadata=c),r.push(j(u.value,this.classifyToken(u.value),I(t,t+u.length),Object.keys(p).length>0?p:void 0)),t+=u.length,a=true;break}}if(!a){let o=e[t],u=this.classifyUnknownChar(o);r.push(j(o,u,I(t,t+1))),t++;}}return new te(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let n=t[t.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return t.push(j(".","operator",I(r,r+1))),true;let s=r+1;for(;s<e.length&&W(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(j(".","operator",I(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[n,a]of Object.entries(e.keywords))if(t.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)t.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))t.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))t.has(n)||t.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&t.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)t.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))t.set(n,{native:n,normalized:a});for(let n of Tt)t.has(n)||t.set(n,{native:n,normalized:n});for(let n of r)t.set(n.native,n);this.profileKeywords=Array.from(t.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>n.native.includes(" ")&&!xt.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let t of this.profileKeywords)if(e.slice(r).startsWith(t.native))return j(t.native,"keyword",I(r,r+t.native.length),t.normalized);return null}tryMultiWordKeyword(e,r,t=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&t(o)))return j(a.native,"keyword",I(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(n=>t.startsWith(n.native))}isKeywordStartAtBoundary(e,r,t=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!t(o)})}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 r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,t){let n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return j(e,"keyword",I(r,t),o)}trySelector(e,r){let t=kt(e,r);return t?j(t,"selector",I(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let n=t[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=t[1];return {...j(n,"event-modifier",I(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=wt(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryNumber(e,r){let t=St(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,n=false){let a=r;if(n)for(;a<e.length&&Fe(e[a]);)a++;let o=e.slice(a);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let m=o[u.length]||"";if(W(m))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,t=true){let n=r,a="";if(t&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!pe(e[n]))return null;for(;n<e.length&&pe(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&pe(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,t,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,m=[...t,...yr.STANDARD_TIME_UNITS],c=this.tryMatchTimeUnit(e,l,m,o);return c&&(s+=c.suffix,l=c.endPos),j(s,"literal",I(r,l))}tryUrl(e,r){let t=At(e,r);return t?j(t,"url",I(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!W(e[r+1]))return null;let t=r+1;for(;t<e.length&&W(e[t]);)t++;let n=e.slice(r,t);return j(n,"identifier",I(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return j(t,"operator",I(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?j(n,"operator",I(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?j(n,"punctuation",I(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let n of t)if(e.slice(r,r+n.length)===n)return j(n,"particle",I(r,r+n.length));return null}};fr.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var hr=fr;function vr(i){return {stem:i,confidence:1}}function Ge(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var Bt=Object.defineProperty,Ft=Object.getOwnPropertyNames,Fr=(i,e)=>function(){return i&&(e=(0, i[Ft(i)[0]])(i=0)),e},Lt=(i,e)=>{for(var r in e)Bt(i,r,{get:e[r],enumerable:true});};function gr(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function G(i,e,r={},t){let n=Lr[i],a=gr(n,r),o=Or[i],u=o?gr(o,r):void 0;return {code:i,message:a,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var x,Lr,Or,Ot=Fr({"src/generators/schema-error-codes.ts"(){x={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Lr={[x.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[x.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[x.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[x.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[x.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[x.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[x.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[x.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[x.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[x.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[x.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[x.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[x.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[x.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[x.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[x.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Or={[x.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[x.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[x.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[x.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[x.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[x.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[x.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[x.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[x.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[x.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[x.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[x.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[x.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Rr={};Lt(Rr,{SchemaErrorCodes:()=>x,formatValidationResults:()=>jt,getValidationStats:()=>Vt,validateAllKeywordCollisions:()=>qt,validateAllSchemas:()=>It,validateCommandSchema:()=>Pr,validateKeywordCollisions:()=>Nr,validateRoleValues:()=>$t});function Rt(i,e){return {action:i,items:e}}function Pr(i){let e=[];for(let t of i.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&Ze.has(i.action)?e.push(G(x.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(G(x.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!Ze.has(i.action)&&e.push(G(x.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of i.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(G(x.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":Pt(i,e);break;case "on":Nt(i,e);break;case "if":case "unless":Mt(i,e);break;case "repeat":case "for":case "while":_t(i,e);break}return i.roles.filter(t=>t.required).length===0&&(Mr.has(i.action)?e.push(G(x.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(G(x.NO_REQUIRED_ROLES,"warning",{}))),Rt(i.action,e)}function Pt(i,e){let r=i.roles.find(n=>n.role==="patient"),t=i.roles.find(n=>n.role==="goal");r&&!t&&e.push(G(x.TRANSITION_MISSING_GOAL,"error",{}));}function Nt(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(G(x.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(G(x.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Mt(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(G(x.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(G(x.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function _t(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(G(x.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(G(x.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function It(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[n,a]of Object.entries(i)){let o=Pr(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(n,o);}return r}function jt(i,e={}){let r=[],{showNotes:t=false,showCodes:n=true}=e;for(let[a,o]of i){let u=o.items.filter(m=>m.severity==="error"),s=o.items.filter(m=>m.severity==="warning"),l=o.items.filter(m=>m.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let m of u){let c=n?` [${m.code}]`:"";r.push(` ERROR${c}: ${m.message}`),m.suggestion&&r.push(` \u{1F4A1} Suggestion: ${m.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let m of s){let c=n?` [${m.code}]`:"";r.push(` ${c?`${m.code}: `:""}${m.message}`),m.suggestion&&r.push(` \u{1F4A1} ${m.suggestion}`);}}if(t&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let m of l){let c=n?` [${m.code}]`:"";r.push(` ${c?`${m.code}: `:""}${m.message}`);}}}return r.join(`
2
- `)}function Vt(i){let e=0,r=0,t=0,n={};for(let a of i.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:n}}function $t(i,e){let r=[];for(let t of e){let n=i.roles.find(a=>a.role===t.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(t.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects type [${n.expectedTypes.join(", ")}], got '${t.type}'`,code:x.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:x.SELECTOR_KIND_MISMATCH})));}return r}function Nr(i){let e=[];if(!i.keywords)return {language:i.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(i.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let u of a.alternatives){let s=r.get(u)||[];s.push({command:n,isPrimary:false}),r.set(u,s);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1)continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>t[n.type]-t[a.type]),{language:i.code,collisions:e}}function qt(i){let e=[];for(let[,r]of Object.entries(i)){let t=Nr(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var Ze,Mr,Wt=Fr({"src/generators/schema-validator.ts"(){Ot(),Ze=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Mr=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint"]);}});var ye=new Map,oe=new Map,Re=new Map,Xe=null;function _r(i,e){let r={...i};for(let t of Object.keys(e)){let n=e[t],a=i[t];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[t]=_r(a,n):r[t]=n);}return r}function Kt(i,e){return _r(i,e)}function rr(i){if(!i.extends)return i;let e=oe.get(i.extends);if(!e)return console.warn(`[Registry] Profile '${i.code}' extends '${i.extends}' but base is not registered. Make sure to import the base language before the variant.`),i;let r=rr(e);return Kt(r,i)}function Ir(i,e,r){ye.set(i,e),oe.set(i,r),Re.delete(i);}function jr(i){Xe=i;}var Er=new Map;function De(i){return i.split("-")[0]}function xe(i){return i.includes("-")}function Ut(i){let e=ye.get(i);if(!e&&xe(i)){let r=De(i);e=ye.get(r);}if(!e){let r=Array.from(ye.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return e}function Ht(i){let e=oe.get(i);if(!e&&xe(i)){let r=De(i);e=oe.get(r);}if(!e){let r=Array.from(oe.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return rr(e)}function N(i){let e=oe.get(i);return !e&&xe(i)&&(e=oe.get(De(i))),e?rr(e):void 0}function Gt(){return Array.from(ye.keys())}function Vr(i){if(ye.has(i)&&oe.has(i))return true;if(xe(i)){let e=De(i);return ye.has(e)&&oe.has(e)}return false}function Yt(i,e){return Ut(e).tokenize(i)}function ae(i){let e=Re.get(i);if(!e&&xe(i)&&(e=Re.get(De(i))),e)return e;let r=Er.get(i);if(!r&&xe(i)&&(r=Er.get(De(i))),r)return Re.set(i,r),r;if(!Xe)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let t=Ht(i),n=Xe(t);return Re.set(i,n),n}function fe(i){let e="complex";return i.startsWith("#")&&!i.includes(" ")?e="id":i.startsWith(".")&&!i.includes(" ")?e="class":i.startsWith("[")&&i.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(e="element"),{type:"selector",value:i,selectorKind:e}}function _(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function we(i){return He(i)}function ie(i){return {type:"reference",value:i}}function de(i,e){return {type:"property-path",object:i,property:e}}function Z(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Oe(i,e,r,t,n,a){let o=new Map;o.set("event",i);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),n!==void 0&&n.length>0&&(u.parameterNames=n),u}function ki(i,e,r,t,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:i,parameters:e,eventHandlers:r};return t!==void 0&&t.length>0&&(a.initBlock=t),n!==void 0&&(a.metadata=n),a}function bi(i,e,r,t){let n={kind:"def",action:"def",roles:new Map,name:i,parameters:e,body:r};return t!==void 0&&(n.metadata=t),n}function Je(i,e="then",r){let t={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:e};return r!==void 0&&(t.metadata=r),t}function wi(i,e,r,t){let n=new Map;n.set("condition",i);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),t!==void 0&&(a.metadata=t),a}function Ie(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):i==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ve(i){let e=i.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function ge(i){let e=i.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Ee(i,e){return $r(i,e,"source")}function tr(i,e){return $r(i,e,"destination")}function $r(i,e,r){if(!e||!i.roles.some(a=>a.role===r))return [];let t=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,t]:[t,n]}]}var Ci={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},Ai={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},Si={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},Di={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"},markerVariants:{en:["before","after"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},xi={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},Ti={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Bi={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fi={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Li={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oi={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ri={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Pi={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Ni={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Mi={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},_i={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Ii={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},ji={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},Vi={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},$i={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},qi={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Wi={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Ki={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Ui={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},Hi={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Gi={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Yi={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Zi={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Xi={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Ji={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},Qi={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},en={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},rn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},tn={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},nn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},an={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},on={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},un={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""},markerOptional:{en:true},markerVariants:{he:["\u05D0\u05EA"],zh:["\u628A"]}}]},sn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},ln={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},cn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},mn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},pn={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},dn={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},fn={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},yn={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},hn={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},vn={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},gn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},En={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},zn={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},kn={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},bn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},wn={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},Cn={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},An={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Sn={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Dn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},xn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Tn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528"}}]},Bn={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Fn={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Ln={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},On={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Rn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Pn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Nn={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},qr={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},Mn={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},_n={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:qr}]},In={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:qr}]},jn={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Mn}]},Vn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},he={toggle:Ci,add:Ai,remove:Si,put:Di,set:xi,show:Pi,hide:Ni,on:Mi,trigger:_i,wait:Ii,fetch:ji,increment:Vi,decrement:$i,append:qi,prepend:Wi,log:Ki,get:Ui,take:Hi,make:Gi,halt:Yi,settle:Zi,throw:Xi,send:Ji,if:Qi,unless:en,else:rn,repeat:tn,for:nn,while:an,continue:on,go:un,scroll:Nn,push:_n,replace:In,process:jn,transition:sn,clone:ln,focus:cn,blur:mn,empty:pn,open:dn,close:fn,select:yn,clear:hn,reset:vn,breakpoint:gn,call:En,return:zn,js:kn,async:bn,tell:wn,default:Cn,init:An,behavior:Sn,install:Dn,measure:xn,swap:Tn,morph:Bn,beep:Fn,break:Ln,copy:On,exit:Rn,pick:Pn,render:Vn,bind:Ti,live:Bi,eventsource:Fi,socket:Li,worker:Oi,intercept:Ri,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function le(i){return he[i]}function $n(){return Object.values(he).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Wt(),Rr)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(he);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(i=>{console.debug("Schema validation skipped:",i);});function se(i,e){let r=i.possessive?.keywords?.[e];if(r)return r;let t=i.possessive?.specialForms;if(t){for(let[n,a]of Object.entries(t))if(a===e)return n}}var Wr=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function zr(i,e,r,t){let n=Wr.find(o=>o.lang===i);if(!n)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(t,n.of)}function qn(i,e){let r=Wr.find(n=>n.lang===i);if(!r)return false;let t=e.toLowerCase();return t===r.at.toLowerCase()||t===r.of.toLowerCase()||t===r.end.toLowerCase()}var Ye=.8,Wn=.6,Kn=.15,Un=.5,kr=.15,br=.1,wr=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"]),Hn={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"]},Gn=class{calculate(i){return this.calculateWithBreakdown(i).final}calculateWithBreakdown(i){let e=this.scoreRoleCoverage(i),r=this.scoreStemPenalty(i),t=this.scoreLanguageBoost(i),n=this.scoreLanguageAdjustment(i),a=e;return a=Math.max(Un,a+r),a=Math.min(1,a+t),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:n,final:a}}scoreRoleCoverage(i){let{pattern:e,captured:r}=i,t=0,n=0,a=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")n+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(n+=Ye,r.has(u.role)?t+=Ye:a(u.role)&&(t+=Ye*Wn));return n>0?t/n:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*Kn}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:wr.has(r.value)||r.alternatives?.some(t=>wr.has(t))?kr:0}scoreLanguageAdjustment(i){let{pattern:e,captured:r}=i;if(e.language!=="ar")return 0;let t=0;for(let[n,a]of r.entries()){let o=Hn[n];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-br,Math.min(br,t))}},Yn=new Gn,Zn=new Set(Object.values(he).filter(i=>i.bareKeyword===true).map(i=>i.action)),U=class R{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Yn;}matchPattern(e,r){let t=e.mark(),n=new Map;if(this.currentProfile=N(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,n))return e.reset(t),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-t.position,confidence:o}}matchBest(e,r){this.matchCache.clear();let t=[],n=e.position();for(let o of r){let u=e.mark(),s=`${n}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let a=t[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let m=this.matchPatternToken(e,l,t,r[s+1]??n);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!m){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,t){if(r.has("source"))return;let n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(t,n))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let m=l.value.toLowerCase();return o.primary?.toLowerCase()===m?true:!!o.alternatives?.some(c=>c.toLowerCase()===m)},s=o?.position;if(s!=="after"&&u(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&u(a)){let l=this.tokenToSemanticValue(n);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,t,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t,n);case "group":return this.matchGroupToken(e,r,t,n);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let n=this.getMatchType(t,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(t,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(t),null;let a=n.join("").toLowerCase();for(let[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.toLowerCase()===a))return _(o);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let n=r.split(t);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==t)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,t,n){this.skipNoiseWords(e);let a=e.peek();if(!a)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let E=this.tryFoldHyphenActionKeyword(e);if(E)return t.set(r.role,E),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!R.tokenLooksLikeEvent(a))return r.optional||false;let E=(a.normalized??a.value).toLowerCase();if(R.POSITIONAL_OR_SCOPE_KEYWORDS.has(E)||this.currentProfile&&(se(this.currentProfile,a.value)??se(this.currentProfile,E))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let E=(a.normalized??a.value).toLowerCase();if(R.STRUCTURAL_NEVER_EVENT.has(E))return r.optional||false}if(r.role==="duration"){let E=(a.normalized??a.value).toLowerCase();if(R.POSITIONAL_OR_SCOPE_KEYWORDS.has(E))return r.optional||false}if(r.optional&&n===void 0&&r.role!=="event"&&r.role!=="action"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in he)return true;let o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let E=this.tryMatchOperatorRunExpression(e);if(E)return t.set(r.role,E),true}if(r.expectedTypes?.includes("property-path")){let E=this.tryMatchOfPossessiveExpression(e);if(E)return t.set(r.role,E),true;let b=this.tryMatchPostNominalPossessiveExpression(e);if(b)return t.set(r.role,b),true}let s=this.tryMatchPossessiveExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchMethodCallExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,l),true);let c=r.role==="event"&&this.currentPatternCommand==="on"||R.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(c)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,c),true);let p=this.tryMatchPossessiveSelectorExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(p.type,r.expectedTypes)?r.optional||false:(t.set(r.role,p),true);let d=r.role!=="condition",f=this.tryMatchPropertyAccessExpression(e,d);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(f.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,f),true);let y=this.tryMatchSelectorPropertyExpression(e);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!Ie(y.type,r.expectedTypes)?r.optional||false:(t.set(r.role,y),true);if(a.kind==="identifier"&&a.value==="{"&&(!r.expectedTypes?.length||r.expectedTypes.includes("literal"))){let E=this.tryMatchBraceRunLiteral(e);if(E)return t.set(r.role,E),true}let h=this.tokenToSemanticValue(a);if(!h)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(h.type)){let E=h.type==="selector"&&String(h.value).startsWith("@"),b=r.expectedTypes.some(C=>C==="expression"||C==="reference");if(!(E&&b))return r.optional||false}if(t.set(r.role,h),e.advance(),r.role==="event"){let E=e.peek();E&&E.kind==="selector"&&E.value.startsWith("[")&&"value"in h&&(t.set(r.role,_(`${String(h.value)}${E.value}`)),e.advance());let b=e.peek();if(b&&(b.kind==="particle"||b.kind==="keyword")&&(b.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,b)){let C=e.peek(1);if(C&&(C.kind==="selector"||C.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!t.has("source")&&t.set("source",A);}}}return true}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(t=>this.getMatchType(r,t)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e){let r=e.peek();if(!r)return null;let t=(r.normalized??r.value).toLowerCase();if(!R.POSITIONAL_KEYWORDS.has(t)&&!R.POSITIONAL_KEYWORDS.has(r.value.toLowerCase()))return null;let n=e.mark(),a=[r.normalized??r.value];e.advance();let o=e.peek();if(!o||o.kind!=="selector")return e.reset(n),null;a.push(o.value),e.advance();let u=0;for(;u++<8;){let m=e.peek();if(m&&m.kind==="selector"&&m.value.startsWith("."))a.push(m.value),e.advance();else break}let s=e.peek(),l=e.peek(1);return s&&l&&l.kind==="selector"&&(s.kind==="keyword"||s.kind==="particle"||s.kind==="identifier")&&!R.POSITIONAL_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&!R.COMMAND_ACTION_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&(a.push(s.normalized??s.value,l.value),e.advance(),e.advance()),{type:"expression",raw:a.join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let t=e.peek(1),n=e.peek(2),a=(t?.normalized??"").toLowerCase(),o=!!t&&(t.value.toLowerCase()==="on"||a==="destination"||a==="on");return !t||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){let r=e.value.toLowerCase(),t=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||t==="of"||t==="source")return true;let n=this.currentProfile?.code?R.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return !!n&&n.has(r)}tryMatchOperatorRunExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let n=1;for(;;){let o=e.peek();if(!o||!R.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}n++;}if(n<2)return e.reset(r),null;let a=e.tokens.slice(t,e.position()).map(o=>o.value).join(" ");return {type:"expression",raw:a,value:a}}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let t=e.mark(),n=0;for(;!e.isAtEnd();){let a=e.advance();if(a.value==="(")n++;else if(a.value===")"&&(n--,n===0))return true}return e.reset(t),false}return this.tryMatchPossessiveExpression(e)?true:(r.kind==="literal"||r.kind==="identifier"||r.kind==="selector"||r.kind==="keyword")&&!R.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||!this.isOfPossessiveMarker(n))return e.reset(t),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"?(e.reset(t),null):(e.advance(),de(fe(a.value),r.value))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=[r.value,r.normalized].filter(Boolean),n;for(let s of t)if(n=se(this.currentProfile,s)??se(this.currentProfile,s.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),m=(s.normalized??"").toLowerCase();o.some(c=>c.toLowerCase()===l||c.toLowerCase()===m)&&e.advance();}}let u=e.peek();if(!u||qn(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let m=e.peek();if(m&&m.value.startsWith("(")){let c="",p=0,d=0;for(;!e.isAtEnd()&&d++<R.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;c+=f.value,e.advance();for(let y of f.value)y==="("?p++:y===")"&&p--;if(p<=0)break}l+=c;}return de(ie(n),l)}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=c=>{for(let p of [c.value,c.normalized].filter(Boolean))if(se(this.currentProfile,p)??se(this.currentProfile,p.toLowerCase()))return true;return false},t=e.peek();if(!t)return null;let n=t.kind==="selector"&&t.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(t.value);if(!(t.kind==="identifier"&&!this.isStructuralKeyword(t.value)&&!(t.normalized&&this.isStructuralKeyword(t.normalized))&&!(t.normalized&&this.isRoleMarkerConcept(t.normalized))||t.kind==="selector"&&(t.value.startsWith("*")||t.value.startsWith("@"))||n)||r(t))return null;let o=e.mark(),u=t.value;n&&(u=u.substring(1)),e.advance();let s=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let l=e.peek();if(!l)return e.reset(o),null;let m;for(let c of [l.value,l.normalized].filter(Boolean))if(m=se(this.currentProfile,c)??se(this.currentProfile,c.toLowerCase()),m)break;return m?(e.advance(),de(ie(m),s)):(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())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let t=e.normalized?.toLowerCase();return !(t&&Zn.has(t))}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let t=e.mark();e.advance();let n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<R.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return n.push("}"),_(n.join(" "));n.push(u.value);}return e.reset(t),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let t=e.peek(1);if(!t||t.value!=="(")return null;let n=e.mark();e.advance(),e.advance();let a=[],o=false,u=0;for(;!e.isAtEnd()&&u++<R.MAX_METHOD_ARGS+2;){let s=e.peek();if(!s)break;if(s.value===")"){e.advance(),o=true;break}if(s.value===","){e.advance();continue}a.push(s.value),e.advance();}return o?{type:"expression",raw:`${r.value}(${a.join(", ")})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<R.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}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let a=t.value.toLowerCase(),o=e.peek();if((t.kind==="identifier"||R.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=t.value,f=[],y=0;for(;y<R.MAX_PROPERTY_DEPTH;){let b=e.peek();if(b&&b.kind==="selector"&&/^\.[a-zA-Z_]/.test(b.value))d+=`.${b.value.slice(1)}`,f.push(b.value.slice(1)),e.advance(),y++;else break}let h=e.peek(),E=!!h&&h.value.startsWith("(");if(r&&!E&&f.length>0&&we(a))return de(ie(a),f.join("."));if(E){let b=e.mark(),C=[],A=0,z=false;for(;!e.isAtEnd();){let g=e.peek();if(!g)break;if(g.value==="(")A++;else if(g.value===")"){if(C.push(g.value),e.advance(),A--,A===0&&(z=true),z)break;continue}C.push(g.value),e.advance();}z?d+=C.join(""):e.reset(b);}return {type:"expression",raw:d}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${t.value}.${s.value}`,m=1;for(;!e.isAtEnd()&&m<R.MAX_PROPERTY_DEPTH;){let d=e.peek();if(!d||d.kind!=="operator"||d.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,m++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let d=[],f=0;for(;!e.isAtEnd()&&d.length<R.MAX_METHOD_ARGS;){let h=e.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(f===0){e.advance();break}f--;}if(h.kind==="punctuation"&&h.value==="("&&f++,h.kind==="punctuation"&&h.value===","){e.advance();continue}d.push(h.value),e.advance();}return {type:"expression",raw:`${l}(${d.join(", ")})`}}let p=t.value.toLowerCase();if(r&&we(p)){let d=l.split(".").slice(1).join(".");return de(ie(p),d)}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",u=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let p=he[this.currentPatternCommand];return !!p&&p.roles.some(d=>d.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation")&&!s;if(!o&&!l&&!u)return e.reset(t),null;e.advance(),u&&e.advance();let m=e.peek();return !m||!(m.kind==="identifier"||(o||u)&&(m.kind==="selector"||m.kind==="keyword"))?(e.reset(t),null):(e.advance(),de(fe(r.value),m.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(t),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return de(fe(r.value),o)}matchGroupToken(e,r,t,n){let a=e.mark(),o=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,n)){e.reset(a);for(let s of t.keys())o.has(s)||t.delete(s);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return fe(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return we(r)?ie(r):_(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return fe(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ie(e.value);let t=e.value.toLowerCase();return we(t)?ie(t):{type:"expression",raw:e.value};case "url":return _(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return _(n,"string")}if(e==="true")return _(true,"boolean");if(e==="false")return _(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?_(e,"duration"):_(n,"number")}let t=parseFloat(e);return isNaN(t)?_(e,"string"):_(t,"number")}applyExtractionRules(e,r){for(let[t,n]of Object.entries(e.extraction))r.has(t)||(n.value!==void 0?r.set(t,{type:"literal",value:n.value}):n.default&&r.set(t,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=r.value.toLowerCase();if(R.ENGLISH_NOISE_WORDS.has(t)){let n=e.mark();e.advance();let a=e.peek();if(a&&(a.kind==="selector"||a.kind==="identifier"))return;let o=e.peek(1);if(a&&a.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let u=a?(a.normalized??a.value).toLowerCase():"";if(a&&R.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&R.COMMAND_ACTION_KEYWORDS.has(l),c=!s||s.kind==="particle"||R.CLAUSE_BOUNDARY_KEYWORDS.has(l)||m;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&we(u)&&c||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&we(u))return;e.reset(n);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(t=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return t?r:void 0}};U.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]);U.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);U.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);U.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);U.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(he).map(i=>i.toLowerCase()));U.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);U.OF_POSSESSIVE_MARKERS={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin"])};U.RUN_OPERATORS=new Set(["+","-","*","/"]);U.MAX_BRACE_RUN_TOKENS=64;U.MAX_PROPERTY_DEPTH=10;U.MAX_METHOD_ARGS=20;U.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);U.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Xn=U,Q=new Xn;function H(i,e){return Yt(i,e)}function Kr(){return Gt()}var $e=["if","unless","repeat","for","while"];function ne(i,e){let r=new Set([e]),n=N(i)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function X(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var Jn=new Set($e);function ir(i,e){let r=i.normalized?.toLowerCase();return r?Jn.has(r):e.some(t=>X(i,t))}var Cr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Qn=new Set(["destination","source","style","patient","on","from","to"]);function ea(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(Cr.has(e)||Cr.has(r)||Qn.has(e))}var Ar=new Set(["ja","ko"]);function Qe(i){let e=new Set;i?.primary&&e.add(i.primary.toLowerCase());for(let r of i?.alternatives??[])e.add(r.toLowerCase());return e}function Ur(i,e){let r=[],t=e.position.end,n=i.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){t=e.position.end+n[0].length;for(let a of n[1].split(/[,،、]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:t}}function Hr(i,e,r){let t=e+1;if(t>=i.length)return -1;let n=Qe(N(r)?.roleMarkers?.patient);return n.size>0&&X(i[t],n)&&t++,t<i.length?t:-1}function ra(i,e,r){if(!N(e))return null;let t=ne(e,"behavior"),n=ne(e,"def"),a=i.toLowerCase(),o=[...t].some(m=>a.includes(m)),u=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!o&&!u)return null;let s=H(i,e).tokens;if(s.length<2)return null;if(X(s[0],t))return Sr(i,e,s,r,0);let l=s.findIndex((m,c)=>c>0&&X(m,t));return l>0&&/^[A-Z][A-Za-z0-9_]*$/.test(s[0].value)?Sr(i,e,s,r,l):X(s[0],n)?ia(i,e,s,r):null}function ta(i,e,r){let t=N(e);if(!t)return null;let n=t.wordOrder!=="SOV",a=Ar.has(e)?Qe(t.roleMarkers?.event):new Set,o=Ar.has(e)?Qe(t.keywords?.on):new Set,u=a.size>0&&o.size>0,s=ne(e,"end"),l=ne(e,"on"),m=i.toLowerCase(),c=[...s].some(g=>m.includes(g)),p=(n||u)&&(()=>{let g=0;for(let w of l)if(w){for(let v=m.indexOf(w);v>=0;v=m.indexOf(w,v+w.length))if(++g>=2)return true}return false})();if(!c&&!p)return null;let d=H(i,e).tokens;if(d.length<2)return null;let f=$e.map(g=>ne(e,g)),y=g=>ir(g,f),h=g=>X(g,s),E=[],b=0,C=0;for(let g=0;g<d.length;g++){let w=d[g];if(h(w)){if(b>0){b--;continue}let v=i.slice(d[C].position.start,w.position.start).trim();v&&E.push(v),C=g+1;}else if(y(w))b++;else if(n&&b===0&&g>C&&X(w,l)&&ea(d[g+1])){let v=i.slice(d[C].position.start,w.position.start).trim();v&&E.push(v),C=g;}else if(u&&b===0&&g-1>C&&X(w,a)&&d[g+1]!==void 0&&X(d[g+1],o)){let v=d[g-1],k=i.slice(d[C].position.start,v.position.start).trim();k&&E.push(k),C=g-1;}}if(C<d.length){let g=i.slice(d[C].position.start).trim();g&&E.push(g);}if(E.length<2)return null;let A=[],z=[];for(let g of E){let w;try{w=r.statement(g,e);}catch{return null}if(!w||w.kind!=="event-handler")return null;let v=w;A.push(v);let k=!v.body||v.body.length===0;z.push(k?.2:v.metadata?.confidence??.75);}return Je(A,"then",{sourceLanguage:e,confidence:je(z),sourceText:i})}function je(i){return i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0}function Gr(i){let e=[];for(let r of i){let t=r.statements;r.kind==="compound"&&Array.isArray(t)?e.push(...t):e.push(r);}return e}function Sr(i,e,r,t,n){let a=n>0,o=a?0:Hr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(s))return null;let{parameters:l,headerEnd:m}=Ur(i,u),c=a?n+1:r.findIndex(v=>v.position.start>=m);c<=o&&(c=o+1);let p=ne(e,"init"),d=ne(e,"end"),f=$e.map(v=>ne(e,v)),y=v=>ir(v,f),h=v=>X(v,d),E=[],b=[],C=[],A=false,z=0,g=c;for(let v=c;v<r.length;v++){let k=r[v];if(h(k)){if(z>0){z--;continue}if(v===g){A=true;break}if(X(r[g],p)){let D=i.slice(r[g].position.end,k.position.start).trim();if(D)try{let S=Gr(t.body(D,e));b.push(...S),C.push(je(S.map(L=>L.metadata?.confidence??.75)));}catch{C.push(0);}}else {let D=i.slice(r[g].position.start,k.position.start).trim();try{let S=t.statement(D,e);if(S&&S.kind==="event-handler"){let L=S;E.push(L);let T=!L.body||L.body.length===0;C.push(T?.2:L.metadata?.confidence??.75);}else C.push(0);}catch{C.push(0);}}g=v+1;}else y(k)&&z++;}if(E.length===0&&b.length===0)return null;let w=(A?1:.8)*je(C);return ki(s,l,E,b.length>0?b:void 0,{sourceLanguage:e,confidence:w,sourceText:i})}function ia(i,e,r,t){let n=Hr(r,0,e);if(n<0)return null;let a=r[n],o=a.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(o))return null;let{parameters:u,headerEnd:s}=Ur(i,a),l=r.findIndex(z=>z.position.start>=s);l<=n&&(l=n+1);let m=ne(e,"end"),c=$e.map(z=>ne(e,z)),p=z=>ir(z,c),d=z=>X(z,m),f=0,y=-1;for(let z=l;z<r.length;z++)if(d(r[z])){if(f===0){y=z;break}f--;}else p(r[z])&&f++;let h=r[l]?.position.start??s,E=y>=0?r[y].position.start:i.length,b=i.slice(h,E).trim();if(!b)return null;let C;try{C=Gr(t.body(b,e));}catch{return null}if(C.length===0)return null;let A=je(C.map(z=>z.metadata?.confidence??.75));return y<0&&(A*=.8),bi(o,u,C,{sourceLanguage:e,confidence:A,sourceText:i})}var Ae={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};Object.fromEntries(Object.entries(Ae).map(([i,e])=>{let r={};for(let[t,n]of Object.entries(e))n in r||(r[n]=t);return [i,r]}));var Ce=new Set(["if","unless","while","repeat","for"]),sa=new Set(["then","end","else","if","unless","while","for","repeat","and"]),la=new Set(["first","last","next","previous","random","closest"]),Se=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Dr=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function M(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function K(i,e){return e.length===0?i:{...i,diagnostics:e}}function xr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var ca=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Yr(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=le(i.action),n=t?.primaryRole;if(t&&n&&n!=="patient"&&!t.roles.some(a=>a.role==="patient")&&i.roles.has("patient")&&!i.roles.has(n)){let a=i.roles,o=a.get("patient");o!==void 0&&(a.delete("patient"),a.set(n,o));}if(i.action==="tell"){let a=i.roles,o=a.get("patient"),u=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(a.delete("patient"),a.set("destination",o));}if(i.action==="transition"){let a=i.roles,o=a.get("destination");o&&o.type==="literal"&&!a.has("goal")&&(a.delete("destination"),a.set("goal",o));let u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&a.set("patient",{type:"expression",raw:u.value});}if(i.action==="morph"){let a=i.roles,o=a.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&a.set("patient",{type:"expression",raw:o.value});}if(i.action==="wait"){let a=i.roles;if(!a.has("event")){let o=a.get("duration"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&Se.has(u.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:u,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let a=i.roles,o=a.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&a.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let a=i.roles;for(let o of ["destination","source"]){let u=a.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&a.set(o,{type:"expression",raw:u.value});}}}let r=i;for(let t of ca){let n=r[t];if(Array.isArray(n))for(let a of n)Yr(a,e);}return i}var J=class F{constructor(){this.parseDepth=0,this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return Yr(this.parseInternal(e,r),this.boundIdentifiers)}finally{this.parseDepth--;}}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let t=e.roles.get(r);t?.type==="expression"&&typeof t.raw=="string"&&/^[A-Za-z_]\w*$/.test(t.raw)&&this.boundIdentifiers.add(t.raw);}parseInternal(e,r){let t=ra(e,r,{statement:(v,k)=>this.parse(v,k),body:(v,k)=>this.parseStatements(v,k)});if(t)return t;let n=ta(e,r,{statement:(v,k)=>this.parse(v,k),body:(v,k)=>this.parseStatements(v,k)});if(n)return n;let{modifiers:a,remainingInput:o}=this.extractStandaloneModifiers(e,r),u=o||e,l=this.stripAsyncModifier(u,r).remainingInput??u,c=this.stripDoNotThrowModifier(l,r).remainingInput??l,p=[],d=H(c,r),f=ae(r);if(f.length===0)throw new Dr(`No patterns available for language: ${r}`,r,c,[M(`No patterns registered for language '${r}'`,"error","no-patterns")]);let y=[...f].sort((v,k)=>k.priority-v.priority);{let v=d.tokens;if(N(r)?.wordOrder==="VSO"&&v.length>=4&&v[0]?.normalized==="source"){let k=v.findIndex(D=>D.normalized==="on");if(k>=2&&k+1<v.length){let D=c.slice(v[0].position.start,v[k].position.start).trim(),S=v[k+1].position.end,L=c.slice(v[k].position.start,S)+" "+D+c.slice(S);if(L!==c)try{let T=this.parse(L,r);if(T&&T.kind==="event-handler"){let B=a?this.applyModifiers(T,a):T;return K(B,p)}}catch{}}}}{let v=d.tokens;for(let k=1;k<v.length-1;k++){let D=v[k],S=D.value,L=(D.normalized??D.value).toLowerCase();if(!(L==="or"||F.OR_KEYWORDS.has(S)||F.OR_KEYWORDS.has(L)))continue;let B=v[k+1],P=(B.normalized??B.value).toLowerCase();if(!F.KNOWN_EVENTS.has(P))break;let O=k+1,$=v[k+2];$&&$.kind==="selector"&&$.value.startsWith("[")&&(O=k+2);let q=v[k].position.start,ce=v[O].position.end,ee=(c.slice(0,q).trimEnd()+" "+c.slice(ce).trimStart()).trim();if(ee&&ee!==c)try{let me=this.parse(ee,r);if(me&&me.kind==="event-handler"){me.additionalEvents=[{type:"literal",value:P}];let Ue=a?this.applyModifiers(me,a):me;return K(Ue,p)}}catch{}break}}let h=y.filter(v=>v.command==="on"),E=d.mark(),b=Q.matchBest(d,h);if(b){p.push(M(`event pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let v=false;if(/^event-[a-z]+-bare$/.test(b.pattern.id)){let k=b.captured.get("event"),D=(k?.raw??k?.value??"").toString().toLowerCase(),S=Ae[r],L=F.KNOWN_EVENTS.has(D)||!!S&&Object.keys(S).some(T=>T.toLowerCase()===D);if(D&&!L){let T=this.trySOVEventExtraction(c,r,y);if(T){p.push(M(`bare-event mis-anchor on "${D}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let B=a?this.applyModifiers(T,a):T;return K(B,p)}if(k?.type==="reference"||k?.type==="expression"){d.reset(E);let B=y.filter(O=>O.command!=="on"),P=Q.matchBest(d,B);d.reset(E),P&&P.pattern.command!=="on"?(v=true,p.push(M(`bare-event mis-anchor on reference "${D}" rejected; command ${P.pattern.command} preferred`,"info","stage-bare-event-guard"))):Q.matchBest(d,h);}}}if(!v){let k=this.buildEventHandler(b,d,r),D=a?this.applyModifiers(k,a):k;return K(D,p)}}p.push(M(`event patterns: ${h.length} tried, no match`,"info","stage-event"));let C=this.tryTrailingEventExtraction(c,r,y);if(C){p.push(M("trailing event extraction succeeded","info","stage-trailing-event"));let v=a?this.applyModifiers(C,a):C;return K(v,p)}let A=y.filter(v=>v.command!=="on"),z=Q.matchBest(d,A);if(z){if(Ce.has(z.pattern.command)){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(M(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let D=a?this.applyModifiers(v,a):v;return K(D,p)}let k=this.tryMidStreamEventExtraction(c,r,y);if(k){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let D=a?this.applyModifiers(k,a):k;return K(D,p)}}else if(F.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(c,r)){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(M(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let k=a?this.applyModifiers(v,a):v;return K(k,p)}}else if(N(r)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(c,r,y);if(v){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let k=a?this.applyModifiers(v,a):v;return K(k,p)}}if(z.consumedTokens<d.tokens.length&&N(r)?.wordOrder==="SOV"){let v=this.trySOVEventExtraction(c,r,y);if(v){p.push(M(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let k=a?this.applyModifiers(v,a):v;return K(k,p)}}return p.push(M(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match")),K(this.buildCommand(z,r),p)}if(p.push(M(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!c.includes(`
4
- `)&&N(r)?.wordOrder==="VSO"){let v=this.tryMidStreamEventExtraction(c,r,y);if(v){p.push(M("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let k=a?this.applyModifiers(v,a):v;return K(k,p)}}let g=this.trySOVEventExtraction(c,r,y);if(g){p.push(M("SOV event extraction succeeded","info","stage-sov"));let v=a?this.applyModifiers(g,a):g;return K(v,p)}p.push(M("SOV event extraction: no event keyword found","info","stage-sov"));let w=this.tryCompoundCommandParsing(d,A,r);if(w)return p.push(M("compound command parsing succeeded","info","stage-compound")),K(w,p);throw p.push(M("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(M(`all parse stages exhausted for "${c}"`,"error","parse-failed")),new Dr(`Could not parse input in ${r}: ${c}`,r,c,p)}parseStatements(e,r){let t=H(e,r),n=ae(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);return this.parseBodyWithClauses(t,n,r)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Kr()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[a,o]of e.captured)t[a]=o;let n=Z(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");let a=Q.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,t),u=n;o.length>0&&n.type==="literal"&&(u={type:"literal",value:[String(n.value),...o.map(c=>String("value"in c?c.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"&&l.value==="if"){let m=r.tokens,c=-1;for(let p=r.position()-1;p>=0;p--){let d=m[p],f=(d.normalized??d.value).toLowerCase();if(this.isIfKeyword(f,t)){c=p;break}}if(c>=0){let p=ae(t).filter(h=>h.command!=="on").sort((h,E)=>E.priority-h.priority),d=new te(m.slice(c),t),f=this.parseBodyWithClauses(d,p,t);if(f.some(h=>h.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(h=>h.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Oe(u,f,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}}}if(l&&l.type==="literal"){let m=l.value,c={};for(let[A,z]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(c[A]=z);if(m==="repeat"){let A=r.peek(),z=w=>(w.normalized??w.value).toLowerCase();if(A&&A.kind==="keyword"&&z(A)==="forever")c.loopType={type:"literal",value:"forever"},delete c.patient,r.advance();else if(A&&A.kind==="keyword"&&z(A)==="event"){r.advance();let w=r.peek();if(w)for(c.event={type:"literal",value:z(w)},c.loopType={type:"literal",value:"until-event"},delete c.patient;!r.isAtEnd();){let v=r.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,t)||this.isEndKeyword(v.value,t)))break;r.advance();}}let g=c.patient;g&&g.type==="reference"&&g.value==="me"&&delete c.patient;}let p=Z(m,c,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!Ce.has(m)||m==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,g=r.position(),w=k=>k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,t)||this.isEndKeyword(k.value,t)),v=-1;for(let k=g-1;k>=0;k--){let D=z[k];if(w(D))break;if((D.normalized??D.value).toLowerCase()===m){v=k;break}}if(v>=0){let k=g;for(;k<z.length&&!w(z[k]);)k++;let D=z.slice(v,k),S=D;if(A){let L=String(n.value??"").toLowerCase(),T=D.findIndex(B=>(B.normalized??B.value).toLowerCase()===L);if(T<0)S=null;else {let B=D[T-1],P=B&&B.kind==="keyword"&&B.normalized?.toLowerCase()==="on"?T-1:T;S=[...D.slice(0,P),...D.slice(T+1)];}}if(S&&S.length>1){let L=ae(t).filter(V=>V.command!=="on").sort((V,ue)=>ue.priority-V.priority),T=this.parseClause(S,L,t),B=T[0],P=V=>V!==null&&typeof V=="object"&&typeof V.type=="string"?V.type:typeof V,O=le(m),$=O?.primaryRole,q=V=>V==="patient"&&$&&$!=="patient"&&!O?.roles.some(ue=>ue.role==="patient")?$:V,ce=(V,ue)=>{if(!Ce.has(m)||!O)return false;let ze=O.roles.find(ct=>ct.role===q(V));return ze?ze.expectedTypes.length>0&&!ze.expectedTypes.includes(P(ue)):true},ee=!!B&&B.kind==="command"&&Object.entries(c).every(([V,ue])=>{if(ce(V,ue))return true;let ze=B.roles.get(q(V));return ze!==void 0&&P(ze)===P(ue)}),me=B?.metadata?.patternId??"",Ue=!Ce.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(me);if(T.length===1&&B&&B.kind==="command"&&B.action===m&&ee&&Ue&&B.roles.size>Object.keys(c).length)for(p=B;r.position()<k;)r.advance();}}}if(!Ce.has(m)){let A=p;if(le(m)?.roles.some(S=>S.role==="quantity"&&!S.required)&&!A.roles.has("quantity")){let S=r.peek();S&&/^-?\d+(\.\d+)?$/.test(S.value)&&(p=Z(m,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(S.value),dataType:"number"}},A.metadata),r.advance());}let g=p;if(le(m)?.roles.some(S=>S.role==="duration"&&!S.required)&&!g.roles.has("duration")){let S=r.peek();S&&/^\d+(\.\d+)?(ms|s)$/i.test(S.value)&&(p=Z(m,{...Object.fromEntries(g.roles),duration:{type:"literal",value:S.value,dataType:"string"}},g.metadata),r.advance(),this.consumeForPostposition(r,t));}let v=p,k=le(m);if(k?.roles.find(S=>S.role==="responseType"&&!S.required)&&!v.roles.has("responseType")){let S=O=>typeof O=="string"&&F.RESPONSE_TYPE_WORDS.has(O.toLowerCase()),L=(O,$)=>{let q=Object.fromEntries(v.roles);$&&delete q.destination,q.responseType={type:"expression",raw:O},p=Z(m,q,v.metadata);},T=v.roles.get("destination"),B=k?.roles.find(O=>O.role==="destination"),P=T?.raw??T?.value;if(T&&B&&!B.expectedTypes.includes(T.type)&&S(P))L(P,true);else {let O=r.peek();O&&S(O.value)&&(L(O.value,false),r.advance());}}if(m==="wait"){let S=p;if(!S.roles.has("event")){let L=r.peek();if(L&&Se.has(L.value.toLowerCase())){let T=Object.fromEntries(S.roles),B=T.duration;B&&B.type!=="literal"&&B.type!=="expression"&&delete T.duration;let P=T.patient;P&&P.type==="reference"&&P.value==="me"&&delete T.patient,T.event={type:"literal",value:L.value,dataType:"string"},p=Z(m,T,S.metadata),r.advance(),this.consumeForPostposition(r,t);}}}}let d=e.captured.get("continues"),f=d?.type==="literal"&&d.value==="then",y=r.peek(),h=!!y&&this.isThenKeyword(y.value,t),b=Ce.has(m)&&!!y&&!this.isEndKeyword(y.value,t),C=!!y&&!this.isEndKeyword(y.value,t);if(f||h||b||C){let A=ae(t).filter(w=>w.command!=="on").sort((w,v)=>v.priority-w.priority),z=ae(t).filter(w=>w.id.startsWith("grammar-")&&w.id.includes("-continuation")).sort((w,v)=>v.priority-w.priority),g=this.parseBodyWithGrammarPatterns(r,A,z,t);g.length>0?s=[p,...g]:s=[p];}else s=[p];}else {let m=ae(t).filter(c=>c.command!=="on").sort((c,p)=>p.priority-c.priority);s=this.parseBodyWithClauses(r,m,t);}return Oe(u,s,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let n=[],a=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(a.length===0){let f=this.consumeJsBlock(e,t);if(f){n.push(f);continue}let y=this.tryParseConditionalBlock(e,r,t);if(y){n.push(y);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t),m=a[a.length-1],c=e.peek(1),p=m?.value.toLowerCase()==="at"&&c?.value.toLowerCase()==="of"||zr(t,s.value,m?.value,c?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&o>0){o--,u.pop(),a.push(s),e.advance();continue}if(l&&u.includes("if")){a.push(s),e.advance();continue}if(l){if(a.length>0){let f=this.parseClause(a,r,t);n.push(...f),a.length=0,o=f.filter(y=>{let h=y;return (h.action==="for"||h.action==="repeat"||h.action==="while")&&(!Array.isArray(h.body)||h.body.length===0)}).length,u.length=0;for(let y=0;y<o;y++)u.push("other");}e.advance();continue}if(d){e.advance();let f=[];for(;!e.isAtEnd();){let y=e.peek();if(!y||y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,t)||this.isEndKeyword(y.value,t)))break;f.push(y),e.advance();}if(f.length>0){let y=a.length>0?this.parseClause(a,r,t):[];y.length===0&&a.length>0?n.push(...this.parseClause([...a,...f],r,t)):(n.push(...y),n.push(...this.parseClause(f,r,t)));}else if(a.length>0){let y=this.parseClause(a,r,t);n.push(...y);}a.length=0;break}if(s.kind==="keyword"){let f=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(f,t)||this.isUnlessKeyword(f,t)||f==="while"||f==="for"||f==="repeat")&&(o++,u.push(this.isIfKeyword(f,t)?"if":"other"));}a.push(s),e.advance();}if(a.length>0){let s=this.parseClause(a,r,t);n.push(...s);}this.foldFrontedWhileIntoRepeat(n,t);for(let s=n.length-1;s>=0;s--){let l=n[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(s,1);}return n.length>1?[Je(n,"then",{sourceLanguage:t})]:n}foldFrontedWhileIntoRepeat(e,r){for(let t=0;t+1<e.length;t++){let n=e[t],a=e[t+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...a,roles:u,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}parseClause(e,r,t){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let h=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(h,t)&&(n="unless",a=e.slice(0,-1));}let u=null;if(n&&a.length>=3){let h=N(t),E=h?F.buildVerbLookup(h):null;if(E)for(let b=1;b<a.length-1;b++){let C=a[b],A=E.get(C.value.toLowerCase())??(C.normalized?E.get(C.normalized.toLowerCase()):void 0);if(A&&!F.CONDITION_OPERATORS.has(A)){u=a.slice(0,b),a=a.slice(b);break}}}let s=new te(a,t),l=[],m=0,c=[],p=u,d=()=>{if(c.length===0)return;let h=c.slice();if(c.length=0,n&&l.length===0&&p===null){p=h;return}let E=h[0];if(E&&(E.kind==="identifier"||E.kind==="selector"||E.kind==="literal"||E.kind==="reference"))for(let C of this.parseSOVClauseByVerbAnchoring(h,t)){let A=C.action,z=C.roles;A&&le(A)&&z instanceof Map&&z.size>0&&l.push(C);}};for(;!s.isAtEnd();){let h=s.peek(),E=!!h&&h.normalized?.toLowerCase()==="repeat",b=s.mark(),C=Q.matchBest(s,r);if(E&&C&&C.pattern.command!=="repeat"){s.reset(b),d(),l.push(Z("repeat",{},{sourceLanguage:t,confidence:.6})),m++,s.advance();continue}if(C&&C.pattern.command==="if"){let A=s.mark(),z=c.length;for(s.reset(b);!s.isAtEnd();){let w=s.peek();if(!w||this.isIfKeyword((w.normalized??w.value).toLowerCase(),t))break;c.push(w),s.advance();}let g=this.tryParseConditionalBlock(s,r,t);if(g){d(),l.push(g),m++;continue}c.length=z,s.reset(A);}if(C){d();let A=this.buildCommand(C,t);l.push(A),m++,this.tryAttachTrailingRole(s,A,t);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(d(),l.push(Z("repeat",{},{sourceLanguage:t,confidence:.6})),m++):A&&c.push(A),s.advance();}}d();let f=l;if(m===0){let h=this.parseSOVClauseByVerbAnchoring(a,t);h.length>0&&(f=h);}let y=p;return n&&f.length>0&&y&&y.length>0?[Z(n,{condition:{type:"expression",raw:this.joinTokenText(y)}},{sourceLanguage:t,patternId:`${n}-${t}-trailing-guard`,confidence:.85}),...f]:f}tryAttachTrailingRole(e,r,t){let n=le(r.action);if(!n)return;let a=N(t);if(!a)return;let o=r.roles,u=(l,m)=>{if(!l)return false;if(l.kind==="selector")return true;let c=(l.normalized??l.value).toLowerCase();return sa.has(c)?false:c==="body"||c==="it"||c==="you"||c==="result"||c==="document"||c==="window"||this.boundIdentifiers.has(l.value)?true:m?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:m}of s){if(!n.roles.some(h=>h.role===l))continue;let c=a.roleMarkers?.[l];if(!c)continue;let p=o.get(l);if(p&&!(p.type==="reference"&&p.value==="me"))continue;let d=h=>{if(!h||h.kind!=="particle"&&h.kind!=="keyword")return false;let E=h.value.toLowerCase();return c.primary?.toLowerCase()===E?true:m?false:(h.normalized??"").toLowerCase()===l?true:!!c.alternatives?.some(b=>b.toLowerCase()===E)},f=e.peek(),y=e.peek(1);if(!f||!y)return;if(m&&c.position==="after"){let h=e.peek(2),E=(f.normalized??f.value).toLowerCase();if(la.has(E)&&y.kind==="selector"&&d(h)){o.set(l,{type:"expression",raw:`${E} ${y.value}`}),e.advance(),e.advance(),e.advance();return}}if(c.position==="after"){if(u(f,m)&&d(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),h&&o.set(l,h);return}}else if(d(f)&&u(y,m)){e.advance();let h=this.tokenToSemanticValue(e.advance());h&&o.set(l,h);return}}}static buildVerbLookup(e){let r=new Map;for(let[t,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(t)&&(r.set(n.primary.toLowerCase(),t),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((t!=="event"||!r.has(n.primary))&&r.set(n.primary,t),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=N(r);if(!t||t.wordOrder!=="SOV")return [];let n=F.buildVerbLookup(t),a=F.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let y=e[f];if(a.has(y.value))continue;let h=n.get(y.value.toLowerCase()),E=y.normalized?n.get(y.normalized.toLowerCase()):void 0,b=h||E;if(b){s=f,l=b;break}}if(s===-1)break;let m=e.slice(u,s),c=e.length;for(let f=s+1;f<e.length;f++){let y=e[f];if(y.kind==="conjunction"||this.isThenKeyword(y.value,r)){c=f;break}if(f>s+1&&!a.has(y.value)&&(n.get(y.value.toLowerCase())||(y.normalized?n.get(y.normalized.toLowerCase()):void 0))){c=f;break}}let p=e.slice(s+1,c),d=this.extractRolesFromMarkedTokens(m,p,a,l,r);if(o.push(Z(l,d,{sourceLanguage:r,confidence:.7})),u=c,u<e.length){let f=e[u];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,n,a){let o={},u=s=>{let l=[];for(let m of s){let c=t.get(m.value);if(c&&m.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(c,n,o);d&&(o[d]=p);}l=[];}else l.push(m);}if(l.length>0)if(l.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(l[0].value)&&!o.duration&&le(n)?.roles.some(c=>c.role==="duration"))o.duration={type:"literal",value:l[0].value,dataType:"string"};else {let c=this.tokensToSemanticValue(l);c&&(o.patient?o.destination||(o.destination=c):o.patient=c);}};return u(e),u(r),o}mapRoleForCommand(e,r,t){return t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(a=>a.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let t=r.map(a=>a.value).join(""),n=r[0];return n.kind==="selector"||n.value.startsWith("#")||n.value.startsWith(".")||n.value.startsWith("@")||n.value.startsWith("*")?fe(t):n.kind==="literal"||n.value.startsWith('"')||n.value.startsWith("'")?_(xr(t),"string"):n.kind==="reference"?ie(t):_(t)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return fe(r);if(r.startsWith('"')||r.startsWith("'"))return _(xr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return _(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return _(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return _(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ie(t):e.kind==="reference"?ie(e.normalized||"me"):_(r)}parseBodyWithGrammarPatterns(e,r,t,n){let a=[],o=[],u=false,s=()=>{!u&&o.length>0&&a.push(...this.parseSOVClauseByVerbAnchoring(o,n)),o=[],u=false;},l=0,m=()=>{let c=0;for(let p of a){let d=p;(d.action==="for"||d.action==="repeat"||d.action==="while")&&(!Array.isArray(d.body)||d.body.length===0)&&c++;}return c-l};for(;!e.isAtEnd();){let c=e.peek();if(c&&this.isThenKeyword(c.value,n)){s(),e.advance();continue}if(c&&this.isEndKeyword(c.value,n)){let d=e.peek(-1),f=e.peek(1);if(!zr(n,c.value,d?.value,f?.value)){if(s(),m()>0){l++,e.advance();continue}e.advance();break}}if(c&&!u&&this.isIfKeyword((c.normalized??c.value).toLowerCase(),n)){s();let d=this.tryParseConditionalBlock(e,r,n);if(d){a.push(d),u=true;continue}}let p=false;if(t.length>0){let d=Q.matchBest(e,t);if(d){let f=d.pattern.command,y={};for(let[b,C]of d.captured)b!=="event"&&b!=="action"&&b!=="continues"&&(y[b]=C);let h=Z(f,y,{sourceLanguage:n,patternId:d.pattern.id});a.push(h),p=true,u=true;let E=d.captured.get("continues");if(E&&E.type==="literal"&&E.value==="then")continue}}if(!p){let d=e.mark(),f=Q.matchBest(e,r);if(f){if(f.pattern.command==="if"){let h=e.mark();for(e.reset(d);!e.isAtEnd();){let b=e.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),n))break;e.advance();}let E=this.tryParseConditionalBlock(e,r,n);if(E){s(),a.push(E),u=true;continue}e.reset(h);}let y=this.buildCommand(f,n);a.push(y),this.tryAttachTrailingRole(e,y,n),p=true,u=true;}}p||(c&&o.push(c),e.advance());}s();for(let c=a.length-1;c>=0;c--){let p=a[c];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&a.splice(c,1);}return a}tryCompoundCommandParsing(e,r,t){let n=e.tokens,a=n.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,t)),o=n.some(l=>this.isElseKeyword(l.value,t));if(!a&&!o)return null;let u=new te(n,t),s=this.parseBodyWithClauses(u,r,t);return s.length===0?null:s.length===1?s[0]:Je(s,"then",{sourceLanguage:t,confidence:.65})}matchEventMarkerPhrase(e,r,t){let n=F.SOV_EVENT_MARKER_PHRASES[t];if(!n)return 0;for(let a of n)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let t=F.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:n}=H(e,r),a=Ae[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length;u++){let s=n[u],l=s.value.toLowerCase(),m=s.normalized?.toLowerCase();if(!(!!m&&(F.KNOWN_EVENTS.has(m)||Se.has(m))||F.KNOWN_EVENTS.has(l)||Se.has(l)||o.has(l)))continue;let p=this.matchEventParamPhrase(n,u+1).len,d=n[u+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(n,u+1+p,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let t=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return {len:n-r+1,names:t};if(a!==","){if(e[n].kind!=="identifier")break;t.push(a);}}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let t=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(t==="me"||t==="i"||t==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!t&&r.has(t)}tryTrailingEventExtraction(e,r,t){let n=H(e,r).tokens;if(n.length<3)return null;let a=Ae[r],o=new Set;if(a)for(let C of Object.keys(a))o.add(C.toLowerCase());let u=n.length-2,s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let m=n[n.length-1],c=m.value.toLowerCase(),p=m.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(c)||o.has(c)))return null;let f=p&&F.KNOWN_EVENTS.has(p)?p:a?.[c]??c,y=n.slice(0,u);if(y.length===0)return null;let h=t.filter(C=>C.command!=="on"),E=new te(y,r),b=this.parseBodyWithClauses(E,h,r);return b.length===0?null:Oe({type:"literal",value:f},b,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let n=H(e,r).tokens;if(n.length<3)return null;let a=Ae[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length-1;u++){let s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let m=n[u+1],c=m.value.toLowerCase(),p=m.normalized?.toLowerCase();if(!(!!p&&F.KNOWN_EVENTS.has(p)||F.KNOWN_EVENTS.has(c)||o.has(c)))continue;let f=p&&F.KNOWN_EVENTS.has(p)?p:a?.[c]??c,y=n.filter((C,A)=>A!==u&&A!==u+1);if(y.length===0)return null;let h=t.filter(C=>C.command!=="on"),E=new te(y,r),b=this.parseBodyWithClauses(E,h,r);return b.length===0?null:Oe({type:"literal",value:f},b,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let n=F.SOV_EVENT_MARKERS[r];if(!n)return null;let o=H(e,r).tokens,u=Ae[r],s=new Set;if(u)for(let z of Object.keys(u))s.add(z.toLowerCase());let l=F.SOV_SOURCE_MARKERS[r],m=-1,c="",p="",d=1,f=[];for(let z=0;z<o.length;z++){let g=o[z],w=g.value.toLowerCase(),v=w,k="",D=w.indexOf("[");D>0&&(v=w.slice(0,D),k=g.value.slice(D));let S=g.normalized?.toLowerCase(),L=S&&(F.KNOWN_EVENTS.has(S)||Se.has(S)),T=s.has(w)||s.has(v),B=F.KNOWN_EVENTS.has(v)||Se.has(v);if(L||T||B){let P=o[z-1];if(P&&(P.normalized??P.value).toLowerCase()==="event")continue;let O;L?O=S:T?O=u?.[w]??u?.[v]??v:O=v;let $=this.matchEventParamPhrase(o,z+1);if(n.size>0){let q=1+$.len,ce=o[z+q];ce&&ce.kind==="selector"&&ce.value.startsWith("[")&&(q+=1);let ee=o[z+q];if(ee&&(ee.kind==="particle"||ee.kind==="keyword")&&n.has(ee.value)){m=z,c=O,p=k||(q===$.len+2?o[z+q-1].value:""),d=q+1,f=$.names;break}}else {m=z,c=O,p=k,d=1+$.len+this.matchEventMarkerPhrase(o,z+1+$.len,r),f=$.names;break}}}if(m===-1){let z=new Set(t.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<o.length;g++){let w=o[g];if(w.kind==="identifier")if(n.size>0){let v=1,k=o[g+1];k&&k.kind==="selector"&&k.value.startsWith("[")&&(v=2);let D=o[g+v];if(D&&(D.kind==="particle"||D.kind==="keyword")&&n.has(D.value)){m=g,c=w.value,p=v===2?o[g+1].value:"",d=v+1;break}}else {let v=this.matchEventMarkerPhrase(o,g+1,r);if(v>0){m=g,c=w.value,p="",d=1+v;break}let k=o[g+1];if(k&&k.kind==="keyword"&&k.normalized!=null&&z.has(k.normalized)){m=g,c=w.value,p="",d=1;break}}}}if(m===-1)return null;let y=new Set;for(let z=m;z<m+d;z++)y.add(z);if(l){let z=m+d;if(z<o.length){let g=o[z];if((g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value))y.add(z);else if(this.isStrippableSourceRef(g,l.windowTokens)){let w=o[z+1];w&&(w.kind==="particle"||w.kind==="keyword")&&l.markers.has(w.value)&&(y.add(z),y.add(z+1));}}if(m>=2){let g=o[m-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(o[m-2],l.windowTokens)&&(y.add(m-2),y.add(m-1));}for(let g=0;g<m;g++){let w=o[g],v=w.value.toLowerCase(),k=w.normalized?.toLowerCase();if(l.windowTokens.has(v)||k&&l.windowTokens.has(k)){y.add(g);break}}}let h=o.filter((z,g)=>!y.has(g));if(h.length===0)return null;let E=t.filter(z=>z.command!=="on"),b=new te(h,r),C=this.parseBodyWithClauses(b,E,r);if(C.length===0)return null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Oe({type:"literal",value:c},C,void 0,A,f)}profileKeywordMatches(e,r,t){let n=N(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===t?true:!!n.alternatives?.some(a=>a.toLowerCase()===t):false}consumeForPostposition(e,r){let t=e.peek();if(!t)return;let n=(t.normalized??"").toLowerCase(),a=N(r)?.keywords?.for;(n==="for"||t.value===a?.primary||(a?.alternatives??[]).includes(t.value))&&e.advance();}isThenKeyword(e,r){let t=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(t):t==="then"||this.profileKeywordMatches(r,"then",t)}isElseKeyword(e,r){let t=e.toLowerCase();return t==="else"?true:this.profileKeywordMatches(r,"else",t)}isEndKeyword(e,r){let t=e.toLowerCase(),a={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])}[r];return a?t==="end"||a.has(t):t==="end"||this.profileKeywordMatches(r,"end",t)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}consumeJsBlock(e,r){let t=e.peek();if(!t||!this.isJsKeyword(t))return null;let n=e.mark(),a=[];e.advance();let o=false;for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(e.advance(),this.isEndKeyword(s.value,r)){o=true;break}a.push(s);}if(!o)return e.reset(n),null;let u=a.map(s=>s.value).join(" ").trim();return Z("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}isIfKeyword(e,r){let t=e.toLowerCase();return t==="if"?true:this.profileKeywordMatches(r,"if",t)}isUnlessKeyword(e,r){let t=e.toLowerCase();return t==="unless"?true:this.profileKeywordMatches(r,"unless",t)}isBlockEndToken(e,r,t){return this.isEndKeyword(e.value,t)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,t){let n=e.peek();if(!n)return null;let a=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(a,t))return null;let o=e.mark();e.advance();let u=[],s=0;for(;!e.isAtEnd();){let g=e.peek();if(!g)break;let w=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)){s++,u.push(g),e.advance();continue}if(this.isBlockEndToken(g,e.peek(1)??void 0,t)){if(s===0){e.advance();break}s--,u.push(g),e.advance();continue}u.push(g),e.advance();}if(u.length===0)return e.reset(o),null;let l=N(t),m=l?.wordOrder==="SOV"?F.buildVerbLookup(l):null,c=0,p=0,d=[];for(;c<u.length;c++){let g=u[c],w=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?p++:this.isBlockEndToken(g,u[c+1],t)&&p--,p===0&&this.isThenKeyword(g.value,t)){c++;break}if(p===0&&d.length>0){let v=(u[c-1].normalized??u[c-1].value).toLowerCase(),k=u[c-1].value.toLowerCase(),D=(g.normalized??g.value).toLowerCase(),S=F.CONDITION_COPULAS.has(v)||F.CONDITION_COPULAS_SURFACE.has(k)&&F.CONDITION_PREDICATES.has(D),L=m!==null&&m.has(g.value.toLowerCase())&&!F.CONDITION_PREDICATES.has(D);if(!F.CONDITION_OPERATORS.has(D)&&(!S||L)&&(this.tokensBeginCommand(u.slice(c),r,t)||this.sovCommandStartsAt(u.slice(c),m)))break}d.push(g);}if(d.length===0)return e.reset(o),null;let y=[],h=[],E=false,b=0;for(;c<u.length;c++){let g=u[c],w=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?b++:this.isBlockEndToken(g,u[c+1],t)&&b--,b===0&&!E&&this.isElseKeyword(g.value,t)){E=true;continue}(E?h:y).push(g);}let C={type:"expression",raw:this.joinTokenText(d)},A=this.parseBranch(y,r,t),z=h.length>0?this.parseBranch(h,r,t):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(o),null):wi(C,A,z,{sourceLanguage:t,patternId:`conditional-${t}-folded`,confidence:1})}joinTokenText(e){return e.map(r=>r.kind==="keyword"?r.normalized??r.value:r.value).join(" ").trim()}tokensBeginCommand(e,r,t){if(e.length===0)return false;let n=new te(e,t);return Q.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),n=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!n(u)||s.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&t(l))return true}return false}parseBranch(e,r,t){if(e.length===0)return [];let n=new te(e,t),a=this.parseBodyWithClauses(n,r,t);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=H(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),u=F.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let d=1;if(d<n.length){let f=n[d];(f.kind==="keyword"||f.kind==="particle")&&(d++,l++);}if(d<n.length){let f=n[d];if(f.kind==="literal"){let y=f.value.match(/^(\d+)(ms|s|m)?$/);if(y){let h=parseInt(y[1],10),E=y[2]||"ms";E==="s"?h*=1e3:E==="m"&&(h*=6e4),s[u]=h,l=d+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let m=n.slice(l);if(m.length===0)return {modifiers:null,remainingInput:null};let c=m[0].position.start,p=e.slice(c);return {modifiers:s,remainingInput:p}}stripAsyncModifier(e,r){let t=N(r)?.keywords?.async,n=new Set(["async"]);t?.primary&&n.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=H(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=H(e,r).tokens;for(let n=0;n<t.length-1;n++){if(t[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<t.length;l++){let m=t[l];if(m.normalized?.toLowerCase()==="throw"){a=l;break}let c=m.kind;if(c==="selector"||c==="literal"||c==="reference"||c==="conjunction")break}if(a===-1)continue;let o=t[n].position.start,u=t[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let n=e.mark(),a=e.peek();if(!a)break;let o=(a.normalized||a.value).toLowerCase();if(!F.OR_KEYWORDS.has(o)){e.reset(n);break}e.advance();let u=e.peek();if(!u){e.reset(n);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};J.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);J.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);J.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])};J.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};J.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};J.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);J.CONDITION_COPULAS_SURFACE=new Set(["est","\u0435\u0441\u0442\u044C","\u0454","\xE9","ay","\u0647\u0648","adalah","\u0E40\u0E1B\u0E47\u0E19","\u09B9\u09AF\u09BC","\u0939\u0948","dir","kanqa"]);J.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);J.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);J.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};J.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var ma=J,pa=new ma;function da(i,e){return pa.parse(i,e)}function fa(i,e){try{let r=H(i,e),t=ae(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...t].sort((l,m)=>m.priority-l.priority),a=n.filter(l=>l.command==="on"),o=Q.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=n.filter(l=>l.command!=="on"),s=Q.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${i}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Zr(i,e){try{let t=da(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:H(i,e).tokens.length}}catch{}let r=fa(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Xr(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,n)=>{let a=t[r]??99,o=n[r]??99;return a-o})}function ya(i,e){let r=i.markerOverride?.[e.code],t=e.roleMarkers[i.role];if(r!==void 0)return {primary:r,position:t?.position??"before",isOverride:true};if(t&&t.primary){let n={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(n.alternatives=t.alternatives),n}return null}function Ve(i,e){let r,t;if(i.markerOverride&&i.markerOverride[e.code]!==void 0)r=i.markerOverride[e.code];else {let a=e.roleMarkers[i.role];a&&(r=a.primary,t=a.alternatives?[...a.alternatives]:void 0);}let n=i.markerVariants?.[e.code];if(n&&n.length>0){let a=t?[...t]:[];for(let o of n)o!==r&&!a.includes(o)&&a.push(o);t=a;}return {marker:r,alternatives:t}}function Pe(i,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(i.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function ha(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let m of l)a.push({type:"literal",value:m});else {let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(m);}}let o=e.roleMarkers.destination;o&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),a.push(...Ee(i,e.roleMarkers.source)),a.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function va(i,e,r,t,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let s=t.primary.split(/\s+/);if(s.length>1)for(let l of s)a.push({type:"literal",value:l});else {let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(l);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),a.push(...Ee(i,e.roleMarkers.source)),a.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function ga(i,e,r,t,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),a.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let m of l)a.push({type:"literal",value:m});else {let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(m);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${i.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Ea(i,e,r,t,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(m=>!m.includes(" ")&&m.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let m=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(m);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...Ee(i,e.roleMarkers.source)),a.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function za(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${i.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function ka(i,e,r,t){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${i.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function ba(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let c=t.primary.split(/\s+/);if(c.length>1)for(let p of c)a.push({type:"literal",value:p});else {let p=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(p);}}let u=[...i.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.sovPosition??999,f=p.sovPosition??999;return d-f});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:p,alternatives:d}=Ve(c,e);if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(c=>`{${c.role}}`).join(" "),m={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Pe(a,m,i),{id:`${i.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:a},extraction:m}}function wa(i,e,r,t,n){let a=[],u=[...i.roles.filter(m=>m.required)].sort((m,c)=>{let p=m.sovPosition??999,d=c.sovPosition??999;return p-d});for(let m of u){a.push({type:"role",role:m.role,optional:false});let{marker:c,alternatives:p}=Ve(m,e);c&&a.push(p?{type:"literal",value:c,alternatives:p}:{type:"literal",value:c});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),t.position==="after"){let m=t.primary.split(/\s+/);if(m.length>1)for(let c of m)a.push({type:"literal",value:c});else a.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary});}let s=u.map(m=>`{${m.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Pe(a,l,i),{id:`${i.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${t.primary}`,tokens:a},extraction:l}}function Ca(i,e,r,t,n){let a=[],u=[...i.roles.filter(h=>h.required)].sort((h,E)=>{let b=h.sovPosition??999,C=E.sovPosition??999;return b-C}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:m}=Ve(s,e);if(l){let h=m?{type:"literal",value:l,alternatives:m}:{type:"literal",value:l};a.push(h);}if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let h=t.primary.split(/\s+/);if(h.length>1)for(let E of h)a.push({type:"literal",value:E});else {let E=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(E);}}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(c);let p=u[1];a.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:f}=Ve(p,e);if(d){let h=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};a.push(h);}let y={action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return Pe(a,y,i),{id:`${i.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${p.role}}`,tokens:a},extraction:y}}function Tr(i,e,r,t,n){let a=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Ee(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function Aa(i,e,r,t,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Ee(i,e.roleMarkers.source)),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}return a.push({type:"role",role:"event",optional:false}),{id:`${i.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function Sa(i,e,r,t,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...i.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of s){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}a.push({type:"role",role:c.role,optional:false});}if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(c);}a.push({type:"role",role:"event",optional:false});let l=s.map(c=>`{${c.role}}`).join(" "),m={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return Pe(a,m,i),{id:`${i.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:a},extraction:m}}function Br(i,e,r,t,n){let a=[];if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(c);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...i.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of s){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(f);}a.push({type:"role",role:c.role,optional:false});}let l=s.map(c=>`{${c.role}}`).join(" "),m={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))};return Pe(a,m,i),{id:`${i.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:m}}function Da(i,e,r,t,n){let a=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Ee(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${t.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}function xa(i,e,r,t){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Ee(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...ge(i)}}}var Te={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function er(i,e,r=Te){let t=`${i.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[i.action];if(!a)throw new Error(`No keyword translation for '${i.action}' in ${e.code}`);let o=Oa(i,e,a),u=nr(i,e),s=_a(i,e,a);return {id:t,language:e.code,command:i.action,priority:n,template:{format:s,tokens:o},extraction:u}}function Ta(i,e,r=Te){if(i.roles.filter(u=>!u.required).length===0)return null;let n=i.roles.filter(u=>u.required),a={...i,roles:n};return {...er(a,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:nr(i,e)}}function Ba(i,e,r=Te){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(u=>u.required);if(t.length!==1)return null;let n=e.keywords[i.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=t.map(u=>({type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes}));return {id:`${i.action}-${e.code}-generated-verb-first`,language:e.code,command:i.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${t[0].role}>`,tokens:[a,...o]},extraction:nr(i,e)}}function Fa(i,e,r=Te){let t=[];if(t.push(er(i,e,r)),r.generateSimpleVariants){let n=Ta(i,e,r);n&&t.push(n);}for(let n of i.omitRoleVariants??[]){let a={...i,roles:i.roles.filter(u=>u.role!==n)},o=er(a,e,r);t.push({...o,id:`${i.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let n=Ba(i,e,r);n&&t.push(n);}return t}function Jr(i,e=Te){let r=[],t=$n();for(let n of t){if(!i.keywords[n.action])continue;let a=Fa(n,i,e);if(r.push(...a),i.eventHandler?.eventMarker){let o=La(n,i,e);r.push(...o);}}return r}function La(i,e,r=Te){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],n=e.eventHandler.eventMarker,a=e.keywords[i.action];if(!a)return [];if(i.roles.length===0)return [];let u=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push(ba(i,e,a,n,r)),t.push(Ca(i,e,a,n,r)),t.push(wa(i,e,a,n,r));else {t.push(ha(i,e,a,n,r)),t.push(va(i,e,a,n,r));let s=e.roleMarkers.destination;s&&s.primary!==n.primary&&t.push(ga(i,e,a,n,r));let l=n.primary.split(/\s+/),m=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&m&&t.push(Ea(i,e,a,n,r)),t.push(za(i,e,a,n,r));let c=ka(i,e,a,r);c&&t.push(c);}else e.wordOrder==="VSO"?u?(t.push(Br(i,e,a,n,r)),t.push(Sa(i,e,a,n,r))):(t.push(Tr(i,e,a,n,r)),t.push(Aa(i,e,a,n,r)),e.eventHandler?.negationMarker&&t.push(Da(i,e,a,n,r)),e.tokenization?.prefixes&&t.push(xa(i,e,a,r))):u?t.push(Br(i,e,a,n,r)):t.push(Tr(i,e,a,n,r));return t}function Oa(i,e,r){let t=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=Pa(i,e);switch(e.wordOrder){case "SVO":t.push(n),t.push(...a);break;case "SOV":t.push(...a),t.push(n);break;case "VSO":t.push(n),t.push(...a);break;default:t.push(n),t.push(...a);}return Ra(t)}function Ra(i){let e=[];for(let r of i){let t=e[e.length-1];if(t&&t.type==="literal"&&r.type==="literal"&&t.value===r.value){let n=[...t.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...t,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function Pa(i,e){let r=[],t=Xr(i.roles,e.wordOrder);for(let n of t){let a=Na(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Na(i,e){let r=[],t=i.markerOverride?.[e.code],n=e.roleMarkers[i.role],a={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(t!==void 0){let o=t?t.split(/\s+/).filter(Boolean):[],u=n?.position??"before",s=i.markerOptional?.[e.code]===true,l=m=>{let c={type:"literal",value:m};r.push(s?{type:"group",optional:true,tokens:[c]}:c);};if(u==="before"){for(let m of o)l(m);r.push(a);}else {r.push(a);for(let m of o)l(m);}}else if(n){let o=i.markerVariants?.[e.code]??[],u=()=>{let l=[...new Set([...n.alternatives??[],...o])].filter(m=>m!==n.primary);return l.length?{type:"literal",value:n.primary,alternatives:l}:{type:"literal",value:n.primary}},s=l=>{r.push(e.markersOptional||i.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[l]}:l);};n.position==="before"?(n.primary&&s(u()),r.push(a)):(r.push(a),s(u()));}else r.push(a);return r}function Ma(i,e){let r={};for(let t of i.roles){let n=t.markerOverride?.[e.code],a=e.roleMarkers[t.role];if(n!==void 0)r[t.role]=n?{marker:n}:{};else if(a&&a.primary){let o=t.markerVariants?.[e.code]??[],u=[...new Set([...a.alternatives??[],...o])].filter(s=>s!==a.primary);r[t.role]=u.length?{marker:a.primary,markerAlternatives:u}:{marker:a.primary};}else r[t.role]={};}return r}function nr(i,e){let r=Ma(i,e),t={};for(let n of i.roles){let a=r[n.role]||{};!n.required&&n.default?t[n.role]={...a,default:n.default}:t[n.role]=a;}return t}function _a(i,e,r){let t=[],a=Xr(i.roles,e.wordOrder).map(o=>{let u=ya(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":t.push(r.primary,...a);break;case "SOV":t.push(...a,r.primary);break;default:t.push(r.primary,...a);}return t.join(" ")}var Ia=class{constructor(i={}){this.cache=new Map,this.config={maxSize:i.maxSize??1e3,ttlMs:i.ttlMs??0,enabled:i.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(i,e){return `${e}:${i}`}isExpired(i){return this.config.ttlMs===0?false:Date.now()-i.createdAt>this.config.ttlMs}evictLRU(){let i=this.cache.keys().next().value;i!==void 0&&(this.cache.delete(i),this.stats.evictions++);}get(i,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(i,e),t=this.cache.get(r);if(!t){this.stats.misses++;return}if(this.isExpired(t)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),t.lastAccessed=Date.now(),this.cache.set(r,t),this.stats.hits++,t.result}set(i,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let t=this.makeKey(i,e),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:n,lastAccessed:n});}has(i,e){if(!this.config.enabled)return false;let r=this.makeKey(i,e),t=this.cache.get(r);return t?this.isExpired(t)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(i,e){let r=this.makeKey(i,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let i=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:i>0?this.stats.hits/i:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(i){if(i.maxSize!==void 0)for(this.config.maxSize=i.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();i.ttlMs!==void 0&&(this.config.ttlMs=i.ttlMs),i.enabled!==void 0&&(this.config.enabled=i.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new Ia;function ja(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(i)}function Va(i){for(let e of i)if(ja(e))return true;return false}function ar(i){return "a\u0131ouAIOU".includes(i)}function et(i){return "ei\xF6\xFCE\u0130\xD6\xDC".includes(i)}function rt(i){return ar(i)||et(i)}function $a(i){for(let e=i.length-1;e>=0;e--)if(rt(i[e]))return i[e];return null}function qa(i,e){let r=$a(i);if(!r)return true;let t=e.split("").find(n=>rt(n));return t?ar(r)?ar(t):et(t):true}var Wa=[{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}],tt=class{constructor(){this.language="tr";}isNormalizable(i){return !(!Va(i)||i.length<3)}normalize(i){let e=i.toLowerCase();for(let r of Wa)if(e.endsWith(r.pattern)){let t=e.slice(0,-r.pattern.length),n=r.minStemLength??2;if(t.length<n)continue;if(!qa(t,r.pattern)){let o=r.confidence*.9,u={removedSuffixes:[r.pattern]};return r.conjugationType&&(u.conjugationType=r.conjugationType),Ge(t,o,u)}let a={removedSuffixes:[r.pattern]};return r.conjugationType&&(a.conjugationType=r.conjugationType),Ge(t,r.confidence,a)}return vr(i)}},it={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:true,markersOptional:true,verb:{position:"end",suffixes:["mek","mak","yor","di","mi\u015F"],subjectDrop:true},references:{me:"ben",it:"o",you:"sen",result:"sonu\xE7",event:"olay",target:"hedef",body:"g\xF6vde"},possessive:{marker:"\u0131n",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"benim",it:"onun",you:"senin"},keywords:{benim:"me",senin:"you",onun:"it"}},roleMarkers:{patient:{primary:"i",alternatives:["\u0131","u","\xFC","yi","y\u0131","yu","y\xFC","ni","n\u0131","nu","n\xFC"],position:"after"},destination:{primary:"e",alternatives:["a","ye","ya","ne","na","de","da","te","ta","\u0131n","in","un","\xFCn","n\u0131n","nin","nun","n\xFCn"],position:"after"},source:{primary:"den",alternatives:["dan","ten","tan"],position:"after"},style:{primary:"le",alternatives:["la","yle","yla"],position:"after"},event:{primary:"i",alternatives:["\u0131","u","\xFC"],position:"after"}},keywords:{toggle:{primary:"de\u011Fi\u015Ftir",alternatives:["a\xE7/kapat"],normalized:"toggle"},add:{primary:"ekle",normalized:"add"},remove:{primary:"kald\u0131r",alternatives:["sil"],normalized:"remove"},put:{primary:"koy",normalized:"put"},append:{primary:"ili\u015Ftir",normalized:"append"},prepend:{primary:"ba\u015F\u0131naekle",normalized:"prepend"},take:{primary:"tut",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"klonla",normalized:"clone"},swap:{primary:"takas",normalized:"swap"},morph:{primary:"d\xF6n\xFC\u015Ft\xFCr",alternatives:["\u015Fekil de\u011Fi\u015Ftir"],normalized:"morph"},set:{primary:"ayarla",alternatives:["belirle"],normalized:"set"},get:{primary:"al",normalized:"get"},increment:{primary:"art\u0131r",normalized:"increment"},decrement:{primary:"azalt",normalized:"decrement"},log:{primary:"kaydet",normalized:"log"},show:{primary:"g\xF6ster",normalized:"show"},hide:{primary:"gizle",normalized:"hide"},transition:{primary:"ge\xE7i\u015F",normalized:"transition"},on:{primary:"\xFCzerinde",alternatives:["zaman"],normalized:"on"},trigger:{primary:"tetikle",normalized:"trigger"},send:{primary:"g\xF6nder",normalized:"send"},focus:{primary:"odak",alternatives:["odaklanma"],normalized:"focus"},blur:{primary:"bulan\u0131k",alternatives:["bulan\u0131kl\u0131k","bulanik"],normalized:"blur"},empty:{primary:"bo\u015Falt",alternatives:["bosalt","bo\u015F"],normalized:"empty"},open:{primary:"a\xE7",alternatives:["ac"],normalized:"open"},close:{primary:"kapat",normalized:"close"},select:{primary:"vurgula",normalized:"select"},clear:{primary:"temizle",normalized:"clear"},reset:{primary:"s\u0131f\u0131rla",alternatives:["sifirla"],normalized:"reset"},breakpoint:{primary:"kesme-noktas\u0131",alternatives:["kesme-noktasi"],normalized:"breakpoint"},click:{primary:"t\u0131klama",alternatives:["t\u0131kla","tiklama","t\u0131k","tik"],normalized:"click"},hover:{primary:"\xFCzerine gelme",alternatives:["\xFCzerinde gezinme"],normalized:"hover"},submit:{primary:"g\xF6nderme",normalized:"submit"},input:{primary:"giri\u015F",alternatives:["girdi","giris"],normalized:"input"},change:{primary:"de\u011Fi\u015Fiklik",alternatives:["de\u011Fi\u015Fim","degisim"],normalized:"change"},load:{primary:"y\xFCkle",normalized:"load"},go:{primary:"git",normalized:"go"},scroll:{primary:"kayd\u0131r",alternatives:["kaydir"],normalized:"scroll"},push:{primary:"itele",alternatives:["push"],normalized:"push"},replace:{primary:"de\u011Fi\u015Ftir_url",alternatives:["degistir_url"],normalized:"replace"},process:{primary:"i\u015Fle",alternatives:["isle"],normalized:"process"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},unless:{primary:"de\u011Filse",normalized:"unless"},when:{primary:"iken",alternatives:["durumunda","oldu\u011Funda"],normalized:"when"},where:{primary:"nerede",normalized:"where"},else:{primary:"yoksa",normalized:"else"},repeat:{primary:"tekrarla",normalized:"repeat"},for:{primary:"i\xE7in",normalized:"for"},while:{primary:"s\xFCresince",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"devam",normalized:"continue"},halt:{primary:"durdur",normalized:"halt"},throw:{primary:"f\u0131rlat",normalized:"throw"},call:{primary:"\xE7a\u011F\u0131r",normalized:"call"},return:{primary:"d\xF6n",normalized:"return"},then:{primary:"ard\u0131ndan",alternatives:["daha sonra","ardindan"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},or:{primary:"veya",normalized:"or"},not:{primary:"de\u011Fil",alternatives:["degil"],normalized:"not"},end:{primary:"son",alternatives:["biti\u015F","bitti"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asenkron",normalized:"async"},tell:{primary:"s\xF6yle",normalized:"tell"},default:{primary:"varsay\u0131lan",normalized:"default"},init:{primary:"ba\u015Flat",normalized:"init"},behavior:{primary:"davran\u0131\u015F",normalized:"behavior"},install:{primary:"kur",alternatives:["y\xFCklemek"],normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"dur",normalized:"break"},copy:{primary:"kopyala",normalized:"copy"},exit:{primary:"\xE7\u0131k",normalized:"exit"},pick:{primary:"se\xE7",normalized:"pick"},render:{primary:"render",normalized:"render"},into:{primary:"i\xE7ine",normalized:"into"},before:{primary:"\xF6nce",normalized:"before"},after:{primary:"sonra",normalized:"after"},until:{primary:"kadar",normalized:"until"},event:{primary:"olay",normalized:"event"},from:{primary:"den",alternatives:["dan"],normalized:"from"},connect:{primary:"ba\u011Flan",alternatives:["ba\u011Fla","ba\u011Flant\u0131"],normalized:"connect"},stream:{primary:"yay\u0131nla",alternatives:["ak\u0131t","ak\u0131\u015F"],normalized:"stream"},live:{primary:"canl\u0131",alternatives:["ger\xE7ek-zamanl\u0131"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"bind",normalized:"bind"},intercept:{primary:"yakala",alternatives:["araya-gir","intercept"],normalized:"intercept"},worker:{primary:"i\u015F\xE7i",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["olay-kayna\u011F\u0131"],normalized:"eventsource"}},eventHandler:{eventMarker:{primary:"da",alternatives:["de","ta","te"],position:"after"},temporalMarkers:["d\u0131\u011F\u0131nda","di\u011Finde"]}},Ka=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Ua=class{constructor(i=Ka){this.name="operator",this.operators=[...i].sort((e,r)=>r.length-e.length);}canExtract(i,e){return this.operators.some(r=>i.startsWith(r,e))}extract(i,e){for(let r of this.operators)if(i.startsWith(r,e))return {value:r,length:r.length};return null}},Ha="()[]{},:;",Ga=class{constructor(i=Ha){this.punctuation=i,this.name="punctuation";}canExtract(i,e){return this.punctuation.includes(i[e])}extract(i,e){let r=i[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Qr(i,e){let r=i[e];if(r==="#"){let t=i.slice(e).match(/^#[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="."){let t=i.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(t)return t[0];let n=i.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="@"){let t=i.slice(e).match(/^@[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="*"){let t=i.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="["){let t=0,n=e;for(;n<i.length;){if(i[n]==="["&&t++,i[n]==="]"&&(t--,t===0))return i.slice(e,n+1);n++;}return null}if(r==="<"){let t=i.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return t?t[0]:null}return null}var Ya=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Qr(i,e)!==null:false}extract(i,e){let r=Qr(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Za=class{constructor(){this.name="event-modifier";}canExtract(i,e){if(i[e]!==".")return false;let r=i.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(i,e){let r=i.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let t=r[0],n=t.slice(1).split("(")[0],a=r[1];return {value:t,length:t.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}};function Xa(i,e){let r=i.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let t=r.match(/^https?:\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("//")){let t=r.match(/^\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("./")||r.startsWith("../")){let t=r.match(/^\.\.?\/[^\s]*/);return t?t[0]:null}if(r.startsWith("/")){let t=r.match(/^\/[^\s]*/);return t?t[0]:null}return null}var Ja=class{constructor(){this.name="url";}canExtract(i,e){let r=i.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(i,e){let r=Xa(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Qa=class{constructor(){this.name="variable-ref";}canExtract(i,e){let r=i[e];return (r===":"||r==="$"||r==="^")&&e+1<i.length&&/[a-zA-Z_]/.test(i[e+1])}extract(i,e){if(!this.canExtract(i,e))return null;let r=1;for(;e+r<i.length&&/[a-zA-Z0-9_]/.test(i[e+r]);)r++;return {value:i.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function qe(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(i)}var eo=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),ro=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"]),to=class{constructor(){this.name="turkish-keyword";}setContext(i){this.context=i;}canExtract(i,e){return qe(i[e])}extract(i,e){if(!this.context)throw new Error("TurkishKeywordExtractor: context not set");let r=e,t=12;for(let c=Math.min(t,i.length-r);c>=2;c--){let p=i.slice(r,r+c);if(r+c<i.length&&qe(i[r+c]))continue;let d=true;for(let y=0;y<p.length;y++)if(!qe(p[y])){d=false;break}if(!d)continue;let f=this.context.lookupKeyword(p);if(f)return {value:p,length:c,metadata:{normalized:f.normalized!==f.native?f.normalized:void 0}};if(this.context.normalizer){let y=this.context.normalizer.normalize(p);if(y.stem!==p&&y.confidence>=.7){let h=this.context.lookupKeyword(y.stem);if(h)return {value:p,length:c,metadata:{normalized:h.normalized,stem:y.stem,stemConfidence:y.confidence}}}}}let n="",a=e;for(;a<i.length&&qe(i[a]);)n+=i[a],a++;for(let c=n.length;c>=2&&!(c<n.length);c--){let p=n.substring(0,c),d=this.context.lookupKeyword(p);if(d)return {value:p,length:c,metadata:{normalized:d.normalized!==d.native?d.normalized:void 0}}}if(!n||!n)return null;if(eo.has(n.toLowerCase()))return {value:n,length:a-r,metadata:{postpositionValue:n.toLowerCase()}};if(ro.has(n.toLowerCase()))return {value:n,length:a-r,metadata:{caseSuffixValue:n.toLowerCase()}};let o=this.context.lookupKeyword(n),u=o&&o.normalized!==o.native?o.normalized:void 0,s,l,m;if(!o&&this.context.normalizer){let c=this.context.normalizer.normalize(n);if(c.stem!==n&&c.confidence>=.7){let p=this.context.lookupKeyword(c.stem);p&&(s=p.normalized,l=c.stem,m=c.confidence);}}return {value:n,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:m}}}};function io(){return new to}function no(){return [new Ja,new Za,new Qa,new Ya]}var ao=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","boyunca"]),oo=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"]),uo=[{native:"do\u011Fru",normalized:"true"},{native:"dogru",normalized:"true"},{native:"yanl\u0131\u015F",normalized:"false"},{native:"yanlis",normalized:"false"},{native:"null",normalized:"null"},{native:"bo\u015F",normalized:"null"},{native:"bos",normalized:"null"},{native:"tan\u0131ms\u0131z",normalized:"undefined"},{native:"tanimsiz",normalized:"undefined"},{native:"ilk",normalized:"first"},{native:"son",normalized:"last"},{native:"sonuncu",normalized:"last"},{native:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"enyak\u0131n",normalized:"closest"},{native:"enyakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{native:"farebas",normalized:"mousedown"},{native:"fareb\u0131rak",normalized:"mouseup"},{native:"farebirak",normalized:"mouseup"},{native:"kayd\u0131r",normalized:"scroll"},{native:"kaydir",normalized:"scroll"},{native:"tu\u015F_bas",normalized:"keydown"},{native:"tus_bas",normalized:"keydown"},{native:"tu\u015F_b\u0131rak",normalized:"keyup"},{native:"tus_birak",normalized:"keyup"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"}],so=class extends hr{constructor(){super(),this.language="tr",this.direction="ltr",this.initializeKeywordsFromProfile(it,uo),this.setNormalizer(new tt),this.registerExtractors(no()),this.registerExtractor(new pr),this.registerExtractor(new dr),this.registerExtractor(io()),this.registerExtractor(new Ua),this.registerExtractor(new Ga);}classifyToken(i){let e=i.toLowerCase();return ao.has(e)||oo.has(e)?"particle":this.isKeyword(e)?"keyword":i.startsWith("/")||i.startsWith("./")||i.startsWith("../")||i.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||i.startsWith("'")||/^\d/.test(i)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(i)?"operator":"identifier"}},lo=new so;Ir("tr",lo,it);function We(i){let e=i.getAttribute("data-lang");if(e)return or(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return or(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?or(t):null}function or(i){return i.split("-")[0].toLowerCase()}var nt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"]],on:[["event",""],["source","from"]],open:[["style","as"],["patient",""]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"],["scope","on"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],socket:[],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],while:[["condition",""]],worker:[]};function Ke(i){switch(i.kind){case "event-handler":return co(i);case "compound":return mo(i);default:return po(i)}}function co(i){let e=["on"],r=i.roles.get("event");r&&e.push(Ne(r));let t=i.roles.get("source");if(t&&e.push("from",Ne(t)),i.body&&i.body.length>0){let n=i.body.map(Ke);e.push(n.join(" then "));}return e.join(" ")}function mo(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(Ke).join(` ${e} `)}function po(i){let e=nt[i.action];if(e){let t=[i.action];for(let[n,a]of e){let o=i.roles.get(n);o&&(n==="destination"&&o.type==="reference"&&o.value==="me"||(a&&t.push(a),t.push(Ne(o))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(Ne(t));return r.join(" ")}function Ne(i){switch(i.type){case "literal":return typeof i.value=="string"&&i.dataType==="string"?`"${i.value}"`:String(i.value);case "selector":return i.value;case "reference":return i.value;case "property-path":return fo(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function fo(i){let e=Ne(i.object),r=i.property;if(i.object.type==="reference")switch(i.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var ot=.5,yo={confidenceThreshold:ot,strategy:"semantic",fallbackToOriginal:true};function ho(i,e){return typeof i=="number"?i:i[e]??i["*"]??ot}function ur(i,e,r={}){let t={...yo,...r},n=at(i,e,t);if(n!==null)return n;let a=go(i);if(a){let o=at(a.commands,e,t);if(o!==null)return a.prefix+o}return i}function at(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=ho(r.confidenceThreshold,e),n=ut(i,e,t);if(n!==null)return n}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=Eo(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var vo=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function go(i){let e=i.match(vo);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function ut(i,e,r){try{let t=ko(i,e);if(t.length>1)return bo(t,e,r);if(!Vr(e))return null;let n=Zr(i,e);return n.confidence<r||!n.node?null:Ke(n.node)}catch{return null}}function Eo(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function zo(i){let e=["then"],r=N(i);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let n of t.alternatives)e.includes(n)||e.push(n);}return e}function ko(i,e){let t=zo(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),a=i.split(`
5
- `).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of a){let s=u.split(n);o.push(...s);}return o}function bo(i,e,r){let t=[];for(let n of i){let a=ut(n.trim(),e,r);if(a===null)return null;t.push(a);}return t.join(" then ")}function sr(i={}){return function(r){let{internals:t}=r,n=t.runtime,a=n.getScript.bind(n);n.getScript=function(o){let u=a(o);if(!u)return null;let s=wo(o,i);if(!s||s==="en")return u;let l=ur(u,s,i);return i.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function wo(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=We(i);return r||(e.defaultLanguage??null)}function st(i,e,r={}){return e==="en"?i:ur(i,e,r)}jr(i=>Jr(i));function lt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(sr()),Co());}function Co(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(t=>{let n=e.getInternalData(t);n.initialized&&(n.initialized=false);}),e.processNode(document.body);}var Hu=["tr"];lt();exports.plugin=sr;exports.preprocess=st;exports.resolveLanguage=We;exports.supportedLanguages=Hu;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function ue(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function We(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Re(i){return {type:"reference",value:i}}function Ke(i,e){return {type:"property-path",object:i,property:e}}var xr=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function ar(i,e=xr){return e.has(i)}var Ht=class{constructor(i){this.namespace=i,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let i=process.env.DEBUG||"";return i==="*"||i.includes("framework:*")||i.includes(`framework:${this.namespace}`)}return false}log(i,e,...r){if(!this.enabled)return;let t=`[framework:${this.namespace}]`,n=new Date().toISOString();switch(i){case "debug":console.debug(`${n} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${t} WARN:`,e,...r);break;case "error":console.error(`${n} ${t} ERROR:`,e,...r);break}}debug(i,...e){this.log("debug",i,...e);}info(i,...e){this.log("info",i,...e);}warn(i,...e){this.log("warn",i,...e);}error(i,...e){this.log("error",i,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Gt(i){return new Ht(i)}function Ce(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Yt(i,e){return i?.possessive?.keywords?.[e]}var Pe=class Ae{constructor(){this.logger=Gt("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,t){let n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",t?.code);}this.currentProfile=t,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:u}}matchBest(e,r,t){let n=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&n.push(s),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let v=this.collectStopMarkers(r,l+1);if(n)for(let h of n)v.add(h);let f=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||this.isStopMarker(h,v))break;f.push(h.value),e.advance();}if(f.length>0){t.set(c.role,{type:"expression",raw:f.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(n)for(let h of n)v.add(h);if(this.matchGroupToken(e,c,t,v)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let p=c.type==="role"&&c.optional===true,d=p?e.mark():null;if(c.type==="role"&&!p){let v=l+1<r.length?r[l+1]:null;if(v?.type==="literal"){let f=e.peek();if(f&&this.getMatchType(f,v.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}}let E=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",E),E){p?(u=d,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let v=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",v),v)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let n=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(t,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!Ce(a.type,r.expectedTypes)?r.optional||false:(t.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ce(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ce(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Ce(s.type,r.expectedTypes)?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!Ce(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let c=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!Ce(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),t.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=r.normalized||r.value,n=this.safeToLowerCase(t),a=Yt(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Ke(Re(a),l)}return 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 r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<Ae.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}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${a.value}`,u=1;for(;!e.isAtEnd()&&u<Ae.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<Ae.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(t),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(t),null):(e.advance(),Ke(We(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(t),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return Ke(We(r.value),o)}matchGroupToken(e,r,t,n){let a=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,n))return true;e.reset(a);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=Ae.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,t,n))return true;e.reset(a);for(let d of t.keys())o.has(d)||t.delete(d);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let t=new Set;for(let n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(t.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)t.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!a.optional)break}}return t}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return We(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return ue(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Re(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return ue(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return ue(n,"string")}if(e==="true")return ue(true,"boolean");if(e==="false")return ue(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?ue(e,"duration"):ue(n,"number")}let t=parseFloat(e);return isNaN(t)?ue(e,"string"):ue(t,"number")}applyExtractionRules(e,r){for(let[t,n]of Object.entries(e.extraction))r.has(t)||(n.value!==void 0?r.set(t,{type:"literal",value:n.value}):n.default&&r.set(t,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=a(c.role),p=.8;n+=p,r.has(c.role)?t+=p:m&&(t+=p*.6);}}let o=n>0?t/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let t=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(t.has(r.value))return .15;if(r.alternatives){for(let n of r.alternatives)if(t.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,n={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[a,o]of r.entries()){let u=n[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if(Ae.ENGLISH_NOISE_WORDS.has(t)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(t=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return t?r:void 0}};Pe.MAX_MARKER_SCAN=3;Pe.MAX_PROPERTY_DEPTH=10;Pe.MAX_METHOD_ARGS=20;Pe.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Zt=Pe;new Zt;var Fr=class{constructor(){this.name="string-literal";}canExtract(i,e){let r=i[e];return r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(i,e){let r=i[e];if(r==="\u201C"){let a=1;for(;e+a<i.length;){if(i[e+a]==="\u201D")return a++,{value:i.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<i.length;){if(i[e+a]==="\u2019")return a++,{value:i.substring(e,e+a),length:a};a++;}return null}let t=1,n=false;for(;e+t<i.length;){let a=i[e+t];if(n){n=false,t++;continue}if(a==="\\"){n=true,t++;continue}if(a===r)return t++,{value:i.substring(e,e+t),length:t};t++;}return null}},Lr=class{constructor(){this.name="number";}canExtract(i,e){return /\d/.test(i[e])}extract(i,e){let r=0,t=false;for(;e+r<i.length;){let o=i[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let n=i.substring(e,e+r),a=e+r;if(a<i.length){let o=i.slice(a),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function Xt(i){return "setContext"in i&&typeof i.setContext=="function"}function Jt(i){let e={language:i.language,direction:i.direction,lookupKeyword:i.lookupKeyword.bind(i),isKeyword:i.isKeyword.bind(i),isKeywordStart:i.isKeywordStart.bind(i),...i.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:i.isKeywordStartAtBoundary.bind(i)}:{}};return i.normalizer?{...e,normalizer:i.normalizer}:e}var re=class{constructor(i,e){this.pos=0,this.tokens=i,this.language=e;}peek(i=0){let e=this.pos+i;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(i){this.pos=i.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(i){let e=[];for(;!this.isAtEnd()&&i(this.peek());)e.push(this.advance());return e}skipWhile(i){for(;!this.isAtEnd()&&i(this.peek());)this.advance();}};function $(i,e){return {start:i,end:e}}function V(i,e,r,t){if(typeof i=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let n=i;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:n,kind:e,position:r,normalized:t};if(t){let{normalized:a,stem:o,stemConfidence:u,metadata:s}=t;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function Oe(i){return /\s/.test(i)}function Qt(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function ei(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function fe(i){return /\d/.test(i)}function ri(i){return /[a-zA-Z]/.test(i)}function X(i){return /[a-zA-Z0-9_-]/.test(i)}function ti(i,e){if(e>=i.length)return null;let r=i[e];if(!Qt(r))return null;let t=e,n="";if(r==="#"||r==="."){for(n+=i[t++];t<i.length&&X(i[t]);)n+=i[t++];if(n.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let o=t+1;for(;o<i.length&&X(i[o]);)o++;if(o<i.length&&i[o]==="(")return n}}else if(r==="["){let a=1,o=false,u=null,s=false;for(n+=i[t++];t<i.length&&a>0;){let l=i[t];n+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,t++;}if(a!==0)return null}else if(r==="@"){for(n+=i[t++];t<i.length&&X(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="*"){for(n+=i[t++];t<i.length&&X(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="<"){if(n+=i[t++],t>=i.length||!ri(i[t]))return null;for(;t<i.length&&X(i[t]);)n+=i[t++];for(;t<i.length;){let a=i[t];if(a==="."){if(n+=i[t++],t>=i.length||!X(i[t]))return null;for(;t<i.length&&X(i[t]);)n+=i[t++];}else if(a==="#"){if(n+=i[t++],t>=i.length||!X(i[t]))return null;for(;t<i.length&&X(i[t]);)n+=i[t++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(n+=i[t++];t<i.length&&o>0;){let c=i[t];n+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<i.length&&Oe(i[t]);)n+=i[t++];if(t<i.length&&i[t]==="/")for(n+=i[t++];t<i.length&&Oe(i[t]);)n+=i[t++];if(t>=i.length||i[t]!==">")return null;n+=i[t++];}return n||null}function ii(i,e){if(e>=i.length||i[e]!=="'"||e+1>=i.length||i[e+1].toLowerCase()!=="s")return false;if(e+2>=i.length)return true;let t=i[e+2];return Oe(t)||t==="*"||!X(t)}function ni(i,e){if(e>=i.length)return null;let r=i[e];if(!ei(r)||r==="'"&&ii(i,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,u=false;for(;a<i.length;){let s=i[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===n)return o;a++;}return o}function ai(i,e){if(e>=i.length)return false;let r=i[e],t=i[e+1]||"",n=i[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(t==="/"||t==="."&&n==="/"))return true;let a=i.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function oi(i,e){if(!ai(i,e))return null;let r=e,t="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<i.length;){let a=i[r];if(a==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=a,r++;r<i.length&&/[a-zA-Z0-9_-]/.test(i[r]);)t+=i[r++];break}if(n.test(a))t+=a,r++;else break}return t.length<2?null:t}function ui(i,e){if(e>=i.length)return null;let r=i[e];if(!fe(r)&&r!=="-"&&r!=="+")return null;let t=e,n="";if((i[t]==="-"||i[t]==="+")&&(n+=i[t++]),t>=i.length||!fe(i[t]))return null;for(;t<i.length&&fe(i[t]);)n+=i[t++];if(t<i.length&&i[t]===".")for(n+=i[t++];t<i.length&&fe(i[t]);)n+=i[t++];return t<i.length&&(i.slice(t,t+2)==="ms"?n+="ms":(i[t]==="s"||i[t]==="m"||i[t]==="h")&&(n+=i[t])),n}var si=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(si);var li=new Set(["patient","destination","source","style","event","eventMarker","agent","goal","manner","into","from","to","with","at","of","as","by","in","on","over","under","between","through","without"]),ci=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],He=class Ue{constructor(){this.profileKeywords=[],this.multiWordKeywords=[],this.profileKeywordMap=new Map,this.rawExtraEntries=[],this.extractors=[];}getExtraKeywordEntries(){return this.rawExtraEntries}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Xt(e)&&e.setContext(Jt(this)),this.extractors.push(e);}registerExtractors(e){for(let r of e)this.registerExtractor(r);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let r=[],t=0;for(;t<e.length;){for(;t<e.length&&Oe(e[t]);)t++;if(t>=e.length)break;let n=this.tryMultiWordKeyword(e,t);if(n){r.push(n),t=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,t)){let u=o.extract(e,t);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,m={};if(u.metadata)for(let[d,y]of Object.entries(u.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(m[d]=y);let p={};s&&(p.normalized=s),l&&(p.stem=l),c!==void 0&&(p.stemConfidence=c),Object.keys(m).length>0&&(p.metadata=m),r.push(V(u.value,this.classifyToken(u.value),$(t,t+u.length),Object.keys(p).length>0?p:void 0)),t+=u.length,a=true;break}}if(!a){let o=e[t],u=this.classifyUnknownChar(o);r.push(V(o,u,$(t,t+1))),t++;}}return new re(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let t of e){let n=r[r.length-1];if(n&&Ue.ASCII_WORD.test(n.value)&&Ue.COLON_QUALIFIER.test(t.value)&&n.position.end===t.position.start){let a=n.value+t.value;r[r.length-1]=V(a,this.classifyToken(a),$(n.position.start,t.position.end));continue}r.push(t);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let n=t[t.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return t.push(V(".","operator",$(r,r+1))),true;let s=r+1;for(;s<e.length&&X(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(V(".","operator",$(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[n,a]of Object.entries(e.keywords))if(t.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)t.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))t.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))t.has(n)||t.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&t.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)t.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))t.set(n,{native:n,normalized:a});for(let n of ci)t.has(n)||t.set(n,{native:n,normalized:n});for(let n of r)t.set(n.native,n);this.profileKeywords=Array.from(t.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>n.native.includes(" ")&&!li.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let t of this.profileKeywords)if(e.slice(r).startsWith(t.native))return V(t.native,"keyword",$(r,r+t.native.length),t.normalized);return null}tryMultiWordKeyword(e,r,t=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&t(o)))return V(a.native,"keyword",$(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(n=>t.startsWith(n.native))}isKeywordStartAtBoundary(e,r,t=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!t(o)})}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 r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,t){let n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return V(e,"keyword",$(r,t),o)}trySelector(e,r){let t=ti(e,r);return t?V(t,"selector",$(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let n=t[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=t[1];return {...V(n,"event-modifier",$(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=ni(e,r);return t?V(t,"literal",$(r,r+t.length)):null}tryNumber(e,r){let t=ui(e,r);return t?V(t,"literal",$(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,n=false){let a=r;if(n)for(;a<e.length&&Oe(e[a]);)a++;let o=e.slice(a);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(X(c))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,t=true){let n=r,a="";if(t&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!fe(e[n]))return null;for(;n<e.length&&fe(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&fe(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,t,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,c=[...t,...Ue.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),V(s,"literal",$(r,l))}tryUrl(e,r){let t=oi(e,r);return t?V(t,"url",$(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!X(e[r+1]))return null;let t=r+1;for(;t<e.length&&X(e[t]);)t++;let n=e.slice(r,t);return V(n,"identifier",$(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return V(t,"operator",$(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?V(n,"operator",$(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?V(n,"punctuation",$(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let n of t)if(e.slice(r,r+n.length)===n)return V(n,"particle",$(r,r+n.length));return null}};He.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;He.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;He.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var Rr=He;function Or(i){return {stem:i,confidence:1}}function or(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var mi=Object.defineProperty,pi=Object.getOwnPropertyNames,tt=(i,e)=>function(){return i&&(e=(0, i[pi(i)[0]])(i=0)),e},di=(i,e)=>{for(var r in e)mi(i,r,{get:e[r],enumerable:true});};function Pr(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function Q(i,e,r={},t){let n=it[i],a=Pr(n,r),o=nt[i],u=o?Pr(o,r):void 0;return {code:i,message:a,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var B,it,nt,fi=tt({"src/generators/schema-error-codes.ts"(){B={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},it={[B.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[B.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[B.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[B.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[B.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[B.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[B.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[B.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[B.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[B.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[B.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[B.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[B.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[B.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[B.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[B.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[B.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},nt={[B.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[B.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[B.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[B.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[B.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[B.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[B.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[B.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[B.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[B.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[B.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[B.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[B.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[B.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),at={};di(at,{SchemaErrorCodes:()=>B,formatValidationResults:()=>ki,getValidationStats:()=>bi,validateAllKeywordCollisions:()=>Ci,validateAllSchemas:()=>zi,validateCommandSchema:()=>ot,validateKeywordCollisions:()=>ut,validateRoleValues:()=>wi});function yi(i,e){return {action:i,items:e}}function ot(i){let e=[];for(let t of i.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&pr.has(i.action)?e.push(Q(B.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(Q(B.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!pr.has(i.action)&&e.push(Q(B.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of i.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(Q(B.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":hi(i,e);break;case "on":vi(i,e);break;case "if":case "unless":Ei(i,e);break;case "repeat":case "for":case "while":gi(i,e);break}return i.roles.filter(t=>t.required).length===0&&(st.has(i.action)?e.push(Q(B.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(Q(B.NO_REQUIRED_ROLES,"warning",{}))),yi(i.action,e)}function hi(i,e){let r=i.roles.find(n=>n.role==="patient"),t=i.roles.find(n=>n.role==="goal");r&&!t&&e.push(Q(B.TRANSITION_MISSING_GOAL,"error",{}));}function vi(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(Q(B.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(Q(B.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Ei(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(Q(B.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(Q(B.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function gi(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(Q(B.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(Q(B.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function zi(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[n,a]of Object.entries(i)){let o=ot(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(n,o);}return r}function ki(i,e={}){let r=[],{showNotes:t=false,showCodes:n=true}=e;for(let[a,o]of i){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let c of u){let m=n?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of s){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(t&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
+ `)}function bi(i){let e=0,r=0,t=0,n={};for(let a of i.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:n}}function wi(i,e){let r=[];for(let t of e){let n=i.roles.find(a=>a.role===t.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(t.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects type [${n.expectedTypes.join(", ")}], got '${t.type}'`,code:B.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:B.SELECTOR_KIND_MISMATCH})));}return r}function ut(i){let e=[];if(!i.keywords)return {language:i.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(i.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let u of a.alternatives){let s=r.get(u)||[];s.push({command:n,isPrimary:false}),r.set(u,s);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1)continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>t[n.type]-t[a.type]),{language:i.code,collisions:e}}function Ci(i){let e=[];for(let[,r]of Object.entries(i)){let t=ut(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var pr,st,Ai=tt({"src/generators/schema-validator.ts"(){fi(),pr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),st=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]);}});var Ee=new Map,ce=new Map,_e=new Map,dr=null;function lt(i,e){let r={...i};for(let t of Object.keys(e)){let n=e[t],a=i[t];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[t]=lt(a,n):r[t]=n);}return r}function Si(i,e){return lt(i,e)}function vr(i){if(!i.extends)return i;let e=ce.get(i.extends);if(!e)return console.warn(`[Registry] Profile '${i.code}' extends '${i.extends}' but base is not registered. Make sure to import the base language before the variant.`),i;let r=vr(e);return Si(r,i)}function ct(i,e,r){Ee.set(i,e),ce.set(i,r),_e.delete(i);}function mt(i){dr=i;}var Nr=new Map;function Te(i){return i.split("-")[0]}function Be(i){return i.includes("-")}function Di(i){let e=Ee.get(i);if(!e&&Be(i)){let r=Te(i);e=Ee.get(r);}if(!e){let r=Array.from(Ee.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return e}function xi(i){let e=ce.get(i);if(!e&&Be(i)){let r=Te(i);e=ce.get(r);}if(!e){let r=Array.from(ce.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return vr(e)}function O(i){let e=ce.get(i);return !e&&Be(i)&&(e=ce.get(Te(i))),e?vr(e):void 0}function Ti(){return Array.from(Ee.keys())}function pt(i){if(Ee.has(i)&&ce.has(i))return true;if(Be(i)){let e=Te(i);return Ee.has(e)&&ce.has(e)}return false}function Bi(i,e){return Di(e).tokenize(i)}function le(i){let e=_e.get(i);if(!e&&Be(i)&&(e=_e.get(Te(i))),e)return e;let r=Nr.get(i);if(!r&&Be(i)&&(r=Nr.get(Te(i))),r)return _e.set(i,r),r;if(!dr)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let t=xi(i),n=dr(t);return _e.set(i,n),n}var dt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function ve(i){let e="complex";return i.startsWith("#")&&!i.includes(" ")?e="id":i.startsWith(".")&&!i.includes(" ")?e="class":i.startsWith("[")&&i.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(e="element"),{type:"selector",value:i,selectorKind:e}}function q(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function Se(i){return ar(i)}function ne(i){return {type:"reference",value:i}}function ye(i,e){return {type:"property-path",object:i,property:e}}function te(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Ne(i,e,r,t,n,a){let o=new Map;o.set("event",i);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),n!==void 0&&n.length>0&&(u.parameterNames=n),u}function rn(i,e,r,t,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:i,parameters:e,eventHandlers:r};return t!==void 0&&t.length>0&&(a.initBlock=t),n!==void 0&&(a.metadata=n),a}function tn(i,e,r,t){let n={kind:"def",action:"def",roles:new Map,name:i,parameters:e,body:r};return t!==void 0&&(n.metadata=t),n}function _r(i,e,r,t){let n={kind:"feature",action:i,roles:new Map,body:e};return r!==void 0&&(n.name=r),t!==void 0&&(n.metadata=t),n}function fr(i,e="then",r){let t={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:e};return r!==void 0&&(t.metadata=r),t}function nn(i,e,r,t){let n=new Map;n.set("condition",i);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),t!==void 0&&(a.metadata=t),a}function Ge(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):i==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ze(i){let e=i.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function ke(i){let e=i.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function be(i,e){return ft(i,e,"source")}function Er(i,e){return ft(i,e,"destination")}function ft(i,e,r){if(!e||!i.roles.some(a=>a.role===r))return [];let t=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,t]:[t,n]}]}var an={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},on={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector","literal"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},un={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},sn={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"},markerVariants:{en:["before","after"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},ln={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"},markerVariants:{tr:["e","a","ye","ya"]}},{role:"scope",description:"The element(s) the attribute/property is set on (defaults to me)",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3,markerOverride:{en:"on",es:"on",pt:"on",fr:"on",de:"on",it:"on",id:"on",ms:"on",sw:"on",tl:"on",zh:"on",vi:"on",ru:"on",uk:"on",pl:"on",th:"on",he:"on",ar:"on",ja:"on",ko:"on",tr:"on",hi:"on",bn:"on",qu:"on"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},cn={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},mn={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},pn={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},dn={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},fn={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},yn={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},hn={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},vn={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},En={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},gn={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},zn={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},kn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},bn={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},wn={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},Cn={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},An={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Sn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Dn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",he:"\u05D0\u05EA",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},xn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Tn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Bn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Fn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ln={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Rn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},On={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Pn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Nn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},_n={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Mn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in",es:"en",fr:"en",de:"in",it:"in",pt:"dentro",id:"dalam",ms:"dalam",pl:"w",ru:"\u0432",uk:"\u0443",sw:"ndani",th:"\u0E43\u0E19",vi:"trong",ar:"\u0641\u064A",tl:"sa_loob",he:"in",zh:"\u5728"}}]},In={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},jn={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},gr={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},$n={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""},markerOptional:{en:true},markerVariants:{he:["\u05D0\u05EA"],zh:["\u628A"]}}],rolePrefixLiteralVariants:[{role:"destination",literal:gr,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},Vn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",omitRoleVariants:["goal"],roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal","expression","selector"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"zu",he:"\u05E2\u05DC",it:"in",ja:"\u306B",ko:"\uC5D0",ms:"ke",pl:"do",ru:"\u0432",th:"\u0E43\u0E19",tr:"e",uk:"\u0432",vi:"v\xE0o",zh:"\u5230",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},qn={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},Wn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Kn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Un={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Hn={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},Gn={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Yn={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Zn={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Xn={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Jn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Qn={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},ea={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},ra={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ta={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},ia={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},na={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta",ja:"\u3092",ko:"\uB97C",tr:"i",hi:"\u0915\u094B",de:"",es:"",fr:"",it:"",pt:"",pl:"",ru:"",uk:"",vi:"",id:"",ms:"",th:"",zh:"\u628A",he:"\u05D0\u05EA"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwa",bn:"\u09A4\u09C7",qu:"man",ja:"\u306B",ko:"\uC5D0",tr:"e",hi:"\u092E\u0947\u0902",de:"zu",es:"a",fr:"\xE0",it:"in",pt:"para",pl:"do",ru:"\u0432",uk:"\u0432",vi:"v\xE0o",id:"ke",ms:"ke",th:"\u0E43\u0E19",zh:"\u5230",he:"\u05E2\u05DC"}}]},aa={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},oa={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},ua={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},sa={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},la={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of",es:"",fr:"",pt:"",it:"",de:"",pl:"",ru:"",uk:"",id:"",ms:"",sw:"",th:"",vi:"",he:"\u05D0\u05EA",zh:"\u628A"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}}]},ca={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"destination",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},ma={action:"beep",description:"Debug output for expressions with type information",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The expression(s) to debug",required:false,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},pa={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},da={action:"copy",description:"Copy text or element content to the clipboard",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The text or element to copy",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},fa={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},ya={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},ha={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},va={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Ea={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:gr}]},ga={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:gr}]},za={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:va}]},ka={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ge={toggle:an,add:on,remove:un,put:sn,set:ln,show:hn,hide:vn,on:En,trigger:gn,wait:zn,fetch:kn,increment:bn,decrement:wn,append:Cn,prepend:An,log:Sn,get:Dn,take:xn,make:Tn,halt:Bn,settle:Fn,throw:Ln,send:Rn,if:On,unless:Pn,else:Nn,repeat:_n,for:Mn,while:In,continue:jn,go:$n,scroll:ha,push:Ea,replace:ga,process:za,transition:Vn,clone:qn,focus:Wn,blur:Kn,empty:Un,open:Hn,close:Gn,select:Yn,clear:Zn,reset:Xn,breakpoint:Jn,call:Qn,return:ea,js:ra,async:ta,tell:ia,default:na,init:aa,behavior:oa,install:ua,measure:sa,swap:la,morph:ca,beep:ma,break:pa,copy:da,exit:fa,pick:ya,render:ka,bind:cn,live:mn,eventsource:pn,socket:dn,worker:fn,intercept:yn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function J(i){return ge[i]}function ba(){return Object.values(ge).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Ai(),at)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(ge);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(i=>{console.debug("Schema validation skipped:",i);});function se(i,e){let r=i.possessive?.keywords?.[e];if(r)return r;let t=i.possessive?.specialForms;if(t){for(let[n,a]of Object.entries(t))if(a===e)return n}}function ur(i){return dt.possessive?.specialForms?.[i]??`${i}'s`}var wa={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},Ca={ar:{\u0643\u0640:"as"},bn:{\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as"},es:{como:"as"},fr:{comme:"as"},hi:{\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as"},id:{sebagai:"as"},it:{come:"as"},ja:{\u3068\u3057\u3066:"as"},ko:{\uB85C:"as"},ms:{sebagai:"as"},pl:{jako:"as"},pt:{como:"as"},qu:{hina:"as"},ru:{\u043A\u0430\u043A:"as"},sw:{kuwa:"as"},tl:{bilang:"as"},tr:{olarak:"as"},uk:{\u044F\u043A:"as"},vi:{nh\u01B0:"as"},zh:{\u4F5C\u4E3A:"as"}},Aa={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ar:new Set(["\u0644\u0640"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin"])};function yt(i,e){let r=e.value.toLowerCase(),t=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||t==="of"||t==="source")return true;let n=i?.code?Aa[i.code]:void 0;return !!n&&n.has(r)}var Sa={destination:"in",source:"from"},Da={ar:new Set(["\u0639\u0646\u062F","\u0641\u064A"]),bn:new Set(["\u098F","\u09A4\u09C7"]),de:new Set(["bei"]),es:new Set(["en"]),fr:new Set(["dans","en","\xE0"]),he:new Set(["\u05DC\u05EA\u05D5\u05DA"]),hi:new Set(["\u092A\u0930","\u092E\u0947\u0902"]),id:new Set(["dalam","di","ke_dalam"]),it:new Set(["a"]),ja:new Set(["\u3067","\u306E\u4E2D","\u3078"]),ko:new Set(["\uC548\uC5D0","\uC5D0","\uC73C\uB85C"]),ms:new Set(["dalam","di","ke_dalam"]),pl:new Set(["do","przy","w"]),pt:new Set(["dentro","em"]),qu:new Set(["pi","ukupi"]),ru:new Set(["\u0432","\u0443"]),sw:new Set(["katika","ndani"]),th:new Set(["\u0E17\u0E35\u0E48","\u0E43\u0E19"]),tl:new Set(["papasok_sa","sa","sa_loob"]),tr:new Set(["de","i\xE7inde","i\xE7ine"]),uk:new Set(["\u0432","\u0443"]),vi:new Set(["trong","t\u1EA1i","v\xE0o"]),zh:new Set(["\u5728","\u8FDB\u5165"])},xa=new Set(["in","into","at","within","inside"]);function Ta(i,e){let r=e.value.toLowerCase();if((i?.code?Da[i.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return xa.has(a)?"in":Sa[a]??n}var sr=new Set(["first","last","next","previous","random","closest"]),Ba={bn:{\u09B6\u09C7\u09B7:"last"}},ht=new Set(Object.keys(ge).map(i=>i.toLowerCase()));function vt(i,e,r){let t=i[e];if(!t)return null;let n=(t.normalized??t.value).toLowerCase(),a=i[e+1],o=r?.code&&a?.kind==="selector"&&a.value.startsWith("<")?Ba[r.code]?.[t.value.toLowerCase()]:void 0;if(!sr.has(n)&&!sr.has(t.value.toLowerCase())&&o===void 0)return null;let u=[{text:o??t.normalized??t.value,token:t}],s=e+1,l=i[s];if(!l||l.kind!=="selector")return null;u.push({text:l.value,token:l}),s++;let c=0;for(;c++<8;){let d=i[s];if(d&&d.kind==="selector"&&d.value.startsWith("."))u.push({text:d.value,token:d}),s++;else break}let m=i[s],p=i[s+1];return m&&p&&p.kind==="selector"&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!sr.has((m.normalized??m.value).toLowerCase())&&!ht.has((m.normalized??m.value).toLowerCase())&&(u.push({text:Ta(r,m),token:m}),u.push({text:p.value,token:p}),s+=2),{parts:u,consumed:s-e}}function Fa(i,e){let r=Ca[i];return r?r[e.toLowerCase()]??e:e}function xe(i,e){let r=wa[i];return r?r[e.toLowerCase()]??e:e}function La(i,e){let r=[e.value,e.normalized].filter(Boolean);for(let t of r){let n=se(i,t)??se(i,t.toLowerCase());if(n)return n}}function Et(i){return i.kind==="literal"||i.kind==="operator"||i.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(i.value)}function Ra(i,e){let r=i?.references;if(!r)return false;let t=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>t.includes(a.toLowerCase()))}function Oa(i,e){return Et(i)?xe(e,i.value)!==i.value?true:i.kind==="identifier":false}var Pa={ar:{\u0647\u0648:{beforePredicate:"is"}},hi:{\u0939\u0948:{beforePredicate:"is"},\u0928\u0939\u0940\u0902:{beforeBareIdentifier:"no"}},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is"}},ja:{\u7A7A:{afterCopula:"empty"}},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no"}},tl:{walang:{beforeBareIdentifier:"no"},may:{afterSubject:"exists"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists"}},tr:{var:{afterSubject:"exists"}}},Na=new Set(["empty","null","undefined","true","false"]),_a=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function Ma(i,e,r,t){let n=Pa[i],a=n?.[e.value]??n?.[e.value.toLowerCase()];if(a){if(a.beforeTypeName&&t?.kind==="identifier"&&_a.has(t.value))return a.beforeTypeName;if(a.beforePredicate&&t&&(t.kind==="literal"||t.kind==="keyword"&&Na.has((t.normalized??"").toLowerCase())))return a.beforePredicate;if(a.beforeBareIdentifier&&t?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(t.value))return a.beforeBareIdentifier;if(a.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return a.afterSubject;if(a.afterCopula&&r?.kind==="keyword"&&(r.normalized??"").toLowerCase()==="is")return a.afterCopula}}function yr(i,e){let r=e?.code??"en",t="",n,a=(u,s)=>{if(n===void 0){t=u,n=s;return}let c=n.position?.end!==void 0&&s.position?.start!==void 0&&n.position.end===s.position.start&&(u.startsWith(".")||u.startsWith("!"));t+=(c?"":" ")+u,n=s;},o=u=>u.kind==="keyword"?u.normalized??u.value:u.value;for(let u=0;u<i.length;u++){let s=i[u],l=e?La(e,s):void 0,c=i[u+1];if(l!==void 0&&c){let E=e?.possessive?.connectors,v=!!E?.length&&E.some(k=>{let S=k.toLowerCase();return S===c.value.toLowerCase()||S===(c.normalized??"").toLowerCase()}),f=v?u+2:u+1,h=i[f];if(h&&Oa(h,r)){a(ur(l),s),a(xe(r,h.value),h),u=f;continue}if(v&&h&&/^\.[a-zA-Z_]\w*$/.test(h.value)&&c.position?.end!==void 0&&h.position?.start!==void 0&&c.position.end===h.position.start){a(ur(l),s),a(xe(r,h.value.slice(1)),h),u=f;continue}if(!v&&/^\.[a-zA-Z_]\w*$/.test(c.value)&&s.position?.end!==void 0&&c.position?.start!==void 0&&s.position.end===c.position.start&&!Ra(e,s)){a(ur(l),s),a(xe(r,c.value.slice(1)),c),u+=1;continue}}let m=i[u+2];if(c&&m&&m.kind==="selector"&&yt(e,c)&&Et(s)){a(xe(r,s.value),s),a("of",c),a(m.value,m),u+=2;continue}let p=vt(i,u,e);if(p){for(let E of p.parts)a(E.text,E.token);u+=p.consumed-1;continue}let d=Ma(r,s,i[u-1],c);if(d!==void 0){a(d,s);continue}let y=Fa(r,s.value);if(y!==s.value){a(y,s);continue}a(o(s),s);}return t.trim()}var gt=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function Mr(i,e,r,t){let n=gt.find(o=>o.lang===i);if(!n)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(t,n.of)}function Ia(i,e){let r=gt.find(n=>n.lang===i);if(!r)return false;let t=e.toLowerCase();return t===r.at.toLowerCase()||t===r.of.toLowerCase()||t===r.end.toLowerCase()}var zt={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};function ja(i){return zt[i]}function $a(i,e){return zt[e]?.has(i.toLowerCase())??false}var kt=96,Va=/^[A-Za-z_][\w-]*$/,qa=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function bt(i,e){let r=i.peek(e);return !!r&&r.kind==="identifier"&&qa.test(r.value)}function wt(i,e){let r=i.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Va.test(r.value))return false;let t=i.peek(e+1),n=i.peek(e+2);return !!t&&t.value===":"&&!!n}function Ir(i,e=0){return bt(i,e)||wt(i,e)}function Wa(i){let e=i.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",t=-1,n=0,a=0;for(;!i.isAtEnd()&&a++<kt;){let o=i.advance();if(!o)break;if(t>=0&&o.position.start>t&&(r+=" ".repeat(o.position.start-t)),r+=o.value,t=o.position.end,o.value==="{"||o.value==="(")n++;else if((o.value==="}"||o.value===")")&&(n--,n===0))return r}return null}function jr(i){let e=i.peek();return e?e.value==="{"||e.value==="("?Wa(i):e.value===","||e.value===":"?null:(i.advance(),e.value):null}function Me(i,e){let r=i.mark(),t=[];if(e!==void 0){let a=i.peek();if(!a||a.value!==":"||!i.peek(1))return null;i.advance();let o=jr(i);if(o===null)return i.reset(r),null;t.push(`${e}:${o}`);}else if(!Ir(i))return null;let n=0;for(;n++<kt;){let a=i.peek();if(!a)break;if(a.value===","){if(t.length===0||!Ir(i,1))break;i.advance();continue}if(bt(i,0)){t.push(i.advance().value);continue}if(!wt(i,0))break;let o=i.advance().value;i.advance();let u=jr(i);if(u===null)return i.reset(r),null;t.push(`${o}:${u}`);}return t.length===0?(i.reset(r),null):`{${t.join(", ")}}`}var lr=.8,Ka=.6,Ua=.15,Ha=.5,$r=.15,Vr=.1,qr=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"]),Ga={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"]},Ya=class{calculate(i){return this.calculateWithBreakdown(i).final}calculateWithBreakdown(i){let e=this.scoreRoleCoverage(i),r=this.scoreStemPenalty(i),t=this.scoreLanguageBoost(i),n=this.scoreLanguageAdjustment(i),a=e;return a=Math.max(Ha,a+r),a=Math.min(1,a+t),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:n,final:a}}scoreRoleCoverage(i){let{pattern:e,captured:r}=i,t=0,n=0,a=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")n+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(n+=lr,r.has(u.role)?t+=lr:a(u.role)&&(t+=lr*Ka));return n>0?t/n:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*Ua}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:qr.has(r.value)||r.alternatives?.some(t=>qr.has(t))?$r:0}scoreLanguageAdjustment(i){let{pattern:e,captured:r}=i;if(e.language!=="ar")return 0;let t=0;for(let[n,a]of r.entries()){let o=Ga[n];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-Vr,Math.min(Vr,t))}},Za=new Ya,Xa=new Set(Object.values(ge).filter(i=>i.bareKeyword===true).map(i=>i.action)),Z=class _{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Za;}matchPattern(e,r){let t=e.mark(),n=new Map;if(this.currentProfile=O(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,n))return e.reset(t),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-t.position,confidence:o}}matchBest(e,r){this.matchCache.clear();let t=[],n=e.position();for(let o of r){let u=e.mark(),s=`${n}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let a=t[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let c=this.matchPatternToken(e,l,t,r[s+1]??n);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,t){if(r.has("source"))return;let n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(t,n))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(m=>m.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&u(a)){let l=this.tokenToSemanticValue(n);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,t,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t,n);case "group":return this.matchGroupToken(e,r,t,n);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let n=this.getMatchType(t,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(t,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(t),null;let a=n.join("").toLowerCase();for(let[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.toLowerCase()===a))return q(o);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let n=r.split(t);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==t)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,t,n){this.skipNoiseWords(e);let a=e.peek();if(!a)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let f=this.tryFoldHyphenActionKeyword(e);if(f)return t.set(r.role,f),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!_.tokenLooksLikeEvent(a))return r.optional||false;let f=(a.normalized??a.value).toLowerCase();if(_.POSITIONAL_OR_SCOPE_KEYWORDS.has(f)||this.currentProfile&&(se(this.currentProfile,a.value)??se(this.currentProfile,f))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let f=(a.normalized??a.value).toLowerCase();if(_.STRUCTURAL_NEVER_EVENT.has(f))return r.optional||false}if(a.kind==="keyword"){let f=(a.normalized??a.value).toLowerCase();if(f==="then"||f==="end"&&e.peek(1)?.kind!=="selector"||$a(a.value,this.currentProfile?.code??""))return r.optional||false}if(r.role==="duration"){let f=(a.normalized??a.value).toLowerCase();if(_.POSITIONAL_OR_SCOPE_KEYWORDS.has(f))return r.optional||false}if(r.optional&&n===void 0&&r.role!=="event"&&r.role!=="action"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in ge)return true;let o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ge(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ge(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let f=this.tryMatchBeepPrefixExpression(e);if(f)return t.set(r.role,f),true;let h=this.tryMatchOperatorRunExpression(e);if(h)return t.set(r.role,h),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let f=this.tryMatchPickRangeExpression(e);if(f)return t.set(r.role,f),true}if(r.expectedTypes?.includes("property-path")){let f=this.tryMatchOfPossessiveExpression(e);if(f)return t.set(r.role,f),true;let h=this.tryMatchPostNominalPossessiveExpression(e);if(h)return t.set(r.role,h),true}let s=this.tryMatchPossessiveExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchMethodCallExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(l.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||_.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,m),true);let p=this.tryMatchPossessiveSelectorExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!Ge(p.type,r.expectedTypes)?r.optional||false:(t.set(r.role,p),true);let d=r.role!=="condition",y=this.tryMatchPropertyAccessExpression(e,d);if(y)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(y.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,y),true);let E=this.tryMatchSelectorPropertyExpression(e);if(E)return r.expectedTypes&&r.expectedTypes.length>0&&!Ge(E.type,r.expectedTypes)?r.optional||false:(t.set(r.role,E),true);if(a.kind==="identifier"&&a.value==="{"){let f=r.expectedTypes,k=f?.length===1&&f[0]==="expression"?this.tryMatchBraceRunExpression(e):!f?.length||f.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(k)return t.set(r.role,k),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let f=Me(e);if(f)return t.set(r.role,{type:"expression",raw:f}),true}let v=this.tokenToSemanticValue(a);if(!v)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)){let f=v.type==="selector"&&String(v.value).startsWith("@"),h=r.expectedTypes.some(k=>k==="expression"||k==="reference");if(!(f&&h))return r.optional||false}if(t.set(r.role,v),e.advance(),r.role==="event"){let f=e.peek();f&&f.kind==="selector"&&f.value.startsWith("[")&&"value"in v&&(t.set(r.role,q(`${String(v.value)}${f.value}`)),e.advance());let h=e.peek();if(h&&(h.kind==="particle"||h.kind==="keyword")&&(h.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,h)){let k=e.peek(1);if(k&&(k.kind==="selector"||k.kind==="identifier")){e.advance();let S=this.tokenToSemanticValue(e.advance());S&&!t.has("source")&&t.set("source",S);}}}return true}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(t=>this.getMatchType(r,t)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e){let r=vt(e.tokens,e.position(),this.currentProfile);if(!r)return null;for(let t=0;t<r.consumed;t++)e.advance();return {type:"expression",raw:r.parts.map(t=>t.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let t=e.peek(1),n=e.peek(2),a=(t?.normalized??"").toLowerCase(),o=!!t&&(t.value.toLowerCase()==="on"||a==="destination"||a==="on");return !t||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return yt(this.currentProfile,e)}tryMatchBeepPrefixExpression(e){let r=e.peek(),t=e.peek(1);if(!r||!t||t.value!=="!"||(r.normalized??r.value).toLowerCase()!=="beep"||!(r.position?.end!==void 0&&t.position?.start!==void 0&&r.position.end===t.position.start))return null;let a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let s=e.peek();if(!s||!_.RUN_OPERATORS.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let u=yr(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}tryMatchOperatorRunExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let n=1;for(;;){let o=e.peek();if(!o||!_.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}n++;}if(n<2)return e.reset(r),null;let a=yr(e.tokens.slice(t,e.position()),this.currentProfile);return {type:"expression",raw:a,value:a}}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(_.PICK_RANGE_SEPARATORS.has(r))return true;let t=this.currentProfile?.code;return t?_.PICK_RANGE_SEPARATORS_BY_LANG[t]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let n=e.peek();if(!n||!this.isPickRangeSeparator(n)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&_.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(t,e.position()),[u,,s,l]=o,c=p=>p.kind==="keyword"?p.normalized??p.value:p.value,m=`${c(u)} to ${c(s)}`;return l&&(m+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:m,value:m}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let t=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let n=t==="start"||t==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&n?(e.advance(),true):false}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let t=e.mark(),n=0;for(;!e.isAtEnd();){let a=e.advance();if(a.value==="(")n++;else if(a.value===")"&&(n--,n===0))return true}return e.reset(t),false}return this.tryMatchPossessiveExpression(e)?true:(r.kind==="literal"||r.kind==="identifier"||r.kind==="selector"||r.kind==="keyword")&&!_.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(se(this.currentProfile,r)??se(this.currentProfile,r.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?xe(this.currentProfile.code,e):e}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector"&&!this.isBareWordPropertyHead(r))return null;let t=e.mark();e.advance();let n=e.peek();if(!n||!this.isOfPossessiveMarker(n))return e.reset(t),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"?(e.reset(t),null):(e.advance(),ye(ve(a.value),this.toEnglishProperty(r.value)))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=[r.value,r.normalized].filter(Boolean),n;for(let s of t)if(n=se(this.currentProfile,s)??se(this.currentProfile,s.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||Ia(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))&&!(u.normalized&&_.COMMAND_ACTION_KEYWORDS.has(u.normalized.toLowerCase()))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1)),s=this.toEnglishProperty(s);let l=s;for(;;){let m=e.peek();if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=m.value,e.advance();continue}if(m?.value==="?"){let p=e.peek(1);if(p?.kind==="selector"&&p.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(p.value)){l+=`?${p.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let m="",p=0,d=0;for(;!e.isAtEnd()&&d++<_.MAX_METHOD_ARGS+2;){let y=e.peek();if(!y)break;m+=y.value,e.advance();for(let E of y.value)E==="("?p++:E===")"&&p--;if(p<=0)break}l+=m;}return ye(ne(n),l)}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let t=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||t)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;t&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let u=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let s=e.peek();if(!s)return e.reset(a),null;let l;for(let c of [s.value,s.normalized].filter(Boolean))if(l=se(this.currentProfile,c)??se(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),ye(ne(l),u)):(e.reset(a),null)}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let t=e.normalized?.toLowerCase();return !(t&&Xa.has(t))}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let t=e.mark();e.advance();let n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<_.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return n.push("}"),q(n.join(" "));n.push(u.value);}return e.reset(t),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let t=e.mark(),n="",a=-1,o=0,u=0;for(;!e.isAtEnd()&&u++<_.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(a>=0&&s.position.start>a&&(n+=" ".repeat(s.position.start-a)),n+=s.value,a=s.position.end,s.value==="{")o++;else if(s.value==="}"&&(o--,o===0))return {type:"expression",raw:n}}return e.reset(t),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let t=e.peek(1);if(!t||t.value!=="(")return null;let n=e.mark();e.advance();let a=e.advance(),o="",u=a.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<_.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let m=u!==void 0&&c.position?.start===u;o+=(o===""||m?"":" ")+c.value,u=c.position?.end,e.advance();}return s?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(t),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<_.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}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let n=e.mark();e.advance();let a=t.value.toLowerCase(),o=e.peek();if((t.kind==="identifier"||_.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=t.value,y=[],E=0;for(;E<_.MAX_PROPERTY_DEPTH;){let h=e.peek();if(h&&h.kind==="selector"&&/^\.[a-zA-Z_]/.test(h.value))d+=`.${h.value.slice(1)}`,y.push(h.value.slice(1)),e.advance(),E++;else break}let v=e.peek(),f=!!v&&v.value.startsWith("(");if(r&&!f&&y.length>0&&Se(a))return ye(ne(a),y.join("."));if(f){let h=e.mark(),k=[],S=0,A=false;for(;!e.isAtEnd();){let z=e.peek();if(!z)break;if(z.value==="(")S++;else if(z.value===")"){if(k.push(z.value),e.advance(),S--,S===0&&(A=true),A)break;continue}k.push(z.value),e.advance();}A?d+=k.join(""):e.reset(h);}return {type:"expression",raw:d}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${t.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<_.MAX_PROPERTY_DEPTH;){let d=e.peek();if(!d||d.kind!=="operator"||d.value!==".")break;e.advance();let y=e.peek();if(!y||y.kind!=="identifier")break;e.advance(),l+=`.${y.value}`,c++;}let m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let d=[],y=0;for(;!e.isAtEnd()&&d.length<_.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(y===0){e.advance();break}y--;}if(v.kind==="punctuation"&&v.value==="("&&y++,v.kind==="punctuation"&&v.value===","){e.advance();continue}d.push(v.value),e.advance();}return {type:"expression",raw:`${l}(${d.join(", ")})`}}let p=t.value.toLowerCase();if(r&&Se(p)){let d=l.split(".").slice(1).join(".");return ye(ne(p),d)}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",u=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let p=ge[this.currentPatternCommand];return !!p&&p.roles.some(d=>d.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation")&&!s;if(!o&&!l&&!u)return e.reset(t),null;e.advance(),u&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(o||u)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(t),null):(e.advance(),ye(ve(r.value),this.toEnglishProperty(c.value)))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(t),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return ye(ve(r.value),o)}matchGroupToken(e,r,t,n){let a=e.mark(),o=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,n)){e.reset(a);for(let s of t.keys())o.has(s)||t.delete(s);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return ve(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Se(r)?ne(r):q(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ve(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ne(e.value);let t=e.value.toLowerCase();return Se(t)?ne(t):{type:"expression",raw:e.value};case "url":return q(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return q(n,"string")}if(e==="true")return q(true,"boolean");if(e==="false")return q(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?q(e,"duration"):q(n,"number")}let t=parseFloat(e);return isNaN(t)?q(e,"string"):q(t,"number")}applyExtractionRules(e,r){for(let[t,n]of Object.entries(e.extraction)){let a=r.get(t);if(a){if(n.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(t,n.transform(o));}}else n.value!==void 0?r.set(t,{type:"literal",value:n.value}):n.default&&r.set(t,n.default);}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=r.value.toLowerCase();if(_.ENGLISH_NOISE_WORDS.has(t)){let n=e.mark();e.advance();let a=e.peek();if(a&&(a.kind==="selector"||a.kind==="identifier"))return;let o=e.peek(1);if(a&&a.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let u=a?(a.normalized??a.value).toLowerCase():"";if(a&&_.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&_.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||_.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&Se(u)&&m||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&Se(u))return;e.reset(n);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(t=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return t?r:void 0}};Z.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);Z.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);Z.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);Z.COMMAND_ACTION_KEYWORDS=ht;Z.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);Z.RUN_OPERATORS=new Set(["+","-","*","/"]);Z.PICK_RANGE_SEPARATORS=new Set(["to"]);Z.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};Z.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);Z.MAX_BRACE_RUN_TOKENS=64;Z.MAX_PROPERTY_DEPTH=10;Z.MAX_METHOD_ARGS=20;Z.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);Z.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ja=Z,ie=new Ja;function K(i,e){return Bi(i,e)}function Ct(){return Ti()}var $e=["if","unless","repeat","for","while"],Je=/^[A-Z][A-Za-z0-9_]*$/;function G(i,e){let r=new Set([e]),n=O(i)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function j(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var Qa=new Set($e);function Qe(i,e){let r=i.normalized?.toLowerCase();return r?Qa.has(r):e.some(t=>j(i,t))}var Wr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),eo=new Set(["destination","source","style","patient","on","from","to"]);function At(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(Wr.has(e)||Wr.has(r)||eo.has(e))}var Kr=new Set(["ja","ko"]);function Ie(i){let e=new Set;i?.primary&&e.add(i.primary.toLowerCase());for(let r of i?.alternatives??[])e.add(r.toLowerCase());return e}function St(i,e){let r=[],t=e.position.end,n=i.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){t=e.position.end+n[0].length;for(let a of n[1].split(/[,،、]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:t}}function er(i,e,r){let t=e+1;if(t>=i.length)return -1;let n=Ie(O(r)?.roleMarkers?.patient);return n.size>0&&j(i[t],n)&&t++,t<i.length?t:-1}var Dt=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function ro(i){let e=1;if(i[1]?.value==="("){let r=0,t=1;for(;t<i.length;t++)if(i[t].value==="(")r++;else if(i[t].value===")"&&--r===0)break;if(t>=i.length)return -1;e=t+1;}return e+1}function to(i,e,r){let t=O(r);if(t?.wordOrder!=="SOV"||!Dt.test(i[0].value)||e!==ro(i))return false;let n=Ie(t.roleMarkers?.patient);return n.size===0?false:j(i[e-1],n)}function io(i,e,r){if(!O(e))return null;let t=G(e,"behavior"),n=G(e,"def"),a=i.toLowerCase(),o=[...t].some(m=>a.includes(m)),u=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!o&&!u)return null;let s=K(i,e).tokens;if(s.length<2)return null;if(j(s[0],t))return Ur(i,e,s,r,0);let l=s.findIndex((m,p)=>p>0&&j(m,t));if(l>0&&Je.test(s[0].value))return Ur(i,e,s,r,l);if(j(s[0],n))return Hr(i,e,s,r,0);let c=s.findIndex((m,p)=>p>0&&j(m,n));return c>0&&to(s,c,e)?Hr(i,e,s,r,c):null}function no(i,e,r){let t=O(e);if(!t)return null;let n=t.wordOrder!=="SOV",a=Kr.has(e)?Ie(t.roleMarkers?.event):new Set,o=Kr.has(e)?Ie(t.keywords?.on):new Set,u=a.size>0&&o.size>0,s=G(e,"end"),l=G(e,"on"),c=i.toLowerCase(),m=[...s].some(z=>c.includes(z)),p=(n||u)&&(()=>{let z=0;for(let g of l)if(g){for(let C=c.indexOf(g);C>=0;C=c.indexOf(g,C+g.length))if(++z>=2)return true}return false})();if(!m&&!p)return null;let d=K(i,e).tokens;if(d.length<2)return null;let y=$e.map(z=>G(e,z)),E=z=>Qe(z,y),v=z=>j(z,s),f=[],h=0,k=0;for(let z=0;z<d.length;z++){let g=d[z];if(v(g)){if(h>0){h--;continue}let C=i.slice(d[k].position.start,g.position.start).trim();C&&f.push(C),k=z+1;}else if(E(g))h++;else if(n&&h===0&&z>k&&j(g,l)&&At(d[z+1])){let C=i.slice(d[k].position.start,g.position.start).trim();C&&f.push(C),k=z;}else if(u&&h===0&&z-1>k&&j(g,a)&&d[z+1]!==void 0&&j(d[z+1],o)){let C=d[z-1],b=i.slice(d[k].position.start,C.position.start).trim();b&&f.push(b),k=z-1;}}if(k<d.length){let z=i.slice(d[k].position.start).trim();z&&f.push(z);}if(f.length<2)return null;let S=[],A=[];for(let z of f){let g;try{g=r.statement(z,e);}catch{return null}if(!g||g.kind!=="event-handler")return null;let C=g;S.push(C);let b=!C.body||C.body.length===0;A.push(b?.2:C.metadata?.confidence??.75);}return fr(S,"then",{sourceLanguage:e,confidence:je(A),sourceText:i})}function je(i){return i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0}function zr(i){let e=[];for(let r of i){let t=r.statements;r.kind==="compound"&&Array.isArray(t)?e.push(...t):e.push(r);}return e}function Ur(i,e,r,t,n){let a=n>0,o=a?0:er(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!Je.test(s))return null;let{parameters:l,headerEnd:c}=St(i,u),m=a?n+1:r.findIndex(C=>C.position.start>=c);m<=o&&(m=o+1);let p=G(e,"init"),d=G(e,"end"),y=$e.map(C=>G(e,C)),E=C=>Qe(C,y),v=C=>j(C,d),f=[],h=[],k=[],S=false,A=0,z=m;for(let C=m;C<r.length;C++){let b=r[C];if(v(b)){if(A>0){A--;continue}if(C===z){S=true;break}if(j(r[z],p)){let w=i.slice(r[z].position.end,b.position.start).trim();if(w)try{let D=zr(t.body(w,e));h.push(...D),k.push(je(D.map(x=>x.metadata?.confidence??.75)));}catch{k.push(0);}}else {let w=i.slice(r[z].position.start,b.position.start).trim();try{let D=t.statement(w,e);if(D&&D.kind==="event-handler"){let x=D;f.push(x);let L=!x.body||x.body.length===0;k.push(L?.2:x.metadata?.confidence??.75);}else k.push(0);}catch{k.push(0);}}z=C+1;}else E(b)&&A++;}if(f.length===0&&h.length===0)return null;let g=(S?1:.8)*je(k);return rn(s,l,f,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:i})}function Hr(i,e,r,t,n){let a=n>0,o=a?0:er(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!Dt.test(s))return null;let{parameters:l,headerEnd:c}=St(i,u),m=a?n+1:r.findIndex(g=>g.position.start>=c);m<=o&&(m=o+1);let p=G(e,"end"),d=$e.map(g=>G(e,g)),y=g=>Qe(g,d),E=g=>j(g,p),v=0,f=-1;for(let g=m;g<r.length;g++)if(E(r[g])){if(v===0){f=g;break}v--;}else y(r[g])&&v++;let h=r[m]?.position.start??c,k=f>=0?r[f].position.start:i.length,S=i.slice(h,k).trim();if(!S)return null;let A;try{A=zr(t.body(S,e));}catch{return null}if(A.length===0)return null;let z=je(A.map(g=>g.metadata?.confidence??.75));return f<0&&(z*=.8),tn(s,l,A,{sourceLanguage:e,confidence:z,sourceText:i})}var hr=["live","eventsource","socket","worker","intercept"],ao=new Set(["intercept"]),kr=new Set(["eventsource","socket","worker"]),oo=new Set(["eventsource","socket"]),uo=new Set(["worker"]),so=6,lo=2;function co(i,e){for(let t of hr)if(j(i[0],G(e,t)))return {action:t,keywordIdx:0};if(O(e)?.wordOrder!=="SOV")return null;let r=Math.min(i.length,so);for(let t=1;t<r;t++)for(let n of hr)if(n!=="live"&&j(i[t],G(e,n))&&!(kr.has(n)&&!Je.test(i[0].value))&&!(n==="intercept"&&t>lo))return {action:n,keywordIdx:t};return null}function mo(i,e,r){let t=Ie(O(r)?.roleMarkers?.source);return t.size===0||e+1>=i.length?0:j(i[e],t)||j(i[e+1],t)?2:0}function po(i,e,r,t,n){if(i==="live")return r+1;if(r>0){let s=r+1;return i==="eventsource"&&(s+=mo(e,s,t)),s}let a=er(e,r,t);if(a<0)return -1;if(i==="worker")return a+1;let o=G(t,"on"),u=n>=0?n:e.length;for(let s=a+1;s<u;s++)if(j(e[s],o)&&At(e[s+1]))return s;return u}function fo(i,e,r,t){if(!kr.has(i))return;let n=r>0?0:er(e,r,t);if(!(n<0))return e[n].value}function yo(i,e,r){if(!O(e))return null;let t=i.toLowerCase(),n=false;for(let u of hr){for(let s of G(e,u))if(s&&t.includes(s)){n=true;break}if(n)break}if(!n)return null;let a=K(i,e).tokens;if(a.length<2)return null;let o=co(a,e);return o?ho(i,e,a,r,o.action,o.keywordIdx):null}function ho(i,e,r,t,n,a){let o=G(e,"end"),u=$e.map(S=>G(e,S)),s=S=>Qe(S,u),l=S=>j(S,o),c=fo(n,r,a,e);if(kr.has(n)&&(!c||!Je.test(c)))return null;let m=S=>({sourceLanguage:e,confidence:S,sourceText:i}),p=Gr(r,a+1,l,s);if(ao.has(n))return p>=0&&p!==r.length-1?null:_r(n,[],c,m(p>=0?1:.8));let d=po(n,r,a,e,p);if(d<0||d>r.length)return null;let y=[],E=[],v=false,f=uo.has(n);if(f||oo.has(n)){let S=f?"def":"event-handler",A=0,z=d;for(let g=d;g<r.length;g++){let C=r[g];if(l(C)){if(A>0){A--;continue}if(v=true,g===z)break;let b=f?C.position.end:C.position.start,w=i.slice(r[z].position.start,b).trim();try{let D=t.statement(w,e);if(D&&D.kind===S){let x=D;y.push(x);let L=!x.body||x.body.length===0;E.push(L?.2:x.metadata?.confidence??.75);}else E.push(0);}catch{E.push(0);}z=g+1;}else s(C)&&A++;}}else {let S=Gr(r,d,l,s);v=S>=0;let A=S>=0?r[S].position.start:i.length,z=i.slice(r[d].position.start,A).trim();if(!z)return null;try{y.push(...zr(t.body(z,e)));}catch{return null}if(y.length===0)return null;E.push(...y.map(g=>g.metadata?.confidence??.75));}if(y.length===0&&!v)return null;let h=v?1:.8,k=E.length>0?h*je(E):h;return _r(n,y,c,m(k))}function Gr(i,e,r,t){let n=0;for(let a=e;a<i.length;a++)if(r(i[a])){if(n===0)return a;n--;}else t(i[a])&&n++;return -1}var pe={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll",\u307C\u304B\u3057:"blur"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};Object.fromEntries(Object.entries(pe).map(([i,e])=>{let r={};for(let[t,n]of Object.entries(e))n in r||(r[n]=t);return [i,r]}));var zo={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},ko=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],bo=/^(\d+)(ms|s|m)?$/,wo=new Set(["selector","literal","url","event-modifier"]);function Co(i){let e=i.match(bo);if(!e)return null;let r=parseInt(e[1],10),t=e[2]||"ms";return t==="s"?r*=1e3:t==="m"&&(r*=6e4),r}function Ao(i){for(let e=1;e<i.length;e++){let r=i[e];if(wo.has(r.kind))continue;let t=r.value.toLowerCase(),n=zo[t];if(n){let a=0;for(let o=e+1;o<i.length;o++){let u=i[o],s=Co(u.value);if(s!==null)return {modifiers:{[n]:s},start:r.position.start,end:u.position.end};if(u.kind==="selector"||u.kind==="literal"||u.kind==="url"||++a>2)break}continue}for(let a of ko){if(a[0]!==t||e+a.length>i.length)continue;let o=true;for(let u=1;u<a.length;u++)if(i[e+u].value.toLowerCase()!==a[u]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:i[e+a.length-1].position.end}}}return null}var he=new Set(["if","unless","while","repeat","for"]),cr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Do=new Set(["first","last","next","previous","random","closest"]),De=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Xr=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function M(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function I(i,e){return e.length===0?i:{...i,diagnostics:e}}var Ze=120;function xo(i,e,r){let t=e.tokens.length;if(i.consumedTokens>=t)return null;let n=e.tokens[i.consumedTokens],a=e.tokens[t-1];if(!n||!a)return null;let o=r.slice(n.position.start,a.position.end);if(!o.trim())return null;let u=o.length>Ze?`${o.slice(0,Ze)}\u2026`:o,s=t-i.consumedTokens;return `pattern ${i.pattern.id} left ${s} token(s) unconsumed: "${u}"`}var To=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function mr(i){let e=[],r=new Set((i.diagnostics??[]).map(n=>`${n.code}|${n.message}`)),t=n=>{if(!n||typeof n!="object")return;if(n!==i)for(let o of n.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let u=`${o.code}|${o.message}`;r.has(u)||(r.add(u),e.push(o));}let a=n;for(let o of xt){let u=a[o];if(Array.isArray(u))for(let s of u)t(s);}};return t(i),e.length===0?i:I(i,[...i.diagnostics??[],...e])}function Jr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var xt=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Tt(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=J(i.action),n=t?.primaryRole;if(t&&n&&n!=="patient"&&!t.roles.some(a=>a.role==="patient")&&i.roles.has("patient")&&!i.roles.has(n)){let a=i.roles,o=a.get("patient");o!==void 0&&(a.delete("patient"),a.set(n,o));}if(i.action==="tell"){let a=i.roles,o=a.get("patient"),u=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(a.delete("patient"),a.set("destination",o));}if(i.action==="fetch"){let a=i.roles,o=a.get("patient"),u=a.get("source");o&&u&&(o.type==="literal"||o.type==="expression")&&u.type==="expression"&&!a.has("style")&&(a.delete("patient"),a.set("style",u),a.set("source",o));}if(i.action==="transition"){let a=i.roles,o=a.get("destination");o&&o.type==="literal"&&!a.has("goal")&&(a.delete("destination"),a.set("goal",o));let u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&a.set("patient",{type:"expression",raw:u.value});}if(i.action==="morph"){let a=i.roles,o=a.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&a.set("patient",{type:"expression",raw:o.value});}if(i.action==="wait"){let a=i.roles;if(!a.has("event")){let o=a.get("duration"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&De.has(u.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:u,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let a=i.roles,o=a.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&a.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let a=i.roles;for(let o of ["destination","source"]){let u=a.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&a.set(o,{type:"expression",raw:u.value});}}}let r=i;for(let t of xt){let n=r[t];if(Array.isArray(n))for(let a of n)Tt(a,e);}return i}var Y=class T{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let t=Tt(this.parseInternal(e,r),this.boundIdentifiers),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(t=I(t,[...t.diagnostics??[],...n])),this.parseDepth===1&&(t=mr(t),t.kind==="event-handler")){let a={node:t,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let s=0;s<4;s++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let u=this.reclaimEventCompoundTail(a.node,a.input,r);u&&(a=u),t=a.node;}return t}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=T.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let t=O(e)?.roleMarkers;if(t){for(let n of Object.values(t))if(n){if(n.primary)for(let a of n.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of n.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let n of T.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());T.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let t=(e.normalized??e.value).toLowerCase();return To.has(t)?true:T.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,t){if(e.length===0)return;let n=this.coverageFrames[this.coverageFrames.length-1];if(!n||!e.some(u=>!this.isCoverageResidueToken(u,r)))return;let a=e.map(u=>u.value).join(" ").trim();if(!a)return;let o=a.length>Ze?`${a.slice(0,Ze)}\u2026`:a;n.push(M(`${t} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let t=e.roles.get(r);t?.type==="expression"&&typeof t.raw=="string"&&/^[A-Za-z_]\w*$/.test(t.raw)&&this.boundIdentifiers.add(t.raw);}parseInternal(e,r){let t=io(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(t)return t;let n=yo(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(n)return n;let a=no(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(a)return a;let{modifiers:o,remainingInput:u}=this.extractStandaloneModifiers(e,r),s=u||e,c=this.stripAsyncModifier(s,r).remainingInput??s,p=this.stripDoNotThrowModifier(c,r).remainingInput??c,d=[],y=K(p,r),E=le(r);if(E.length===0)throw new Xr(`No patterns available for language: ${r}`,r,p,[M(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...E].sort((b,w)=>w.priority-b.priority);{let b=y.tokens;if(O(r)?.wordOrder==="VSO"&&b.length>=4&&b[0]?.normalized==="source"){let w=b.findIndex(D=>D.normalized==="on");if(w>=2&&w+1<b.length){let D=p.slice(b[0].position.start,b[w].position.start).trim(),x=b[w+1].position.end,L=p.slice(b[w].position.start,x)+" "+D+p.slice(x);if(L!==p)try{let F=this.parse(L,r);if(F&&F.kind==="event-handler"){let R=o?this.applyModifiers(F,o):F;return I(R,d)}}catch{}}}}{let b=y.tokens,w=b[0]?.normalized==="if";for(let D=0;w&&D+3<b.length;D++){let x=(b[D+3]?.normalized??b[D+3]?.value??"").toLowerCase();if(b[D]?.normalized==="source"&&b[D+2]?.normalized==="on"&&T.KNOWN_EVENTS.has(x)){let L=(p.slice(0,b[D].position.start).trimEnd()+" "+p.slice(b[D+1].position.end).trimStart()).trim();if(L&&L!==p)try{let F=this.parse(L,r);if(F&&F.kind==="event-handler"){let R=o?this.applyModifiers(F,o):F;return I(R,d)}}catch{}break}}}{let b=y.tokens;for(let w=1;w<b.length-1;w++){let D=b[w],x=D.value,L=(D.normalized??D.value).toLowerCase();if(!(L==="or"||T.OR_KEYWORDS.has(x)||T.OR_KEYWORDS.has(L)))continue;let R=b[w+1],P=(R.normalized??R.value).toLowerCase();if(!T.KNOWN_EVENTS.has(P))break;let N=w+1,U=b[w+2];U&&U.kind==="selector"&&U.value.startsWith("[")&&(N=w+2);let H=b[w].position.start,me=b[N].position.end,ae=(p.slice(0,H).trimEnd()+" "+p.slice(me).trimStart()).trim();if(ae&&ae!==p)try{let de=this.parse(ae,r);if(de&&de.kind==="event-handler"){de.additionalEvents=[{type:"literal",value:P}];let nr=o?this.applyModifiers(de,o):de;return I(nr,d)}}catch{}break}}{let b=Ao(y.tokens);if(b){let w=(p.slice(0,b.start).trimEnd()+" "+p.slice(b.end).trimStart()).trim();if(w&&w!==p)try{let D=this.parse(w,r);if(D&&D.kind==="event-handler"){let x=this.applyModifiers(D,{...o??{},...b.modifiers});return I(x,d)}}catch{}}}let f=v.filter(b=>b.command==="on"),h=y.mark(),k=ie.matchBest(y,f);if(k){d.push(M(`event pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let b=false;if(/^event-[a-z]+-bare$/.test(k.pattern.id)){let w=k.captured.get("event"),D=(w?.raw??w?.value??"").toString().toLowerCase(),x=pe[r],L=T.KNOWN_EVENTS.has(D)||!!x&&Object.keys(x).some(F=>F.toLowerCase()===D);if(D&&!L){let F=this.trySOVEventExtraction(p,r,v);if(F){d.push(M(`bare-event mis-anchor on "${D}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let R=o?this.applyModifiers(F,o):F;return I(R,d)}if(w?.type==="reference"||w?.type==="expression"){y.reset(h);let R=v.filter(N=>N.command!=="on"),P=ie.matchBest(y,R);y.reset(h),P&&P.pattern.command!=="on"?(b=true,d.push(M(`bare-event mis-anchor on reference "${D}" rejected; command ${P.pattern.command} preferred`,"info","stage-bare-event-guard"))):ie.matchBest(y,f);}}}if(!b){let w=this.buildEventHandler(k,y,r),D=o?this.applyModifiers(w,o):w;return I(D,d)}}d.push(M(`event patterns: ${f.length} tried, no match`,"info","stage-event"));let S=this.tryTrailingEventExtraction(p,r,v);if(S){d.push(M("trailing event extraction succeeded","info","stage-trailing-event"));let b=o?this.applyModifiers(S,o):S;return I(b,d)}let A=v.filter(b=>b.command!=="on"),z=ie.matchBest(y,A);if(z){if(he.has(z.pattern.command)){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(M(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let x=o?this.applyModifiers(w,o):w;return I(x,d)}let D=this.tryMidStreamEventExtraction(p,r,v);if(D){d.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let x=o?this.applyModifiers(D,o):D;return I(x,d)}}else if(T.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(p,r)){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(M(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let D=o?this.applyModifiers(w,o):w;return I(D,d)}}else if(O(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(p,r,v);if(w){d.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let D=o?this.applyModifiers(w,o):w;return I(D,d)}}if(z.consumedTokens<y.tokens.length&&O(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(M(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let D=o?this.applyModifiers(w,o):w;return I(D,d)}}if(z.consumedTokens<y.tokens.length&&!he.has(z.pattern.command)){let w=this.tryTopLevelCommandSequence(y,A,r);if(w)return d.push(M(`top-level command sequence: ${w.statements.length} commands`,"info","stage-top-level-sequence")),I(w,d)}d.push(M(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let b=xo(z,y,p);return b&&d.push(M(b,"warning","unconsumed-input")),I(this.buildCommand(z,r),d)}if(d.push(M(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!p.includes(`
4
+ `)&&O(r)?.wordOrder==="VSO"){let b=this.tryMidStreamEventExtraction(p,r,v);if(b){d.push(M("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let w=o?this.applyModifiers(b,o):b;return I(w,d)}}let g=this.trySOVEventExtraction(p,r,v);if(g){d.push(M("SOV event extraction succeeded","info","stage-sov"));let b=o?this.applyModifiers(g,o):g;return I(b,d)}d.push(M("SOV event extraction: no event keyword found","info","stage-sov"));let C=this.tryCompoundCommandParsing(y,A,r);if(C)return d.push(M("compound command parsing succeeded","info","stage-compound")),I(C,d);throw d.push(M("compound parsing: no then-keywords or no command matches","info","stage-compound")),d.push(M(`all parse stages exhausted for "${p}"`,"error","parse-failed")),new Xr(`Could not parse input in ${r}: ${p}`,r,p,d)}parseStatements(e,r){let t=K(e,r),n=le(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(t,n,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let u=a[a.length-1];a[a.length-1]=I(u,[...u.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Ct()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[a,o]of e.captured)t[a]=o;let n=te(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");{let m=n.type==="expression"?n.raw:n.type==="literal"?n.value:void 0;if(typeof m=="string"&&/^[^\s()[\]{}:]+$/.test(m)){let p=pe[t]?.[m];p?n={type:"literal",value:p,dataType:"string"}:n.type==="expression"&&T.KNOWN_EVENTS.has(m.toLowerCase())&&(n={type:"literal",value:m.toLowerCase(),dataType:"string"});}}let a=ie.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.includes("source")&&!(o.type==="reference"&&o.value==="me")&&(a={...a??{},from:o});let u=this.extractOrConjunctionEvents(r,t),s=n;u.length>0&&n.type==="literal"&&(s={type:"literal",value:[String(n.value),...u.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let m=r.tokens,p=-1;for(let d=r.position()-1;d>=0;d--){let y=m[d],E=(y.normalized??y.value).toLowerCase();if(this.isIfKeyword(E,t)){p=d;break}}if(p>=0){let d=le(t).filter(k=>k.command!=="on").sort((k,S)=>S.priority-k.priority),y=m.slice(p);if(e.pattern.id.endsWith("vso-verb-first")&&s.type==="literal"){let k=String(s.value??"").split("[")[0].trim().toLowerCase(),S=y.findIndex((A,z)=>{if(z===0||k==="")return false;let g=(A.normalized??A.value).toLowerCase(),C=y[z-1];return g===k&&C.kind==="keyword"&&(C.normalized??"").toLowerCase()==="on"});if(S>0){let A=y[S+1],z=A&&A.kind==="selector"&&A.value.startsWith("[")?1:0;y=[...y.slice(0,S-1),...y.slice(S+1+z)];}}let E=new re(y,t),v=this.coverageMark(),f=this.parseBodyWithClauses(E,d,t);if(f.some(k=>k.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(k=>k.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Ne(s,f,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(v);}}if(c&&c.type==="literal"){let m=c.value,p={};for(let[A,z]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(p[A]=z);if(m==="repeat"){let A=r.peek(),z=C=>(C.normalized??C.value).toLowerCase();if(A&&A.kind==="keyword"&&z(A)==="forever")p.loopType={type:"literal",value:"forever"},delete p.patient,r.advance();else if(A&&A.kind==="keyword"&&z(A)==="event"){r.advance();let C=r.peek();if(C)for(p.event={type:"literal",value:z(C)},p.loopType={type:"literal",value:"until-event"},delete p.patient;!r.isAtEnd();){let b=r.peek();if(!b||b.kind==="conjunction"||b.kind==="keyword"&&(this.isThenKeyword(b.value,t)||this.isEndKeyword(b.value,t)))break;r.advance();}}let g=p.patient;g&&g.type==="reference"&&g.value==="me"&&delete p.patient;}let d=te(m,p,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(d),!he.has(m)||m==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,g=r.position(),C=w=>w.kind==="conjunction"||w.kind==="keyword"&&(this.isThenKeyword(w.value,t)||this.isEndKeyword(w.value,t)),b=-1;for(let w=g-1;w>=0;w--){let D=z[w];if(C(D))break;if((D.normalized??D.value).toLowerCase()===m){b=w;break}}if(b>=0){let w=g;for(;w<z.length&&!C(z[w]);)w++;let D=z.slice(b,w),x=D;if(A){let L=String(n.value??"").toLowerCase(),F=D.findIndex(R=>(R.normalized??R.value).toLowerCase()===L);if(F<0)x=null;else {let R=D[F-1],P=R&&R.kind==="keyword"&&R.normalized?.toLowerCase()==="on"?F-1:F;x=[...D.slice(0,P),...D.slice(F+1)];}}if(x&&x.length>1){let L=le(t).filter(W=>W.command!=="on").sort((W,oe)=>oe.priority-W.priority),F=this.coverageMark(),R=this.parseClause(x,L,t),P=R[0],N=W=>W!==null&&typeof W=="object"&&typeof W.type=="string"?W.type:typeof W,U=J(m),H=U?.primaryRole,me=W=>W==="patient"&&H&&H!=="patient"&&!U?.roles.some(oe=>oe.role==="patient")?H:W,ae=(W,oe)=>{if(!he.has(m)||!U)return false;let we=U.roles.find(Le=>Le.role===me(W));return we?we.expectedTypes.length>0&&!we.expectedTypes.includes(N(oe)):true},de=!!P&&P.kind==="command"&&Object.entries(p).every(([W,oe])=>{if(ae(W,oe))return true;let we=P.roles.get(me(W));if(we!==void 0&&N(we)===N(oe))return true;if(W==="patient"&&m==="pick"&&N(oe)==="literal"){let Le=P.roles.get("method");return Le!==void 0&&N(Le)==="literal"&&String(Le.value)===String(oe.value)}return false}),nr=P?.metadata?.patternId??"",Wt=!he.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(nr);if(R.length===1&&P&&P.kind==="command"&&P.action===m&&de&&Wt&&P.roles.size>Object.keys(p).length)for(d=P;r.position()<w;)r.advance();else this.coverageRollback(F);}}}if(!he.has(m)){let A=d;if(J(m)?.roles.some(x=>x.role==="quantity"&&!x.required)&&!A.roles.has("quantity")){let x=r.peek();x&&/^-?\d+(\.\d+)?$/.test(x.value)&&(d=te(m,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(x.value),dataType:"number"}},A.metadata),r.advance());}let g=d;if(J(m)?.roles.some(x=>x.role==="duration"&&!x.required)&&!g.roles.has("duration")){let x=/^\d+(\.\d+)?(ms|s)$/i,L=r.peek(),F=false;if(L&&L.kind==="particle"){let R=r.peek(1);R&&x.test(R.value)&&(F=true,L=R);}L&&x.test(L.value)&&(d=te(m,{...Object.fromEntries(g.roles),duration:{type:"literal",value:L.value,dataType:"string"}},g.metadata),F&&r.advance(),r.advance(),this.consumeForPostposition(r,t));}let b=d,w=J(m);if(w?.roles.find(x=>x.role==="responseType"&&!x.required)&&!b.roles.has("responseType")){let x=N=>typeof N=="string"&&T.RESPONSE_TYPE_WORDS.has(N.toLowerCase()),L=(N,U)=>{let H=Object.fromEntries(b.roles);U&&delete H.destination,H.responseType={type:"expression",raw:N},d=te(m,H,b.metadata);},F=b.roles.get("destination"),R=w?.roles.find(N=>N.role==="destination"),P=F?.raw??F?.value;if(F&&R&&!R.expectedTypes.includes(F.type)&&x(P))L(P,true);else {let N=r.peek();N&&x(N.value)&&(L(N.value,false),r.advance());}}if(m==="wait"){let x=d;if(!x.roles.has("event")){let L=r.peek();if(L&&De.has(L.value.toLowerCase())){let F=Object.fromEntries(x.roles),R=F.duration;R&&R.type!=="literal"&&R.type!=="expression"&&delete F.duration;let P=F.patient;P&&P.type==="reference"&&P.value==="me"&&delete F.patient,F.event={type:"literal",value:L.value,dataType:"string"},d=te(m,F,x.metadata),r.advance(),this.consumeForPostposition(r,t);}}}this.tryAttachTrailingRole(r,d,t),this.tryAttachTrailingStyle(r,d,t),this.tryAttachTrailingExpressionRole(r,d,t);}let y=e.captured.get("continues"),E=y?.type==="literal"&&y.value==="then",v=r.peek(),f=!!v&&this.isThenKeyword(v.value,t),k=he.has(m)&&!!v&&!this.isEndKeyword(v.value,t),S=!!v&&!this.isEndKeyword(v.value,t);if(E||f||k||S){let A=le(t).filter(C=>C.command!=="on").sort((C,b)=>b.priority-C.priority),z=le(t).filter(C=>C.id.startsWith("grammar-")&&C.id.includes("-continuation")).sort((C,b)=>b.priority-C.priority),g=this.parseBodyWithGrammarPatterns(r,A,z,t);g.length>0?l=[d,...g]:l=[d];}else l=[d],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),t,"handler body tail");}else {let m=le(t).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);l=this.parseBodyWithClauses(r,m,t);}return Ne(s,l,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let n=[],a=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(a.length===0){let y=this.consumeJsBlock(e,t);if(y){n.push(y);continue}let E=this.tryParseConditionalBlock(e,r,t);if(E){n.push(E);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t),c=a[a.length-1],m=e.peek(1),p=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||Mr(t,s.value,c?.value,m?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&o>0){o--,u.pop(),a.push({...s,metadata:{...s.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&u.includes("if")){a.push(s),e.advance();continue}if(l){if(a.length>0){let y=this.parseClause(a,r,t);n.push(...y),a.length=0,o=y.filter(E=>{let v=E;return (v.action==="for"||v.action==="repeat"||v.action==="while")&&(!Array.isArray(v.body)||v.body.length===0)}).length,u.length=0;for(let E=0;E<o;E++)u.push("other");}e.advance();continue}if(d){e.advance();let y=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||E.kind==="conjunction"||E.kind==="keyword"&&(this.isThenKeyword(E.value,t)||this.isEndKeyword(E.value,t)))break;y.push(E),e.advance();}if(y.length>0){let E=this.coverageMark(),v=a.length>0?this.parseClause(a,r,t):[];v.length===0&&a.length>0?(this.coverageRollback(E),n.push(...this.parseClause([...a,...y],r,t))):(n.push(...v),n.push(...this.parseClause(y,r,t)));}else if(a.length>0){let E=this.parseClause(a,r,t);n.push(...E);}a.length=0;break}if(s.kind==="keyword"){let y=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(y,t)||this.isUnlessKeyword(y,t)||y==="while"||y==="for"||y==="repeat")&&(o++,u.push(this.isIfKeyword(y,t)?"if":"other"));}a.push(s),e.advance();}if(a.length>0){let s=this.parseClause(a,r,t);n.push(...s);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),t,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,t);for(let s=n.length-1;s>=0;s--){let l=n[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(s,1);}return n.length>1?[fr(n,"then",{sourceLanguage:t})]:n}tryTopLevelCommandSequence(e,r,t){let n=this.coverageMark(),a;try{let l=new re(e.tokens,t);a=this.parseBodyWithClauses(l,r,t);}catch{return this.coverageRollback(n),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(n),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(n),null;let u=o.statements.map(l=>l.metadata?.confidence??.75),s=u.reduce((l,c)=>l+c,0)/u.length;return fr(o.statements,o.chainType,{sourceLanguage:t,confidence:s})}foldFrontedWhileIntoRepeat(e,r){for(let t=0;t+1<e.length;t++){let n=e[t],a=e[t+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...a,roles:u,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}parseClause(e,r,t){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let f=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(f,t)&&(n="unless",a=e.slice(0,-1));}let u=null;if(n&&a.length>=3){let f=O(t),h=f?T.buildVerbLookup(f):null;if(h)for(let k=1;k<a.length-1;k++){let S=a[k],A=h.get(S.value.toLowerCase())??(S.normalized?h.get(S.normalized.toLowerCase()):void 0);if(A&&!T.CONDITION_OPERATORS.has(A)){u=a.slice(0,k),a=a.slice(k);break}}}let s=new re(a,t),l=[],c=this.coverageMark(),m=0,p=[],d=u,y=()=>{if(p.length===0)return;let f=p.slice();if(p.length=0,n&&l.length===0&&d===null){d=f;return}let h=f[0];if(!(h&&(h.kind==="identifier"||h.kind==="selector"||h.kind==="literal"||h.kind==="reference"))){this.recordDroppedTokens(f,t,"body clause");return}let S=false;for(let A of this.parseSOVClauseByVerbAnchoring(f,t)){let z=A.action,g=A.roles;z&&J(z)&&g instanceof Map&&g.size>0&&(l.push(A),S=true);}S||this.recordDroppedTokens(f,t,"body clause");};for(;!s.isAtEnd();){let f=s.peek(),h=!!f&&f.normalized?.toLowerCase()==="repeat",k=s.mark(),S=ie.matchBest(s,r);if(h&&S&&S.pattern.command!=="repeat"){s.reset(k),y(),l.push(te("repeat",{},{sourceLanguage:t,confidence:.6})),m++,s.advance();continue}if(S&&S.pattern.command==="if"){let A=s.mark(),z=p.length;for(s.reset(k);!s.isAtEnd();){let C=s.peek();if(!C||this.isIfKeyword((C.normalized??C.value).toLowerCase(),t))break;p.push(C),s.advance();}let g=this.tryParseConditionalBlock(s,r,t);if(g){y(),l.push(g),m++;continue}p.length=z,s.reset(A);}if(S){y();let A=this.buildCommand(S,t);l.push(A),m++,this.tryAttachTrailingRole(s,A,t),this.tryAttachTrailingStyle(s,A,t),this.tryAttachTrailingExpressionRole(s,A,t);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(y(),l.push(te("repeat",{},{sourceLanguage:t,confidence:.6})),m++):A&&p.push(A),s.advance();}}y();let E=l;if(m===0){let f=this.parseSOVClauseByVerbAnchoring(a,t);f.length>0&&(this.coverageRollback(c),E=f);}let v=d;return n&&E.length>0&&v&&v.length>0?[te(n,{condition:{type:"expression",raw:this.joinTokenText(v,t)}},{sourceLanguage:t,patternId:`${n}-${t}-trailing-guard`,confidence:.85}),...E]:(n&&v&&v.length>0&&E.length===0&&this.recordDroppedTokens(v,t,"body clause"),E)}tryAttachTrailingRole(e,r,t){let n=J(r.action);if(!n)return;let a=O(t);if(!a)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return cr.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of s){if(!n.roles.some(v=>v.role===l))continue;let m=a.roleMarkers?.[l];if(!m)continue;let p=o.get(l);if(p&&!(p.type==="reference"&&p.value==="me"))continue;let d=v=>{if(!v||v.kind!=="particle"&&v.kind!=="keyword")return false;let f=v.value.toLowerCase();return m.primary?.toLowerCase()===f?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(h=>h.toLowerCase()===f)},y=e.peek(),E=e.peek(1);if(!y||!E)return;if(c&&m.position==="after"){let v=e.peek(2),f=(y.normalized??y.value).toLowerCase();if(Do.has(f)&&E.kind==="selector"&&d(v)){o.set(l,{type:"expression",raw:`${f} ${E.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(u(y,c)&&d(E)){let v=this.tokenToSemanticValue(y);e.advance(),e.advance(),v&&o.set(l,v);return}if(c&&u(y,c)){let v=e.peek(2),f=e.peek(3);if((E.normalized??E.value).toLowerCase()==="in"&&v&&!d(v)&&d(f)){let h=this.tokenToSemanticValue(y);e.advance(),e.advance(),e.advance(),e.advance(),h&&o.set(l,h);return}}}else if(d(y)&&u(E,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&o.set(l,v);return}}}tryAttachTrailingStyle(e,r,t){if(r.action!=="fetch"&&r.action!=="render")return;let n=r.roles;if(!J(r.action)?.roles.some(f=>f.role==="style"))return;let o=n.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let f=Me(e,o.raw);f&&(n.set("style",{type:"expression",raw:f}),this.tryAttachResponseTypeAfterStyle(e,r,t));}return}if(r.action==="fetch"){let f=n.get("patient"),h=n.get("source");if(f&&h&&(f.type==="literal"||f.type==="expression")&&h.type==="expression"&&typeof h.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(h.raw)&&e.peek()?.value===":"){let k=Me(e,h.raw);k&&(n.set("source",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,t));return}}let s=O(t)?.roleMarkers?.style;if(!s)return;if(s.position==="before"){let f=new Set([s.primary,...s.alternatives??[]].map(A=>A.toLowerCase())),h=e.peek();if(!h||!f.has(h.value.toLowerCase()))return;let k=e.mark();e.advance();let S=Me(e);if(!S){e.reset(k);return}n.set("style",{type:"expression",raw:S}),this.tryAttachResponseTypeAfterStyle(e,r,t);return}if(s.position!=="after")return;let l=new Set([s.primary,...s.alternatives??[]].map(f=>f.toLowerCase())),c=f=>f.kind==="conjunction"||f.kind==="keyword"&&(this.isThenKeyword(f.value,t)||this.isEndKeyword(f.value,t)),m=24,p=-1,d=0;for(let f=0;f<m;f++){let h=e.peek(f);if(!h||c(h))break;if(h.value==="("||h.value==="{"?d++:(h.value===")"||h.value==="}")&&(d=Math.max(0,d-1)),d===0&&(h.kind==="particle"||h.kind==="keyword")&&l.has(h.value.toLowerCase())){p=f;break}}if(p<=0)return;let y=[];for(let f=0;f<p;f++){let h=e.peek(f);h&&y.push(h);}if(y.length===1&&T.RESPONSE_TYPE_WORDS.has(y[0].value.toLowerCase()))return;let E=new re(y,t),v=Me(E);n.set("style",{type:"expression",raw:v&&E.isAtEnd()?v:this.joinTokenText(y,t)});for(let f=0;f<=p;f++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,t);}tryAttachResponseTypeAfterStyle(e,r,t){let n=r.roles;if(n.has("responseType")||!J(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&T.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),u=e.peek();if(!u)return;let s=c=>{n.set("responseType",{type:"expression",raw:c});};if(T.AS_MARKERS_BEFORE[t]?.some(c=>u.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(o(u.value)){e.advance(),s(u.value);for(let c of T.AS_MARKERS_AFTER[t]??[])if(c.every((m,p)=>e.peek(p)?.value.toLowerCase()===m)){for(let m=0;m<c.length;m++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,t){let n=r.action,a=n==="js"?{role:"patient",terminator:"boundary"}:n==="go"||n==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,u=o.get(a.role);if(n==="go"&&u&&u.type==="expression"&&String(u.raw).toLowerCase()==="url"){let f=e.peek();if(f&&!cr.has((f.normalized??f.value).toLowerCase())){let k=this.tokenToSemanticValue(f);if(k.type==="literal"||k.type==="selector"){o.set(a.role,k),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let h=o.get("patient");if(h&&(h.type==="literal"||h.type==="selector")){o.set(a.role,h),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(n==="go"&&u&&u.type==="expression"){let f=/^url\s+(\S+)$/i.exec(String(u.raw??""));if(f){let h=f[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!u){let f=o.get("patient");if(f&&f.type==="expression"&&String(f.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!cr.has((h.normalized??h.value).toLowerCase())){let k=this.tokenToSemanticValue(h);if(k.type==="literal"||k.type==="selector"){o.set(a.role,k),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(u&&!(u.type==="reference"&&u.value==="me"))return;let s=O(t);if(!s)return;let l=null;if(a.terminator==="destination-marker"){let f=s.roleMarkers?.destination;if(!f||f.position!=="after")return;l=f.primary.toLowerCase();}let c=f=>f.kind==="conjunction"||f.kind==="keyword"&&(this.isThenKeyword(f.value,t)||this.isEndKeyword(f.value,t)),m=24,p=[],d=0,y=false;for(let f=0;f<m;f++){let h=e.peek(f);if(!h||c(h))break;if(h.value==="("||h.value==="{"?d++:(h.value===")"||h.value==="}")&&(d=Math.max(0,d-1)),l!==null&&d===0&&(h.kind==="particle"||h.kind==="keyword")&&h.value.toLowerCase()===l){y=true;break}p.push(h);}if(p.length===0||l!==null&&!y)return;let E=p.length+(y?1:0);if(n==="go"&&p.length===2&&p[0].value.toLowerCase()==="url"){let f=this.tokenToSemanticValue(p[1]);if(f.type==="literal"||f.type==="selector"){o.set(a.role,f),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!J(n)?.roles.some(k=>k.role==="patient")&&o.delete("patient");for(let k=0;k<E;k++)e.advance();return}}let v=p;if(n==="js"){let f=s.keywords?.js,h=S=>[f?.primary,...f?.alternatives??[]].some(A=>!!A&&A.length>S.value.length&&A.includes(S.value)),k=0;for(;k<v.length&&h(v[k]);)k++;if(v=v.slice(k),v.length===0)return}if(o.set(a.role,{type:"expression",raw:this.joinTokenText(v,t)}),a.role!=="patient"){let f=o.get("patient");f&&f.type==="reference"&&f.value==="me"&&!J(n)?.roles.some(h=>h.role==="patient")&&o.delete("patient");}for(let f=0;f<E;f++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[t,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(t)&&(r.set(n.primary.toLowerCase(),t),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((t!=="event"||!r.has(n.primary))&&r.set(n.primary,t),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=O(r);if(!t||t.wordOrder!=="SOV")return [];let n=T.buildVerbLookup(t),a=T.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let y=u;y<e.length;y++){let E=e[y];if(a.has(E.value))continue;let v=n.get(E.value.toLowerCase()),f=E.normalized?n.get(E.normalized.toLowerCase()):void 0,h=v||f;if(h){s=y,l=h;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let y=s+1;y<e.length;y++){let E=e[y];if(E.kind==="conjunction"||this.isThenKeyword(E.value,r)){m=y;break}if(y>s+1&&!a.has(E.value)&&(n.get(E.value.toLowerCase())||(E.normalized?n.get(E.normalized.toLowerCase()):void 0))){m=y;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,a,l,r);if(o.push(te(l,d,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let y=e[u];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,n,a){let o={},u=(l,c)=>{let m=this.isEndKeyword(l.value,a),p=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !m&&!p?false:l.metadata?.closesTrackedBlock===true||m?true:!(c&&c.kind==="selector")},s=l=>{let c=[];for(let m=0;m<l.length;m++){let p=l[m];if(u(p,l[m+1]))continue;let d=t.get(p.value);if(d&&p.kind==="particle"&&c.length>0){let y=this.tokensToSemanticValue(c,a);if(y){let E=this.mapRoleForCommand(d,n,o);E&&(o[E]=y);}c=[];}else c.push(p);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&J(n)?.roles.some(p=>p.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let p=this.tokensToSemanticValue(c,a);p&&(o.patient?o.destination||(o.destination=p):o.patient=p);}};return s(e),s(r),o}mapRoleForCommand(e,r,t){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length>=2&&(t[0].kind==="selector"||/^[#.@*<]/.test(t[0].value))){let o=t.findIndex((u,s)=>s>0&&(u.normalized??u.value).toLowerCase()==="in");o>0&&(t=t.slice(0,o));}if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(o=>o.value).join(""),a=t[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?ve(n):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?q(Jr(n),"string"):a.kind==="reference"?ne(n):q(this.joinTokenText(t,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return ve(r);if(r.startsWith('"')||r.startsWith("'"))return q(Jr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return q(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return q(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return q(false);if(r.length>1&&(r.startsWith(":")||r.startsWith("$")))return ne(r);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ne(t):e.kind==="reference"?ne(e.normalized||"me"):q(r)}parseBodyWithGrammarPatterns(e,r,t,n){let a=[],o=[],u=false,s=()=>{if(!u&&o.length>0){let m=this.parseSOVClauseByVerbAnchoring(o,n);a.push(...m),m.length===0&&this.recordDroppedTokens(o,n,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,n,"fused body walk");o=[],u=false;},l=0,c=()=>{let m=0;for(let p of a){let d=p;(d.action==="for"||d.action==="repeat"||d.action==="while")&&(!Array.isArray(d.body)||d.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,n)){s(),e.advance();continue}if(m&&this.isEndKeyword(m.value,n)){let d=e.peek(-1),y=e.peek(1);if(!Mr(n,m.value,d?.value,y?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!u&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),n)){s();let d=this.tryParseConditionalBlock(e,r,n);if(d){a.push(d),u=true;continue}}let p=false;if(t.length>0){let d=ie.matchBest(e,t);if(d){let y=d.pattern.command,E={};for(let[h,k]of d.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(E[h]=k);let v=te(y,E,{sourceLanguage:n,patternId:d.pattern.id});a.push(v),p=true,u=true;let f=d.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then")continue}}if(!p){let d=e.mark(),y=ie.matchBest(e,r);if(y){if(y.pattern.command==="if"){let v=e.mark();for(e.reset(d);!e.isAtEnd();){let h=e.peek();if(!h||this.isIfKeyword((h.normalized??h.value).toLowerCase(),n))break;e.advance();}let f=this.tryParseConditionalBlock(e,r,n);if(f){s(),a.push(f),u=true;continue}e.reset(v);}let E=this.buildCommand(y,n);a.push(E),this.tryAttachTrailingRole(e,E,n),p=true,u=true;}}p||(m&&o.push(m),e.advance());}s(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let m=a.length-1;m>=0;m--){let p=a[m];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&a.splice(m,1);}return a}tryCompoundCommandParsing(e,r,t){let n=e.tokens,a=n.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,t)),o=n.some(c=>this.isElseKeyword(c.value,t));if(!a&&!o)return null;let u=new re(n,t),s=this.coverageMark(),l=this.parseBodyWithClauses(u,r,t);return l.length===0?(this.coverageRollback(s),null):l[0]}matchEventMarkerPhrase(e,r,t){let n=T.SOV_EVENT_MARKER_PHRASES[t];if(!n)return 0;for(let a of n)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let t=T.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:n}=K(e,r),a=pe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length;u++){let s=n[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(T.KNOWN_EVENTS.has(c)||De.has(c))||T.KNOWN_EVENTS.has(l)||De.has(l)||o.has(l)))continue;let p=this.matchEventParamPhrase(n,u+1).len,d=n[u+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(n,u+1+p,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let t=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return {len:n-r+1,names:t};if(a!==","){if(e[n].kind!=="identifier")break;t.push(a);}}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let t=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(t==="me"||t==="i"||t==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!t&&r.has(t)}tryTrailingEventExtraction(e,r,t){let n=K(e,r).tokens;if(n.length<3)return null;let a=pe[r],o=new Set;if(a)for(let S of Object.keys(a))o.add(S.toLowerCase());let u=n.length-2,s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&T.KNOWN_EVENTS.has(p)||T.KNOWN_EVENTS.has(m)||o.has(m)))return null;let y=p&&T.KNOWN_EVENTS.has(p)?p:a?.[m]??m,E=n.slice(0,u);if(E.length===0)return null;let v=t.filter(S=>S.command!=="on"),f=new re(E,r),h=this.coverageMark(),k=this.parseBodyWithClauses(f,v,r);return k.length===0?(this.coverageRollback(h),null):Ne({type:"literal",value:y},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let n=K(e,r).tokens;if(n.length<3)return null;let a=pe[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length-1;u++){let s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=n[u+1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&T.KNOWN_EVENTS.has(p)||T.KNOWN_EVENTS.has(m)||o.has(m)))continue;let y=p&&T.KNOWN_EVENTS.has(p)?p:a?.[m]??m,E=n.filter((S,A)=>A!==u&&A!==u+1);if(E.length===0)return null;let v=t.filter(S=>S.command!=="on"),f=new re(E,r),h=this.coverageMark(),k=this.parseBodyWithClauses(f,v,r);return k.length===0?(this.coverageRollback(h),null):Ne({type:"literal",value:y},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let n=T.SOV_EVENT_MARKERS[r];if(!n)return null;let o=K(e,r).tokens,u=pe[r],s=new Set;if(u)for(let z of Object.keys(u))s.add(z.toLowerCase());let l=T.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1,y=[];for(let z=0;z<o.length;z++){let g=o[z],C=g.value.toLowerCase(),b=C,w="",D=C.indexOf("[");D>0&&(b=C.slice(0,D),w=g.value.slice(D));let x=g.normalized?.toLowerCase(),L=x&&(T.KNOWN_EVENTS.has(x)||De.has(x)),F=s.has(C)||s.has(b),R=T.KNOWN_EVENTS.has(b)||De.has(b);if(L||F||R){let P=o[z-1];if(P&&(P.normalized??P.value).toLowerCase()==="event")continue;let N;L?N=x:F?N=u?.[C]??u?.[b]??b:N=b;let U=this.matchEventParamPhrase(o,z+1);if(n.size>0){let H=1+U.len,me=o[z+H];me&&me.kind==="selector"&&me.value.startsWith("[")&&(H+=1);let ae=o[z+H];if(ae&&(ae.kind==="particle"||ae.kind==="keyword")&&n.has(ae.value)){c=z,m=N,p=w||(H===U.len+2?o[z+H-1].value:""),d=H+1,y=U.names;break}}else {c=z,m=N,p=w,d=1+U.len+this.matchEventMarkerPhrase(o,z+1+U.len,r),y=U.names;break}}}if(c===-1){let z=new Set(t.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<o.length;g++){let C=o[g];if(C.kind==="identifier")if(n.size>0){let b=1,w=o[g+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(b=2);let D=o[g+b];if(D&&(D.kind==="particle"||D.kind==="keyword")&&n.has(D.value)){c=g,m=C.value,p=b===2?o[g+1].value:"",d=b+1;break}}else {let b=this.matchEventMarkerPhrase(o,g+1,r);if(b>0){c=g,m=C.value,p="",d=1+b;break}let w=o[g+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&z.has(w.normalized)){c=g,m=C.value,p="",d=1;break}}}}if(c===-1)return null;let E=new Set;for(let z=c;z<c+d;z++)E.add(z);if(l){let z=c+d;if(z<o.length){let g=o[z];if((g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value))E.add(z);else if(this.isStrippableSourceRef(g,l.windowTokens)){let C=o[z+1];C&&(C.kind==="particle"||C.kind==="keyword")&&l.markers.has(C.value)&&(E.add(z),E.add(z+1));}}if(c>=2){let g=o[c-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(E.add(c-2),E.add(c-1));}for(let g=0;g<c;g++){let C=o[g],b=C.value.toLowerCase(),w=C.normalized?.toLowerCase();if(l.windowTokens.has(b)||w&&l.windowTokens.has(w)){E.add(g);break}}}let v=o.filter((z,g)=>!E.has(g));if(v.length===0)return null;let f=t.filter(z=>z.command!=="on"),h=new re(v,r),k=this.coverageMark(),S=this.parseBodyWithClauses(h,f,r);if(S.length===0)return this.coverageRollback(k),null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Ne({type:"literal",value:m},S,void 0,A,y)}profileKeywordMatches(e,r,t){let n=O(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===t?true:!!n.alternatives?.some(a=>a.toLowerCase()===t):false}consumeForPostposition(e,r){let t=e.peek();if(!t)return;let n=(t.normalized??"").toLowerCase(),a=O(r)?.keywords?.for;(n==="for"||t.value===a?.primary||(a?.alternatives??[]).includes(t.value))&&e.advance();}isThenKeyword(e,r){let t=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(t):t==="then"||this.profileKeywordMatches(r,"then",t)}isElseKeyword(e,r){let t=e.toLowerCase();return t==="else"?true:this.profileKeywordMatches(r,"else",t)}isEndKeyword(e,r){let t=e.toLowerCase(),n=ja(r);return n?t==="end"||n.has(t):t==="end"||this.profileKeywordMatches(r,"end",t)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}consumeJsBlock(e,r){let t=e.peek();if(!t||!this.isJsKeyword(t))return null;let n=e.mark(),a=[];e.advance();let o=e.peek();o&&t.position?.end!==void 0&&t.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${t.value}${o.value}`.toLowerCase())&&e.advance();let u=false;for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(e.advance(),this.isEndKeyword(l.value,r)){u=true;break}a.push(l);}if(!u)return e.reset(n),null;let s=a.map(l=>l.value).join(" ").trim();return te("js",{patient:{type:"expression",raw:s||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}isIfKeyword(e,r){let t=e.toLowerCase();return t==="if"?true:this.profileKeywordMatches(r,"if",t)}isUnlessKeyword(e,r){let t=e.toLowerCase();return t==="unless"?true:this.profileKeywordMatches(r,"unless",t)}isBlockEndToken(e,r,t){return this.isEndKeyword(e.value,t)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,t){let n=e.peek();if(!n)return null;let a=(n.normalized??n.value).toLowerCase();if(!this.isIfKeyword(a,t))return null;let o=e.mark(),u=this.coverageMark();e.advance();let s=[],l=0;for(;!e.isAtEnd();){let g=e.peek();if(!g)break;let C=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(C,t)||this.isUnlessKeyword(C,t)){l++,s.push(g),e.advance();continue}if(this.isBlockEndToken(g,e.peek(1)??void 0,t)){if(l===0){e.advance();break}l--,s.push(g),e.advance();continue}s.push(g),e.advance();}if(s.length===0)return e.reset(o),this.coverageRollback(u),null;let c=O(t),m=c?.wordOrder==="SOV"?T.buildVerbLookup(c):null,p=0,d=0,y=[];for(;p<s.length;p++){let g=s[p],C=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(C,t)||this.isUnlessKeyword(C,t)?d++:this.isBlockEndToken(g,s[p+1],t)&&d--,d===0&&this.isThenKeyword(g.value,t)){p++;break}if(d===0&&y.length>0){let b=(s[p-1].normalized??s[p-1].value).toLowerCase(),w=s[p-1].value.toLowerCase(),D=(g.normalized??g.value).toLowerCase(),x=T.CONDITION_COPULAS.has(b)||T.CONDITION_COPULAS_SURFACE.has(w)&&T.CONDITION_PREDICATES.has(D),L=m!==null&&m.has(g.value.toLowerCase())&&!T.CONDITION_PREDICATES.has(D),F=/^\.[a-zA-Z_]\w*$/.test(g.value)&&s[p-1].position?.end!==void 0&&g.position?.start!==void 0&&s[p-1].position.end===g.position.start;if(!T.CONDITION_OPERATORS.has(D)&&!F&&(!x||L)&&(this.tokensBeginCommand(s.slice(p),r,t)||this.sovCommandStartsAt(s.slice(p),m)))break}y.push(g);}if(y.length===0)return e.reset(o),this.coverageRollback(u),null;let v=[],f=[],h=false,k=0;for(;p<s.length;p++){let g=s[p],C=(g.normalized??g.value).toLowerCase();if(this.isIfKeyword(C,t)||this.isUnlessKeyword(C,t)?k++:this.isBlockEndToken(g,s[p+1],t)&&k--,k===0&&!h&&this.isElseKeyword(g.value,t)){h=true;continue}(h?f:v).push(g);}let S={type:"expression",raw:this.joinTokenText(y,t)},A=this.parseBranch(v,r,t),z=f.length>0?this.parseBranch(f,r,t):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(o),this.coverageRollback(u),null):nn(S,A,z,{sourceLanguage:t,patternId:`conditional-${t}-folded`,confidence:1})}joinTokenText(e,r){return yr(e,O(r))}tokensBeginCommand(e,r,t){if(e.length===0)return false;let n=new re(e,t);return ie.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),n=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!n(u)||s.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&t(l))return true}return false}parseBranch(e,r,t){if(e.length===0)return [];let n=new re(e,t),a=this.parseBodyWithClauses(n,r,t);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=K(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),u=T.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let d=1;if(d<n.length){let y=n[d],E=n[d+1],v=y.kind==="identifier"&&E?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(E.value);(y.kind==="keyword"||y.kind==="particle"||v)&&(d++,l++);}if(d<n.length){let y=n[d];if(y.kind==="literal"){let E=y.value.match(/^(\d+)(ms|s|m)?$/);if(E){let v=parseInt(E[1],10),f=E[2]||"ms";f==="s"?v*=1e3:f==="m"&&(v*=6e4),s[u]=v,l=d+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let c=n.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,p=e.slice(m);return {modifiers:s,remainingInput:p}}stripAsyncModifier(e,r){let t=O(r)?.keywords?.async,n=new Set(["async"]);t?.primary&&n.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=K(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=K(e,r).tokens;for(let n=0;n<t.length-1;n++){if(t[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<t.length;l++){let c=t[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(a===-1)continue;let o=t[n].position.start,u=t[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,t)=>r+(parseInt(/left (\d+) token/.exec(t.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(t=>{if(t.code!=="unconsumed-input")return true;let n=/unconsumed: "(.*)"$/.exec(t.message)?.[1];return !n||n.replace(/\s+/g," ").trim()!==r})}}reclaimDanglingFromTail(e,r,t){let n=T.droppedTokenCount,a=T.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),u=O(t)?.roleMarkers?.source,s=new Set;u?.primary&&s.add(u.primary),u?.alternatives?.forEach(c=>s.add(c));let l=K(r,t).tokens;for(let c=0;c<l.length;c++){let m=l[c];if(m.normalized!=="source"&&!s.has(m.value))continue;let p=u?.position==="after"?c-1:c+1,d=l[p];if(!d||d.kind!=="identifier"&&d.kind!=="keyword")continue;let y=Math.min(m.position.start,d.position.start),E=Math.max(m.position.end,d.position.end),v=r.slice(y,E).replace(/\s+/g," ").trim();if(!a.some(h=>h===v||h.includes(v)))continue;let f=(r.slice(0,y).trimEnd()+" "+r.slice(E).trimStart()).trim();if(!(!f||f===r))try{let h=this.parse(f,t);if(!h||h.kind!=="event-handler")continue;let k=mr(h);if(n(k)<o)return {node:{...k,eventModifiers:{...k.eventModifiers,from:{type:"literal",value:d.value,dataType:"string"}}},input:f}}catch{}}return null}reclaimEventCompoundTail(e,r,t){let n=T.unconsumedSpans(e);if(n.length===0)return null;let a=pe[t];if(!a)return null;let o=e.roles,u=o.get("event"),s=u?.type==="literal"&&typeof u.value=="string"?u.value:null;if(!s)return null;let l=m=>m.replace(/\s+/g," ").trim(),c=K(r,t).tokens;for(let m of n)for(let p=1;p<c.length;p++)for(let d=p;d<c.length;d++){let y=l(r.slice(c[p].position.start,c[d].position.end));if(y.length>m.length)break;if(y!==m)continue;let E=c[p-1];if((a[E.value]??E.normalized)!==s)break;let f=l(r.slice(E.position.start,c[d].position.end)),h=a[f];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:T.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,t){let n=T.unconsumedSpans(e);if(n.length===0)return null;let a=T.AS_MARKERS_BEFORE[t];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),u=T.droppedTokenCount(e),s=K(r,t).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1];if(!a.some(y=>c.value.toLowerCase()===y)||!T.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let p=o(r.slice(c.position.start,m.position.end));if(!n.includes(p))continue;let d=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(m.position.end).trimStart()).trim();if(!(!d||d===r))try{let y=this.parse(d,t);if(!y||y.kind!=="event-handler")continue;let E=mr(y);if(T.droppedTokenCount(E)>=u)continue;let v=T.findResponseTypeTarget(E);if(!v)continue;return v.roles.set("responseType",{type:"expression",raw:m.value}),{node:E,input:d}}catch{}}return null}static findResponseTypeTarget(e){let r=null,t=n=>{if(!n||typeof n!="object"||r)return;if(n.kind==="command"){let o=n;if(J(o.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let u=a[o];Array.isArray(u)&&u.forEach(s=>t(s));}};return t(e),r}reclaimCapturedDestinationTail(e,r,t){let n=T.unconsumedSpans(e);if(n.length===0)return null;let a=O(t)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let u=l=>l.replace(/\s+/g," ").trim(),s=K(r,t).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1],p=o.has(c.value)&&m.normalized==="me",d=c.normalized==="me"&&o.has(m.value);if(!p&&!d)continue;let y=u(r.slice(c.position.start,m.position.end));if(!n.includes(y))continue;let E=false,v=f=>{if(!f||typeof f!="object"||E)return;if(f.kind==="command"){let k=f.roles.get("destination");if(k?.type==="reference"&&k.value==="me"){E=true;return}}let h=f;for(let k of ["body","statements","thenBranch","elseBranch","commands"]){let S=h[k];Array.isArray(S)&&S.forEach(A=>v(A));}};if(v(e),!!E)return {node:T.withoutSpanDiagnostics(e,y),input:r}}return null}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let n=e.mark(),a=e.peek();if(!a)break;let o=(a.normalized||a.value).toLowerCase();if(!T.OR_KEYWORDS.has(o)){e.reset(n);break}e.advance();let u=e.peek();if(!u){e.reset(n);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};Y.coverageMarkerSurfaces=new Map;Y.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Y.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};Y.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Y.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Y.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Y.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])};Y.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Y.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};Y.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Y.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Y.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Y.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Y.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};Y.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var Bo=Y,Fo=new Bo;function Lo(i,e){return Fo.parse(i,e)}function Ro(i,e){try{let r=K(i,e),t=le(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...t].sort((l,c)=>c.priority-l.priority),a=n.filter(l=>l.command==="on"),o=ie.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=n.filter(l=>l.command!=="on"),s=ie.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${i}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Bt(i,e){try{let t=Lo(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:K(i,e).tokens.length}}catch{}let r=Ro(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Ft(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,n)=>{let a=t[r]??99,o=n[r]??99;return a-o})}function Oo(i,e){let r=i.markerOverride?.[e.code],t=e.roleMarkers[i.role];if(r!==void 0)return {primary:r,position:t?.position??"before",isOverride:true};if(t&&t.primary){let n={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(n.alternatives=t.alternatives),n}return null}function Xe(i,e){let r,t;if(i.markerOverride&&i.markerOverride[e.code]!==void 0)r=i.markerOverride[e.code];else {let a=e.roleMarkers[i.role];a&&(r=a.primary,t=a.alternatives?[...a.alternatives]:void 0);}let n=i.markerVariants?.[e.code];if(n&&n.length>0){let a=t?[...t]:[];for(let o of n)o!==r&&!a.includes(o)&&a.push(o);t=a;}return {marker:r,alternatives:t}}function Ve(i,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(i.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function Po(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(c);}}let o=e.roleMarkers.destination;o&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary}]}),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),a.push(...be(i,e.roleMarkers.source)),a.push(...Er(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function No(i,e,r,t,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(c);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push(...be(i,e.roleMarkers.source));let s=e.roleMarkers.destination;if(i.action==="swap"&&s){let l=i.roles.find(c=>c.role==="patient")?.markerOverride?.[e.code];if(l&&l!==s.primary){let c=s.alternatives??[];c.includes(l)||(s={...s,alternatives:[...c,l]});}}return a.push(...Er(i,s)),{id:`${i.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function _o(i,e,r,t,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),a.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${i.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Mo(i,e,r,t,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...be(i,e.roleMarkers.source)),a.push(...Er(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function Io(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${i.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function jo(i,e,r,t){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${i.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function $o(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let m=t.primary.split(/\s+/);if(m.length>1)for(let p of m)a.push({type:"literal",value:p});else {let p=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(p);}}let u=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.sovPosition??999,y=p.sovPosition??999;return d-y});for(let m of u){a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:d}=Xe(m,e);if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(y);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Ve(a,c,i),{id:`${i.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function Vo(i,e,r,t,n){let a=[],u=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.sovPosition??999,d=m.sovPosition??999;return p-d});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:p}=Xe(c,e);m&&a.push(p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),t.position==="after"){let c=t.primary.split(/\s+/);if(c.length>1)for(let m of c)a.push({type:"literal",value:m});else a.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Ve(a,l,i),{id:`${i.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${t.primary}`,tokens:a},extraction:l}}function qo(i,e,r,t,n){let a=[],u=[...i.roles.filter(v=>v.required)].sort((v,f)=>{let h=v.sovPosition??999,k=f.sovPosition??999;return h-k}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=Xe(s,e);if(l){let v=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(v);}if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let v=t.primary.split(/\s+/);if(v.length>1)for(let f of v)a.push({type:"literal",value:f});else {let f=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(f);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m);let p=u[1];a.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:y}=Xe(p,e);if(d){let v=y?{type:"literal",value:d,alternatives:y}:{type:"literal",value:d};a.push(v);}let E={action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return Ve(a,E,i),{id:`${i.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${p.role}}`,tokens:a},extraction:E}}function Qr(i,e,r,t,n){let a=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...be(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function Wo(i,e,r,t,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o),a.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&a.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),a.push(...be(i,e.roleMarkers.source)),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(s);}if(a.push({type:"role",role:"event",optional:false}),i.action==="swap"){let s=i.roles.find(l=>l.role==="patient")?.markerOverride?.[e.code];s&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:s},{type:"role",role:"destination",optional:false}]});}return {id:`${i.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function Ko(i,e,r,t,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,y=p.svoPosition??999;return d-y});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(y);}a.push({type:"role",role:m.role,optional:false});}if(t.position==="before"){let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ve(a,c,i),{id:`${i.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:a},extraction:c}}function et(i,e,r,t,n){let a=[];if(t.position==="before"){let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,y=p.svoPosition??999;return d-y});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};a.push(y);}a.push({type:"role",role:m.role,optional:false});}let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Ve(a,c,i),{id:`${i.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function Uo(i,e,r,t,n){let a=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...be(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${t.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}function Ho(i,e,r,t){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...be(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ze(i),...ke(i)}}}var Fe={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Ye(i,e,r=Fe){let t=`${i.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[i.action];if(!a)throw new Error(`No keyword translation for '${i.action}' in ${e.code}`);let o=Xo(i,e,a),u=br(i,e),s=tu(i,e,a);return {id:t,language:e.code,command:i.action,priority:n,template:{format:s,tokens:o},extraction:u}}function Go(i,e,r=Fe){if(i.roles.filter(u=>!u.required).length===0)return null;let n=i.roles.filter(u=>u.required),a={...i,roles:n};return {...Ye(a,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:br(i,e)}}function rt(i,e,r=Fe){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(u=>u.required);if(t.length!==1)return null;let n=e.keywords[i.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=t.flatMap(u=>{let s=u.valuePrefixLiteral?.[e.code],l={type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes};return s?[{type:"literal",value:s},l]:[l]});return {id:`${i.action}-${e.code}-generated-verb-first`,language:e.code,command:i.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${t[0].role}>`,tokens:[a,...o]},extraction:br(i,e)}}function Yo(i,e,r=Fe){let t=[];if(t.push(Ye(i,e,r)),r.generateSimpleVariants){let n=Go(i,e,r);n&&t.push(n);}for(let n of i.omitRoleVariants??[]){let a={...i,roles:i.roles.filter(u=>u.role!==n)},o=Ye(a,e,r);t.push({...o,id:`${i.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let n=rt(i,e,r);n&&t.push(n);}for(let n of i.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...u}=i,s={...u,roles:i.roles.map(p=>p.role===n.role?{...p,valuePrefixLiteral:{[e.code]:a}}:p)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},m=Ye(s,e,r);if(t.push({...m,id:`${i.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...m.extraction,...c}}),r.generateVerbFirstVariants!==false){let p=rt(s,e,r);p&&t.push({...p,id:`${i.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...p.extraction,...c}});}}return t}function Lt(i,e=Fe){let r=[],t=ba();for(let n of t){if(!i.keywords[n.action])continue;let a=Yo(n,i,e);if(r.push(...a),i.eventHandler?.eventMarker){let o=Zo(n,i,e);r.push(...o);}}return r}function Zo(i,e,r=Fe){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],n=e.eventHandler.eventMarker,a=e.keywords[i.action];if(!a)return [];if(i.roles.length===0)return [];let u=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push($o(i,e,a,n,r)),t.push(qo(i,e,a,n,r)),t.push(Vo(i,e,a,n,r));else {t.push(Po(i,e,a,n,r)),t.push(No(i,e,a,n,r));let s=e.roleMarkers.destination;s&&s.primary!==n.primary&&t.push(_o(i,e,a,n,r));let l=n.primary.split(/\s+/),c=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&t.push(Mo(i,e,a,n,r)),t.push(Io(i,e,a,n,r));let m=jo(i,e,a,r);m&&t.push(m);}else e.wordOrder==="VSO"?u?(t.push(et(i,e,a,n,r)),t.push(Ko(i,e,a,n,r))):(t.push(Qr(i,e,a,n,r)),t.push(Wo(i,e,a,n,r)),e.eventHandler?.negationMarker&&t.push(Uo(i,e,a,n,r)),e.tokenization?.prefixes&&t.push(Ho(i,e,a,r))):u?t.push(et(i,e,a,n,r)):t.push(Qr(i,e,a,n,r));return t}function Xo(i,e,r){let t=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=Qo(i,e);switch(e.wordOrder){case "SVO":t.push(n),t.push(...a);break;case "SOV":t.push(...a),t.push(n);break;case "VSO":t.push(n),t.push(...a);break;default:t.push(n),t.push(...a);}return Jo(t)}function Jo(i){let e=[];for(let r of i){let t=e[e.length-1];if(t&&t.type==="literal"&&r.type==="literal"&&t.value===r.value){let n=[...t.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...t,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function Qo(i,e){let r=[],t=Ft(i.roles,e.wordOrder);for(let n of t){let a=eu(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function eu(i,e){let r=[],t=i.markerOverride?.[e.code],n=e.roleMarkers[i.role],a=i.renderOverride?.[e.code]==="",o={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes},u=i.valuePrefixLiteral?.[e.code],s=()=>{u&&r.push({type:"literal",value:u}),r.push(o);};if(t!==void 0){let l=t?t.split(/\s+/).filter(Boolean):[],c=n?.position??"before",m=i.markerOptional?.[e.code]===true,p=d=>{let y=a?{type:"literal",value:d,renderSuppress:true}:{type:"literal",value:d};r.push(m?{type:"group",optional:true,tokens:[y]}:y);};if(c==="before"){for(let d of l)p(d);s();}else {s();for(let d of l)p(d);}}else if(n){let l=i.markerVariants?.[e.code]??[],c=()=>{let p=[...new Set([...n.alternatives??[],...l])].filter(d=>d!==n.primary);return {type:"literal",value:n.primary,...p.length?{alternatives:p}:{},...a?{renderSuppress:true}:{}}},m=p=>{r.push(e.markersOptional||i.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[p]}:p);};n.position==="before"?(n.primary&&m(c()),s()):(s(),m(c()));}else s();return r}function ru(i,e){let r={};for(let t of i.roles){let n=t.markerOverride?.[e.code],a=e.roleMarkers[t.role];if(t.valuePrefixLiteral?.[e.code])r[t.role]={marker:t.valuePrefixLiteral[e.code]};else if(n!==void 0)r[t.role]=n?{marker:n}:{};else if(a&&a.primary){let o=t.markerVariants?.[e.code]??[],u=[...new Set([...a.alternatives??[],...o])].filter(s=>s!==a.primary);r[t.role]=u.length?{marker:a.primary,markerAlternatives:u}:{marker:a.primary};}else r[t.role]={};}return r}function br(i,e){let r=ru(i,e),t={};for(let n of i.roles){let a=r[n.role]||{};!n.required&&n.default?t[n.role]={...a,default:n.default}:t[n.role]=a;}return t}function tu(i,e,r){let t=[],a=Ft(i.roles,e.wordOrder).map(o=>{let u=Oo(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":t.push(r.primary,...a);break;case "SOV":t.push(...a,r.primary);break;default:t.push(r.primary,...a);}return t.join(" ")}var iu=class{constructor(i={}){this.cache=new Map,this.config={maxSize:i.maxSize??1e3,ttlMs:i.ttlMs??0,enabled:i.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(i,e){return `${e}:${i}`}isExpired(i){return this.config.ttlMs===0?false:Date.now()-i.createdAt>this.config.ttlMs}evictLRU(){let i=this.cache.keys().next().value;i!==void 0&&(this.cache.delete(i),this.stats.evictions++);}get(i,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(i,e),t=this.cache.get(r);if(!t){this.stats.misses++;return}if(this.isExpired(t)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),t.lastAccessed=Date.now(),this.cache.set(r,t),this.stats.hits++,t.result}set(i,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let t=this.makeKey(i,e),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:n,lastAccessed:n});}has(i,e){if(!this.config.enabled)return false;let r=this.makeKey(i,e),t=this.cache.get(r);return t?this.isExpired(t)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(i,e){let r=this.makeKey(i,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let i=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:i>0?this.stats.hits/i:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(i){if(i.maxSize!==void 0)for(this.config.maxSize=i.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();i.ttlMs!==void 0&&(this.config.ttlMs=i.ttlMs),i.enabled!==void 0&&(this.config.enabled=i.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new iu;function nu(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(i)}function au(i){for(let e of i)if(nu(e))return true;return false}function Cr(i){return "a\u0131ouAIOU".includes(i)}function Ot(i){return "ei\xF6\xFCE\u0130\xD6\xDC".includes(i)}function Pt(i){return Cr(i)||Ot(i)}function ou(i){for(let e=i.length-1;e>=0;e--)if(Pt(i[e]))return i[e];return null}function uu(i,e){let r=ou(i);if(!r)return true;let t=e.split("").find(n=>Pt(n));return t?Cr(r)?Cr(t):Ot(t):true}var su=[{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}],Nt=class{constructor(){this.language="tr";}isNormalizable(i){return !(!au(i)||i.length<3)}normalize(i){let e=i.toLowerCase();for(let r of su)if(e.endsWith(r.pattern)){let t=e.slice(0,-r.pattern.length),n=r.minStemLength??2;if(t.length<n)continue;if(!uu(t,r.pattern)){let o=r.confidence*.9,u={removedSuffixes:[r.pattern]};return r.conjugationType&&(u.conjugationType=r.conjugationType),or(t,o,u)}let a={removedSuffixes:[r.pattern]};return r.conjugationType&&(a.conjugationType=r.conjugationType),or(t,r.confidence,a)}return Or(i)}},_t={code:"tr",name:"Turkish",nativeName:"T\xFCrk\xE7e",regions:["priority"],direction:"ltr",script:"latin",wordOrder:"SOV",markingStrategy:"case-suffix",usesSpaces:true,markersOptional:true,verb:{position:"end",suffixes:["mek","mak","yor","di","mi\u015F"],subjectDrop:true},references:{me:"ben",it:"o",you:"sen",result:"sonu\xE7",event:"olay",target:"hedef",body:"g\xF6vde",document:"belge",window:"pencere",detail:"detay"},possessive:{marker:"\u0131n",markerPosition:"after-object",usePossessiveAdjectives:true,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","ile"],position:"after"},event:{primary:"i",alternatives:["\u0131","u","\xFC"],position:"after"}},keywords:{toggle:{primary:"de\u011Fi\u015Ftir",alternatives:["a\xE7/kapat"],normalized:"toggle"},add:{primary:"ekle",normalized:"add"},remove:{primary:"kald\u0131r",alternatives:["sil"],normalized:"remove"},put:{primary:"koy",normalized:"put"},append:{primary:"ili\u015Ftir",normalized:"append"},prepend:{primary:"ba\u015F\u0131naekle",normalized:"prepend"},take:{primary:"tut",normalized:"take"},make:{primary:"yap",normalized:"make"},clone:{primary:"klonla",normalized:"clone"},swap:{primary:"takas",normalized:"swap"},morph:{primary:"d\xF6n\xFC\u015Ft\xFCr",alternatives:["\u015Fekil de\u011Fi\u015Ftir"],normalized:"morph"},set:{primary:"ayarla",alternatives:["belirle"],normalized:"set"},get:{primary:"al",normalized:"get"},increment:{primary:"art\u0131r",normalized:"increment"},decrement:{primary:"azalt",normalized:"decrement"},log:{primary:"kaydet",normalized:"log"},show:{primary:"g\xF6ster",normalized:"show"},hide:{primary:"gizle",normalized:"hide"},transition:{primary:"ge\xE7i\u015F",normalized:"transition"},on:{primary:"\xFCzerinde",alternatives:["zaman"],normalized:"on"},trigger:{primary:"tetikle",normalized:"trigger"},send:{primary:"g\xF6nder",normalized:"send"},focus:{primary:"odak",alternatives:["odaklanma"],normalized:"focus"},blur:{primary:"bulan\u0131k",alternatives:["bulan\u0131kl\u0131k","bulanik"],normalized:"blur"},empty:{primary:"bo\u015Falt",alternatives:["bosalt","bo\u015F"],normalized:"empty"},open:{primary:"a\xE7",alternatives:["ac"],normalized:"open"},close:{primary:"kapat",normalized:"close"},select:{primary:"vurgula",normalized:"select"},clear:{primary:"temizle",normalized:"clear"},reset:{primary:"s\u0131f\u0131rla",alternatives:["sifirla"],normalized:"reset"},breakpoint:{primary:"kesme-noktas\u0131",alternatives:["kesme-noktasi"],normalized:"breakpoint"},click:{primary:"t\u0131klama",alternatives:["t\u0131kla","tiklama","t\u0131k","tik"],normalized:"click"},hover:{primary:"\xFCzerine gelme",alternatives:["\xFCzerinde gezinme"],normalized:"hover"},submit:{primary:"g\xF6nderme",normalized:"submit"},input:{primary:"giri\u015F",alternatives:["girdi","giris"],normalized:"input"},change:{primary:"de\u011Fi\u015Fiklik",alternatives:["de\u011Fi\u015Fim","degisim"],normalized:"change"},load:{primary:"y\xFCkle",normalized:"load"},go:{primary:"git",normalized:"go"},scroll:{primary:"kayd\u0131r",alternatives:["kaydir"],normalized:"scroll"},push:{primary:"itele",alternatives:["push"],normalized:"push"},replace:{primary:"de\u011Fi\u015Ftir_url",alternatives:["degistir_url"],normalized:"replace"},process:{primary:"i\u015Fle",alternatives:["isle"],normalized:"process"},wait:{primary:"bekle",normalized:"wait"},fetch:{primary:"getir",normalized:"fetch"},settle:{primary:"sabitlen",normalized:"settle"},if:{primary:"e\u011Fer",normalized:"if"},unless:{primary:"de\u011Filse",normalized:"unless"},when:{primary:"iken",alternatives:["durumunda","oldu\u011Funda"],normalized:"when"},where:{primary:"nerede",normalized:"where"},else:{primary:"yoksa",normalized:"else"},repeat:{primary:"tekrarla",normalized:"repeat"},for:{primary:"i\xE7in",normalized:"for"},while:{primary:"s\xFCresince",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"devam",normalized:"continue"},halt:{primary:"durdur",normalized:"halt"},throw:{primary:"f\u0131rlat",normalized:"throw"},call:{primary:"\xE7a\u011F\u0131r",normalized:"call"},return:{primary:"d\xF6n",normalized:"return"},then:{primary:"ard\u0131ndan",alternatives:["daha sonra","ardindan"],normalized:"then"},and:{primary:"ve",alternatives:["ayr\u0131ca","hem de"],normalized:"and"},or:{primary:"veya",normalized:"or"},not:{primary:"de\u011Fil",alternatives:["degil"],normalized:"not"},matches:{primary:"e\u015Fle\u015Fir",normalized:"matches"},is:{primary:"dir",normalized:"is"},no:{primary:"yok",normalized:"no"},end:{primary:"son",alternatives:["biti\u015F","bitti"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"asenkron",normalized:"async"},tell:{primary:"s\xF6yle",normalized:"tell"},default:{primary:"varsay\u0131lan",normalized:"default"},init:{primary:"ba\u015Flat",normalized:"init"},behavior:{primary:"davran\u0131\u015F",normalized:"behavior"},install:{primary:"kur",alternatives:["y\xFCklemek"],normalized:"install"},measure:{primary:"\xF6l\xE7",normalized:"measure"},beep:{primary:"bip",normalized:"beep"},break:{primary:"dur",normalized:"break"},copy:{primary:"kopyala",normalized:"copy"},exit:{primary:"\xE7\u0131k",normalized:"exit"},pick:{primary:"se\xE7",normalized:"pick"},render:{primary:"render",normalized:"render"},into:{primary:"i\xE7ine",normalized:"into"},before:{primary:"\xF6nce",normalized:"before"},after:{primary:"sonra",normalized:"after"},until:{primary:"kadar",normalized:"until"},event:{primary:"olay",normalized:"event"},from:{primary:"den",alternatives:["dan"],normalized:"from"},connect:{primary:"ba\u011Flan",alternatives:["ba\u011Fla","ba\u011Flant\u0131"],normalized:"connect"},stream:{primary:"yay\u0131nla",alternatives:["ak\u0131t","ak\u0131\u015F"],normalized:"stream"},live:{primary:"canl\u0131",alternatives:["ger\xE7ek-zamanl\u0131"],normalized:"live"},socket:{primary:"soket",alternatives:["websocket"],normalized:"socket"},bind:{primary:"bind",normalized:"bind"},intercept:{primary:"yakala",alternatives:["araya-gir","intercept"],normalized:"intercept"},worker:{primary:"i\u015F\xE7i",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["olay-kayna\u011F\u0131"],normalized:"eventsource"}},eventHandler:{eventMarker:{primary:"da",alternatives:["de","ta","te"],position:"after"},temporalMarkers:["d\u0131\u011F\u0131nda","di\u011Finde"]}},lu=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],cu=class{constructor(i=lu){this.name="operator",this.operators=[...i].sort((e,r)=>r.length-e.length);}canExtract(i,e){return this.operators.some(r=>i.startsWith(r,e))}extract(i,e){for(let r of this.operators)if(i.startsWith(r,e))return {value:r,length:r.length};return null}},mu="()[]{},:;",pu=class{constructor(i=mu){this.punctuation=i,this.name="punctuation";}canExtract(i,e){return this.punctuation.includes(i[e])}extract(i,e){let r=i[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function wr(i,e){let r=e;for(;r<i.length&&i[r]===":";){let t=i.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!t)break;let n=r+t[0].length;if(i[n]==="("){let a=0,o=n;for(;o<i.length;){if(i[o]==="(")a++;else if(i[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Rt(i,e){let r=i[e];if(r==="#"){let t=i.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!t)return null;let n=wr(i,e+t[0].length);return i.slice(e,n)}if(r==="."){let t=i.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(t)return t[0];let n=i.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=wr(i,e+n[0].length);return i.slice(e,a)}if(r==="@"){let t=i.slice(e).match(/^@[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="*"){let t=i.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="["){let t=0,n=e;for(;n<i.length;){if(i[n]==="["&&t++,i[n]==="]"&&(t--,t===0)){let a=wr(i,n+1);return i.slice(e,a)}n++;}return null}if(r==="<"){let t=i.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return t?t[0]:null}return null}var du=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Rt(i,e)!==null:false}extract(i,e){let r=Rt(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},fu=class{constructor(){this.name="event-modifier";}canExtract(i,e){if(i[e]!==".")return false;let r=i.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(i,e){let r=i.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let t=r[0],n=t.slice(1).split("(")[0],a=r[1];return {value:t,length:t.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},yu=["http://","https://","//","./","../","/"];function hu(i,e){let r=1;for(let t=e;t<i.length;t++){let n=i[t];if(n==="{")r++;else if(n==="}"&&--r===0)return t+1}return -1}function vu(i,e){let r=i.slice(e),t=yu.find(a=>r.startsWith(a));if(!t)return null;let n=t.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=hu(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Eu=class{constructor(){this.name="url";}canExtract(i,e){let r=i.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(i,e){let r=vu(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},gu=class{constructor(){this.name="variable-ref";}canExtract(i,e){let r=i[e];return (r===":"||r==="$"||r==="^")&&e+1<i.length&&/[a-zA-Z_]/.test(i[e+1])}extract(i,e){if(!this.canExtract(i,e))return null;let r=1;for(;e+r<i.length&&/[a-zA-Z0-9_]/.test(i[e+r]);)r++;return {value:i.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function rr(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:"\xE7\xC7\u011F\u011E\u0131\u0130\xF6\xD6\u015F\u015E\xFC\xDC".includes(i)}var zu=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","do\u011Fru","boyunca"]),ku=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"]),bu=class{constructor(){this.name="turkish-keyword";}setContext(i){this.context=i;}canExtract(i,e){return rr(i[e])}extract(i,e){if(!this.context)throw new Error("TurkishKeywordExtractor: context not set");let r=e,t=12;for(let m=Math.min(t,i.length-r);m>=2;m--){let p=i.slice(r,r+m);if(r+m<i.length&&rr(i[r+m]))continue;let d=true;for(let E=0;E<p.length;E++)if(!rr(p[E])){d=false;break}if(!d)continue;let y=this.context.lookupKeyword(p);if(y)return {value:p,length:m,metadata:{normalized:y.normalized!==y.native?y.normalized:void 0}};if(this.context.normalizer){let E=this.context.normalizer.normalize(p);if(E.stem!==p&&E.confidence>=.7){let v=this.context.lookupKeyword(E.stem);if(v)return {value:p,length:m,metadata:{normalized:v.normalized,stem:E.stem,stemConfidence:E.confidence}}}}}let n="",a=e;for(;a<i.length&&rr(i[a]);)n+=i[a],a++;for(let m=n.length;m>=2&&!(m<n.length);m--){let p=n.substring(0,m),d=this.context.lookupKeyword(p);if(d)return {value:p,length:m,metadata:{normalized:d.normalized!==d.native?d.normalized:void 0}}}if(!n||!n)return null;if(zu.has(n.toLowerCase()))return {value:n,length:a-r,metadata:{postpositionValue:n.toLowerCase()}};if(ku.has(n.toLowerCase()))return {value:n,length:a-r,metadata:{caseSuffixValue:n.toLowerCase()}};let o=this.context.lookupKeyword(n),u=o&&o.normalized!==o.native?o.normalized:void 0,s,l,c;if(!o&&this.context.normalizer){let m=this.context.normalizer.normalize(n);if(m.stem!==n&&m.confidence>=.7){let p=this.context.lookupKeyword(m.stem);p&&(s=p.normalized,l=m.stem,c=m.confidence);}}return {value:n,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:c}}}};function wu(){return new bu}function Cu(){return [new Eu,new fu,new gu,new du]}var Au=new Set(["ile","i\xE7in","kadar","gibi","\xF6nce","\xFCzerinde","alt\u0131nda","i\xE7inde","d\u0131\u015F\u0131nda","aras\u0131nda","kar\u015F\u0131","g\xF6re","ra\u011Fmen","boyunca"]),Su=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"]),Du=[{native:"do\u011Fru",normalized:"true"},{native:"dogru",normalized:"true"},{native:"yanl\u0131\u015F",normalized:"false"},{native:"yanlis",normalized:"false"},{native:"null",normalized:"null"},{native:"bo\u015F",normalized:"null"},{native:"bos",normalized:"null"},{native:"tan\u0131ms\u0131z",normalized:"undefined"},{native:"tanimsiz",normalized:"undefined"},{native:"ilk",normalized:"first"},{native:"son",normalized:"last"},{native:"sonuncu",normalized:"last"},{native:"sonraki",normalized:"next"},{native:"\xF6nceki",normalized:"previous"},{native:"onceki",normalized:"previous"},{native:"enyak\u0131n",normalized:"closest"},{native:"enyakin",normalized:"closest"},{native:"ebeveyn",normalized:"parent"},{native:"fare \xFCzerinde",normalized:"mouseover"},{native:"fare uzerinde",normalized:"mouseover"},{native:"fare d\u0131\u015F\u0131nda",normalized:"mouseout"},{native:"fare disinda",normalized:"mouseout"},{native:"farebas",normalized:"mousedown"},{native:"fareb\u0131rak",normalized:"mouseup"},{native:"farebirak",normalized:"mouseup"},{native:"kayd\u0131r",normalized:"scroll"},{native:"kaydir",normalized:"scroll"},{native:"boyutland\u0131rma",normalized:"resize"},{native:"boyutlandirma",normalized:"resize"},{native:"boyutland\u0131r",normalized:"resize"},{native:"boyutlandir",normalized:"resize"},{native:"kayd\u0131rma",normalized:"scroll"},{native:"kaydirma",normalized:"scroll"},{native:"tu\u015F_bas",normalized:"keydown"},{native:"tus_bas",normalized:"keydown"},{native:"tu\u015F_b\u0131rak",normalized:"keyup"},{native:"tus_birak",normalized:"keyup"},{native:"saniye",normalized:"s"},{native:"milisaniye",normalized:"ms"},{native:"dakika",normalized:"m"},{native:"saat",normalized:"h"},{native:"dahil",normalized:"inclusive"},{native:"hari\xE7",normalized:"exclusive"},{native:"karakterler",normalized:"characters"},{native:"rastgele",normalized:"random"}],xu=class extends Rr{constructor(){super(),this.language="tr",this.direction="ltr",this.initializeKeywordsFromProfile(_t,Du),this.setNormalizer(new Nt),this.registerExtractors(Cu()),this.registerExtractor(new Fr),this.registerExtractor(new Lr),this.registerExtractor(wu()),this.registerExtractor(new cu),this.registerExtractor(new pu);}classifyToken(i){let e=i.toLowerCase();return Au.has(e)||Su.has(e)?"particle":this.isKeyword(e)?"keyword":i.startsWith("/")||i.startsWith("./")||i.startsWith("../")||i.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||i.startsWith("'")||/^\d/.test(i)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(i)?"operator":"identifier"}},Tu=new xu;ct("tr",Tu,_t);function tr(i){let e=i.getAttribute("data-lang");if(e)return Ar(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Ar(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?Ar(t):null}function Ar(i){return i.split("-")[0].toLowerCase()}var Mt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"]],on:[["event",""],["source","from"]],open:[["style","as"],["patient",""]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"],["scope","on"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],socket:[],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],while:[["condition",""]],worker:[]};function ir(i){switch(i.kind){case "event-handler":return Bu(i);case "compound":return Fu(i);default:return Lu(i)}}function Bu(i){let e=["on"],r=i.roles.get("event");r&&e.push(qe(r));let t=i.roles.get("source");if(t&&e.push("from",qe(t)),i.body&&i.body.length>0){let n=i.body.map(ir);e.push(n.join(" then "));}return e.join(" ")}function Fu(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(ir).join(` ${e} `)}function Lu(i){let e=Mt[i.action];if(e){let t=[i.action];for(let[n,a]of e){let o=i.roles.get(n);o&&((n==="destination"||n==="source")&&o.type==="reference"&&o.value==="me"||(a&&t.push(a),t.push(qe(o))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(qe(t));return r.join(" ")}function qe(i){switch(i.type){case "literal":return typeof i.value=="string"&&i.dataType==="string"?`"${i.value}"`:String(i.value);case "selector":return i.value;case "reference":return i.value;case "property-path":return Ru(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function Ru(i){let e=qe(i.object),r=i.property;if(i.object.type==="reference")switch(i.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var jt=.5,Ou={confidenceThreshold:jt,strategy:"semantic",fallbackToOriginal:true};function Pu(i,e){return typeof i=="number"?i:i[e]??i["*"]??jt}function Sr(i,e,r={}){let t={...Ou,...r},n=It(i,e,t);if(n!==null)return n;let a=_u(i);if(a){let o=It(a.commands,e,t);if(o!==null)return a.prefix+o}return i}function It(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=Pu(r.confidenceThreshold,e),n=$t(i,e,t);if(n!==null)return n}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=Mu(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var Nu=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function _u(i){let e=i.match(Nu);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function $t(i,e,r){try{let t=ju(i,e);if(t.length>1)return $u(t,e,r);if(!pt(e))return null;let n=Bt(i,e);return n.confidence<r||!n.node?null:ir(n.node)}catch{return null}}function Mu(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function Iu(i){let e=["then"],r=O(i);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let n of t.alternatives)e.includes(n)||e.push(n);}return e}function ju(i,e){let t=Iu(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),a=i.split(`
5
+ `).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of a){let s=u.split(n);o.push(...s);}return o}function $u(i,e,r){let t=[];for(let n of i){let a=$t(n.trim(),e,r);if(a===null)return null;t.push(a);}return t.join(" then ")}function Dr(i={}){return function(r){let{internals:t}=r,n=t.runtime,a=n.getScript.bind(n);n.getScript=function(o){let u=a(o);if(!u)return null;let s=Vu(o,i);if(!s||s==="en")return u;let l=Sr(u,s,i);return i.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function Vu(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=tr(i);return r||(e.defaultLanguage??null)}function Vt(i,e,r={}){return e==="en"?i:Sr(i,e,r)}mt(i=>Lt(i));function qt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Dr()),qu());}function qu(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(t=>{let n=e.getInternalData(t);n.initialized&&(n.initialized=false);}),e.processNode(document.body);}var pl=["tr"];qt();exports.plugin=Dr;exports.preprocess=Vt;exports.resolveLanguage=tr;exports.supportedLanguages=pl;return exports;})({});