@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.
- package/dist/hyperscript-i18n-ar.global.js +5 -5
- package/dist/hyperscript-i18n-bn.global.js +5 -5
- package/dist/hyperscript-i18n-de.global.js +5 -5
- package/dist/hyperscript-i18n-east-asian.global.js +5 -5
- package/dist/hyperscript-i18n-en.global.js +7 -7
- package/dist/hyperscript-i18n-es.global.js +5 -5
- package/dist/hyperscript-i18n-fr.global.js +5 -5
- package/dist/hyperscript-i18n-he.global.js +5 -5
- package/dist/hyperscript-i18n-hi.global.js +5 -5
- package/dist/hyperscript-i18n-id.global.js +5 -5
- package/dist/hyperscript-i18n-it.global.js +5 -5
- package/dist/hyperscript-i18n-ja.global.js +5 -5
- package/dist/hyperscript-i18n-ko.global.js +5 -5
- package/dist/hyperscript-i18n-ms.global.js +5 -5
- package/dist/hyperscript-i18n-pl.global.js +5 -5
- package/dist/hyperscript-i18n-pt.global.js +5 -5
- package/dist/hyperscript-i18n-qu.global.js +5 -5
- package/dist/hyperscript-i18n-ru.global.js +5 -5
- package/dist/hyperscript-i18n-slavic.global.js +5 -5
- package/dist/hyperscript-i18n-south-asian.global.js +5 -5
- package/dist/hyperscript-i18n-southeast-asian.global.js +5 -5
- package/dist/hyperscript-i18n-sw.global.js +5 -5
- package/dist/hyperscript-i18n-th.global.js +5 -5
- package/dist/hyperscript-i18n-tl.global.js +5 -5
- package/dist/hyperscript-i18n-tr.global.js +5 -5
- package/dist/hyperscript-i18n-uk.global.js +5 -5
- package/dist/hyperscript-i18n-vi.global.js +5 -5
- package/dist/hyperscript-i18n-western.global.js +5 -5
- package/dist/hyperscript-i18n-zh.global.js +5 -5
- package/dist/hyperscript-i18n.global.js +28 -27
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var HyperscriptI18n=(function(exports){'use strict';function te(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function Ie(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Oe(i){return {type:"reference",value:i}}function je(i,e){return {type:"property-path",object:i,property:e}}var sr=new Set(["me","you","it","result","event","target","body"]);function Ge(i,e=sr){return e.has(i)}var lt=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}]`,a=new Date().toISOString();switch(i){case "debug":console.debug(`${a} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${a} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${a} ${t} WARN:`,e,...r);break;case "error":console.error(`${a} ${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 ct(i){return new lt(i)}function be(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 mt(i,e){return i?.possessive?.keywords?.[e]}var Pe=class we{constructor(){this.logger=ct("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 a=e.mark(),n=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 u=this.matchTokenSequence(e,r.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",u),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!u)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(a),null;let o=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-a.position,confidence:o}}matchBest(e,r,t){let a=[];for(let u of r){let o=e.mark(),s=this.matchPattern(e,u,t);s&&a.push(s),e.reset(o);}if(a.length===0)return null;a.sort((u,o)=>{let s=o.pattern.priority-u.pattern.priority;if(s!==0)return s;let l=o.confidence-u.confidence;return Math.abs(l)>.001?l:o.consumedTokens-u.consumedTokens});let n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],u=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!u)for(;e.peek()?.kind==="conjunction";)e.advance();let o=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(a)for(let b of a)v.add(b);let g=[];for(;!e.isAtEnd();){let b=e.peek();if(!b||this.isStopMarker(b,v))break;g.push(b.value),e.advance();}if(g.length>0){t.set(c.role,{type:"expression",raw:g.join(" ")}),o=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(a)for(let b of a)v.add(b);if(this.matchGroupToken(e,c,t,v)){o=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 g=e.peek();if(g&&this.getMatchType(g,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(o&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(o),t.delete(s),o=null,s=null;let b=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",b),b)continue}return false}}}let E=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",E),E){p?(o=d,s=c.role):(o=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(o&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(o),t.delete(s),o=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 a=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",a),a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let u=this.getMatchType(t,n);if(u!=="none")return this.totalKeywordMatches++,u==="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 a=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null"),!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!be(n.type,r.expectedTypes)?r.optional||false:(t.set(r.role,n),true);let u=this.tryMatchMethodCallExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!be(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let o=this.tryMatchPossessiveSelectorExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!be(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!be(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&&!be(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null");let c=this.tokenToSemanticValue(a);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&&!be(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,a=this.safeToLowerCase(t),n=mt(this.currentProfile,a);if(!n)return null;let u=e.mark();e.advance();let o=e.peek();if(!o)return e.reset(u),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let s=o.value;o.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()),je(Oe(n),l)}return e.reset(u),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 a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(t),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<we.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}o.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${o.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let u=`${r.value}.${n.value}`,o=1;for(;!e.isAtEnd()&&o<we.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(),u+=`.${c.value}`,o++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<we.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:`${u}(${l.join(", ")})`}}return {type:"expression",raw:u}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),je(Ie(r.value),n.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 a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let u=a.value.slice(1);return je(Ie(r.value),u)}matchGroupToken(e,r,t,a){let n=e.mark(),u=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let l of t.keys())u.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=we.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,a))return true;e.reset(n);for(let d of t.keys())u.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 a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(t.add(n.value.toLowerCase()),n.alternatives)for(let u of n.alternatives)t.add(u.toLowerCase());break}if(n.type==="group"){for(let u of n.tokens)if(u.type==="literal"){if(t.add(u.value.toLowerCase()),u.alternatives)for(let o of u.alternatives)t.add(o.toLowerCase());break}if(!n.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 Ie(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return te(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Oe(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return te(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return te(a,"string")}if(e==="true")return te(true,"boolean");if(e==="false")return te(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?te(e,"duration"):te(a,"number")}let t=parseFloat(e);return isNaN(t)?te(e,"string"):te(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,a=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")a+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=n(c.role),p=.8;a+=p,r.has(c.role)?t+=p:m&&(t+=p*.6);}}let u=a>0?t/a:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;u=Math.max(.5,u-l);}let o=this.calculateVSOConfidenceBoost(e);u=Math.min(1,u+o);let s=this.arabicPrepositionDisambiguation(e,r);return u=Math.max(0,Math.min(1,u+s)),u}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 a of r.alternatives)if(t.has(a))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,a={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[n,u]of r.entries()){let o=a[n];if(!o||o.length===0)continue;let s="metadata"in u?u.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;o.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(we.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.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 pt=Pe;new pt;var mr=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 n=1;for(;e+n<i.length;){if(i[e+n]==="\u201D")return n++,{value:i.substring(e,e+n),length:n};n++;}return null}if(r==="\u2018"){let n=1;for(;e+n<i.length;){if(i[e+n]==="\u2019")return n++,{value:i.substring(e,e+n),length:n};n++;}return null}let t=1,a=false;for(;e+t<i.length;){let n=i[e+t];if(a){a=false,t++;continue}if(n==="\\"){a=true,t++;continue}if(n===r)return t++,{value:i.substring(e,e+t),length:t};t++;}return null}},pr=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 u=i[e+r];if(/\d/.test(u))r++;else if(u==="."&&!t)t=true,r++;else break}if(r===0)return null;let a=i.substring(e,e+r),n=e+r;if(n<i.length){let u=i.slice(n),o=[{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 o)if(u.startsWith(l.pattern))return {value:a+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(u.startsWith("ms"))return {value:a+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(u.startsWith(l.pattern))return {value:a+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(u))return {value:a+u[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:a,length:r}}};function dt(i){return "setContext"in i&&typeof i.setContext=="function"}function ft(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 ie=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 j(i,e){return {start:i,end:e}}function V(i,e,r,t){if(typeof i=="object"){let{value:n,kind:u,position:o,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:n,kind:u,position:o,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let a=i;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:a,kind:e,position:r,normalized:t};if(t){let{normalized:n,stem:u,stemConfidence:o,metadata:s}=t;return {value:a,kind:e,position:r,...n!==void 0&&{normalized:n},...u!==void 0&&{stem:u},...o!==void 0&&{stemConfidence:o},...s!==void 0&&{metadata:s}}}return {value:a,kind:e,position:r}}function Re(i){return /\s/.test(i)}function yt(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function vt(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function de(i){return /\d/.test(i)}function ht(i){return /[a-zA-Z]/.test(i)}function K(i){return /[a-zA-Z0-9_-]/.test(i)}function Et(i,e){if(e>=i.length)return null;let r=i[e];if(!yt(r))return null;let t=e,a="";if(r==="#"||r==="."){for(a+=i[t++];t<i.length&&K(i[t]);)a+=i[t++];if(a.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let u=t+1;for(;u<i.length&&K(i[u]);)u++;if(u<i.length&&i[u]==="(")return a}}else if(r==="["){let n=1,u=false,o=null,s=false;for(a+=i[t++];t<i.length&&n>0;){let l=i[t];a+=l,s?s=false:l==="\\"?s=true:u?l===o&&(u=false,o=null):l==='"'||l==="'"||l==="`"?(u=true,o=l):l==="["?n++:l==="]"&&n--,t++;}if(n!==0)return null}else if(r==="@"){for(a+=i[t++];t<i.length&&K(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="*"){for(a+=i[t++];t<i.length&&K(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="<"){if(a+=i[t++],t>=i.length||!ht(i[t]))return null;for(;t<i.length&&K(i[t]);)a+=i[t++];for(;t<i.length;){let n=i[t];if(n==="."){if(a+=i[t++],t>=i.length||!K(i[t]))return null;for(;t<i.length&&K(i[t]);)a+=i[t++];}else if(n==="#"){if(a+=i[t++],t>=i.length||!K(i[t]))return null;for(;t<i.length&&K(i[t]);)a+=i[t++];}else if(n==="["){let u=1,o=false,s=null,l=false;for(a+=i[t++];t<i.length&&u>0;){let c=i[t];a+=c,l?l=false:c==="\\"?l=true:o?c===s&&(o=false,s=null):c==='"'||c==="'"||c==="`"?(o=true,s=c):c==="["?u++:c==="]"&&u--,t++;}if(u!==0)return null}else break}for(;t<i.length&&Re(i[t]);)a+=i[t++];if(t<i.length&&i[t]==="/")for(a+=i[t++];t<i.length&&Re(i[t]);)a+=i[t++];if(t>=i.length||i[t]!==">")return null;a+=i[t++];}return a||null}function gt(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 Re(t)||t==="*"||!K(t)}function zt(i,e){if(e>=i.length)return null;let r=i[e];if(!vt(r)||r==="'"&>(i,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,u=r,o=false;for(;n<i.length;){let s=i[n];if(u+=s,o)o=false;else if(s==="\\")o=true;else if(s===a)return u;n++;}return u}function kt(i,e){if(e>=i.length)return false;let r=i[e],t=i[e+1]||"",a=i[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(a)||r==="."&&(t==="/"||t==="."&&a==="/"))return true;let n=i.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function bt(i,e){if(!kt(i,e))return null;let r=e,t="",a=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<i.length;){let n=i[r];if(n==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=n,r++;r<i.length&&/[a-zA-Z0-9_-]/.test(i[r]);)t+=i[r++];break}if(a.test(n))t+=n,r++;else break}return t.length<2?null:t}function wt(i,e){if(e>=i.length)return null;let r=i[e];if(!de(r)&&r!=="-"&&r!=="+")return null;let t=e,a="";if((i[t]==="-"||i[t]==="+")&&(a+=i[t++]),t>=i.length||!de(i[t]))return null;for(;t<i.length&&de(i[t]);)a+=i[t++];if(t<i.length&&i[t]===".")for(a+=i[t++];t<i.length&&de(i[t]);)a+=i[t++];return t<i.length&&(i.slice(t,t+2)==="ms"?a+="ms":(i[t]==="s"||i[t]==="m"||i[t]==="h")&&(a+=i[t])),a}var Ct=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ct);var At=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"]),Dt=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],dr=class fr{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){dt(e)&&e.setContext(ft(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&&Re(e[t]);)t++;if(t>=e.length)break;let a=this.tryMultiWordKeyword(e,t);if(a){r.push(a),t=a.position.end;continue}let n=false;for(let u of this.extractors)if(u.canExtract(e,t)){let o=u.extract(e,t);if(o){let s=o.metadata?.normalized,l=o.metadata?.stem,c=o.metadata?.stemConfidence,m={};if(o.metadata)for(let[d,f]of Object.entries(o.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(m[d]=f);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(o.value,this.classifyToken(o.value),j(t,t+o.length),Object.keys(p).length>0?p:void 0)),t+=o.length,n=true;break}}if(!n){let u=e[t],o=this.classifyUnknownChar(u);r.push(V(u,o,j(t,t+1))),t++;}}return new ie(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let a=t[t.length-1],n=a&&a.position.end<r;if(a&&!n&&(a.kind==="identifier"||a.kind==="keyword"||a.kind==="selector"))return t.push(V(".","operator",j(r,r+1))),true;let s=r+1;for(;s<e.length&&K(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(V(".","operator",j(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[a,n]of Object.entries(e.keywords))if(t.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let u of n.alternatives)t.set(u,{native:u,normalized:n.normalized||a});}if(e.references){for(let[a,n]of Object.entries(e.references))t.set(n,{native:n,normalized:a});for(let a of Object.keys(e.references))t.has(a)||t.set(a,{native:a,normalized:a});}if(e.roleMarkers){for(let[a,n]of Object.entries(e.roleMarkers))if(n.primary&&t.set(n.primary,{native:n.primary,normalized:a}),n.alternatives)for(let u of n.alternatives)t.set(u,{native:u,normalized:a});}if(e.possessive?.keywords)for(let[a,n]of Object.entries(e.possessive.keywords))t.set(a,{native:a,normalized:n});for(let a of Dt)t.has(a)||t.set(a,{native:a,normalized:a});for(let a of r)t.set(a.native,a);this.profileKeywords=Array.from(t.values()).sort((a,n)=>n.native.length-a.native.length),this.multiWordKeywords=this.profileKeywords.filter(a=>a.native.includes(" ")&&!At.has(a.normalized)),this.profileKeywordMap=new Map;for(let a of this.profileKeywords){this.profileKeywordMap.set(a.native.toLowerCase(),a);let n=this.removeDiacritics(a.native);n!==a.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),a);}}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",j(r,r+t.native.length),t.normalized);return null}tryMultiWordKeyword(e,r,t=a=>/[\p{L}\p{N}_]/u.test(a)){if(this.multiWordKeywords.length===0)return null;let a=e.slice(r);for(let n of this.multiWordKeywords){if(!a.startsWith(n.native))continue;let u=e[r+n.native.length];if(!(u!==void 0&&t(u)))return V(n.native,"keyword",j(r,r+n.native.length),n.normalized)}return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(a=>t.startsWith(a.native))}isKeywordStartAtBoundary(e,r,t=a=>/[\p{L}\p{N}_]/u.test(a)){let a=e.slice(r);return this.profileKeywords.some(n=>{if(!a.startsWith(n.native))return false;let u=e[r+n.native.length];return u===void 0||!t(u)})}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 a=this.tryNormalize(e);if(!a)return null;let n=this.lookupKeyword(a.stem);if(!n)return null;let u={normalized:n.normalized,stem:a.stem,stemConfidence:a.confidence};return V(e,"keyword",j(r,t),u)}trySelector(e,r){let t=Et(e,r);return t?V(t,"selector",j(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 a=t[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],u=t[1];return {...V(a,"event-modifier",j(r,r+a.length)),metadata:{modifierName:n,value:u?n==="queue"?u:parseInt(u,10):void 0}}}tryString(e,r){let t=zt(e,r);return t?V(t,"literal",j(r,r+t.length)):null}tryNumber(e,r){let t=wt(e,r);return t?V(t,"literal",j(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,a=false){let n=r;if(a)for(;n<e.length&&Re(e[n]);)n++;let u=e.slice(n);for(let o of t){let s=u.slice(0,o.length);if(o.caseInsensitive?s.toLowerCase()===o.pattern.toLowerCase():s===o.pattern){if(o.notFollowedBy&&(u[o.length]||"")===o.notFollowedBy)continue;if(o.checkBoundary){let c=u[o.length]||"";if(K(c))continue}return {suffix:o.suffix,endPos:n+o.length}}}return null}parseBaseNumber(e,r,t=true){let a=r,n="";if(t&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!de(e[a]))return null;for(;a<e.length&&de(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&de(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,t,a={}){let{allowSign:n=true,skipWhitespace:u=false}=a,o=this.parseBaseNumber(e,r,n);if(!o)return null;let{number:s,endPos:l}=o,c=[...t,...fr.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,u);return m&&(s+=m.suffix,l=m.endPos),V(s,"literal",j(r,l))}tryUrl(e,r){let t=bt(e,r);return t?V(t,"url",j(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!K(e[r+1]))return null;let t=r+1;for(;t<e.length&&K(e[t]);)t++;let a=e.slice(r,t);return V(a,"identifier",j(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return V(t,"operator",j(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?V(a,"operator",j(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?V(a,"punctuation",j(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let a of t)if(e.slice(r,r+a.length)===a)return V(a,"particle",j(r,r+a.length));return null}};dr.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 yr=dr;function Ce(i){return {stem:i,confidence:1}}function M(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var St=Object.defineProperty,Bt=Object.getOwnPropertyNames,xr=(i,e)=>function(){return i&&(e=(0, i[Bt(i)[0]])(i=0)),e},xt=(i,e)=>{for(var r in e)St(i,r,{get:e[r],enumerable:true});};function vr(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function Y(i,e,r={},t){let a=Fr[i],n=vr(a,r),u=Tr[i],o=u?vr(u,r):void 0;return {code:i,message:n,severity:e,...t&&{role:t},...o&&{suggestion:o}}}var B,Fr,Tr,Ft=xr({"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"},Fr={[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."},Tr={[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."};}}),Or={};xt(Or,{SchemaErrorCodes:()=>B,formatValidationResults:()=>_t,getValidationStats:()=>Lt,validateAllKeywordCollisions:()=>jt,validateAllSchemas:()=>Mt,validateCommandSchema:()=>Rr,validateKeywordCollisions:()=>Pr,validateRoleValues:()=>It});function Tt(i,e){return {action:i,items:e}}function Rr(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(Y(B.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(Y(B.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!Ze.has(i.action)&&e.push(Y(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(Y(B.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":Ot(i,e);break;case "on":Rt(i,e);break;case "if":case "unless":Pt(i,e);break;case "repeat":case "for":case "while":Nt(i,e);break}return i.roles.filter(t=>t.required).length===0&&(Nr.has(i.action)?e.push(Y(B.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(Y(B.NO_REQUIRED_ROLES,"warning",{}))),Tt(i.action,e)}function Ot(i,e){let r=i.roles.find(a=>a.role==="patient"),t=i.roles.find(a=>a.role==="goal");r&&!t&&e.push(Y(B.TRANSITION_MISSING_GOAL,"error",{}));}function Rt(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(Y(B.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(Y(B.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Pt(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(Y(B.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(Y(B.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Nt(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(Y(B.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(Y(B.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Mt(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[a,n]of Object.entries(i)){let u=Rr(n),o=u.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&u.items.some(l=>l.severity==="note");(o||s)&&r.set(a,u);}return r}function _t(i,e={}){let r=[],{showNotes:t=false,showCodes:a=true}=e;for(let[n,u]of i){let o=u.items.filter(c=>c.severity==="error"),s=u.items.filter(c=>c.severity==="warning"),l=u.items.filter(c=>c.severity==="note");if(o.length>0){r.push(` \u274C ${n}:`);for(let c of o){let m=a?` [${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 ${n}:`);for(let c of s){let m=a?` [${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 ${n}:`);for(let c of l){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
|
|
2
|
-
`)}function Lt(i){let e=0,r=0,t=0,a={};for(let n of i.values())for(let u of n.items)u.severity==="error"?e++:u.severity==="warning"?r++:u.severity==="note"&&t++,a[u.code]=(a[u.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:a}}function It(i,e){let r=[];for(let t of e){let a=i.roles.find(n=>n.role===t.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(t.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects type [${a.expectedTypes.join(", ")}], got '${t.type}'`,code:B.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:B.SELECTOR_KIND_MISMATCH})));}return r}function Pr(i){let e=[];if(!i.keywords)return {language:i.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(i.keywords)){if(!n||!n.primary)continue;let u=r.get(n.primary)||[];if(u.push({command:a,isPrimary:true}),r.set(n.primary,u),n.alternatives)for(let o of n.alternatives){let s=r.get(o)||[];s.push({command:a,isPrimary:false}),r.set(o,s);}}for(let[a,n]of r){let u=[...new Set(n.map(l=>l.command))];if(u.length<=1)continue;let o=n.filter(l=>l.isPrimary).length,s;o>=2?s="primary-primary":o===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:a,commands:u.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>t[a.type]-t[n.type]),{language:i.code,collisions:e}}function jt(i){let e=[];for(let[,r]of Object.entries(i)){let t=Pr(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var Ze,Nr,Vt=xr({"src/generators/schema-validator.ts"(){Ft(),Ze=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Nr=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 ve=new Map,oe=new Map,Me=new Map,Xe=null;function Mr(i,e){let r={...i};for(let t of Object.keys(e)){let a=e[t],n=i[t];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[t]=Mr(n,a):r[t]=a);}return r}function $t(i,e){return Mr(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 $t(r,i)}function _r(i,e,r){ve.set(i,e),oe.set(i,r),Me.delete(i);}function Lr(i){Xe=i;}var hr=new Map;function xe(i){return i.split("-")[0]}function Fe(i){return i.includes("-")}function qt(i){let e=ve.get(i);if(!e&&Fe(i)){let r=xe(i);e=ve.get(r);}if(!e){let r=Array.from(ve.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 Wt(i){let e=oe.get(i);if(!e&&Fe(i)){let r=xe(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 _(i){let e=oe.get(i);return !e&&Fe(i)&&(e=oe.get(xe(i))),e?rr(e):void 0}function Kt(){return Array.from(ve.keys())}function Ir(i){if(ve.has(i)&&oe.has(i))return true;if(Fe(i)){let e=xe(i);return ve.has(e)&&oe.has(e)}return false}function Ut(i,e){return qt(e).tokenize(i)}function ue(i){let e=Me.get(i);if(!e&&Fe(i)&&(e=Me.get(xe(i))),e)return e;let r=hr.get(i);if(!r&&Fe(i)&&(r=hr.get(xe(i))),r)return Me.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=Wt(i),a=Xe(t);return Me.set(i,a),a}function ye(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(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function Ae(i){return Ge(i)}function ae(i){return {type:"reference",value:i}}function fe(i,e){return {type:"property-path",object:i,property:e}}function X(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,a,n){let u=new Map;u.set("event",i);let o={kind:"event-handler",action:"on",roles:u,body:e};return r!==void 0&&(o.eventModifiers=r),t!==void 0&&(o.metadata=t),a!==void 0&&a.length>0&&(o.parameterNames=a),o}function Ei(i,e,r,t,a){let n={kind:"behavior",action:"behavior",roles:new Map,name:i,parameters:e,eventHandlers:r};return t!==void 0&&t.length>0&&(n.initBlock=t),a!==void 0&&(n.metadata=a),n}function gi(i,e,r,t){let a={kind:"def",action:"def",roles:new Map,name:i,parameters:e,body:r};return t!==void 0&&(a.metadata=t),a}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 zi(i,e,r,t){let a=new Map;a.set("condition",i);let n={kind:"conditional",action:"if",roles:a,thenBranch:e};return r!==void 0&&(n.elseBranch=r),t!==void 0&&(n.metadata=t),n}function Ve(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 Ee(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 ze(i,e){return jr(i,e,"source")}function tr(i,e){return jr(i,e,"destination")}function jr(i,e,r){if(!e||!i.roles.some(n=>n.role===r))return [];let t=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},a={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[a,t]:[t,a]}]}var ki={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)"}},bi={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"}},wi={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"}},Ci={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"}},Ai={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>"}},Di={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>"}},Si={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Bi={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},xi={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fi={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ti={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oi={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}]},Ri={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}]},Pi={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}]},Ni={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}]},Mi={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}]},_i={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}]},Li={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"}}]},Ii={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"}}]},ji={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"}}]},Vi={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"}}]},$i={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}]},qi={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}]},Wi={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}]},Ki={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}]},Ui={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}]},Hi={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}]},Gi={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}]},Yi={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"}}]},Zi={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}]},Xi={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}]},Ji={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Qi={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"'},ea={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"}}]},ra={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}]},ta={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},ia={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"]}}]},aa={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}]},na={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"}}]},ua={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}]},oa={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}]},sa={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}]},la={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"}}]},ca={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}]},ma={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}]},pa={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}]},da={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}]},fa={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},ya={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}]},va={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}]},ha={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}]},Ea={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},ga={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"}}]},za={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"}}]},ka={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ba={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}]},wa={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}]},Ca={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"}}]},Aa={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"}}]},Da={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"}}]},Sa={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}]},Ba={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},xa={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},Ta={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}]},Oa={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"}}]},Vr={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"},Ra={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"},Pa={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:Vr}]},Na={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:Vr}]},Ma={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:Ra}]},_a={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:ki,add:bi,remove:wi,put:Ci,set:Ai,show:Oi,hide:Ri,on:Pi,trigger:Ni,wait:Mi,fetch:_i,increment:Li,decrement:Ii,append:ji,prepend:Vi,log:$i,get:qi,take:Wi,make:Ki,halt:Ui,settle:Hi,throw:Gi,send:Yi,if:Zi,unless:Xi,else:Ji,repeat:Qi,for:ea,while:ra,continue:ta,go:ia,scroll:Oa,push:Pa,replace:Na,process:Ma,transition:aa,clone:na,focus:ua,blur:oa,empty:sa,open:la,close:ca,select:ma,clear:pa,reset:da,breakpoint:fa,call:ya,return:va,js:ha,async:Ea,tell:ga,default:za,init:ka,behavior:ba,install:wa,measure:Ca,swap:Aa,morph:Da,beep:Sa,break:Ba,copy:xa,exit:Fa,pick:Ta,render:_a,bind:Di,live:Si,eventsource:Bi,socket:xi,worker:Fi,intercept:Ti,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function ce(i){return he[i]}function La(){return Object.values(he).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Vt(),Or)).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 le(i,e){let r=i.possessive?.keywords?.[e];if(r)return r;let t=i.possessive?.specialForms;if(t){for(let[a,n]of Object.entries(t))if(n===e)return a}}var $r=[{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 Er(i,e,r,t){let a=$r.find(u=>u.lang===i);if(!a)return false;let n=(u,o)=>(u??"").toLowerCase()===o.toLowerCase();return n(e,a.end)&&n(r,a.at)&&n(t,a.of)}function Ia(i,e){let r=$r.find(a=>a.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,ja=.6,Va=.15,$a=.5,gr=.15,zr=.1,kr=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"]),qa={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"]},Wa=class{calculate(i){return this.calculateWithBreakdown(i).final}calculateWithBreakdown(i){let e=this.scoreRoleCoverage(i),r=this.scoreStemPenalty(i),t=this.scoreLanguageBoost(i),a=this.scoreLanguageAdjustment(i),n=e;return n=Math.max($a,n+r),n=Math.min(1,n+t),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:a,final:n}}scoreRoleCoverage(i){let{pattern:e,captured:r}=i,t=0,a=0,n=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")a+=1,r.has(u.role)&&(t+=1);else if(u.type==="group")for(let o of u.tokens)o.type==="role"&&(a+=Ye,r.has(o.role)?t+=Ye:n(o.role)&&(t+=Ye*ja));return a>0?t/a:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*Va}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:kr.has(r.value)||r.alternatives?.some(t=>kr.has(t))?gr:0}scoreLanguageAdjustment(i){let{pattern:e,captured:r}=i;if(e.language!=="ar")return 0;let t=0;for(let[a,n]of r.entries()){let u=qa[a];if(!u||u.length===0)continue;let o="metadata"in n?n.metadata:void 0;o&&typeof o.prepositionValue=="string"&&(u.includes(o.prepositionValue)?t+=.1:t-=.1);}return Math.max(-zr,Math.min(zr,t))}},Ka=new Wa,Ua=new Set(Object.values(he).filter(i=>i.bareKeyword===true).map(i=>i.action)),H=class P{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Ka;}matchPattern(e,r){let t=e.mark(),a=new Map;if(this.currentProfile=_(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(t),null;let u=this.confidenceModel.calculate({pattern:r,captured:a,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-t.position,confidence:u}}matchBest(e,r){this.matchCache.clear();let t=[],a=e.position();for(let u of r){let o=e.mark(),s=`${a}:${u.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,u),this.matchCache.set(s,l)),l&&t.push(l),e.reset(o);}if(t.length===0)return null;t.sort((u,o)=>{let s=o.pattern.priority-u.pattern.priority;return s!==0?s:o.confidence-u.confidence});let n=t[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],u=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!u)for(;e.peek()?.kind==="conjunction";)e.advance();let o=0;for(let s=0;s<r.length;s++){let l=r[s];o>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let c=this.matchPatternToken(e,l,t,r[s+1]??a);if(o=l.type==="role"&&l.role==="event"?2:Math.max(0,o-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,t){if(r.has("source"))return;let a=e.peek(),n=e.peek(1);if(!a||!n||this.patternTokenWouldMatch(t,a))return;let u=this.currentProfile?.roleMarkers?.source,o=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!u)return false;let c=l.value.toLowerCase();return u.primary?.toLowerCase()===c?true:!!u.alternatives?.some(m=>m.toLowerCase()===c)},s=u?.position;if(s!=="after"&&o(a)&&n.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&a.kind==="selector"&&o(n)){let l=this.tokenToSemanticValue(a);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,t,a){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t,a);case "group":return this.matchGroupToken(e,r,t,a);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let a=this.getMatchType(t,r.value);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let u=this.getMatchType(t,n);if(u!=="none")return this.totalKeywordMatches++,u==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [r.value,...r.alternatives??[]])for(let u of ["-","_"])if(n.includes(u)&&this.tryMatchShatteredCompound(e,n,u))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),a=[];for(;;){let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword")break;a.push(u.value),e.advance();let o=e.peek();if(!o||o.value!=="-")break;e.advance(),a.push("-");}if(a.length<3||a[a.length-1]==="-")return e.reset(t),null;let n=a.join("").toLowerCase();for(let[u,o]of Object.entries(r.keywords))if(o.primary.toLowerCase()===n||o.alternatives?.some(s=>s.toLowerCase()===n))return I(u);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let a=r.split(t);if(a.length<2||a.some(u=>u.length===0))return false;let n=e.mark();for(let u=0;u<a.length;u++){if(u>0){let s=e.peek();if(!s||s.value!==t)return e.reset(n),false;e.advance();}let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword"&&o.kind!=="particle"||o.value.toLowerCase()!==a[u].toLowerCase())return e.reset(n),false;e.advance();}return true}matchRoleToken(e,r,t,a){this.skipNoiseWords(e);let n=e.peek();if(!n)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return t.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!P.tokenLooksLikeEvent(n))return r.optional||false;let g=(n.normalized??n.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(le(this.currentProfile,n.value)??le(this.currentProfile,g))!==void 0||n.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(n.normalized??n.value).toLowerCase();if(P.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(r.role==="duration"){let g=(n.normalized??n.value).toLowerCase();if(P.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(r.optional&&a===void 0&&r.role!=="event"&&r.role!=="action"&&n.kind==="keyword"&&(n.normalized??n.value).toLowerCase()in he)return true;let u=this.tryMatchPositionalExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ve(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let o=this.tryMatchCaretScopeExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ve(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchOperatorRunExpression(e);if(g)return t.set(r.role,g),true}if(r.expectedTypes?.includes("property-path")){let g=this.tryMatchOfPossessiveExpression(e);if(g)return t.set(r.role,g),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 m=r.role==="event"&&this.currentPatternCommand==="on"||P.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&&!Ve(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 E=this.tryMatchSelectorPropertyExpression(e);if(E)return r.expectedTypes&&r.expectedTypes.length>0&&!Ve(E.type,r.expectedTypes)?r.optional||false:(t.set(r.role,E),true);if(n.kind==="identifier"&&n.value==="{"&&(!r.expectedTypes?.length||r.expectedTypes.includes("literal"))){let g=this.tryMatchBraceRunLiteral(e);if(g)return t.set(r.role,g),true}let v=this.tokenToSemanticValue(n);if(!v)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)){let g=v.type==="selector"&&String(v.value).startsWith("@"),b=r.expectedTypes.some(C=>C==="expression"||C==="reference");if(!(g&&b))return r.optional||false}if(t.set(r.role,v),e.advance(),r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in v&&(t.set(r.role,I(`${String(v.value)}${g.value}`)),e.advance());let b=e.peek();if(b&&(b.kind==="particle"||b.kind==="keyword")&&(b.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(a,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(!P.POSITIONAL_KEYWORDS.has(t)&&!P.POSITIONAL_KEYWORDS.has(r.value.toLowerCase()))return null;let a=e.mark(),n=[r.normalized??r.value];e.advance();let u=e.peek();if(!u||u.kind!=="selector")return e.reset(a),null;n.push(u.value),e.advance();let o=0;for(;o++<8;){let c=e.peek();if(c&&c.kind==="selector"&&c.value.startsWith("."))n.push(c.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")&&!P.POSITIONAL_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&!P.COMMAND_ACTION_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&(n.push(s.normalized??s.value,l.value),e.advance(),e.advance()),{type:"expression",raw:n.join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let t=e.peek(1),a=e.peek(2),n=(t?.normalized??"").toLowerCase(),u=!!t&&(t.value.toLowerCase()==="on"||n==="destination"||n==="on");return !t||!a||a.kind!=="selector"||!u?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${a.value}`})}isOfPossessiveMarker(e){let r=e.value.toLowerCase(),t=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||t==="of"||t==="source")return true;let a=this.currentProfile?.code?P.OF_POSSESSIVE_MARKERS[this.currentProfile.code]:void 0;return !!a&&a.has(r)}tryMatchOperatorRunExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let a=1;for(;;){let u=e.peek();if(!u||!P.RUN_OPERATORS.has(u.value))break;let o=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(o);break}a++;}if(a<2)return e.reset(r),null;let n=e.tokens.slice(t,e.position()).map(u=>u.value).join(" ");return {type:"expression",raw:n,value:n}}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let t=e.mark(),a=0;for(;!e.isAtEnd();){let n=e.advance();if(n.value==="(")a++;else if(n.value===")"&&(a--,a===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")&&!P.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 a=e.peek();if(!a||!this.isOfPossessiveMarker(a))return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"?(e.reset(t),null):(e.advance(),fe(ye(n.value),r.value))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=[r.value,r.normalized].filter(Boolean),a;for(let s of t)if(a=le(this.currentProfile,s)??le(this.currentProfile,s.toLowerCase()),a)break;if(!a)return null;let n=e.mark();e.advance();let u=this.currentProfile.possessive?.connectors;if(u&&u.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();u.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let o=e.peek();if(!o||Ia(this.currentProfile.code,o.value))return e.reset(n),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)&&!(o.normalized&&this.isStructuralKeyword(o.normalized))&&!(o.normalized&&this.isRoleMarkerConcept(o.normalized))||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let s=o.value;o.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();if(c&&c.value.startsWith("(")){let m="",p=0,d=0;for(;!e.isAtEnd()&&d++<P.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;m+=f.value,e.advance();for(let E of f.value)E==="("?p++:E===")"&&p--;if(p<=0)break}l+=m;}return fe(ae(a),l)}return e.reset(n),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=m=>{for(let p of [m.value,m.normalized].filter(Boolean))if(le(this.currentProfile,p)??le(this.currentProfile,p.toLowerCase()))return true;return false},t=e.peek();if(!t)return null;let a=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("@"))||a)||r(t))return null;let u=e.mark(),o=t.value;a&&(o=o.substring(1)),e.advance();let s=o;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(u),null;let c;for(let m of [l.value,l.normalized].filter(Boolean))if(c=le(this.currentProfile,m)??le(this.currentProfile,m.toLowerCase()),c)break;return c?(e.advance(),fe(ae(c),s)):(e.reset(u),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&&Ua.has(t))}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let t=e.mark();e.advance();let a=["{"],n=1,u=0;for(;!e.isAtEnd()&&u++<P.MAX_BRACE_RUN_TOKENS;){let o=e.advance();if(!o)break;if(o.value==="{")n++;else if(o.value==="}"&&(n--,n===0))return a.push("}"),I(a.join(" "));a.push(o.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 a=e.mark();e.advance(),e.advance();let n=[],u=false,o=0;for(;!e.isAtEnd()&&o++<P.MAX_METHOD_ARGS+2;){let s=e.peek();if(!s)break;if(s.value===")"){e.advance(),u=true;break}if(s.value===","){e.advance();continue}n.push(s.value),e.advance();}return u?{type:"expression",raw:`${r.value}(${n.join(", ")})`}:(e.reset(a),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(t),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<P.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}o.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${o.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let a=e.mark();e.advance();let n=t.value.toLowerCase(),u=e.peek();if((t.kind==="identifier"||P.PROPERTY_ACCESS_BASES.has(n))&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value)){let d=t.value,f=[],E=0;for(;E<P.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(),E++;else break}let v=e.peek(),g=!!v&&v.value.startsWith("(");if(r&&!g&&f.length>0&&Ae(n))return fe(ae(n),f.join("."));if(g){let b=e.mark(),C=[],A=0,z=false;for(;!e.isAtEnd();){let h=e.peek();if(!h)break;if(h.value==="(")A++;else if(h.value===")"){if(C.push(h.value),e.advance(),A--,A===0&&(z=true),z)break;continue}C.push(h.value),e.advance();}z?d+=C.join(""):e.reset(b);}return {type:"expression",raw:d}}let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(a),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(a),null;e.advance();let l=`${t.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<P.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}`,c++;}let m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let d=[],f=0;for(;!e.isAtEnd()&&d.length<P.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(f===0){e.advance();break}f--;}if(v.kind==="punctuation"&&v.value==="("&&f++,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&&Ae(p)){let d=l.split(".").slice(1).join(".");return fe(ae(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 a=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),u=!!a&&a.kind==="punctuation"&&a.value==="'s",o=!!a&&a.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(a?.normalized??"").toLowerCase()!=="source")return false;let p=he[this.currentPatternCommand];return !!p&&p.roles.some(d=>d.role==="source")})(),l=!!a&&!!n&&n!=="'s"&&a.value===n&&(a.kind==="particle"||a.kind==="punctuation")&&!s;if(!u&&!l&&!o)return e.reset(t),null;e.advance(),o&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(u||o)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(t),null):(e.advance(),fe(ye(r.value),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 a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let u=a.value.slice(1);return fe(ye(r.value),u)}matchGroupToken(e,r,t,a){let n=e.mark(),u=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,a)){e.reset(n);for(let s of t.keys())u.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 ye(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Ae(r)?ae(r):I(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return ye(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ae(e.value);let t=e.value.toLowerCase();return Ae(t)?ae(t):{type:"expression",raw:e.value};case "url":return I(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return I(a,"string")}if(e==="true")return I(true,"boolean");if(e==="false")return I(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?I(e,"duration"):I(a,"number")}let t=parseFloat(e);return isNaN(t)?I(e,"string"):I(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.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(P.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;let u=e.peek(1);if(n&&n.kind==="keyword"&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value))return;let o=n?(n.normalized??n.value).toLowerCase():"";if(n&&P.POSITIONAL_OR_SCOPE_KEYWORDS.has(o))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&P.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||P.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(n&&n.kind==="keyword"&&this.currentProfile?.code!=="en"&&Ae(o)&&m||n&&n.kind==="keyword"&&this.currentProfile?.code==="en"&&Ae(o))return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};H.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]);H.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);H.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);H.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);H.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(he).map(i=>i.toLowerCase()));H.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);H.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"])};H.RUN_OPERATORS=new Set(["+","-","*","/"]);H.MAX_BRACE_RUN_TOKENS=64;H.MAX_PROPERTY_DEPTH=10;H.MAX_METHOD_ARGS=20;H.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);H.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ha=H,ee=new Ha;function G(i,e){return Ut(i,e)}function qr(){return Kt()}var We=["if","unless","repeat","for","while"];function ne(i,e){let r=new Set([e]),a=_(i)?.keywords?.[e];if(a){a.primary&&r.add(a.primary.toLowerCase());for(let n of a.alternatives??[])r.add(n.toLowerCase());}return r}function J(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var Ga=new Set(We);function ir(i,e){let r=i.normalized?.toLowerCase();return r?Ga.has(r):e.some(t=>J(i,t))}var br=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Ya=new Set(["destination","source","style","patient","on","from","to"]);function Za(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(br.has(e)||br.has(r)||Ya.has(e))}var wr=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 Wr(i,e){let r=[],t=e.position.end,a=i.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(a){t=e.position.end+a[0].length;for(let n of a[1].split(/[,،、]/)){let u=n.trim();u&&r.push(u);}}return {parameters:r,headerEnd:t}}function Kr(i,e,r){let t=e+1;if(t>=i.length)return -1;let a=Qe(_(r)?.roleMarkers?.patient);return a.size>0&&J(i[t],a)&&t++,t<i.length?t:-1}function Xa(i,e,r){if(!_(e))return null;let t=ne(e,"behavior"),a=ne(e,"def"),n=i.toLowerCase(),u=[...t].some(c=>n.includes(c)),o=/\bdef\b/.test(n)||[...a].some(c=>c!=="def"&&n.includes(c));if(!u&&!o)return null;let s=G(i,e).tokens;if(s.length<2)return null;if(J(s[0],t))return Cr(i,e,s,r,0);let l=s.findIndex((c,m)=>m>0&&J(c,t));return l>0&&/^[A-Z][A-Za-z0-9_]*$/.test(s[0].value)?Cr(i,e,s,r,l):J(s[0],a)?Qa(i,e,s,r):null}function Ja(i,e,r){let t=_(e);if(!t)return null;let a=t.wordOrder!=="SOV",n=wr.has(e)?Qe(t.roleMarkers?.event):new Set,u=wr.has(e)?Qe(t.keywords?.on):new Set,o=n.size>0&&u.size>0,s=ne(e,"end"),l=ne(e,"on"),c=i.toLowerCase(),m=[...s].some(h=>c.includes(h)),p=(a||o)&&(()=>{let h=0;for(let w of l)if(w){for(let y=c.indexOf(w);y>=0;y=c.indexOf(w,y+w.length))if(++h>=2)return true}return false})();if(!m&&!p)return null;let d=G(i,e).tokens;if(d.length<2)return null;let f=We.map(h=>ne(e,h)),E=h=>ir(h,f),v=h=>J(h,s),g=[],b=0,C=0;for(let h=0;h<d.length;h++){let w=d[h];if(v(w)){if(b>0){b--;continue}let y=i.slice(d[C].position.start,w.position.start).trim();y&&g.push(y),C=h+1;}else if(E(w))b++;else if(a&&b===0&&h>C&&J(w,l)&&Za(d[h+1])){let y=i.slice(d[C].position.start,w.position.start).trim();y&&g.push(y),C=h;}else if(o&&b===0&&h-1>C&&J(w,n)&&d[h+1]!==void 0&&J(d[h+1],u)){let y=d[h-1],k=i.slice(d[C].position.start,y.position.start).trim();k&&g.push(k),C=h-1;}}if(C<d.length){let h=i.slice(d[C].position.start).trim();h&&g.push(h);}if(g.length<2)return null;let A=[],z=[];for(let h of g){let w;try{w=r.statement(h,e);}catch{return null}if(!w||w.kind!=="event-handler")return null;let y=w;A.push(y);let k=!y.body||y.body.length===0;z.push(k?.2:y.metadata?.confidence??.75);}return Je(A,"then",{sourceLanguage:e,confidence:$e(z),sourceText:i})}function $e(i){return i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0}function Ur(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 Cr(i,e,r,t,a){let n=a>0,u=n?0:Kr(r,a,e);if(u<0)return null;let o=r[u],s=o.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(s))return null;let{parameters:l,headerEnd:c}=Wr(i,o),m=n?a+1:r.findIndex(y=>y.position.start>=c);m<=u&&(m=u+1);let p=ne(e,"init"),d=ne(e,"end"),f=We.map(y=>ne(e,y)),E=y=>ir(y,f),v=y=>J(y,d),g=[],b=[],C=[],A=false,z=0,h=m;for(let y=m;y<r.length;y++){let k=r[y];if(v(k)){if(z>0){z--;continue}if(y===h){A=true;break}if(J(r[h],p)){let S=i.slice(r[h].position.end,k.position.start).trim();if(S)try{let D=Ur(t.body(S,e));b.push(...D),C.push($e(D.map(O=>O.metadata?.confidence??.75)));}catch{C.push(0);}}else {let S=i.slice(r[h].position.start,k.position.start).trim();try{let D=t.statement(S,e);if(D&&D.kind==="event-handler"){let O=D;g.push(O);let x=!O.body||O.body.length===0;C.push(x?.2:O.metadata?.confidence??.75);}else C.push(0);}catch{C.push(0);}}h=y+1;}else E(k)&&z++;}if(g.length===0&&b.length===0)return null;let w=(A?1:.8)*$e(C);return Ei(s,l,g,b.length>0?b:void 0,{sourceLanguage:e,confidence:w,sourceText:i})}function Qa(i,e,r,t){let a=Kr(r,0,e);if(a<0)return null;let n=r[a],u=n.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(u))return null;let{parameters:o,headerEnd:s}=Wr(i,n),l=r.findIndex(z=>z.position.start>=s);l<=a&&(l=a+1);let c=ne(e,"end"),m=We.map(z=>ne(e,z)),p=z=>ir(z,m),d=z=>J(z,c),f=0,E=-1;for(let z=l;z<r.length;z++)if(d(r[z])){if(f===0){E=z;break}f--;}else p(r[z])&&f++;let v=r[l]?.position.start??s,g=E>=0?r[E].position.start:i.length,b=i.slice(v,g).trim();if(!b)return null;let C;try{C=Ur(t.body(b,e));}catch{return null}if(C.length===0)return null;let A=$e(C.map(z=>z.metadata?.confidence??.75));return E<0&&(A*=.8),gi(u,o,C,{sourceLanguage:e,confidence:A,sourceText:i})}var Se={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};Object.fromEntries(Object.entries(Se).map(([i,e])=>{let r={};for(let[t,a]of Object.entries(e))a in r||(r[a]=t);return [i,r]}));var De=new Set(["if","unless","while","repeat","for"]),nn=new Set(["then","end","else","if","unless","while","for","repeat","and"]),un=new Set(["first","last","next","previous","random","closest"]),Be=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"]),Ar=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function L(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function U(i,e){return e.length===0?i:{...i,diagnostics:e}}function Dr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var on=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Hr(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=ce(i.action),a=t?.primaryRole;if(t&&a&&a!=="patient"&&!t.roles.some(n=>n.role==="patient")&&i.roles.has("patient")&&!i.roles.has(a)){let n=i.roles,u=n.get("patient");u!==void 0&&(n.delete("patient"),n.set(a,u));}if(i.action==="tell"){let n=i.roles,u=n.get("patient"),o=n.get("destination");u&&(u.type==="selector"||u.type==="reference")&&(!o||o.type==="literal")&&(n.delete("patient"),n.set("destination",u));}if(i.action==="transition"){let n=i.roles,u=n.get("destination");u&&u.type==="literal"&&!n.has("goal")&&(n.delete("destination"),n.set("goal",u));let o=n.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(o.value)&&n.set("patient",{type:"expression",raw:o.value});}if(i.action==="morph"){let n=i.roles,u=n.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(u.value)&&n.set("patient",{type:"expression",raw:u.value});}if(i.action==="wait"){let n=i.roles;if(!n.has("event")){let u=n.get("duration"),o=u?.type==="expression"?u.raw:u?.type==="literal"?u.value:void 0;typeof o=="string"&&Be.has(o.toLowerCase())&&(n.delete("duration"),n.set("event",{type:"literal",value:o,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let n=i.roles,u=n.get("event");if(u&&u.type==="expression"){let o=u.raw;typeof o=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(o)&&n.set("event",{type:"literal",value:o,dataType:"string"});}}if(e?.size){let n=i.roles;for(let u of ["destination","source"]){let o=n.get(u);o&&o.type==="literal"&&typeof o.value=="string"&&e.has(o.value)&&n.set(u,{type:"expression",raw:o.value});}}}let r=i;for(let t of on){let a=r[t];if(Array.isArray(a))for(let n of a)Hr(n,e);}return i}var Q=class T{constructor(){this.parseDepth=0,this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return Hr(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=Xa(e,r,{statement:(y,k)=>this.parse(y,k),body:(y,k)=>this.parseStatements(y,k)});if(t)return t;let a=Ja(e,r,{statement:(y,k)=>this.parse(y,k),body:(y,k)=>this.parseStatements(y,k)});if(a)return a;let{modifiers:n,remainingInput:u}=this.extractStandaloneModifiers(e,r),o=u||e,l=this.stripAsyncModifier(o,r).remainingInput??o,m=this.stripDoNotThrowModifier(l,r).remainingInput??l,p=[],d=G(m,r),f=ue(r);if(f.length===0)throw new Ar(`No patterns available for language: ${r}`,r,m,[L(`No patterns registered for language '${r}'`,"error","no-patterns")]);let E=[...f].sort((y,k)=>k.priority-y.priority);{let y=d.tokens;if(_(r)?.wordOrder==="VSO"&&y.length>=4&&y[0]?.normalized==="source"){let k=y.findIndex(S=>S.normalized==="on");if(k>=2&&k+1<y.length){let S=m.slice(y[0].position.start,y[k].position.start).trim(),D=y[k+1].position.end,O=m.slice(y[k].position.start,D)+" "+S+m.slice(D);if(O!==m)try{let x=this.parse(O,r);if(x&&x.kind==="event-handler"){let F=n?this.applyModifiers(x,n):x;return U(F,p)}}catch{}}}}{let y=d.tokens;for(let k=1;k<y.length-1;k++){let S=y[k],D=S.value,O=(S.normalized??S.value).toLowerCase();if(!(O==="or"||T.OR_KEYWORDS.has(D)||T.OR_KEYWORDS.has(O)))continue;let F=y[k+1],N=(F.normalized??F.value).toLowerCase();if(!T.KNOWN_EVENTS.has(N))break;let R=k+1,q=y[k+2];q&&q.kind==="selector"&&q.value.startsWith("[")&&(R=k+2);let W=y[k].position.start,me=y[R].position.end,re=(m.slice(0,W).trimEnd()+" "+m.slice(me).trimStart()).trim();if(re&&re!==m)try{let pe=this.parse(re,r);if(pe&&pe.kind==="event-handler"){pe.additionalEvents=[{type:"literal",value:N}];let He=n?this.applyModifiers(pe,n):pe;return U(He,p)}}catch{}break}}let v=E.filter(y=>y.command==="on"),g=d.mark(),b=ee.matchBest(d,v);if(b){p.push(L(`event pattern matched: ${b.pattern.id} (confidence: ${b.confidence.toFixed(2)})`,"info","pattern-match"));let y=false;if(/^event-[a-z]+-bare$/.test(b.pattern.id)){let k=b.captured.get("event"),S=(k?.raw??k?.value??"").toString().toLowerCase(),D=Se[r],O=T.KNOWN_EVENTS.has(S)||!!D&&Object.keys(D).some(x=>x.toLowerCase()===S);if(S&&!O){let x=this.trySOVEventExtraction(m,r,E);if(x){p.push(L(`bare-event mis-anchor on "${S}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let F=n?this.applyModifiers(x,n):x;return U(F,p)}if(k?.type==="reference"||k?.type==="expression"){d.reset(g);let F=E.filter(R=>R.command!=="on"),N=ee.matchBest(d,F);d.reset(g),N&&N.pattern.command!=="on"?(y=true,p.push(L(`bare-event mis-anchor on reference "${S}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):ee.matchBest(d,v);}}}if(!y){let k=this.buildEventHandler(b,d,r),S=n?this.applyModifiers(k,n):k;return U(S,p)}}p.push(L(`event patterns: ${v.length} tried, no match`,"info","stage-event"));let C=this.tryTrailingEventExtraction(m,r,E);if(C){p.push(L("trailing event extraction succeeded","info","stage-trailing-event"));let y=n?this.applyModifiers(C,n):C;return U(y,p)}let A=E.filter(y=>y.command!=="on"),z=ee.matchBest(d,A);if(z){if(De.has(z.pattern.command)){let y=this.trySOVEventExtraction(m,r,E);if(y){p.push(L(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let S=n?this.applyModifiers(y,n):y;return U(S,p)}let k=this.tryMidStreamEventExtraction(m,r,E);if(k){p.push(L(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let S=n?this.applyModifiers(k,n):k;return U(S,p)}}else if(T.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let y=this.trySOVEventExtraction(m,r,E);if(y){p.push(L(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let k=n?this.applyModifiers(y,n):y;return U(k,p)}}else if(_(r)?.wordOrder==="VSO"){let y=this.tryMidStreamEventExtraction(m,r,E);if(y){p.push(L(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let k=n?this.applyModifiers(y,n):y;return U(k,p)}}if(z.consumedTokens<d.tokens.length&&_(r)?.wordOrder==="SOV"){let y=this.trySOVEventExtraction(m,r,E);if(y){p.push(L(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let k=n?this.applyModifiers(y,n):y;return U(k,p)}}return p.push(L(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match")),U(this.buildCommand(z,r),p)}if(p.push(L(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!m.includes(`
|
|
4
|
-
`)&&_(r)?.wordOrder==="VSO"){let y=this.tryMidStreamEventExtraction(m,r,E);if(y){p.push(L("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let k=n?this.applyModifiers(y,n):y;return U(k,p)}}let h=this.trySOVEventExtraction(m,r,E);if(h){p.push(L("SOV event extraction succeeded","info","stage-sov"));let y=n?this.applyModifiers(h,n):h;return U(y,p)}p.push(L("SOV event extraction: no event keyword found","info","stage-sov"));let w=this.tryCompoundCommandParsing(d,A,r);if(w)return p.push(L("compound command parsing succeeded","info","stage-compound")),U(w,p);throw p.push(L("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(L(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Ar(`Could not parse input in ${r}: ${m}`,r,m,p)}parseStatements(e,r){let t=G(e,r),a=ue(r).filter(n=>n.command!=="on").sort((n,u)=>u.priority-n.priority);return this.parseBodyWithClauses(t,a,r)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return qr()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[n,u]of e.captured)t[n]=u;let a=X(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(a),a}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let a=e.captured.get("event");if(!a)throw new Error("Event handler pattern matched but no event captured");let n=ee.extractEventModifiers(r),u=this.extractOrConjunctionEvents(r,t),o=a;u.length>0&&a.type==="literal"&&(o={type:"literal",value:[String(a.value),...u.map(m=>String("value"in m?m.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"&&l.value==="if"){let c=r.tokens,m=-1;for(let p=r.position()-1;p>=0;p--){let d=c[p],f=(d.normalized??d.value).toLowerCase();if(this.isIfKeyword(f,t)){m=p;break}}if(m>=0){let p=ue(t).filter(v=>v.command!=="on").sort((v,g)=>g.priority-v.priority),d=new ie(c.slice(m),t),f=this.parseBodyWithClauses(d,p,t);if(f.some(v=>v.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(v=>v.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Ne(o,f,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}}}if(l&&l.type==="literal"){let c=l.value,m={};for(let[A,z]of e.captured)A!=="event"&&A!=="action"&&A!=="continues"&&(m[A]=z);if(c==="repeat"){let A=r.peek(),z=w=>(w.normalized??w.value).toLowerCase();if(A&&A.kind==="keyword"&&z(A)==="forever")m.loopType={type:"literal",value:"forever"},delete m.patient,r.advance();else if(A&&A.kind==="keyword"&&z(A)==="event"){r.advance();let w=r.peek();if(w)for(m.event={type:"literal",value:z(w)},m.loopType={type:"literal",value:"until-event"},delete m.patient;!r.isAtEnd();){let y=r.peek();if(!y||y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,t)||this.isEndKeyword(y.value,t)))break;r.advance();}}let h=m.patient;h&&h.type==="reference"&&h.value==="me"&&delete m.patient;}let p=X(c,m,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!De.has(c)||c==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,h=r.position(),w=k=>k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,t)||this.isEndKeyword(k.value,t)),y=-1;for(let k=h-1;k>=0;k--){let S=z[k];if(w(S))break;if((S.normalized??S.value).toLowerCase()===c){y=k;break}}if(y>=0){let k=h;for(;k<z.length&&!w(z[k]);)k++;let S=z.slice(y,k),D=S;if(A){let O=String(a.value??"").toLowerCase(),x=S.findIndex(F=>(F.normalized??F.value).toLowerCase()===O);if(x<0)D=null;else {let F=S[x-1],N=F&&F.kind==="keyword"&&F.normalized?.toLowerCase()==="on"?x-1:x;D=[...S.slice(0,N),...S.slice(x+1)];}}if(D&&D.length>1){let O=ue(t).filter($=>$.command!=="on").sort(($,se)=>se.priority-$.priority),x=this.parseClause(D,O,t),F=x[0],N=$=>$!==null&&typeof $=="object"&&typeof $.type=="string"?$.type:typeof $,R=ce(c),q=R?.primaryRole,W=$=>$==="patient"&&q&&q!=="patient"&&!R?.roles.some(se=>se.role==="patient")?q:$,me=($,se)=>{if(!De.has(c)||!R)return false;let ke=R.roles.find(ot=>ot.role===W($));return ke?ke.expectedTypes.length>0&&!ke.expectedTypes.includes(N(se)):true},re=!!F&&F.kind==="command"&&Object.entries(m).every(([$,se])=>{if(me($,se))return true;let ke=F.roles.get(W($));return ke!==void 0&&N(ke)===N(se)}),pe=F?.metadata?.patternId??"",He=!De.has(c)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(pe);if(x.length===1&&F&&F.kind==="command"&&F.action===c&&re&&He&&F.roles.size>Object.keys(m).length)for(p=F;r.position()<k;)r.advance();}}}if(!De.has(c)){let A=p;if(ce(c)?.roles.some(D=>D.role==="quantity"&&!D.required)&&!A.roles.has("quantity")){let D=r.peek();D&&/^-?\d+(\.\d+)?$/.test(D.value)&&(p=X(c,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(D.value),dataType:"number"}},A.metadata),r.advance());}let h=p;if(ce(c)?.roles.some(D=>D.role==="duration"&&!D.required)&&!h.roles.has("duration")){let D=r.peek();D&&/^\d+(\.\d+)?(ms|s)$/i.test(D.value)&&(p=X(c,{...Object.fromEntries(h.roles),duration:{type:"literal",value:D.value,dataType:"string"}},h.metadata),r.advance(),this.consumeForPostposition(r,t));}let y=p,k=ce(c);if(k?.roles.find(D=>D.role==="responseType"&&!D.required)&&!y.roles.has("responseType")){let D=R=>typeof R=="string"&&T.RESPONSE_TYPE_WORDS.has(R.toLowerCase()),O=(R,q)=>{let W=Object.fromEntries(y.roles);q&&delete W.destination,W.responseType={type:"expression",raw:R},p=X(c,W,y.metadata);},x=y.roles.get("destination"),F=k?.roles.find(R=>R.role==="destination"),N=x?.raw??x?.value;if(x&&F&&!F.expectedTypes.includes(x.type)&&D(N))O(N,true);else {let R=r.peek();R&&D(R.value)&&(O(R.value,false),r.advance());}}if(c==="wait"){let D=p;if(!D.roles.has("event")){let O=r.peek();if(O&&Be.has(O.value.toLowerCase())){let x=Object.fromEntries(D.roles),F=x.duration;F&&F.type!=="literal"&&F.type!=="expression"&&delete x.duration;let N=x.patient;N&&N.type==="reference"&&N.value==="me"&&delete x.patient,x.event={type:"literal",value:O.value,dataType:"string"},p=X(c,x,D.metadata),r.advance(),this.consumeForPostposition(r,t);}}}}let d=e.captured.get("continues"),f=d?.type==="literal"&&d.value==="then",E=r.peek(),v=!!E&&this.isThenKeyword(E.value,t),b=De.has(c)&&!!E&&!this.isEndKeyword(E.value,t),C=!!E&&!this.isEndKeyword(E.value,t);if(f||v||b||C){let A=ue(t).filter(w=>w.command!=="on").sort((w,y)=>y.priority-w.priority),z=ue(t).filter(w=>w.id.startsWith("grammar-")&&w.id.includes("-continuation")).sort((w,y)=>y.priority-w.priority),h=this.parseBodyWithGrammarPatterns(r,A,z,t);h.length>0?s=[p,...h]:s=[p];}else s=[p];}else {let c=ue(t).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,t);}return Ne(o,s,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let a=[],n=[],u=0,o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(n.length===0){let f=this.consumeJsBlock(e,t);if(f){a.push(f);continue}let E=this.tryParseConditionalBlock(e,r,t);if(E){a.push(E);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t),c=n[n.length-1],m=e.peek(1),p=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||Er(t,s.value,c?.value,m?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&u>0){u--,o.pop(),n.push(s),e.advance();continue}if(l&&o.includes("if")){n.push(s),e.advance();continue}if(l){if(n.length>0){let f=this.parseClause(n,r,t);a.push(...f),n.length=0,u=f.filter(E=>{let v=E;return (v.action==="for"||v.action==="repeat"||v.action==="while")&&(!Array.isArray(v.body)||v.body.length===0)}).length,o.length=0;for(let E=0;E<u;E++)o.push("other");}e.advance();continue}if(d){e.advance();let f=[];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;f.push(E),e.advance();}if(f.length>0){let E=n.length>0?this.parseClause(n,r,t):[];E.length===0&&n.length>0?a.push(...this.parseClause([...n,...f],r,t)):(a.push(...E),a.push(...this.parseClause(f,r,t)));}else if(n.length>0){let E=this.parseClause(n,r,t);a.push(...E);}n.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")&&(u++,o.push(this.isIfKeyword(f,t)?"if":"other"));}n.push(s),e.advance();}if(n.length>0){let s=this.parseClause(n,r,t);a.push(...s);}this.foldFrontedWhileIntoRepeat(a,t);for(let s=a.length-1;s>=0;s--){let l=a[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&a.splice(s,1);}return a.length>1?[Je(a,"then",{sourceLanguage:t})]:a}foldFrontedWhileIntoRepeat(e,r){for(let t=0;t+1<e.length;t++){let a=e[t],n=e[t+1];if(a.kind!=="command"||a.action!=="while"||n.kind!=="command"||n.action!=="repeat")continue;let u=a.roles.get("condition");if(!u||n.roles.has("condition")||Array.isArray(a.body)||Array.isArray(n.body))continue;let o=new Map(n.roles);o.set("condition",u),o.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...n,roles:o,metadata:{...n.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(n.metadata?.confidence??0,a.metadata?.confidence??0)}});}}parseClause(e,r,t){if(e.length===0)return [];let a=null,n=e,u=e[e.length-1];if(u&&e.length>=2){let v=(u.normalized??u.value).toLowerCase();this.isUnlessKeyword(v,t)&&(a="unless",n=e.slice(0,-1));}let o=null;if(a&&n.length>=3){let v=_(t),g=v?T.buildVerbLookup(v):null;if(g)for(let b=1;b<n.length-1;b++){let C=n[b],A=g.get(C.value.toLowerCase())??(C.normalized?g.get(C.normalized.toLowerCase()):void 0);if(A&&!T.CONDITION_OPERATORS.has(A)){o=n.slice(0,b),n=n.slice(b);break}}}let s=new ie(n,t),l=[],c=0,m=[],p=o,d=()=>{if(m.length===0)return;let v=m.slice();if(m.length=0,a&&l.length===0&&p===null){p=v;return}let g=v[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let C of this.parseSOVClauseByVerbAnchoring(v,t)){let A=C.action,z=C.roles;A&&ce(A)&&z instanceof Map&&z.size>0&&l.push(C);}};for(;!s.isAtEnd();){let v=s.peek(),g=!!v&&v.normalized?.toLowerCase()==="repeat",b=s.mark(),C=ee.matchBest(s,r);if(g&&C&&C.pattern.command!=="repeat"){s.reset(b),d(),l.push(X("repeat",{},{sourceLanguage:t,confidence:.6})),c++,s.advance();continue}if(C&&C.pattern.command==="if"){let A=s.mark(),z=m.length;for(s.reset(b);!s.isAtEnd();){let w=s.peek();if(!w||this.isIfKeyword((w.normalized??w.value).toLowerCase(),t))break;m.push(w),s.advance();}let h=this.tryParseConditionalBlock(s,r,t);if(h){d(),l.push(h),c++;continue}m.length=z,s.reset(A);}if(C){d();let A=this.buildCommand(C,t);l.push(A),c++,this.tryAttachTrailingRole(s,A,t);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(d(),l.push(X("repeat",{},{sourceLanguage:t,confidence:.6})),c++):A&&m.push(A),s.advance();}}d();let f=l;if(c===0){let v=this.parseSOVClauseByVerbAnchoring(n,t);v.length>0&&(f=v);}let E=p;return a&&f.length>0&&E&&E.length>0?[X(a,{condition:{type:"expression",raw:this.joinTokenText(E)}},{sourceLanguage:t,patternId:`${a}-${t}-trailing-guard`,confidence:.85}),...f]:f}tryAttachTrailingRole(e,r,t){let a=ce(r.action);if(!a)return;let n=_(t);if(!n)return;let u=r.roles,o=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return nn.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(!a.roles.some(v=>v.role===l))continue;let m=n.roleMarkers?.[l];if(!m)continue;let p=u.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 g=v.value.toLowerCase();return m.primary?.toLowerCase()===g?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(b=>b.toLowerCase()===g)},f=e.peek(),E=e.peek(1);if(!f||!E)return;if(c&&m.position==="after"){let v=e.peek(2),g=(f.normalized??f.value).toLowerCase();if(un.has(g)&&E.kind==="selector"&&d(v)){u.set(l,{type:"expression",raw:`${g} ${E.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(o(f,c)&&d(E)){let v=this.tokenToSemanticValue(f);e.advance(),e.advance(),v&&u.set(l,v);return}}else if(d(f)&&o(E,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&u.set(l,v);return}}}static buildVerbLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(t)&&(r.set(a.primary.toLowerCase(),t),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.roleMarkers)){if(!a)continue;if((t!=="event"||!r.has(a.primary))&&r.set(a.primary,t),a.alternatives)for(let u of a.alternatives)r.has(u)||r.set(u,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=_(r);if(!t||t.wordOrder!=="SOV")return [];let a=T.buildVerbLookup(t),n=T.buildMarkerToRoleLookup(t),u=[],o=0;for(;o<e.length;){let s=-1,l="";for(let f=o;f<e.length;f++){let E=e[f];if(n.has(E.value))continue;let v=a.get(E.value.toLowerCase()),g=E.normalized?a.get(E.normalized.toLowerCase()):void 0,b=v||g;if(b){s=f,l=b;break}}if(s===-1)break;let c=e.slice(o,s),m=e.length;for(let f=s+1;f<e.length;f++){let E=e[f];if(E.kind==="conjunction"||this.isThenKeyword(E.value,r)){m=f;break}if(f>s+1&&!n.has(E.value)&&(a.get(E.value.toLowerCase())||(E.normalized?a.get(E.normalized.toLowerCase()):void 0))){m=f;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,n,l,r);if(u.push(X(l,d,{sourceLanguage:r,confidence:.7})),o=m,o<e.length){let f=e[o];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&o++;}}return u}extractRolesFromMarkedTokens(e,r,t,a,n){let u={},o=s=>{let l=[];for(let c of s){let m=t.get(c.value);if(m&&c.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(m,a,u);d&&(u[d]=p);}l=[];}else l.push(c);}if(l.length>0)if(l.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(l[0].value)&&!u.duration&&ce(a)?.roles.some(m=>m.role==="duration"))u.duration={type:"literal",value:l[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(l);m&&(u.patient?u.destination||(u.destination=m):u.patient=m);}};return o(e),o(r),u}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(n=>n.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let t=r.map(n=>n.value).join(""),a=r[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?ye(t):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?I(Dr(t),"string"):a.kind==="reference"?ae(t):I(t)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return ye(r);if(r.startsWith('"')||r.startsWith("'"))return I(Dr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return I(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return I(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return I(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ae(t):e.kind==="reference"?ae(e.normalized||"me"):I(r)}parseBodyWithGrammarPatterns(e,r,t,a){let n=[],u=[],o=false,s=()=>{!o&&u.length>0&&n.push(...this.parseSOVClauseByVerbAnchoring(u,a)),u=[],o=false;},l=0,c=()=>{let m=0;for(let p of n){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,a)){s(),e.advance();continue}if(m&&this.isEndKeyword(m.value,a)){let d=e.peek(-1),f=e.peek(1);if(!Er(a,m.value,d?.value,f?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!o&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),a)){s();let d=this.tryParseConditionalBlock(e,r,a);if(d){n.push(d),o=true;continue}}let p=false;if(t.length>0){let d=ee.matchBest(e,t);if(d){let f=d.pattern.command,E={};for(let[b,C]of d.captured)b!=="event"&&b!=="action"&&b!=="continues"&&(E[b]=C);let v=X(f,E,{sourceLanguage:a,patternId:d.pattern.id});n.push(v),p=true,o=true;let g=d.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then")continue}}if(!p){let d=e.mark(),f=ee.matchBest(e,r);if(f){if(f.pattern.command==="if"){let v=e.mark();for(e.reset(d);!e.isAtEnd();){let b=e.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),a))break;e.advance();}let g=this.tryParseConditionalBlock(e,r,a);if(g){s(),n.push(g),o=true;continue}e.reset(v);}let E=this.buildCommand(f,a);n.push(E),this.tryAttachTrailingRole(e,E,a),p=true,o=true;}}p||(m&&u.push(m),e.advance());}s();for(let m=n.length-1;m>=0;m--){let p=n[m];p.kind==="command"&&p.action==="for"&&(!(p.roles instanceof Map)||p.roles.size===0)&&(!Array.isArray(p.body)||p.body.length===0)&&n.splice(m,1);}return n}tryCompoundCommandParsing(e,r,t){let a=e.tokens,n=a.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,t)),u=a.some(l=>this.isElseKeyword(l.value,t));if(!n&&!u)return null;let o=new ie(a,t),s=this.parseBodyWithClauses(o,r,t);return s.length===0?null:s.length===1?s[0]:Je(s,"then",{sourceLanguage:t,confidence:.65})}matchEventMarkerPhrase(e,r,t){let a=T.SOV_EVENT_MARKER_PHRASES[t];if(!a)return 0;for(let n of a)if(n.every((u,o)=>e[r+o]?.value===u))return n.length;return 0}hasSOVEventMarkerHead(e,r){let t=T.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:a}=G(e,r),n=Se[r],u=new Set;if(n)for(let o of Object.keys(n))u.add(o.toLowerCase());for(let o=0;o<a.length;o++){let s=a[o],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(T.KNOWN_EVENTS.has(c)||Be.has(c))||T.KNOWN_EVENTS.has(l)||Be.has(l)||u.has(l)))continue;let p=this.matchEventParamPhrase(a,o+1).len,d=a[o+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(a,o+1+p,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let t=[];for(let a=r+1;a<e.length;a++){let n=e[a].value;if(n===")")return {len:a-r+1,names:t};if(n!==","){if(e[a].kind!=="identifier")break;t.push(n);}}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 a=e.value.toLowerCase();return r.has(a)||!!t&&r.has(t)}tryTrailingEventExtraction(e,r,t){let a=G(e,r).tokens;if(a.length<3)return null;let n=Se[r],u=new Set;if(n)for(let C of Object.keys(n))u.add(C.toLowerCase());let o=a.length-2,s=a[o];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=a[a.length-1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&T.KNOWN_EVENTS.has(p)||T.KNOWN_EVENTS.has(m)||u.has(m)))return null;let f=p&&T.KNOWN_EVENTS.has(p)?p:n?.[m]??m,E=a.slice(0,o);if(E.length===0)return null;let v=t.filter(C=>C.command!=="on"),g=new ie(E,r),b=this.parseBodyWithClauses(g,v,r);return b.length===0?null:Ne({type:"literal",value:f},b,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let a=G(e,r).tokens;if(a.length<3)return null;let n=Se[r],u=new Set;if(n)for(let o of Object.keys(n))u.add(o.toLowerCase());for(let o=0;o<a.length-1;o++){let s=a[o];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=a[o+1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&T.KNOWN_EVENTS.has(p)||T.KNOWN_EVENTS.has(m)||u.has(m)))continue;let f=p&&T.KNOWN_EVENTS.has(p)?p:n?.[m]??m,E=a.filter((C,A)=>A!==o&&A!==o+1);if(E.length===0)return null;let v=t.filter(C=>C.command!=="on"),g=new ie(E,r),b=this.parseBodyWithClauses(g,v,r);return b.length===0?null:Ne({type:"literal",value:f},b,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let a=T.SOV_EVENT_MARKERS[r];if(!a)return null;let u=G(e,r).tokens,o=Se[r],s=new Set;if(o)for(let z of Object.keys(o))s.add(z.toLowerCase());let l=T.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1,f=[];for(let z=0;z<u.length;z++){let h=u[z],w=h.value.toLowerCase(),y=w,k="",S=w.indexOf("[");S>0&&(y=w.slice(0,S),k=h.value.slice(S));let D=h.normalized?.toLowerCase(),O=D&&(T.KNOWN_EVENTS.has(D)||Be.has(D)),x=s.has(w)||s.has(y),F=T.KNOWN_EVENTS.has(y)||Be.has(y);if(O||x||F){let N=u[z-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let R;O?R=D:x?R=o?.[w]??o?.[y]??y:R=y;let q=this.matchEventParamPhrase(u,z+1);if(a.size>0){let W=1+q.len,me=u[z+W];me&&me.kind==="selector"&&me.value.startsWith("[")&&(W+=1);let re=u[z+W];if(re&&(re.kind==="particle"||re.kind==="keyword")&&a.has(re.value)){c=z,m=R,p=k||(W===q.len+2?u[z+W-1].value:""),d=W+1,f=q.names;break}}else {c=z,m=R,p=k,d=1+q.len+this.matchEventMarkerPhrase(u,z+1+q.len,r),f=q.names;break}}}if(c===-1){let z=new Set(t.filter(h=>h.command!=="on").map(h=>h.command));for(let h=0;h<u.length;h++){let w=u[h];if(w.kind==="identifier")if(a.size>0){let y=1,k=u[h+1];k&&k.kind==="selector"&&k.value.startsWith("[")&&(y=2);let S=u[h+y];if(S&&(S.kind==="particle"||S.kind==="keyword")&&a.has(S.value)){c=h,m=w.value,p=y===2?u[h+1].value:"",d=y+1;break}}else {let y=this.matchEventMarkerPhrase(u,h+1,r);if(y>0){c=h,m=w.value,p="",d=1+y;break}let k=u[h+1];if(k&&k.kind==="keyword"&&k.normalized!=null&&z.has(k.normalized)){c=h,m=w.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<u.length){let h=u[z];if((h.kind==="particle"||h.kind==="keyword")&&l.markers.has(h.value))E.add(z);else if(this.isStrippableSourceRef(h,l.windowTokens)){let w=u[z+1];w&&(w.kind==="particle"||w.kind==="keyword")&&l.markers.has(w.value)&&(E.add(z),E.add(z+1));}}if(c>=2){let h=u[c-1];(h.kind==="particle"||h.kind==="keyword")&&l.markers.has(h.value)&&this.isStrippableSourceRef(u[c-2],l.windowTokens)&&(E.add(c-2),E.add(c-1));}for(let h=0;h<c;h++){let w=u[h],y=w.value.toLowerCase(),k=w.normalized?.toLowerCase();if(l.windowTokens.has(y)||k&&l.windowTokens.has(k)){E.add(h);break}}}let v=u.filter((z,h)=>!E.has(h));if(v.length===0)return null;let g=t.filter(z=>z.command!=="on"),b=new ie(v,r),C=this.parseBodyWithClauses(b,g,r);if(C.length===0)return null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Ne({type:"literal",value:m},C,void 0,A,f)}profileKeywordMatches(e,r,t){let a=_(e)?.keywords?.[r];return a?a.primary?.toLowerCase()===t?true:!!a.alternatives?.some(n=>n.toLowerCase()===t):false}consumeForPostposition(e,r){let t=e.peek();if(!t)return;let a=(t.normalized??"").toLowerCase(),n=_(r)?.keywords?.for;(a==="for"||t.value===n?.primary||(n?.alternatives??[]).includes(t.value))&&e.advance();}isThenKeyword(e,r){let t=e.toLowerCase(),n={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\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 n?n.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={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 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 a=e.mark(),n=[];e.advance();let u=false;for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(e.advance(),this.isEndKeyword(s.value,r)){u=true;break}n.push(s);}if(!u)return e.reset(a),null;let o=n.map(s=>s.value).join(" ").trim();return X("js",{patient:{type:"expression",raw:o||"()"}},{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 a=e.peek();if(!a)return null;let n=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(n,t))return null;let u=e.mark();e.advance();let o=[],s=0;for(;!e.isAtEnd();){let h=e.peek();if(!h)break;let w=(h.normalized??h.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)){s++,o.push(h),e.advance();continue}if(this.isBlockEndToken(h,e.peek(1)??void 0,t)){if(s===0){e.advance();break}s--,o.push(h),e.advance();continue}o.push(h),e.advance();}if(o.length===0)return e.reset(u),null;let l=_(t),c=l?.wordOrder==="SOV"?T.buildVerbLookup(l):null,m=0,p=0,d=[];for(;m<o.length;m++){let h=o[m],w=(h.normalized??h.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?p++:this.isBlockEndToken(h,o[m+1],t)&&p--,p===0&&this.isThenKeyword(h.value,t)){m++;break}if(p===0&&d.length>0){let y=(o[m-1].normalized??o[m-1].value).toLowerCase(),k=o[m-1].value.toLowerCase(),S=(h.normalized??h.value).toLowerCase(),D=T.CONDITION_COPULAS.has(y)||T.CONDITION_COPULAS_SURFACE.has(k)&&T.CONDITION_PREDICATES.has(S),O=c!==null&&c.has(h.value.toLowerCase())&&!T.CONDITION_PREDICATES.has(S);if(!T.CONDITION_OPERATORS.has(S)&&(!D||O)&&(this.tokensBeginCommand(o.slice(m),r,t)||this.sovCommandStartsAt(o.slice(m),c)))break}d.push(h);}if(d.length===0)return e.reset(u),null;let E=[],v=[],g=false,b=0;for(;m<o.length;m++){let h=o[m],w=(h.normalized??h.value).toLowerCase();if(this.isIfKeyword(w,t)||this.isUnlessKeyword(w,t)?b++:this.isBlockEndToken(h,o[m+1],t)&&b--,b===0&&!g&&this.isElseKeyword(h.value,t)){g=true;continue}(g?v:E).push(h);}let C={type:"expression",raw:this.joinTokenText(d)},A=this.parseBranch(E,r,t),z=v.length>0?this.parseBranch(v,r,t):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(u),null):zi(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 a=new ie(e,t);return ee.matchBest(a,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=o=>r.has(o.value.toLowerCase())||!!o.normalized&&r.has(o.normalized.toLowerCase()),a=o=>o.kind==="identifier"||o.kind==="selector"||o.kind==="literal"||o.kind==="reference",n=0,u=0;for(;n+1<e.length;){let o=e[n],s=e[n+1];if(!a(o)||s.kind!=="particle")break;u+=1,n+=2;let l=e[n];if(u>=1&&l&&t(l))return true}return false}parseBranch(e,r,t){if(e.length===0)return [];let a=new ie(e,t),n=this.parseBodyWithClauses(a,r,t);return n.length===1&&n[0]?.kind==="compound"?n[0].statements:n}extractStandaloneModifiers(e,r){let a=G(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let u=a[0].value.toLowerCase(),o=T.STANDALONE_MODIFIERS[u];if(!o)return {modifiers:null,remainingInput:null};let s={},l=1;if(o==="once")s.once=true;else {let d=1;if(d<a.length){let f=a[d];(f.kind==="keyword"||f.kind==="particle")&&(d++,l++);}if(d<a.length){let f=a[d];if(f.kind==="literal"){let E=f.value.match(/^(\d+)(ms|s|m)?$/);if(E){let v=parseInt(E[1],10),g=E[2]||"ms";g==="s"?v*=1e3:g==="m"&&(v*=6e4),s[o]=v,l=d+1;}}}s[o]||(s[o]=o==="debounce"?300:100);}let c=a.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=_(r)?.keywords?.async,a=new Set(["async"]);t?.primary&&a.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>a.add(l.toLowerCase()));let n=G(e,r).tokens,u=n.findIndex(l=>a.has(l.value.toLowerCase()));if(u===-1)return {remainingInput:null};let o=n[u],s=(e.slice(0,o.position.start)+e.slice(o.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=G(e,r).tokens;for(let a=0;a<t.length-1;a++){if(t[a].value.toLowerCase()!=="do")continue;let n=-1;for(let l=a+1;l<=a+5&&l<t.length;l++){let c=t[l];if(c.normalized?.toLowerCase()==="throw"){n=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(n===-1)continue;let u=t[a].position.start,o=t[n].position.end,s=(e.slice(0,u)+e.slice(o)).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 a=e.mark(),n=e.peek();if(!n)break;let u=(n.normalized||n.value).toLowerCase();if(!T.OR_KEYWORDS.has(u)){e.reset(a);break}e.advance();let o=e.peek();if(!o){e.reset(a);break}let s=(o.normalized||o.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};Q.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Q.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Q.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"])};Q.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Q.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"])}};Q.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Q.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"]);Q.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Q.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Q.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};Q.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 sn=Q,ln=new sn;function cn(i,e){return ln.parse(i,e)}function mn(i,e){try{let r=G(i,e),t=ue(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...t].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),u=ee.matchBest(r,n);if(u)return {confidence:u.confidence,parseSuccess:!0,patternId:u.pattern.id,action:u.pattern.command,tokensConsumed:u.consumedTokens};r.reset(r.mark());let o=a.filter(l=>l.command!=="on"),s=ee.matchBest(r,o);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 Gr(i,e){try{let t=cn(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:G(i,e).tokens.length}}catch{}let r=mn(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Yr(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,a)=>{let n=t[r]??99,u=a[r]??99;return n-u})}function pn(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 a={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(a.alternatives=t.alternatives),a}return null}function qe(i,e){let r,t;if(i.markerOverride&&i.markerOverride[e.code]!==void 0)r=i.markerOverride[e.code];else {let n=e.roleMarkers[i.role];n&&(r=n.primary,t=n.alternatives?[...n.alternatives]:void 0);}let a=i.markerVariants?.[e.code];if(a&&a.length>0){let n=t?[...t]:[];for(let u of a)u!==r&&!n.includes(u)&&n.push(u);t=n;}return {marker:r,alternatives:t}}function _e(i,e,r){r.roles.find(a=>a.role==="scope"&&!a.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 dn(i,e,r,t,a){let n=[];if(n.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)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let u=e.roleMarkers.destination;u&&n.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}]}),n.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};n.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),n.push(...ze(i,e.roleMarkers.source)),n.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${o?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function fn(i,e,r,t,a){let n=[];n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let s=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(s);}if(n.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)n.push({type:"literal",value:l});else {let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),n.push(...ze(i,e.roleMarkers.source)),n.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function yn(i,e,r,t,a){let n=[];n.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};n.push(l);}let o=e.roleMarkers.destination;if(o&&(n.push({type:"role",role:"destination",optional:false}),n.push(o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary})),n.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)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${i.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`{patient} ${u?.primary||""} {destination} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function vn(i,e,r,t,a){let n=[];n.push({type:"role",role:"event",optional:false});let u=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];u.length>0&&n.push({type:"literal",value:u[0],alternatives:u.slice(1)});let o=e.roleMarkers.destination;o&&n.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}]}),n.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};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),n.push(...ze(i,e.roleMarkers.source)),n.push(...tr(i,e.roleMarkers.destination)),{id:`${i.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(a.basePriority??100)+52,template:{format:`{event}${u[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function hn(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let o=t.primary.split(/\s+/);if(o.length>1)for(let s of o)n.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${i.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function En(i,e,r,t){let a=e.eventHandler?.temporalMarkers;if(!a||a.length===0)return null;let n=[];n.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),n.push({type:"literal",value:a[0],alternatives:a.slice(1)}),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u?.primary){let s=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(s);}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${i.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function gn(i,e,r,t,a){let n=[];if(n.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)n.push({type:"literal",value:p});else {let p=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(p);}}let o=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.sovPosition??999,f=p.sovPosition??999;return d-f});for(let m of o){n.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:d}=qe(m,e);if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(f);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s);let l=o.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(o.map(m=>[m.role,{fromRole:m.role}]))};return _e(n,c,i),{id:`${i.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:n},extraction:c}}function zn(i,e,r,t,a){let n=[],o=[...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 o){n.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:p}=qe(c,e);m&&n.push(p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m});}if(n.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),n.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)n.push({type:"literal",value:m});else n.push(t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary});}let s=o.map(c=>`{${c.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(o.map(c=>[c.role,{fromRole:c.role}]))};return _e(n,l,i),{id:`${i.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${t.primary}`,tokens:n},extraction:l}}function kn(i,e,r,t,a){let n=[],o=[...i.roles.filter(v=>v.required)].sort((v,g)=>{let b=v.sovPosition??999,C=g.sovPosition??999;return b-C}),s=o[0];n.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=qe(s,e);if(l){let v=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(v);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let v=t.primary.split(/\s+/);if(v.length>1)for(let g of v)n.push({type:"literal",value:g});else {let g=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(g);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(m);let p=o[1];n.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:f}=qe(p,e);if(d){let v=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};n.push(v);}let E={action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return _e(n,E,i),{id:`${i.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${p.role}}`,tokens:n},extraction:E}}function Sr(i,e,r,t,a){let n=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}n.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u),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(...ze(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function bn(i,e,r,t,a){let n=[],u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;if(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(...ze(i,e.roleMarkers.source)),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}return n.push({type:"role",role:"event",optional:false}),{id:`${i.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`${r.primary} {patient} ${o?.primary||""} {destination?} ${t.primary} {event}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function wn(i,e,r,t,a){let n=[],u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,f=p.svoPosition??999;return d-f});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let f=e.roleMarkers[m.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(f);}n.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};n.push(m);}n.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 _e(n,c,i),{id:`${i.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:n},extraction:c}}function Br(i,e,r,t,a){let n=[];if(t.position==="before"){let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(m);}n.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u);let s=[...i.roles.filter(m=>m.required)].sort((m,p)=>{let d=m.svoPosition??999,f=p.svoPosition??999;return d-f});for(let m of s){let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let f=e.roleMarkers[m.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(f);}n.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 _e(n,c,i),{id:`${i.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:c}}function Cn(i,e,r,t,a){let n=[],u=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(l);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&n.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}]}),n.push(...ze(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${t.primary} ${u?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}function An(i,e,r,t){let a=[];a.push({type:"literal",value:"and",alternatives:["then"]}),a.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(n),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(...ze(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} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...Ee(i),...ge(i)}}}var Te={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function er(i,e,r=Te){let t=`${i.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[i.action];if(!n)throw new Error(`No keyword translation for '${i.action}' in ${e.code}`);let u=Fn(i,e,n),o=ar(i,e),s=Nn(i,e,n);return {id:t,language:e.code,command:i.action,priority:a,template:{format:s,tokens:u},extraction:o}}function Dn(i,e,r=Te){if(i.roles.filter(o=>!o.required).length===0)return null;let a=i.roles.filter(o=>o.required),n={...i,roles:a};return {...er(n,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:ar(i,e)}}function Sn(i,e,r=Te){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(o=>o.required);if(t.length!==1)return null;let a=e.keywords[i.action];if(!a)return null;let n=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},u=t.map(o=>({type:"role",role:o.role,optional:false,expectedTypes:o.expectedTypes}));return {id:`${i.action}-${e.code}-generated-verb-first`,language:e.code,command:i.action,priority:(r.basePriority??100)-20,template:{format:`${a.primary} <${t[0].role}>`,tokens:[n,...u]},extraction:ar(i,e)}}function Bn(i,e,r=Te){let t=[];if(t.push(er(i,e,r)),r.generateSimpleVariants){let a=Dn(i,e,r);a&&t.push(a);}for(let a of i.omitRoleVariants??[]){let n={...i,roles:i.roles.filter(o=>o.role!==a)},u=er(n,e,r);t.push({...u,id:`${i.action}-${e.code}-generated-no-${a}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let a=Sn(i,e,r);a&&t.push(a);}return t}function Zr(i,e=Te){let r=[],t=La();for(let a of t){if(!i.keywords[a.action])continue;let n=Bn(a,i,e);if(r.push(...n),i.eventHandler?.eventMarker){let u=xn(a,i,e);r.push(...u);}}return r}function xn(i,e,r=Te){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],a=e.eventHandler.eventMarker,n=e.keywords[i.action];if(!n)return [];if(i.roles.length===0)return [];let o=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(o)t.push(gn(i,e,n,a,r)),t.push(kn(i,e,n,a,r)),t.push(zn(i,e,n,a,r));else {t.push(dn(i,e,n,a,r)),t.push(fn(i,e,n,a,r));let s=e.roleMarkers.destination;s&&s.primary!==a.primary&&t.push(yn(i,e,n,a,r));let l=a.primary.split(/\s+/),c=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&t.push(vn(i,e,n,a,r)),t.push(hn(i,e,n,a,r));let m=En(i,e,n,r);m&&t.push(m);}else e.wordOrder==="VSO"?o?(t.push(Br(i,e,n,a,r)),t.push(wn(i,e,n,a,r))):(t.push(Sr(i,e,n,a,r)),t.push(bn(i,e,n,a,r)),e.eventHandler?.negationMarker&&t.push(Cn(i,e,n,a,r)),e.tokenization?.prefixes&&t.push(An(i,e,n,r))):o?t.push(Br(i,e,n,a,r)):t.push(Sr(i,e,n,a,r));return t}function Fn(i,e,r){let t=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=On(i,e);switch(e.wordOrder){case "SVO":t.push(a),t.push(...n);break;case "SOV":t.push(...n),t.push(a);break;case "VSO":t.push(a),t.push(...n);break;default:t.push(a),t.push(...n);}return Tn(t)}function Tn(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 a=[...t.alternatives??[],...r.alternatives??[]];a.length&&(e[e.length-1]={...t,alternatives:[...new Set(a)]});continue}e.push(r);}return e}function On(i,e){let r=[],t=Yr(i.roles,e.wordOrder);for(let a of t){let n=Rn(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function Rn(i,e){let r=[],t=i.markerOverride?.[e.code],a=e.roleMarkers[i.role],n={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(t!==void 0){let u=t?t.split(/\s+/).filter(Boolean):[],o=a?.position??"before",s=i.markerOptional?.[e.code]===true,l=c=>{let m={type:"literal",value:c};r.push(s?{type:"group",optional:true,tokens:[m]}:m);};if(o==="before"){for(let c of u)l(c);r.push(n);}else {r.push(n);for(let c of u)l(c);}}else if(a){let u=i.markerVariants?.[e.code]??[],o=()=>{let l=[...new Set([...a.alternatives??[],...u])].filter(c=>c!==a.primary);return l.length?{type:"literal",value:a.primary,alternatives:l}:{type:"literal",value:a.primary}},s=l=>{r.push(e.markersOptional||i.markerOptional?.[e.code]?{type:"group",optional:true,tokens:[l]}:l);};a.position==="before"?(a.primary&&s(o()),r.push(n)):(r.push(n),s(o()));}else r.push(n);return r}function Pn(i,e){let r={};for(let t of i.roles){let a=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];if(a!==void 0)r[t.role]=a?{marker:a}:{};else if(n&&n.primary){let u=t.markerVariants?.[e.code]??[],o=[...new Set([...n.alternatives??[],...u])].filter(s=>s!==n.primary);r[t.role]=o.length?{marker:n.primary,markerAlternatives:o}:{marker:n.primary};}else r[t.role]={};}return r}function ar(i,e){let r=Pn(i,e),t={};for(let a of i.roles){let n=r[a.role]||{};!a.required&&a.default?t[a.role]={...n,default:a.default}:t[a.role]=n;}return t}function Nn(i,e,r){let t=[],n=Yr(i.roles,e.wordOrder).map(u=>{let o=pn(u,e),s="";return o&&o.primary?o.position==="before"?s=`${o.primary} {${u.role}}`:s=`{${u.role}} ${o.primary}`:s=`{${u.role}}`,u.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":t.push(r.primary,...n);break;case "SOV":t.push(...n,r.primary);break;default:t.push(r.primary,...n);}return t.join(" ")}var Mn=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),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:a,lastAccessed:a});}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 Mn;function _n(i){return /[а-яА-ЯіІїЇєЄґҐьЬ']/.test(i)}var Xr=new Map([["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438","\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438"],["\u0434\u043E\u0434\u0430\u0439","\u0434\u043E\u0434\u0430\u0442\u0438"],["\u0432\u0438\u0434\u0430\u043B\u0438","\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438"],["\u043F\u0440\u0438\u0431\u0435\u0440\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438"],["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438"],["\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438"],["\u0432\u0441\u0442\u0430\u0432","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438"],["\u0432\u0456\u0437\u044C\u043C\u0438","\u0432\u0437\u044F\u0442\u0438"],["\u0441\u0442\u0432\u043E\u0440\u0438","\u0441\u0442\u0432\u043E\u0440\u0438\u0442\u0438"],["\u043A\u043B\u043E\u043D\u0443\u0439","\u043A\u043B\u043E\u043D\u0443\u0432\u0430\u0442\u0438"],["\u043F\u043E\u043C\u0456\u043D\u044F\u0439","\u043F\u043E\u043C\u0456\u043D\u044F\u0442\u0438"],["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0439","\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438"],["\u0437\u0430\u0434\u0430\u0439","\u0437\u0430\u0434\u0430\u0442\u0438"],["\u043E\u0442\u0440\u0438\u043C\u0430\u0439","\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438"],["\u0437\u0431\u0456\u043B\u044C\u0448","\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438"],["\u0437\u043C\u0435\u043D\u0448","\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438"],["\u0437\u0430\u043F\u0438\u0448\u0438","\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u0438"],["\u043F\u043E\u043A\u0430\u0436\u0438","\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438"],["\u0441\u0445\u043E\u0432\u0430\u0439","\u0441\u0445\u043E\u0432\u0430\u0442\u0438"],["\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438"],["\u0430\u043D\u0456\u043C\u0443\u0439","\u0430\u043D\u0456\u043C\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0438\u043A\u043B\u0438\u0447","\u0432\u0438\u043A\u043B\u0438\u043A\u0430\u0442\u0438"],["\u043D\u0430\u0434\u0456\u0448\u043B\u0438","\u043D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438"],["\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438"],["\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438"],["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u043F\u0435\u0440\u0435\u0439\u0442\u0438"],["\u0439\u0434\u0438","\u0439\u0442\u0438"],["\u0447\u0435\u043A\u0430\u0439","\u0447\u0435\u043A\u0430\u0442\u0438"],["\u0437\u0430\u0447\u0435\u043A\u0430\u0439","\u0437\u0430\u0447\u0435\u043A\u0430\u0442\u0438"],["\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436","\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438"],["\u043F\u043E\u0432\u0442\u043E\u0440\u0438","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0438"],["\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0443\u0439","\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438"],["\u043A\u0438\u043D\u044C","\u043A\u0438\u043D\u0443\u0442\u0438"],["\u043F\u043E\u0432\u0435\u0440\u043D\u0438","\u043F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u0438"],["\u0441\u043A\u0430\u0436\u0438","\u0441\u043A\u0430\u0437\u0430\u0442\u0438"],["\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0439","\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0438\u043C\u0456\u0440\u044F\u0439","\u0432\u0438\u043C\u0456\u0440\u044F\u0442\u0438"]]),Qr=class{constructor(){this.language="uk";}isNormalizable(i){return i.length<3?false:_n(i)}normalize(i){let e=i.toLowerCase();if(e.endsWith("\u0441\u044F")||e.endsWith("\u0441\u044C")){let u=this.tryReflexiveNormalization(e);if(u)return u}if(e.endsWith("\u0442\u0438")||e.endsWith("\u0447\u0438"))return Ce(i);let r=this.tryImperativeLookup(e);if(r)return r;let t=this.tryPastTenseNormalization(e);if(t)return t;let a=this.tryPresentTenseNormalization(e);if(a)return a;let n=this.tryGenericImperativeNormalization(e);return n||Ce(i)}tryReflexiveNormalization(i){let e=i.slice(0,-2);if(i.endsWith("\u0442\u0438\u0441\u044F")||i.endsWith("\u0447\u0438\u0441\u044F"))return Ce(i);let r=this.normalizeNonReflexive(e);if(r.confidence<1){let t=r.stem.endsWith("\u0442\u0438")?r.stem.slice(0,-2)+"\u0442\u0438\u0441\u044F":r.stem+"\u0441\u044F";return M(t,r.confidence*.95,{removedSuffixes:["\u0441\u044F",...r.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}normalizeNonReflexive(i){if(i.endsWith("\u0442\u0438")||i.endsWith("\u0447\u0438"))return Ce(i);let e=this.tryImperativeLookup(i);if(e)return e;let r=this.tryPastTenseNormalization(i);if(r)return r;let t=this.tryPresentTenseNormalization(i);if(t)return t;let a=this.tryGenericImperativeNormalization(i);return a||Ce(i)}tryImperativeLookup(i){return Xr.has(i)?M(Xr.get(i),.95,{removedSuffixes:["imperative"],conjugationType:"imperative"}):null}tryGenericImperativeNormalization(i){return i.endsWith("\u0439\u0442\u0435")&&i.length>5?M(i.slice(0,-3)+"\u0442\u0438",.8,{removedSuffixes:["\u0439\u0442\u0435"],conjugationType:"imperative"}):i.endsWith("\u0456\u0442\u044C")&&i.length>5?M(i.slice(0,-3)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0456\u0442\u044C"],conjugationType:"imperative"}):i.endsWith("\u0439")&&i.length>3?M(i.slice(0,-1)+"\u0442\u0438",.75,{removedSuffixes:["\u0439"],conjugationType:"imperative"}):i.endsWith("\u0438")&&i.length>3?M(i+"\u0442\u0438",.7,{removedSuffixes:["\u0438\u2192\u0438\u0442\u0438"],conjugationType:"imperative"}):null}tryPastTenseNormalization(i){return i.endsWith("\u0430\u043B\u0430")&&i.length>4?M(i.slice(0,-3)+"\u0430\u0442\u0438",.85,{removedSuffixes:["\u0430\u043B\u0430"],conjugationType:"past"}):i.endsWith("\u0438\u043B\u0430")&&i.length>4?M(i.slice(0,-3)+"\u0438\u0442\u0438",.85,{removedSuffixes:["\u0438\u043B\u0430"],conjugationType:"past"}):i.endsWith("\u0430\u043B\u0438")&&i.length>4?M(i.slice(0,-3)+"\u0430\u0442\u0438",.85,{removedSuffixes:["\u0430\u043B\u0438"],conjugationType:"past"}):i.endsWith("\u0438\u043B\u0438")&&i.length>4?M(i.slice(0,-3)+"\u0438\u0442\u0438",.85,{removedSuffixes:["\u0438\u043B\u0438"],conjugationType:"past"}):i.endsWith("\u0430\u0432")&&i.length>3?M(i.slice(0,-2)+"\u0430\u0442\u0438",.82,{removedSuffixes:["\u0430\u0432"],conjugationType:"past"}):i.endsWith("\u0438\u0432")&&i.length>3?M(i.slice(0,-2)+"\u0438\u0442\u0438",.82,{removedSuffixes:["\u0438\u0432"],conjugationType:"past"}):null}tryPresentTenseNormalization(i){return i.endsWith("\u0438\u0448")&&i.length>3?M(i.slice(0,-2)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0438\u0448"],conjugationType:"present"}):i.endsWith("\u0438\u0442\u044C")&&i.length>4?M(i.slice(0,-3)+"\u0438\u0442\u0438",.78,{removedSuffixes:["\u0438\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0438\u043C\u043E")&&i.length>4?M(i.slice(0,-3)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0438\u043C\u043E"],conjugationType:"present"}):i.endsWith("\u044F\u0442\u044C")&&i.length>4?M(i.slice(0,-3)+"\u0438\u0442\u0438",.78,{removedSuffixes:["\u044F\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0454\u0448")&&i.length>3?M(i.slice(0,-2)+"\u0430\u0442\u0438",.78,{removedSuffixes:["\u0454\u0448"],conjugationType:"present"}):i.endsWith("\u0435\u0448")&&i.length>3?M(i.slice(0,-2)+"\u0430\u0442\u0438",.75,{removedSuffixes:["\u0435\u0448"],conjugationType:"present"}):i.endsWith("\u0454")&&i.length>2?M(i.slice(0,-1)+"\u0430\u0442\u0438",.72,{removedSuffixes:["\u0454"],conjugationType:"present"}):i.endsWith("\u0454\u043C\u043E")&&i.length>4?M(i.slice(0,-3)+"\u0430\u0442\u0438",.8,{removedSuffixes:["\u0454\u043C\u043E"],conjugationType:"present"}):i.endsWith("\u044E\u0442\u044C")&&i.length>4?M(i.slice(0,-3)+"\u0430\u0442\u0438",.78,{removedSuffixes:["\u044E\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0443\u0442\u044C")&&i.length>4?M(i.slice(0,-3)+"\u0430\u0442\u0438",.75,{removedSuffixes:["\u0443\u0442\u044C"],conjugationType:"present"}):null}},et={code:"uk",name:"Ukrainian",nativeName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",direction:"ltr",script:"cyrillic",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true,suffixes:["\u0442\u0438","\u0442\u0438\u0441\u044F","\u0438\u0442\u0438","\u0438\u0442\u0438\u0441\u044F","\u0430\u0442\u0438","\u0430\u0442\u0438\u0441\u044F","\u0456\u0442\u0438","\u0456\u0442\u0438\u0441\u044F"]},references:{me:"\u044F",it:"\u0446\u0435",you:"\u0442\u0438",result:"\u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442",event:"\u043F\u043E\u0434\u0456\u044F",target:"\u0446\u0456\u043B\u044C",body:"\u0442\u0456\u043B\u043E"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u043C\u0456\u0439",it:"\u0439\u043E\u0433\u043E",you:"\u0442\u0432\u0456\u0439"},keywords:{\u043C\u0456\u0439:"me",\u043C\u043E\u044F:"me",\u043C\u043E\u0454:"me",\u043C\u043E\u0457:"me",\u0442\u0432\u0456\u0439:"you",\u0442\u0432\u043E\u044F:"you",\u0442\u0432\u043E\u0454:"you",\u0442\u0432\u043E\u0457:"you",\u0439\u043E\u0433\u043E:"it",\u0457\u0457:"it"}},roleMarkers:{destination:{primary:"\u0432",alternatives:["\u043D\u0430","\u0434\u043E"],position:"before"},source:{primary:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0437",alternatives:["\u0456\u0437"],position:"before"}},keywords:{toggle:{primary:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438"],normalized:"toggle",form:"infinitive"},add:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438",alternatives:["\u0434\u043E\u0434\u0430\u0439"],normalized:"add",form:"infinitive"},remove:{primary:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438",alternatives:["\u0432\u0438\u0434\u0430\u043B\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438","\u043F\u0440\u0438\u0431\u0435\u0440\u0438"],normalized:"remove",form:"infinitive"},put:{primary:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",alternatives:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438","\u0432\u0441\u0442\u0430\u0432"],normalized:"put",form:"infinitive"},append:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438_\u0432_\u043A\u0456\u043D\u0435\u0446\u044C",alternatives:["\u0434\u043E\u043F\u0438\u0441\u0430\u0442\u0438"],normalized:"append",form:"infinitive"},prepend:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438_\u043D\u0430_\u043F\u043E\u0447\u0430\u0442\u043E\u043A",normalized:"prepend",form:"infinitive"},take:{primary:"\u0432\u0437\u044F\u0442\u0438",alternatives:["\u0432\u0456\u0437\u044C\u043C\u0438"],normalized:"take",form:"infinitive"},make:{primary:"\u0441\u0442\u0432\u043E\u0440\u0438\u0442\u0438",alternatives:["\u0441\u0442\u0432\u043E\u0440\u0438"],normalized:"make",form:"infinitive"},clone:{primary:"\u043A\u043B\u043E\u043D\u0443\u0432\u0430\u0442\u0438",alternatives:["\u043A\u043B\u043E\u043D\u0443\u0439"],normalized:"clone",form:"infinitive"},swap:{primary:"\u043F\u043E\u043C\u0456\u043D\u044F\u0442\u0438",alternatives:["\u043F\u043E\u043C\u0456\u043D\u044F\u0439"],normalized:"swap",form:"infinitive"},morph:{primary:"\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0439"],normalized:"morph",form:"infinitive"},set:{primary:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438",alternatives:["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u0438","\u0437\u0430\u0434\u0430\u0439"],normalized:"set",form:"infinitive"},get:{primary:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438",alternatives:["\u043E\u0442\u0440\u0438\u043C\u0430\u0439"],normalized:"get",form:"infinitive"},increment:{primary:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438",alternatives:["\u0437\u0431\u0456\u043B\u044C\u0448"],normalized:"increment",form:"infinitive"},decrement:{primary:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438",alternatives:["\u0437\u043C\u0435\u043D\u0448"],normalized:"decrement",form:"infinitive"},log:{primary:"\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u0438",alternatives:["\u0437\u0430\u043F\u0438\u0448\u0438"],normalized:"log",form:"infinitive"},show:{primary:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"],normalized:"show",form:"infinitive"},hide:{primary:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439"],normalized:"hide",form:"infinitive"},transition:{primary:"\u0430\u043D\u0456\u043C\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0430\u043D\u0456\u043C\u0443\u0439"],normalized:"transition",form:"infinitive"},on:{primary:"\u043F\u0440\u0438",normalized:"on"},trigger:{primary:"\u0456\u043D\u0456\u0446\u0456\u044E\u0432\u0430\u0442\u0438",alternatives:["\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0438","\u0437\u0430\u043F\u0443\u0441\u0442\u0438"],normalized:"trigger",form:"infinitive"},send:{primary:"\u043D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438",alternatives:["\u043D\u0430\u0434\u0456\u0448\u043B\u0438"],normalized:"send",form:"infinitive"},focus:{primary:"\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0444\u043E\u043A\u0443\u0441"],normalized:"focus",form:"infinitive"},blur:{primary:"\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0439"],normalized:"blur",form:"infinitive"},empty:{primary:"\u0441\u043F\u043E\u0440\u043E\u0436\u043D\u0438\u0442\u0438",alternatives:["\u043F\u043E\u0440\u043E\u0436\u043D\u0456\u0439"],normalized:"empty"},open:{primary:"\u0432\u0456\u0434\u043A\u0440\u0438\u0442\u0438",normalized:"open"},close:{primary:"\u0437\u0430\u043A\u0440\u0438\u0442\u0438",normalized:"close"},select:{primary:"\u0432\u0438\u0434\u0456\u043B\u0438\u0442\u0438",normalized:"select"},clear:{primary:"\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",normalized:"clear"},reset:{primary:"\u0441\u043A\u0438\u043D\u0443\u0442\u0438",normalized:"reset"},breakpoint:{primary:"\u0442\u043E\u0447\u043A\u0430-\u0437\u0443\u043F\u0438\u043D\u043A\u0438",normalized:"breakpoint"},click:{primary:"\u043A\u043B\u0456\u043A\u0443",alternatives:["\u043A\u043B\u0456\u043A","\u043D\u0430\u0442\u0438\u0441\u043A\u0430\u043D\u043D\u0456"],normalized:"click"},hover:{primary:"\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u043D\u0456",alternatives:["\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u043D\u044F"],normalized:"hover"},submit:{primary:"\u0432\u0456\u0434\u043F\u0440\u0430\u0432\u0446\u0456",alternatives:["\u0432\u0456\u0434\u043F\u0440\u0430\u0432\u043A\u0430","\u043D\u0430\u0434\u0441\u0438\u043B\u0430\u043D\u043D\u044F"],normalized:"submit"},input:{primary:"\u0432\u0432\u0435\u0434\u0435\u043D\u043D\u0456",alternatives:["\u0432\u0432\u0435\u0434\u0435\u043D\u043D\u044F"],normalized:"input"},change:{primary:"\u0437\u043C\u0456\u043D\u0456",alternatives:["\u0437\u043C\u0456\u043D\u0430"],normalized:"change"},load:{primary:"\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",normalized:"load"},go:{primary:"\u043F\u0435\u0440\u0435\u0439\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u0439\u0442\u0438","\u0439\u0434\u0438"],normalized:"go",form:"infinitive"},scroll:{primary:"\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u0438\u0442\u0438",alternatives:["\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u0438"],normalized:"scroll",form:"infinitive"},push:{primary:"\u0448\u0442\u043E\u0432\u0445\u043D\u0443\u0442\u0438",alternatives:["\u0437\u0430\u0448\u0442\u043E\u0432\u0445\u043D\u0443\u0442\u0438"],normalized:"push",form:"infinitive"},replace:{primary:"\u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",alternatives:["\u0437\u0430\u043C\u0456\u043D\u0438"],normalized:"replace",form:"infinitive"},process:{primary:"\u043E\u0431\u0440\u043E\u0431\u0438\u0442\u0438",alternatives:["\u043E\u0431\u0440\u043E\u0431\u043B\u044F\u0442\u0438"],normalized:"process",form:"infinitive"},wait:{primary:"\u0447\u0435\u043A\u0430\u0442\u0438",alternatives:["\u0447\u0435\u043A\u0430\u0439","\u0437\u0430\u0447\u0435\u043A\u0430\u0439"],normalized:"wait",form:"infinitive"},fetch:{primary:"\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438",alternatives:["\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436"],normalized:"fetch",form:"infinitive"},settle:{primary:"\u0441\u0442\u0430\u0431\u0456\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438",normalized:"settle",form:"infinitive"},if:{primary:"\u044F\u043A\u0449\u043E",normalized:"if"},unless:{primary:"\u043A\u0440\u0456\u043C",normalized:"unless"},when:{primary:"\u043A\u043E\u043B\u0438",normalized:"when"},where:{primary:"\u0434\u0435",normalized:"where"},else:{primary:"\u0456\u043D\u0430\u043A\u0448\u0435",normalized:"else"},repeat:{primary:"\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0438",alternatives:["\u043F\u043E\u0432\u0442\u043E\u0440\u0438"],normalized:"repeat",form:"infinitive"},for:{primary:"\u0434\u043B\u044F",alternatives:["\u043A\u043E\u0436\u043D\u0438\u0439"],normalized:"for"},while:{primary:"\u043F\u043E\u043A\u0438",normalized:"while"},forever:{primary:"\u0437\u0430\u0432\u0436\u0434\u0438",normalized:"forever",alternatives:["forever"]},continue:{primary:"\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438",alternatives:["\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0443\u0439"],normalized:"continue",form:"infinitive"},halt:{primary:"\u0437\u0443\u043F\u0438\u043D\u0438\u0442\u0438",alternatives:["\u0437\u0443\u043F\u0438\u043D\u0438\u0441\u044C","\u0441\u0442\u043E\u043F"],normalized:"halt",form:"infinitive"},throw:{primary:"\u043A\u0438\u043D\u0443\u0442\u0438",alternatives:["\u043A\u0438\u043D\u044C"],normalized:"throw",form:"infinitive"},call:{primary:"\u0432\u0438\u043A\u043B\u0438\u043A\u0430\u0442\u0438",alternatives:["\u0432\u0438\u043A\u043B\u0438\u0447"],normalized:"call",form:"infinitive"},return:{primary:"\u043F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u0438",alternatives:["\u043F\u043E\u0432\u0435\u0440\u043D\u0438"],normalized:"return",form:"infinitive"},then:{primary:"\u043F\u043E\u0442\u0456\u043C",alternatives:["\u0434\u0430\u043B\u0456","\u0442\u043E\u0434\u0456"],normalized:"then"},and:{primary:"\u0456",alternatives:["\u0442\u0430"],normalized:"and"},matches:{primary:"\u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454",normalized:"matches"},end:{primary:"\u043A\u0456\u043D\u0435\u0446\u044C",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"\u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u043E",alternatives:["async"],normalized:"async"},tell:{primary:"\u0441\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u0441\u043A\u0430\u0436\u0438"],normalized:"tell",form:"infinitive"},default:{primary:"\u0437\u0430_\u0437\u0430\u043C\u043E\u0432\u0447\u0443\u0432\u0430\u043D\u043D\u044F\u043C",normalized:"default"},init:{primary:"\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0439"],normalized:"init",form:"infinitive"},behavior:{primary:"\u043F\u043E\u0432\u0435\u0434\u0456\u043D\u043A\u0430",normalized:"behavior"},install:{primary:"\u0456\u043D\u0441\u0442\u0430\u043B\u044E\u0432\u0430\u0442\u0438",normalized:"install",form:"infinitive"},measure:{primary:"\u0432\u0438\u043C\u0456\u0440\u044F\u0442\u0438",alternatives:["\u0432\u0438\u043C\u0456\u0440\u044F\u0439"],normalized:"measure",form:"infinitive"},beep:{primary:"\u0437\u0432\u0443\u043A",normalized:"beep"},break:{primary:"\u043F\u0435\u0440\u0435\u0440\u0432\u0430\u0442\u0438",normalized:"break"},copy:{primary:"\u043A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438",normalized:"copy"},exit:{primary:"\u0432\u0438\u0439\u0442\u0438",normalized:"exit"},pick:{primary:"\u0432\u0438\u0431\u0440\u0430\u0442\u0438",normalized:"pick"},render:{primary:"\u0432\u0456\u0434\u043E\u0431\u0440\u0430\u0437\u0438\u0442\u0438",normalized:"render"},into:{primary:"\u0432",alternatives:["\u0443"],normalized:"into"},before:{primary:"\u0434\u043E",alternatives:["\u043F\u0435\u0440\u0435\u0434"],normalized:"before"},after:{primary:"\u043F\u0456\u0441\u043B\u044F",normalized:"after"},until:{primary:"\u043F\u043E\u043A\u0438_\u043D\u0435",normalized:"until"},event:{primary:"\u043F\u043E\u0434\u0456\u044F",normalized:"event"},from:{primary:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"],normalized:"from"},connect:{primary:"\u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438",alternatives:["\u0437\u02BC\u0454\u0434\u043D\u0430\u0442\u0438","\u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F"],normalized:"connect"},stream:{primary:"\u0442\u0440\u0430\u043D\u0441\u043B\u044E\u0432\u0430\u0442\u0438",alternatives:["\u043F\u043E\u0442\u0456\u043A","\u0441\u0442\u0440\u0456\u043C"],normalized:"stream"},live:{primary:"\u043D\u0430\u0436\u0438\u0432\u043E",alternatives:["\u0443-\u043F\u0440\u044F\u043C\u043E\u043C\u0443-\u0435\u0444\u0456\u0440\u0456","\u0432-\u0440\u0435\u0436\u0438\u043C\u0456-\u0440\u0435\u0430\u043B\u044C\u043D\u043E\u0433\u043E-\u0447\u0430\u0441\u0443","\u0436\u0438\u0432\u0438\u0439"],normalized:"live"},socket:{primary:"\u0441\u043E\u043A\u0435\u0442",alternatives:["\u0433\u043D\u0456\u0437\u0434\u043E","websocket","socket"],normalized:"socket"},bind:{primary:"\u043F\u0440\u0438\u0432'\u044F\u0437\u0430\u0442\u0438",alternatives:["\u0437\u0432'\u044F\u0437\u0430\u0442\u0438","\u043F\u0440\u0438\u0454\u0434\u043D\u0430\u0442\u0438","bind"],normalized:"bind"},intercept:{primary:"\u043F\u0435\u0440\u0435\u0445\u043E\u043F\u0438\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0445\u043E\u043F\u043B\u0435\u043D\u043D\u044F","intercept"],normalized:"intercept"},worker:{primary:"\u0440\u043E\u0431\u0456\u0442\u043D\u0438\u043A",alternatives:["\u0432\u043E\u0440\u043A\u0435\u0440","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0434\u0436\u0435\u0440\u0435\u043B\u043E-\u043F\u043E\u0434\u0456\u0439"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"\u043F\u0440\u0438",normalized:"on"},sourceMarker:{primary:"\u043D\u0430",alternatives:["\u0432","\u043F\u0440\u0438"],position:"before"},eventMarker:{primary:"\u043F\u0440\u0438",position:"before"},temporalMarkers:["\u043A\u043E\u043B\u0438","\u044F\u043A\u0449\u043E"]}},Ln=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],In=class{constructor(i=Ln){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}},jn="()[]{},:;",Vn=class{constructor(i=jn){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 Jr(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 a=i.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return a?a[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,a=e;for(;a<i.length;){if(i[a]==="["&&t++,i[a]==="]"&&(t--,t===0))return i.slice(e,a+1);a++;}return null}if(r==="<"){let t=i.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return t?t[0]:null}return null}var $n=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Jr(i,e)!==null:false}extract(i,e){let r=Jr(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},qn=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],a=t.slice(1).split("(")[0],n=r[1];return {value:t,length:t.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}};function Wn(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 Kn=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=Wn(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Un=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 Hn(i){return {isLetter:t=>i.test(t),isIdentifierChar:t=>/[0-9]/.test(t)||i.test(t)}}var Gn=class{constructor(i,e,r){this.name=i;let t=Hn(e);this.isLetter=t.isLetter,this.isIdentifierChar=t.isIdentifierChar,this.prepositions=r;}setContext(i){this.context=i;}canExtract(i,e){let r=i[e];return r==="'"?false:this.isLetter(r)}extract(i,e){if(!this.context)throw new Error(`${this.name}: context not set`);let r=e,t="";for(;r<i.length&&this.isIdentifierChar(i[r]);)t+=i[r++];if(!t)return null;let a=t.toLowerCase(),n=this.prepositions.has(a),u=this.context.lookupKeyword(a),o=u&&u.normalized!==u.native?u.normalized:void 0,s;if(!u&&this.context.normalizer){let l=this.context.normalizer.normalize(t);if(l.stem!==t&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(s=c.normalized);}}return {value:t,length:r-e,metadata:{normalized:o||s,isPreposition:n}}}},Yn=new Set(["\u0432","\u0443","\u043D\u0430","\u0437","\u0456\u0437","\u0437\u0456","\u0434\u043E","\u0432\u0456\u0434","\u043E","\u043E\u0431","\u043F\u0440\u0438","\u0434\u043B\u044F","\u043F\u0456\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043C\u0456\u0436","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u043F\u043E","\u0437\u0430","\u043F\u0440\u043E","\u043F\u0456\u0441\u043B\u044F","\u043D\u0430\u0432\u043A\u043E\u043B\u043E","\u043F\u0440\u043E\u0442\u0438","\u0437\u0430\u043C\u0456\u0441\u0442\u044C","\u043A\u0440\u0456\u043C","\u0441\u0435\u0440\u0435\u0434","\u043A"]);function Zn(){return [new Gn("ukrainian-keyword",/[a-zA-Zа-яА-ЯіІїЇєЄґҐьЬ']/,Yn)]}function Xn(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Jn(i){let e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Qn=class{constructor(){this.name="ascii-identifier";}setContext(i){this.context=i;}canExtract(i,e){return Xn(i[e])}extract(i,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,t="",a=e;for(;a<i.length&&Jn(i[a]);)t+=i[a],a++;if(!t)return null;let n=this.context.lookupKeyword(t),u=n&&n.normalized!==n.native?n.normalized:void 0;return {value:t,length:a-r,metadata:{normalized:u}}}};function eu(){return [new Kn,new qn,new Un,new $n]}var ru=new Set(["\u0432","\u0443","\u043D\u0430","\u0437","\u0456\u0437","\u0437\u0456","\u0434\u043E","\u0432\u0456\u0434","\u043E","\u043E\u0431","\u043F\u0440\u0438","\u0434\u043B\u044F","\u043F\u0456\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043C\u0456\u0436","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u043F\u043E","\u0437\u0430","\u043F\u0440\u043E","\u043F\u0456\u0441\u043B\u044F","\u043D\u0430\u0432\u043A\u043E\u043B\u043E","\u043F\u0440\u043E\u0442\u0438","\u0437\u0430\u043C\u0456\u0441\u0442\u044C","\u043A\u0440\u0456\u043C","\u0441\u0435\u0440\u0435\u0434","\u043A"]),tu=[{native:"\u043C\u0438\u0448\u0430\u0432\u043D\u0438\u0437",normalized:"mousedown"},{native:"\u043C\u0438\u0448\u0430\u0432\u0433\u043E\u0440\u0443",normalized:"mouseup"},{native:"\u0437\u043C\u0456\u043D\u0430\u0440\u043E\u0437\u043C\u0456\u0440\u0443",normalized:"resize"},{native:"\u0456\u0441\u0442\u0438\u043D\u0430",normalized:"true"},{native:"\u043F\u0440\u0430\u0432\u0434\u0430",normalized:"true"},{native:"\u0445\u0438\u0431\u043D\u0456\u0441\u0442\u044C",normalized:"false"},{native:"null",normalized:"null"},{native:"\u043D\u0435\u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E",normalized:"undefined"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0438",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"s"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"ms"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0438",normalized:"ms"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"ms"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D\u0430",normalized:"m"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D\u0438",normalized:"m"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D",normalized:"m"},{native:"\u0433\u043E\u0434\u0438\u043D\u0430",normalized:"h"},{native:"\u0433\u043E\u0434\u0438\u043D\u0438",normalized:"h"},{native:"\u0433\u043E\u0434\u0438\u043D",normalized:"h"},{native:"\u043F\u0435\u0440\u0448\u0438\u0439",normalized:"first"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u0456\u0439",normalized:"last"},{native:"\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439",normalized:"next"},{native:"\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439",normalized:"previous"},{native:"\u043D\u0430\u0439\u0431\u043B\u0438\u0436\u0447\u0438\u0439",normalized:"closest"},{native:"\u0431\u0430\u0442\u044C\u043A\u0456\u0432\u0441\u044C\u043A\u0438\u0439",normalized:"parent"},{native:"\u0432\u0438\u043F\u0430\u0434\u043A\u043E\u0432\u0438\u0439",normalized:"random"},{native:"\u043F\u0435\u0440\u0448\u0430",normalized:"first"},{native:"\u043F\u0435\u0440\u0448\u0435",normalized:"first"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u044F",normalized:"last"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u0454",normalized:"last"},{native:"\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0430",normalized:"next"},{native:"\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044F",normalized:"previous"},{native:"\u043F\u043E\u0440\u043E\u0436\u043D\u044F",normalized:"empty"},{native:"\u043F\u043E\u0440\u043E\u0436\u043D\u0454",normalized:"empty"},{native:"\u043C\u043E\u044F",normalized:"my"},{native:"\u043C\u043E\u0454",normalized:"my"},{native:"\u043C\u043E\u0457",normalized:"my"}],iu=class extends yr{constructor(){super(),this.language="uk",this.direction="ltr",this.initializeKeywordsFromProfile(et,tu),this.setNormalizer(new Qr),this.registerExtractors([...eu(),...Zn(),new mr,new pr,new Qn,new In,new Vn]);}classifyToken(i){let e=i.toLowerCase();return ru.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(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":i.startsWith("/")||i.startsWith("./")||i.startsWith("http")?"url":"identifier"}},au=new iu;_r("uk",au,et);function Ke(i){let e=i.getAttribute("data-lang");if(e)return nr(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return nr(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?nr(t):null}function nr(i){return i.split("-")[0].toLowerCase()}var rt={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 Ue(i){switch(i.kind){case "event-handler":return nu(i);case "compound":return uu(i);default:return ou(i)}}function nu(i){let e=["on"],r=i.roles.get("event");r&&e.push(Le(r));let t=i.roles.get("source");if(t&&e.push("from",Le(t)),i.body&&i.body.length>0){let a=i.body.map(Ue);e.push(a.join(" then "));}return e.join(" ")}function uu(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(Ue).join(` ${e} `)}function ou(i){let e=rt[i.action];if(e){let t=[i.action];for(let[a,n]of e){let u=i.roles.get(a);u&&(a==="destination"&&u.type==="reference"&&u.value==="me"||(n&&t.push(n),t.push(Le(u))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(Le(t));return r.join(" ")}function Le(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 su(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function su(i){let e=Le(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 it=.5,lu={confidenceThreshold:it,strategy:"semantic",fallbackToOriginal:true};function cu(i,e){return typeof i=="number"?i:i[e]??i["*"]??it}function ur(i,e,r={}){let t={...lu,...r},a=tt(i,e,t);if(a!==null)return a;let n=pu(i);if(n){let u=tt(n.commands,e,t);if(u!==null)return n.prefix+u}return i}function tt(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=cu(r.confidenceThreshold,e),a=at(i,e,t);if(a!==null)return a}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=du(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var mu=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function pu(i){let e=i.match(mu);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function at(i,e,r){try{let t=yu(i,e);if(t.length>1)return vu(t,e,r);if(!Ir(e))return null;let a=Gr(i,e);return a.confidence<r||!a.node?null:Ue(a.node)}catch{return null}}function du(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function fu(i){let e=["then"],r=_(i);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let a of t.alternatives)e.includes(a)||e.push(a);}return e}function yu(i,e){let t=fu(e).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),n=i.split(`
|
|
5
|
-
`).map(o=>o.trim()).filter(o=>o.length>0),u=[];for(let o of
|
|
1
|
+
var HyperscriptI18n=(function(exports){'use strict';function se(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function Ue(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Ne(i){return {type:"reference",value:i}}function He(i,e){return {type:"property-path",object:i,property:e}}var Sr=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function ur(i,e=Sr){return e.has(i)}var Wt=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 Kt(i){return new Wt(i)}function Ae(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 Ut(i,e){return i?.possessive?.keywords?.[e]}var Me=class De{constructor(){this.logger=Kt("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 u=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",u),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!u)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let o=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:o}}matchBest(e,r,t){let n=[];for(let u of r){let o=e.mark(),s=this.matchPattern(e,u,t);s&&n.push(s),e.reset(o);}if(n.length===0)return null;n.sort((u,o)=>{let s=o.pattern.priority-u.pattern.priority;if(s!==0)return s;let l=o.confidence-u.confidence;return Math.abs(l)>.001?l:o.consumedTokens-u.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],u=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!u)for(;e.peek()?.kind==="conjunction";)e.advance();let o=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(" ")}),o=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)){o=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(o&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(o),t.delete(s),o=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?(o=d,s=c.role):(o=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(o&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(o),t.delete(s),o=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 u=this.getMatchType(t,a);if(u!=="none")return this.totalKeywordMatches++,u==="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&&!Ae(a.type,r.expectedTypes)?r.optional||false:(t.set(r.role,a),true);let u=this.tryMatchMethodCallExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ae(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let o=this.tryMatchPossessiveSelectorExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ae(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Ae(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&&!Ae(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&&!Ae(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=Ut(this.currentProfile,n);if(!a)return null;let u=e.mark();e.advance();let o=e.peek();if(!o)return e.reset(u),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let s=o.value;o.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()),He(Ne(a),l)}return e.reset(u),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 u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(t),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<De.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}o.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${o.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 u=`${r.value}.${a.value}`,o=1;for(;!e.isAtEnd()&&o<De.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(),u+=`.${c.value}`,o++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<De.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:`${u}(${l.join(", ")})`}}return {type:"expression",raw:u}}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(),He(Ue(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 u=n.value.slice(1);return He(Ue(r.value),u)}matchGroupToken(e,r,t,n){let a=e.mark(),u=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,n))return true;e.reset(a);for(let l of t.keys())u.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=De.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())u.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 u of a.alternatives)t.add(u.toLowerCase());break}if(a.type==="group"){for(let u of a.tokens)if(u.type==="literal"){if(t.add(u.value.toLowerCase()),u.alternatives)for(let o of u.alternatives)t.add(o.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 Ue(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return se(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Ne(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return se(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 se(n,"string")}if(e==="true")return se(true,"boolean");if(e==="false")return se(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?se(e,"duration"):se(n,"number")}let t=parseFloat(e);return isNaN(t)?se(e,"string"):se(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 u=n>0?t/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;u=Math.max(.5,u-l);}let o=this.calculateVSOConfidenceBoost(e);u=Math.min(1,u+o);let s=this.arabicPrepositionDisambiguation(e,r);return u=Math.max(0,Math.min(1,u+s)),u}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,u]of r.entries()){let o=n[a];if(!o||o.length===0)continue;let s="metadata"in u?u.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;o.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(De.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}};Me.MAX_MARKER_SCAN=3;Me.MAX_PROPERTY_DEPTH=10;Me.MAX_METHOD_ARGS=20;Me.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ht=Me;new Ht;var Tr=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}},Fr=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 u=i[e+r];if(/\d/.test(u))r++;else if(u==="."&&!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 u=i.slice(a),o=[{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 o)if(u.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(u.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(u.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(u))return {value:n+u[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function Gt(i){return "setContext"in i&&typeof i.setContext=="function"}function Yt(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 V(i,e){return {start:i,end:e}}function q(i,e,r,t){if(typeof i=="object"){let{value:a,kind:u,position:o,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:a,kind:u,position:o,...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:u,stemConfidence:o,metadata:s}=t;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...u!==void 0&&{stem:u},...o!==void 0&&{stemConfidence:o},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function _e(i){return /\s/.test(i)}function Zt(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function Xt(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function ye(i){return /\d/.test(i)}function Jt(i){return /[a-zA-Z]/.test(i)}function J(i){return /[a-zA-Z0-9_-]/.test(i)}function Qt(i,e){if(e>=i.length)return null;let r=i[e];if(!Zt(r))return null;let t=e,n="";if(r==="#"||r==="."){for(n+=i[t++];t<i.length&&J(i[t]);)n+=i[t++];if(n.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let u=t+1;for(;u<i.length&&J(i[u]);)u++;if(u<i.length&&i[u]==="(")return n}}else if(r==="["){let a=1,u=false,o=null,s=false;for(n+=i[t++];t<i.length&&a>0;){let l=i[t];n+=l,s?s=false:l==="\\"?s=true:u?l===o&&(u=false,o=null):l==='"'||l==="'"||l==="`"?(u=true,o=l):l==="["?a++:l==="]"&&a--,t++;}if(a!==0)return null}else if(r==="@"){for(n+=i[t++];t<i.length&&J(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="*"){for(n+=i[t++];t<i.length&&J(i[t]);)n+=i[t++];if(n.length<=1)return null}else if(r==="<"){if(n+=i[t++],t>=i.length||!Jt(i[t]))return null;for(;t<i.length&&J(i[t]);)n+=i[t++];for(;t<i.length;){let a=i[t];if(a==="."){if(n+=i[t++],t>=i.length||!J(i[t]))return null;for(;t<i.length&&J(i[t]);)n+=i[t++];}else if(a==="#"){if(n+=i[t++],t>=i.length||!J(i[t]))return null;for(;t<i.length&&J(i[t]);)n+=i[t++];}else if(a==="["){let u=1,o=false,s=null,l=false;for(n+=i[t++];t<i.length&&u>0;){let c=i[t];n+=c,l?l=false:c==="\\"?l=true:o?c===s&&(o=false,s=null):c==='"'||c==="'"||c==="`"?(o=true,s=c):c==="["?u++:c==="]"&&u--,t++;}if(u!==0)return null}else break}for(;t<i.length&&_e(i[t]);)n+=i[t++];if(t<i.length&&i[t]==="/")for(n+=i[t++];t<i.length&&_e(i[t]);)n+=i[t++];if(t>=i.length||i[t]!==">")return null;n+=i[t++];}return n||null}function ei(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 _e(t)||t==="*"||!J(t)}function ri(i,e){if(e>=i.length)return null;let r=i[e];if(!Xt(r)||r==="'"&&ei(i,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,u=r,o=false;for(;a<i.length;){let s=i[a];if(u+=s,o)o=false;else if(s==="\\")o=true;else if(s===n)return u;a++;}return u}function ti(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 ii(i,e){if(!ti(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 ni(i,e){if(e>=i.length)return null;let r=i[e];if(!ye(r)&&r!=="-"&&r!=="+")return null;let t=e,n="";if((i[t]==="-"||i[t]==="+")&&(n+=i[t++]),t>=i.length||!ye(i[t]))return null;for(;t<i.length&&ye(i[t]);)n+=i[t++];if(t<i.length&&i[t]===".")for(n+=i[t++];t<i.length&&ye(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 ai=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(ai);var ui=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"]),oi=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],Ye=class Ge{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){Gt(e)&&e.setContext(Yt(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&&_e(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 u of this.extractors)if(u.canExtract(e,t)){let o=u.extract(e,t);if(o){let s=o.metadata?.normalized,l=o.metadata?.stem,c=o.metadata?.stemConfidence,m={};if(o.metadata)for(let[d,y]of Object.entries(o.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(q(o.value,this.classifyToken(o.value),V(t,t+o.length),Object.keys(p).length>0?p:void 0)),t+=o.length,a=true;break}}if(!a){let u=e[t],o=this.classifyUnknownChar(u);r.push(q(u,o,V(t,t+1))),t++;}}return new te(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let t of e){let n=r[r.length-1];if(n&&Ge.ASCII_WORD.test(n.value)&&Ge.COLON_QUALIFIER.test(t.value)&&n.position.end===t.position.start){let a=n.value+t.value;r[r.length-1]=q(a,this.classifyToken(a),V(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(q(".","operator",V(r,r+1))),true;let s=r+1;for(;s<e.length&&J(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(q(".","operator",V(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 u of a.alternatives)t.set(u,{native:u,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 u of a.alternatives)t.set(u,{native:u,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 oi)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(" ")&&!ui.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 q(t.native,"keyword",V(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 u=e[r+a.native.length];if(!(u!==void 0&&t(u)))return q(a.native,"keyword",V(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 u=e[r+a.native.length];return u===void 0||!t(u)})}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 u={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return q(e,"keyword",V(r,t),u)}trySelector(e,r){let t=Qt(e,r);return t?q(t,"selector",V(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],u=t[1];return {...q(n,"event-modifier",V(r,r+n.length)),metadata:{modifierName:a,value:u?a==="queue"?u:parseInt(u,10):void 0}}}tryString(e,r){let t=ri(e,r);return t?q(t,"literal",V(r,r+t.length)):null}tryNumber(e,r){let t=ni(e,r);return t?q(t,"literal",V(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,n=false){let a=r;if(n)for(;a<e.length&&_e(e[a]);)a++;let u=e.slice(a);for(let o of t){let s=u.slice(0,o.length);if(o.caseInsensitive?s.toLowerCase()===o.pattern.toLowerCase():s===o.pattern){if(o.notFollowedBy&&(u[o.length]||"")===o.notFollowedBy)continue;if(o.checkBoundary){let c=u[o.length]||"";if(J(c))continue}return {suffix:o.suffix,endPos:a+o.length}}}return null}parseBaseNumber(e,r,t=true){let n=r,a="";if(t&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!ye(e[n]))return null;for(;n<e.length&&ye(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&ye(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,t,n={}){let{allowSign:a=true,skipWhitespace:u=false}=n,o=this.parseBaseNumber(e,r,a);if(!o)return null;let{number:s,endPos:l}=o,c=[...t,...Ge.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,u);return m&&(s+=m.suffix,l=m.endPos),q(s,"literal",V(r,l))}tryUrl(e,r){let t=ii(e,r);return t?q(t,"url",V(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!J(e[r+1]))return null;let t=r+1;for(;t<e.length&&J(e[t]);)t++;let n=e.slice(r,t);return q(n,"identifier",V(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return q(t,"operator",V(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?q(n,"operator",V(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?q(n,"punctuation",V(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let n of t)if(e.slice(r,r+n.length)===n)return q(n,"particle",V(r,r+n.length));return null}};Ye.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;Ye.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;Ye.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=Ye;function Se(i){return {stem:i,confidence:1}}function L(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var si=Object.defineProperty,li=Object.getOwnPropertyNames,et=(i,e)=>function(){return i&&(e=(0, i[li(i)[0]])(i=0)),e},ci=(i,e)=>{for(var r in e)si(i,r,{get:e[r],enumerable:true});};function Or(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function ee(i,e,r={},t){let n=rt[i],a=Or(n,r),u=tt[i],o=u?Or(u,r):void 0;return {code:i,message:a,severity:e,...t&&{role:t},...o&&{suggestion:o}}}var T,rt,tt,mi=et({"src/generators/schema-error-codes.ts"(){T={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"},rt={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[T.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[T.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[T.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[T.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[T.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.",[T.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.",[T.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[T.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[T.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[T.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[T.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[T.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},tt={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[T.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[T.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[T.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[T.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[T.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[T.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[T.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[T.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[T.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),it={};ci(it,{SchemaErrorCodes:()=>T,formatValidationResults:()=>Ei,getValidationStats:()=>gi,validateAllKeywordCollisions:()=>ki,validateAllSchemas:()=>vi,validateCommandSchema:()=>nt,validateKeywordCollisions:()=>at,validateRoleValues:()=>zi});function pi(i,e){return {action:i,items:e}}function nt(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(ee(T.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(ee(T.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!pr.has(i.action)&&e.push(ee(T.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(ee(T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":di(i,e);break;case "on":fi(i,e);break;case "if":case "unless":yi(i,e);break;case "repeat":case "for":case "while":hi(i,e);break}return i.roles.filter(t=>t.required).length===0&&(ut.has(i.action)?e.push(ee(T.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(ee(T.NO_REQUIRED_ROLES,"warning",{}))),pi(i.action,e)}function di(i,e){let r=i.roles.find(n=>n.role==="patient"),t=i.roles.find(n=>n.role==="goal");r&&!t&&e.push(ee(T.TRANSITION_MISSING_GOAL,"error",{}));}function fi(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(ee(T.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(ee(T.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function yi(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(ee(T.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(ee(T.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function hi(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(ee(T.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(ee(T.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function vi(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[n,a]of Object.entries(i)){let u=nt(a),o=u.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&u.items.some(l=>l.severity==="note");(o||s)&&r.set(n,u);}return r}function Ei(i,e={}){let r=[],{showNotes:t=false,showCodes:n=true}=e;for(let[a,u]of i){let o=u.items.filter(c=>c.severity==="error"),s=u.items.filter(c=>c.severity==="warning"),l=u.items.filter(c=>c.severity==="note");if(o.length>0){r.push(` \u274C ${a}:`);for(let c of o){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 gi(i){let e=0,r=0,t=0,n={};for(let a of i.values())for(let u of a.items)u.severity==="error"?e++:u.severity==="warning"?r++:u.severity==="note"&&t++,n[u.code]=(n[u.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:n}}function zi(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:T.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:T.SELECTOR_KIND_MISMATCH})));}return r}function at(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 u=r.get(a.primary)||[];if(u.push({command:n,isPrimary:true}),r.set(a.primary,u),a.alternatives)for(let o of a.alternatives){let s=r.get(o)||[];s.push({command:n,isPrimary:false}),r.set(o,s);}}for(let[n,a]of r){let u=[...new Set(a.map(l=>l.command))];if(u.length<=1)continue;let o=a.filter(l=>l.isPrimary).length,s;o>=2?s="primary-primary":o===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:u.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 ki(i){let e=[];for(let[,r]of Object.entries(i)){let t=at(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var pr,ut,bi=et({"src/generators/schema-validator.ts"(){mi(),pr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),ut=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 ge=new Map,me=new Map,Ie=new Map,dr=null;function ot(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]=ot(a,n):r[t]=n);}return r}function wi(i,e){return ot(i,e)}function vr(i){if(!i.extends)return i;let e=me.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 wi(r,i)}function st(i,e,r){ge.set(i,e),me.set(i,r),Ie.delete(i);}function lt(i){dr=i;}var Pr=new Map;function Fe(i){return i.split("-")[0]}function Re(i){return i.includes("-")}function Ci(i){let e=ge.get(i);if(!e&&Re(i)){let r=Fe(i);e=ge.get(r);}if(!e){let r=Array.from(ge.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 Ai(i){let e=me.get(i);if(!e&&Re(i)){let r=Fe(i);e=me.get(r);}if(!e){let r=Array.from(me.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 P(i){let e=me.get(i);return !e&&Re(i)&&(e=me.get(Fe(i))),e?vr(e):void 0}function Di(){return Array.from(ge.keys())}function ct(i){if(ge.has(i)&&me.has(i))return true;if(Re(i)){let e=Fe(i);return ge.has(e)&&me.has(e)}return false}function Si(i,e){return Ci(e).tokenize(i)}function ce(i){let e=Ie.get(i);if(!e&&Re(i)&&(e=Ie.get(Fe(i))),e)return e;let r=Pr.get(i);if(!r&&Re(i)&&(r=Pr.get(Fe(i))),r)return Ie.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=Ai(i),n=dr(t);return Ie.set(i,n),n}var mt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Ee(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 W(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function xe(i){return ur(i)}function ae(i){return {type:"reference",value:i}}function he(i,e){return {type:"property-path",object:i,property:e}}function ie(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Le(i,e,r,t,n,a){let u=new Map;u.set("event",i);let o={kind:"event-handler",action:"on",roles:u,body:e};return r!==void 0&&(o.eventModifiers=r),t!==void 0&&(o.metadata=t),n!==void 0&&n.length>0&&(o.parameterNames=n),o}function Ji(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 Qi(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 Nr(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 en(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 Ze(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 ke(i){let e=i.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function be(i){let e=i.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function we(i,e){return pt(i,e,"source")}function Er(i,e){return pt(i,e,"destination")}function pt(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 rn={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)"}},tn={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"}},nn={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"}},an={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"}},un={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>"}},on={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>"}},sn={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},ln={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},cn={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},mn={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},pn={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},dn={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}]},fn={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}]},yn={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}]},hn={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}]},vn={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}]},En={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}]},gn={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"}}]},zn={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"}}]},kn={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"}}]},bn={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"}}]},wn={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}]},Cn={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}]},An={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}]},Dn={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}]},Sn={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}]},xn={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}]},Bn={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}]},Tn={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"}}]},Fn={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}]},Rn={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}]},On={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Pn={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"}}]},_n={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}]},Mn={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"},Ln={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"}]},In={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}]},jn={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"}}]},$n={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}]},Vn={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}]},qn={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}]},Wn={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"}}]},Kn={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}]},Un={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}]},Gn={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}]},Yn={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Zn={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}]},Xn={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}]},Jn={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}]},Qn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},ea={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"}}]},ra={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"}}]},ta={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ia={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}]},na={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}]},aa={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"}}]},ua={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"}}]},oa={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"}}]},sa={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}]},la={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},ca={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}]},ma={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},pa={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}]},da={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"}}]},fa={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"},ya={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}]},ha={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}]},va={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:fa}]},Ea={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}]},ze={toggle:rn,add:tn,remove:nn,put:an,set:un,show:dn,hide:fn,on:yn,trigger:hn,wait:vn,fetch:En,increment:gn,decrement:zn,append:kn,prepend:bn,log:wn,get:Cn,take:An,make:Dn,halt:Sn,settle:xn,throw:Bn,send:Tn,if:Fn,unless:Rn,else:On,repeat:Pn,for:Nn,while:_n,continue:Mn,go:Ln,scroll:da,push:ya,replace:ha,process:va,transition:In,clone:jn,focus:$n,blur:Vn,empty:qn,open:Wn,close:Kn,select:Un,clear:Hn,reset:Gn,breakpoint:Yn,call:Zn,return:Xn,js:Jn,async:Qn,tell:ea,default:ra,init:ta,behavior:ia,install:na,measure:aa,swap:ua,morph:oa,beep:sa,break:la,copy:ca,exit:ma,pick:pa,render:Ea,bind:on,live:sn,eventsource:ln,socket:cn,worker:mn,intercept:pn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Q(i){return ze[i]}function ga(){return Object.values(ze).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(bi(),it)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(ze);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 le(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 or(i){return mt.possessive?.specialForms?.[i]??`${i}'s`}var za={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"}},ka={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"}},ba={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 dt(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?ba[i.code]:void 0;return !!n&&n.has(r)}var wa={destination:"in",source:"from"},Ca={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"])},Aa=new Set(["in","into","at","within","inside"]);function Da(i,e){let r=e.value.toLowerCase();if((i?.code?Ca[i.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return Aa.has(a)?"in":wa[a]??n}var sr=new Set(["first","last","next","previous","random","closest"]),Sa={bn:{\u09B6\u09C7\u09B7:"last"}},ft=new Set(Object.keys(ze).map(i=>i.toLowerCase()));function yt(i,e,r){let t=i[e];if(!t)return null;let n=(t.normalized??t.value).toLowerCase(),a=i[e+1],u=r?.code&&a?.kind==="selector"&&a.value.startsWith("<")?Sa[r.code]?.[t.value.toLowerCase()]:void 0;if(!sr.has(n)&&!sr.has(t.value.toLowerCase())&&u===void 0)return null;let o=[{text:u??t.normalized??t.value,token:t}],s=e+1,l=i[s];if(!l||l.kind!=="selector")return null;o.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("."))o.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())&&!ft.has((m.normalized??m.value).toLowerCase())&&(o.push({text:Da(r,m),token:m}),o.push({text:p.value,token:p}),s+=2),{parts:o,consumed:s-e}}function xa(i,e){let r=ka[i];return r?r[e.toLowerCase()]??e:e}function Te(i,e){let r=za[i];return r?r[e.toLowerCase()]??e:e}function Ba(i,e){let r=[e.value,e.normalized].filter(Boolean);for(let t of r){let n=le(i,t)??le(i,t.toLowerCase());if(n)return n}}function ht(i){return i.kind==="literal"||i.kind==="operator"||i.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(i.value)}function Ta(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 Fa(i,e){return ht(i)?Te(e,i.value)!==i.value?true:i.kind==="identifier":false}var Ra={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"}}},Oa=new Set(["empty","null","undefined","true","false"]),Pa=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function Na(i,e,r,t){let n=Ra[i],a=n?.[e.value]??n?.[e.value.toLowerCase()];if(a){if(a.beforeTypeName&&t?.kind==="identifier"&&Pa.has(t.value))return a.beforeTypeName;if(a.beforePredicate&&t&&(t.kind==="literal"||t.kind==="keyword"&&Oa.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=(o,s)=>{if(n===void 0){t=o,n=s;return}let c=n.position?.end!==void 0&&s.position?.start!==void 0&&n.position.end===s.position.start&&(o.startsWith(".")||o.startsWith("!"));t+=(c?"":" ")+o,n=s;},u=o=>o.kind==="keyword"?o.normalized??o.value:o.value;for(let o=0;o<i.length;o++){let s=i[o],l=e?Ba(e,s):void 0,c=i[o+1];if(l!==void 0&&c){let E=e?.possessive?.connectors,v=!!E?.length&&E.some(k=>{let D=k.toLowerCase();return D===c.value.toLowerCase()||D===(c.normalized??"").toLowerCase()}),f=v?o+2:o+1,h=i[f];if(h&&Fa(h,r)){a(or(l),s),a(Te(r,h.value),h),o=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(or(l),s),a(Te(r,h.value.slice(1)),h),o=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&&!Ta(e,s)){a(or(l),s),a(Te(r,c.value.slice(1)),c),o+=1;continue}}let m=i[o+2];if(c&&m&&m.kind==="selector"&&dt(e,c)&&ht(s)){a(Te(r,s.value),s),a("of",c),a(m.value,m),o+=2;continue}let p=yt(i,o,e);if(p){for(let E of p.parts)a(E.text,E.token);o+=p.consumed-1;continue}let d=Na(r,s,i[o-1],c);if(d!==void 0){a(d,s);continue}let y=xa(r,s.value);if(y!==s.value){a(y,s);continue}a(u(s),s);}return t.trim()}var vt=[{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 _r(i,e,r,t){let n=vt.find(u=>u.lang===i);if(!n)return false;let a=(u,o)=>(u??"").toLowerCase()===o.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(t,n.of)}function _a(i,e){let r=vt.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 Et={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 Ma(i){return Et[i]}function La(i,e){return Et[e]?.has(i.toLowerCase())??false}var gt=96,Ia=/^[A-Za-z_][\w-]*$/,ja=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function zt(i,e){let r=i.peek(e);return !!r&&r.kind==="identifier"&&ja.test(r.value)}function kt(i,e){let r=i.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Ia.test(r.value))return false;let t=i.peek(e+1),n=i.peek(e+2);return !!t&&t.value===":"&&!!n}function Mr(i,e=0){return zt(i,e)||kt(i,e)}function $a(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++<gt;){let u=i.advance();if(!u)break;if(t>=0&&u.position.start>t&&(r+=" ".repeat(u.position.start-t)),r+=u.value,t=u.position.end,u.value==="{"||u.value==="(")n++;else if((u.value==="}"||u.value===")")&&(n--,n===0))return r}return null}function Lr(i){let e=i.peek();return e?e.value==="{"||e.value==="("?$a(i):e.value===","||e.value===":"?null:(i.advance(),e.value):null}function je(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 u=Lr(i);if(u===null)return i.reset(r),null;t.push(`${e}:${u}`);}else if(!Mr(i))return null;let n=0;for(;n++<gt;){let a=i.peek();if(!a)break;if(a.value===","){if(t.length===0||!Mr(i,1))break;i.advance();continue}if(zt(i,0)){t.push(i.advance().value);continue}if(!kt(i,0))break;let u=i.advance().value;i.advance();let o=Lr(i);if(o===null)return i.reset(r),null;t.push(`${u}:${o}`);}return t.length===0?(i.reset(r),null):`{${t.join(", ")}}`}var lr=.8,Va=.6,qa=.15,Wa=.5,Ir=.15,jr=.1,$r=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"]),Ka={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"]},Ua=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(Wa,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=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")n+=1,r.has(u.role)&&(t+=1);else if(u.type==="group")for(let o of u.tokens)o.type==="role"&&(n+=lr,r.has(o.role)?t+=lr:a(o.role)&&(t+=lr*Va));return n>0?t/n:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*qa}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:$r.has(r.value)||r.alternatives?.some(t=>$r.has(t))?Ir: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 u=Ka[n];if(!u||u.length===0)continue;let o="metadata"in a?a.metadata:void 0;o&&typeof o.prepositionValue=="string"&&(u.includes(o.prepositionValue)?t+=.1:t-=.1);}return Math.max(-jr,Math.min(jr,t))}},Ha=new Ua,Ga=new Set(Object.values(ze).filter(i=>i.bareKeyword===true).map(i=>i.action)),X=class M{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Ha;}matchPattern(e,r){let t=e.mark(),n=new Map;if(this.currentProfile=P(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 u=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:u}}matchBest(e,r){this.matchCache.clear();let t=[],n=e.position();for(let u of r){let o=e.mark(),s=`${n}:${u.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,u),this.matchCache.set(s,l)),l&&t.push(l),e.reset(o);}if(t.length===0)return null;t.sort((u,o)=>{let s=o.pattern.priority-u.pattern.priority;return s!==0?s:o.confidence-u.confidence});let a=t[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,t,n){let a=r[0],u=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!u)for(;e.peek()?.kind==="conjunction";)e.advance();let o=0;for(let s=0;s<r.length;s++){let l=r[s];o>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let c=this.matchPatternToken(e,l,t,r[s+1]??n);if(o=l.type==="role"&&l.role==="event"?2:Math.max(0,o-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 u=this.currentProfile?.roleMarkers?.source,o=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!u)return false;let c=l.value.toLowerCase();return u.primary?.toLowerCase()===c?true:!!u.alternatives?.some(m=>m.toLowerCase()===c)},s=u?.position;if(s!=="after"&&o(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&o(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 u=this.getMatchType(t,a);if(u!=="none")return this.totalKeywordMatches++,u==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let u of ["-","_"])if(a.includes(u)&&this.tryMatchShatteredCompound(e,a,u))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),n=[];for(;;){let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword")break;n.push(u.value),e.advance();let o=e.peek();if(!o||o.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[u,o]of Object.entries(r.keywords))if(o.primary.toLowerCase()===a||o.alternatives?.some(s=>s.toLowerCase()===a))return W(u);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let n=r.split(t);if(n.length<2||n.some(u=>u.length===0))return false;let a=e.mark();for(let u=0;u<n.length;u++){if(u>0){let s=e.peek();if(!s||s.value!==t)return e.reset(a),false;e.advance();}let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword"&&o.kind!=="particle"||o.value.toLowerCase()!==n[u].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(!M.tokenLooksLikeEvent(a))return r.optional||false;let f=(a.normalized??a.value).toLowerCase();if(M.POSITIONAL_OR_SCOPE_KEYWORDS.has(f)||this.currentProfile&&(le(this.currentProfile,a.value)??le(this.currentProfile,f))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let f=(a.normalized??a.value).toLowerCase();if(M.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"||La(a.value,this.currentProfile?.code??""))return r.optional||false}if(r.role==="duration"){let f=(a.normalized??a.value).toLowerCase();if(M.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 ze)return true;let u=this.tryMatchPositionalExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ze(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let o=this.tryMatchCaretScopeExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ze(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),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"||M.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&&!Ze(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&&!Ze(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=je(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,W(`${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 D=this.tokenToSemanticValue(e.advance());D&&!t.has("source")&&t.set("source",D);}}}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=yt(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(),u=!!t&&(t.value.toLowerCase()==="on"||a==="destination"||a==="on");return !t||!n||n.kind!=="selector"||!u?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return dt(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(),u=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let s=e.peek();if(!s||!M.RUN_OPERATORS.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let o=yr(e.tokens.slice(u,e.position()),this.currentProfile);return {type:"expression",raw:o,value:o}}tryMatchOperatorRunExpression(e){let r=e.mark(),t=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let n=1;for(;;){let u=e.peek();if(!u||!M.RUN_OPERATORS.has(u.value))break;let o=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(o);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(M.PICK_RANGE_SEPARATORS.has(r))return true;let t=this.currentProfile?.code;return t?M.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&&M.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let u=e.tokens.slice(t,e.position()),[o,,s,l]=u,c=p=>p.kind==="keyword"?p.normalized??p.value:p.value,m=`${c(o)} 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")&&!M.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(le(this.currentProfile,r)??le(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?Te(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(),he(Ee(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=le(this.currentProfile,s)??le(this.currentProfile,s.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let u=this.currentProfile.possessive?.connectors;if(u&&u.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();u.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let o=e.peek();if(!o||_a(this.currentProfile.code,o.value))return e.reset(a),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)&&!(o.normalized&&this.isStructuralKeyword(o.normalized))&&!(o.normalized&&this.isRoleMarkerConcept(o.normalized))&&!(o.normalized&&M.COMMAND_ACTION_KEYWORDS.has(o.normalized.toLowerCase()))||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let s=o.value;o.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++<M.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 he(ae(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(),u=r.value;t&&(u=u.substring(1)),e.advance(),u=this.toEnglishProperty(u);let o=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)o+=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=le(this.currentProfile,c)??le(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),he(ae(l),o)):(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&&Ga.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,u=0;for(;!e.isAtEnd()&&u++<M.MAX_BRACE_RUN_TOKENS;){let o=e.advance();if(!o)break;if(o.value==="{")a++;else if(o.value==="}"&&(a--,a===0))return n.push("}"),W(n.join(" "));n.push(o.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,u=0,o=0;for(;!e.isAtEnd()&&o++<M.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==="{")u++;else if(s.value==="}"&&(u--,u===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(),u="",o=a.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<M.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let m=o!==void 0&&c.position?.start===o;u+=(u===""||m?"":" ")+c.value,o=c.position?.end,e.advance();}return s?{type:"expression",raw:`${r.value}(${u})`}:(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 u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(t),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<M.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}o.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${o.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(),u=e.peek();if((t.kind==="identifier"||M.PROPERTY_ACCESS_BASES.has(a))&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value)){let d=t.value,y=[],E=0;for(;E<M.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&&xe(a))return he(ae(a),y.join("."));if(f){let h=e.mark(),k=[],D=0,A=false;for(;!e.isAtEnd();){let z=e.peek();if(!z)break;if(z.value==="(")D++;else if(z.value===")"){if(k.push(z.value),e.advance(),D--,D===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 o=e.peek();if(!o||o.kind!=="operator"||o.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<M.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<M.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&&xe(p)){let d=l.split(".").slice(1).join(".");return he(ae(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(/^-/,""),u=!!n&&n.kind==="punctuation"&&n.value==="'s",o=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let p=ze[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(!u&&!l&&!o)return e.reset(t),null;e.advance(),o&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(u||o)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(t),null):(e.advance(),he(Ee(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 u=n.value.slice(1);return he(Ee(r.value),u)}matchGroupToken(e,r,t,n){let a=e.mark(),u=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,n)){e.reset(a);for(let s of t.keys())u.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 Ee(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return xe(r)?ae(r):W(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return Ee(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ae(e.value);let t=e.value.toLowerCase();return xe(t)?ae(t):{type:"expression",raw:e.value};case "url":return W(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 W(n,"string")}if(e==="true")return W(true,"boolean");if(e==="false")return W(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?W(e,"duration"):W(n,"number")}let t=parseFloat(e);return isNaN(t)?W(e,"string"):W(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 u=a.type==="literal"?String(a.value):String(a.raw??"");r.set(t,n.transform(u));}}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(M.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 u=e.peek(1);if(a&&a.kind==="keyword"&&u&&u.kind==="selector"&&/^\.[a-zA-Z_]/.test(u.value))return;let o=a?(a.normalized??a.value).toLowerCase():"";if(a&&M.POSITIONAL_OR_SCOPE_KEYWORDS.has(o))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&M.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||M.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&xe(o)&&m||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&xe(o))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}};X.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);X.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);X.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);X.COMMAND_ACTION_KEYWORDS=ft;X.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);X.RUN_OPERATORS=new Set(["+","-","*","/"]);X.PICK_RANGE_SEPARATORS=new Set(["to"]);X.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"])};X.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);X.MAX_BRACE_RUN_TOKENS=64;X.MAX_PROPERTY_DEPTH=10;X.MAX_METHOD_ARGS=20;X.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);X.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ya=X,ne=new Ya;function U(i,e){return Si(i,e)}function bt(){return Di()}var qe=["if","unless","repeat","for","while"],er=/^[A-Z][A-Za-z0-9_]*$/;function Y(i,e){let r=new Set([e]),n=P(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 $(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var Za=new Set(qe);function rr(i,e){let r=i.normalized?.toLowerCase();return r?Za.has(r):e.some(t=>$(i,t))}var Vr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Xa=new Set(["destination","source","style","patient","on","from","to"]);function wt(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(Vr.has(e)||Vr.has(r)||Xa.has(e))}var qr=new Set(["ja","ko"]);function $e(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 Ct(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 u=a.trim();u&&r.push(u);}}return {parameters:r,headerEnd:t}}function tr(i,e,r){let t=e+1;if(t>=i.length)return -1;let n=$e(P(r)?.roleMarkers?.patient);return n.size>0&&$(i[t],n)&&t++,t<i.length?t:-1}var At=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function Ja(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 Qa(i,e,r){let t=P(r);if(t?.wordOrder!=="SOV"||!At.test(i[0].value)||e!==Ja(i))return false;let n=$e(t.roleMarkers?.patient);return n.size===0?false:$(i[e-1],n)}function eu(i,e,r){if(!P(e))return null;let t=Y(e,"behavior"),n=Y(e,"def"),a=i.toLowerCase(),u=[...t].some(m=>a.includes(m)),o=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!u&&!o)return null;let s=U(i,e).tokens;if(s.length<2)return null;if($(s[0],t))return Wr(i,e,s,r,0);let l=s.findIndex((m,p)=>p>0&&$(m,t));if(l>0&&er.test(s[0].value))return Wr(i,e,s,r,l);if($(s[0],n))return Kr(i,e,s,r,0);let c=s.findIndex((m,p)=>p>0&&$(m,n));return c>0&&Qa(s,c,e)?Kr(i,e,s,r,c):null}function ru(i,e,r){let t=P(e);if(!t)return null;let n=t.wordOrder!=="SOV",a=qr.has(e)?$e(t.roleMarkers?.event):new Set,u=qr.has(e)?$e(t.keywords?.on):new Set,o=a.size>0&&u.size>0,s=Y(e,"end"),l=Y(e,"on"),c=i.toLowerCase(),m=[...s].some(z=>c.includes(z)),p=(n||o)&&(()=>{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=U(i,e).tokens;if(d.length<2)return null;let y=qe.map(z=>Y(e,z)),E=z=>rr(z,y),v=z=>$(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&&$(g,l)&&wt(d[z+1])){let C=i.slice(d[k].position.start,g.position.start).trim();C&&f.push(C),k=z;}else if(o&&h===0&&z-1>k&&$(g,a)&&d[z+1]!==void 0&&$(d[z+1],u)){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 D=[],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;D.push(C);let b=!C.body||C.body.length===0;A.push(b?.2:C.metadata?.confidence??.75);}return fr(D,"then",{sourceLanguage:e,confidence:Ve(A),sourceText:i})}function Ve(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 Wr(i,e,r,t,n){let a=n>0,u=a?0:tr(r,n,e);if(u<0)return null;let o=r[u],s=o.value;if(!er.test(s))return null;let{parameters:l,headerEnd:c}=Ct(i,o),m=a?n+1:r.findIndex(C=>C.position.start>=c);m<=u&&(m=u+1);let p=Y(e,"init"),d=Y(e,"end"),y=qe.map(C=>Y(e,C)),E=C=>rr(C,y),v=C=>$(C,d),f=[],h=[],k=[],D=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){D=true;break}if($(r[z],p)){let w=i.slice(r[z].position.end,b.position.start).trim();if(w)try{let S=zr(t.body(w,e));h.push(...S),k.push(Ve(S.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 S=t.statement(w,e);if(S&&S.kind==="event-handler"){let x=S;f.push(x);let R=!x.body||x.body.length===0;k.push(R?.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=(D?1:.8)*Ve(k);return Ji(s,l,f,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:i})}function Kr(i,e,r,t,n){let a=n>0,u=a?0:tr(r,n,e);if(u<0)return null;let o=r[u],s=o.value;if(!At.test(s))return null;let{parameters:l,headerEnd:c}=Ct(i,o),m=a?n+1:r.findIndex(g=>g.position.start>=c);m<=u&&(m=u+1);let p=Y(e,"end"),d=qe.map(g=>Y(e,g)),y=g=>rr(g,d),E=g=>$(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,D=i.slice(h,k).trim();if(!D)return null;let A;try{A=zr(t.body(D,e));}catch{return null}if(A.length===0)return null;let z=Ve(A.map(g=>g.metadata?.confidence??.75));return f<0&&(z*=.8),Qi(s,l,A,{sourceLanguage:e,confidence:z,sourceText:i})}var hr=["live","eventsource","socket","worker","intercept"],tu=new Set(["intercept"]),kr=new Set(["eventsource","socket","worker"]),iu=new Set(["eventsource","socket"]),nu=new Set(["worker"]),au=6,uu=2;function ou(i,e){for(let t of hr)if($(i[0],Y(e,t)))return {action:t,keywordIdx:0};if(P(e)?.wordOrder!=="SOV")return null;let r=Math.min(i.length,au);for(let t=1;t<r;t++)for(let n of hr)if(n!=="live"&&$(i[t],Y(e,n))&&!(kr.has(n)&&!er.test(i[0].value))&&!(n==="intercept"&&t>uu))return {action:n,keywordIdx:t};return null}function su(i,e,r){let t=$e(P(r)?.roleMarkers?.source);return t.size===0||e+1>=i.length?0:$(i[e],t)||$(i[e+1],t)?2:0}function lu(i,e,r,t,n){if(i==="live")return r+1;if(r>0){let s=r+1;return i==="eventsource"&&(s+=su(e,s,t)),s}let a=tr(e,r,t);if(a<0)return -1;if(i==="worker")return a+1;let u=Y(t,"on"),o=n>=0?n:e.length;for(let s=a+1;s<o;s++)if($(e[s],u)&&wt(e[s+1]))return s;return o}function cu(i,e,r,t){if(!kr.has(i))return;let n=r>0?0:tr(e,r,t);if(!(n<0))return e[n].value}function mu(i,e,r){if(!P(e))return null;let t=i.toLowerCase(),n=false;for(let o of hr){for(let s of Y(e,o))if(s&&t.includes(s)){n=true;break}if(n)break}if(!n)return null;let a=U(i,e).tokens;if(a.length<2)return null;let u=ou(a,e);return u?pu(i,e,a,r,u.action,u.keywordIdx):null}function pu(i,e,r,t,n,a){let u=Y(e,"end"),o=qe.map(D=>Y(e,D)),s=D=>rr(D,o),l=D=>$(D,u),c=cu(n,r,a,e);if(kr.has(n)&&(!c||!er.test(c)))return null;let m=D=>({sourceLanguage:e,confidence:D,sourceText:i}),p=Ur(r,a+1,l,s);if(tu.has(n))return p>=0&&p!==r.length-1?null:Nr(n,[],c,m(p>=0?1:.8));let d=lu(n,r,a,e,p);if(d<0||d>r.length)return null;let y=[],E=[],v=false,f=nu.has(n);if(f||iu.has(n)){let D=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 S=t.statement(w,e);if(S&&S.kind===D){let x=S;y.push(x);let R=!x.body||x.body.length===0;E.push(R?.2:x.metadata?.confidence??.75);}else E.push(0);}catch{E.push(0);}z=g+1;}else s(C)&&A++;}}else {let D=Ur(r,d,l,s);v=D>=0;let A=D>=0?r[D].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*Ve(E):h;return Nr(n,y,c,m(k))}function Ur(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 de={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(de).map(([i,e])=>{let r={};for(let[t,n]of Object.entries(e))n in r||(r[n]=t);return [i,r]}));var hu={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},vu=[["\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"]],Eu=/^(\d+)(ms|s|m)?$/,gu=new Set(["selector","literal","url","event-modifier"]);function zu(i){let e=i.match(Eu);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 ku(i){for(let e=1;e<i.length;e++){let r=i[e];if(gu.has(r.kind))continue;let t=r.value.toLowerCase(),n=hu[t];if(n){let a=0;for(let u=e+1;u<i.length;u++){let o=i[u],s=zu(o.value);if(s!==null)return {modifiers:{[n]:s},start:r.position.start,end:o.position.end};if(o.kind==="selector"||o.kind==="literal"||o.kind==="url"||++a>2)break}continue}for(let a of vu){if(a[0]!==t||e+a.length>i.length)continue;let u=true;for(let o=1;o<a.length;o++)if(i[e+o].value.toLowerCase()!==a[o]){u=false;break}if(u)return {modifiers:{once:true},start:r.position.start,end:i[e+a.length-1].position.end}}}return null}var ve=new Set(["if","unless","while","repeat","for"]),cr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),wu=new Set(["first","last","next","previous","random","closest"]),Be=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"]),Yr=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function I(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function j(i,e){return e.length===0?i:{...i,diagnostics:e}}var Je=120;function Cu(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 u=r.slice(n.position.start,a.position.end);if(!u.trim())return null;let o=u.length>Je?`${u.slice(0,Je)}\u2026`:u,s=t-i.consumedTokens;return `pattern ${i.pattern.id} left ${s} token(s) unconsumed: "${o}"`}var Au=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 u of n.diagnostics??[]){if(u.code!=="unconsumed-input")continue;let o=`${u.code}|${u.message}`;r.has(o)||(r.add(o),e.push(u));}let a=n;for(let u of Dt){let o=a[u];if(Array.isArray(o))for(let s of o)t(s);}};return t(i),e.length===0?i:j(i,[...i.diagnostics??[],...e])}function Zr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var Dt=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function St(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=Q(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,u=a.get("patient");u!==void 0&&(a.delete("patient"),a.set(n,u));}if(i.action==="tell"){let a=i.roles,u=a.get("patient"),o=a.get("destination");u&&(u.type==="selector"||u.type==="reference")&&(!o||o.type==="literal")&&(a.delete("patient"),a.set("destination",u));}if(i.action==="fetch"){let a=i.roles,u=a.get("patient"),o=a.get("source");u&&o&&(u.type==="literal"||u.type==="expression")&&o.type==="expression"&&!a.has("style")&&(a.delete("patient"),a.set("style",o),a.set("source",u));}if(i.action==="transition"){let a=i.roles,u=a.get("destination");u&&u.type==="literal"&&!a.has("goal")&&(a.delete("destination"),a.set("goal",u));let o=a.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(o.value)&&a.set("patient",{type:"expression",raw:o.value});}if(i.action==="morph"){let a=i.roles,u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(u.value)&&a.set("patient",{type:"expression",raw:u.value});}if(i.action==="wait"){let a=i.roles;if(!a.has("event")){let u=a.get("duration"),o=u?.type==="expression"?u.raw:u?.type==="literal"?u.value:void 0;typeof o=="string"&&Be.has(o.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:o,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let a=i.roles,u=a.get("event");if(u&&u.type==="expression"){let o=u.raw;typeof o=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(o)&&a.set("event",{type:"literal",value:o,dataType:"string"});}}if(e?.size){let a=i.roles;for(let u of ["destination","source"]){let o=a.get(u);o&&o.type==="literal"&&typeof o.value=="string"&&e.has(o.value)&&a.set(u,{type:"expression",raw:o.value});}}}let r=i;for(let t of Dt){let n=r[t];if(Array.isArray(n))for(let a of n)St(a,e);}return i}var Z=class B{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=St(this.parseInternal(e,r),this.boundIdentifiers),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(t=j(t,[...t.diagnostics??[],...n])),this.parseDepth===1&&(t=mr(t),t.kind==="event-handler")){let a={node:t,input:e},u=a.node.eventModifiers;if(u&&(u.once||u.debounce!==void 0||u.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 o=this.reclaimEventCompoundTail(a.node,a.input,r);o&&(a=o),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=B.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let t=P(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 u of a.toLowerCase().split(/\s+/))r.add(u);}}for(let n of B.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());B.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 Au.has(t)?true:B.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(o=>!this.isCoverageResidueToken(o,r)))return;let a=e.map(o=>o.value).join(" ").trim();if(!a)return;let u=a.length>Je?`${a.slice(0,Je)}\u2026`:a;n.push(I(`${t} left ${e.length} token(s) unconsumed: "${u}"`,"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=eu(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(t)return t;let n=mu(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(n)return n;let a=ru(e,r,{statement:(b,w)=>this.parse(b,w),body:(b,w)=>this.parseStatements(b,w)});if(a)return a;let{modifiers:u,remainingInput:o}=this.extractStandaloneModifiers(e,r),s=o||e,c=this.stripAsyncModifier(s,r).remainingInput??s,p=this.stripDoNotThrowModifier(c,r).remainingInput??c,d=[],y=U(p,r),E=ce(r);if(E.length===0)throw new Yr(`No patterns available for language: ${r}`,r,p,[I(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...E].sort((b,w)=>w.priority-b.priority);{let b=y.tokens;if(P(r)?.wordOrder==="VSO"&&b.length>=4&&b[0]?.normalized==="source"){let w=b.findIndex(S=>S.normalized==="on");if(w>=2&&w+1<b.length){let S=p.slice(b[0].position.start,b[w].position.start).trim(),x=b[w+1].position.end,R=p.slice(b[w].position.start,x)+" "+S+p.slice(x);if(R!==p)try{let F=this.parse(R,r);if(F&&F.kind==="event-handler"){let O=u?this.applyModifiers(F,u):F;return j(O,d)}}catch{}}}}{let b=y.tokens,w=b[0]?.normalized==="if";for(let S=0;w&&S+3<b.length;S++){let x=(b[S+3]?.normalized??b[S+3]?.value??"").toLowerCase();if(b[S]?.normalized==="source"&&b[S+2]?.normalized==="on"&&B.KNOWN_EVENTS.has(x)){let R=(p.slice(0,b[S].position.start).trimEnd()+" "+p.slice(b[S+1].position.end).trimStart()).trim();if(R&&R!==p)try{let F=this.parse(R,r);if(F&&F.kind==="event-handler"){let O=u?this.applyModifiers(F,u):F;return j(O,d)}}catch{}break}}}{let b=y.tokens;for(let w=1;w<b.length-1;w++){let S=b[w],x=S.value,R=(S.normalized??S.value).toLowerCase();if(!(R==="or"||B.OR_KEYWORDS.has(x)||B.OR_KEYWORDS.has(R)))continue;let O=b[w+1],N=(O.normalized??O.value).toLowerCase();if(!B.KNOWN_EVENTS.has(N))break;let _=w+1,H=b[w+2];H&&H.kind==="selector"&&H.value.startsWith("[")&&(_=w+2);let G=b[w].position.start,pe=b[_].position.end,ue=(p.slice(0,G).trimEnd()+" "+p.slice(pe).trimStart()).trim();if(ue&&ue!==p)try{let fe=this.parse(ue,r);if(fe&&fe.kind==="event-handler"){fe.additionalEvents=[{type:"literal",value:N}];let ar=u?this.applyModifiers(fe,u):fe;return j(ar,d)}}catch{}break}}{let b=ku(y.tokens);if(b){let w=(p.slice(0,b.start).trimEnd()+" "+p.slice(b.end).trimStart()).trim();if(w&&w!==p)try{let S=this.parse(w,r);if(S&&S.kind==="event-handler"){let x=this.applyModifiers(S,{...u??{},...b.modifiers});return j(x,d)}}catch{}}}let f=v.filter(b=>b.command==="on"),h=y.mark(),k=ne.matchBest(y,f);if(k){d.push(I(`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"),S=(w?.raw??w?.value??"").toString().toLowerCase(),x=de[r],R=B.KNOWN_EVENTS.has(S)||!!x&&Object.keys(x).some(F=>F.toLowerCase()===S);if(S&&!R){let F=this.trySOVEventExtraction(p,r,v);if(F){d.push(I(`bare-event mis-anchor on "${S}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let O=u?this.applyModifiers(F,u):F;return j(O,d)}if(w?.type==="reference"||w?.type==="expression"){y.reset(h);let O=v.filter(_=>_.command!=="on"),N=ne.matchBest(y,O);y.reset(h),N&&N.pattern.command!=="on"?(b=true,d.push(I(`bare-event mis-anchor on reference "${S}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):ne.matchBest(y,f);}}}if(!b){let w=this.buildEventHandler(k,y,r),S=u?this.applyModifiers(w,u):w;return j(S,d)}}d.push(I(`event patterns: ${f.length} tried, no match`,"info","stage-event"));let D=this.tryTrailingEventExtraction(p,r,v);if(D){d.push(I("trailing event extraction succeeded","info","stage-trailing-event"));let b=u?this.applyModifiers(D,u):D;return j(b,d)}let A=v.filter(b=>b.command!=="on"),z=ne.matchBest(y,A);if(z){if(ve.has(z.pattern.command)){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(I(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let x=u?this.applyModifiers(w,u):w;return j(x,d)}let S=this.tryMidStreamEventExtraction(p,r,v);if(S){d.push(I(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let x=u?this.applyModifiers(S,u):S;return j(x,d)}}else if(B.KNOWN_EVENTS.has(z.pattern.command)&&this.hasSOVEventMarkerHead(p,r)){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(I(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let S=u?this.applyModifiers(w,u):w;return j(S,d)}}else if(P(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(p,r,v);if(w){d.push(I(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let S=u?this.applyModifiers(w,u):w;return j(S,d)}}if(z.consumedTokens<y.tokens.length&&P(r)?.wordOrder==="SOV"){let w=this.trySOVEventExtraction(p,r,v);if(w){d.push(I(`SOV event extraction preferred over partial ${z.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let S=u?this.applyModifiers(w,u):w;return j(S,d)}}if(z.consumedTokens<y.tokens.length&&!ve.has(z.pattern.command)){let w=this.tryTopLevelCommandSequence(y,A,r);if(w)return d.push(I(`top-level command sequence: ${w.statements.length} commands`,"info","stage-top-level-sequence")),j(w,d)}d.push(I(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let b=Cu(z,y,p);return b&&d.push(I(b,"warning","unconsumed-input")),j(this.buildCommand(z,r),d)}if(d.push(I(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!p.includes(`
|
|
4
|
+
`)&&P(r)?.wordOrder==="VSO"){let b=this.tryMidStreamEventExtraction(p,r,v);if(b){d.push(I("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let w=u?this.applyModifiers(b,u):b;return j(w,d)}}let g=this.trySOVEventExtraction(p,r,v);if(g){d.push(I("SOV event extraction succeeded","info","stage-sov"));let b=u?this.applyModifiers(g,u):g;return j(b,d)}d.push(I("SOV event extraction: no event keyword found","info","stage-sov"));let C=this.tryCompoundCommandParsing(y,A,r);if(C)return d.push(I("compound command parsing succeeded","info","stage-compound")),j(C,d);throw d.push(I("compound parsing: no then-keywords or no command matches","info","stage-compound")),d.push(I(`all parse stages exhausted for "${p}"`,"error","parse-failed")),new Yr(`Could not parse input in ${r}: ${p}`,r,p,d)}parseStatements(e,r){let t=U(e,r),n=ce(r).filter(a=>a.command!=="on").sort((a,u)=>u.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(t,n,r),u=this.coverageFrames[this.coverageFrames.length-1];if(u.length>0&&a.length>0){let o=a[a.length-1];a[a.length-1]=j(o,[...o.diagnostics??[],...u]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return bt()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[a,u]of e.captured)t[a]=u;let n=ie(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=de[t]?.[m];p?n={type:"literal",value:p,dataType:"string"}:n.type==="expression"&&B.KNOWN_EVENTS.has(m.toLowerCase())&&(n={type:"literal",value:m.toLowerCase(),dataType:"string"});}}let a=ne.extractEventModifiers(r),u=e.captured.get("source");u&&e.pattern.id.includes("source")&&!(u.type==="reference"&&u.value==="me")&&(a={...a??{},from:u});let o=this.extractOrConjunctionEvents(r,t),s=n;o.length>0&&n.type==="literal"&&(s={type:"literal",value:[String(n.value),...o.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=ce(t).filter(k=>k.command!=="on").sort((k,D)=>D.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(),D=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(D>0){let A=y[D+1],z=A&&A.kind==="selector"&&A.value.startsWith("[")?1:0;y=[...y.slice(0,D-1),...y.slice(D+1+z)];}}let E=new te(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 Le(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=ie(m,p,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(d),!ve.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 S=z[w];if(C(S))break;if((S.normalized??S.value).toLowerCase()===m){b=w;break}}if(b>=0){let w=g;for(;w<z.length&&!C(z[w]);)w++;let S=z.slice(b,w),x=S;if(A){let R=String(n.value??"").toLowerCase(),F=S.findIndex(O=>(O.normalized??O.value).toLowerCase()===R);if(F<0)x=null;else {let O=S[F-1],N=O&&O.kind==="keyword"&&O.normalized?.toLowerCase()==="on"?F-1:F;x=[...S.slice(0,N),...S.slice(F+1)];}}if(x&&x.length>1){let R=ce(t).filter(K=>K.command!=="on").sort((K,oe)=>oe.priority-K.priority),F=this.coverageMark(),O=this.parseClause(x,R,t),N=O[0],_=K=>K!==null&&typeof K=="object"&&typeof K.type=="string"?K.type:typeof K,H=Q(m),G=H?.primaryRole,pe=K=>K==="patient"&&G&&G!=="patient"&&!H?.roles.some(oe=>oe.role==="patient")?G:K,ue=(K,oe)=>{if(!ve.has(m)||!H)return false;let Ce=H.roles.find(Pe=>Pe.role===pe(K));return Ce?Ce.expectedTypes.length>0&&!Ce.expectedTypes.includes(_(oe)):true},fe=!!N&&N.kind==="command"&&Object.entries(p).every(([K,oe])=>{if(ue(K,oe))return true;let Ce=N.roles.get(pe(K));if(Ce!==void 0&&_(Ce)===_(oe))return true;if(K==="patient"&&m==="pick"&&_(oe)==="literal"){let Pe=N.roles.get("method");return Pe!==void 0&&_(Pe)==="literal"&&String(Pe.value)===String(oe.value)}return false}),ar=N?.metadata?.patternId??"",$t=!ve.has(m)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(ar);if(O.length===1&&N&&N.kind==="command"&&N.action===m&&fe&&$t&&N.roles.size>Object.keys(p).length)for(d=N;r.position()<w;)r.advance();else this.coverageRollback(F);}}}if(!ve.has(m)){let A=d;if(Q(m)?.roles.some(x=>x.role==="quantity"&&!x.required)&&!A.roles.has("quantity")){let x=r.peek();x&&/^-?\d+(\.\d+)?$/.test(x.value)&&(d=ie(m,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(x.value),dataType:"number"}},A.metadata),r.advance());}let g=d;if(Q(m)?.roles.some(x=>x.role==="duration"&&!x.required)&&!g.roles.has("duration")){let x=/^\d+(\.\d+)?(ms|s)$/i,R=r.peek(),F=false;if(R&&R.kind==="particle"){let O=r.peek(1);O&&x.test(O.value)&&(F=true,R=O);}R&&x.test(R.value)&&(d=ie(m,{...Object.fromEntries(g.roles),duration:{type:"literal",value:R.value,dataType:"string"}},g.metadata),F&&r.advance(),r.advance(),this.consumeForPostposition(r,t));}let b=d,w=Q(m);if(w?.roles.find(x=>x.role==="responseType"&&!x.required)&&!b.roles.has("responseType")){let x=_=>typeof _=="string"&&B.RESPONSE_TYPE_WORDS.has(_.toLowerCase()),R=(_,H)=>{let G=Object.fromEntries(b.roles);H&&delete G.destination,G.responseType={type:"expression",raw:_},d=ie(m,G,b.metadata);},F=b.roles.get("destination"),O=w?.roles.find(_=>_.role==="destination"),N=F?.raw??F?.value;if(F&&O&&!O.expectedTypes.includes(F.type)&&x(N))R(N,true);else {let _=r.peek();_&&x(_.value)&&(R(_.value,false),r.advance());}}if(m==="wait"){let x=d;if(!x.roles.has("event")){let R=r.peek();if(R&&Be.has(R.value.toLowerCase())){let F=Object.fromEntries(x.roles),O=F.duration;O&&O.type!=="literal"&&O.type!=="expression"&&delete F.duration;let N=F.patient;N&&N.type==="reference"&&N.value==="me"&&delete F.patient,F.event={type:"literal",value:R.value,dataType:"string"},d=ie(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=ve.has(m)&&!!v&&!this.isEndKeyword(v.value,t),D=!!v&&!this.isEndKeyword(v.value,t);if(E||f||k||D){let A=ce(t).filter(C=>C.command!=="on").sort((C,b)=>b.priority-C.priority),z=ce(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=ce(t).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);l=this.parseBodyWithClauses(r,m,t);}return Le(s,l,a,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let n=[],a=[],u=0,o=[];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"||_r(t,s.value,c?.value,m?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&u>0){u--,o.pop(),a.push({...s,metadata:{...s.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&o.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,u=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,o.length=0;for(let E=0;E<u;E++)o.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")&&(u++,o.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 te(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 u=a[0];if(u.statements.length<2)return this.coverageRollback(n),null;let o=u.statements.map(l=>l.metadata?.confidence??.75),s=o.reduce((l,c)=>l+c,0)/o.length;return fr(u.statements,u.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 u=n.roles.get("condition");if(!u||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let o=new Map(a.roles);o.set("condition",u),o.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...a,roles:o,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,u=e[e.length-1];if(u&&e.length>=2){let f=(u.normalized??u.value).toLowerCase();this.isUnlessKeyword(f,t)&&(n="unless",a=e.slice(0,-1));}let o=null;if(n&&a.length>=3){let f=P(t),h=f?B.buildVerbLookup(f):null;if(h)for(let k=1;k<a.length-1;k++){let D=a[k],A=h.get(D.value.toLowerCase())??(D.normalized?h.get(D.normalized.toLowerCase()):void 0);if(A&&!B.CONDITION_OPERATORS.has(A)){o=a.slice(0,k),a=a.slice(k);break}}}let s=new te(a,t),l=[],c=this.coverageMark(),m=0,p=[],d=o,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 D=false;for(let A of this.parseSOVClauseByVerbAnchoring(f,t)){let z=A.action,g=A.roles;z&&Q(z)&&g instanceof Map&&g.size>0&&(l.push(A),D=true);}D||this.recordDroppedTokens(f,t,"body clause");};for(;!s.isAtEnd();){let f=s.peek(),h=!!f&&f.normalized?.toLowerCase()==="repeat",k=s.mark(),D=ne.matchBest(s,r);if(h&&D&&D.pattern.command!=="repeat"){s.reset(k),y(),l.push(ie("repeat",{},{sourceLanguage:t,confidence:.6})),m++,s.advance();continue}if(D&&D.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(D){y();let A=this.buildCommand(D,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(ie("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?[ie(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=Q(r.action);if(!n)return;let a=P(t);if(!a)return;let u=r.roles,o=(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=u.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(wu.has(f)&&E.kind==="selector"&&d(v)){u.set(l,{type:"expression",raw:`${f} ${E.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(o(y,c)&&d(E)){let v=this.tokenToSemanticValue(y);e.advance(),e.advance(),v&&u.set(l,v);return}if(c&&o(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&&u.set(l,h);return}}}else if(d(y)&&o(E,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&u.set(l,v);return}}}tryAttachTrailingStyle(e,r,t){if(r.action!=="fetch"&&r.action!=="render")return;let n=r.roles;if(!Q(r.action)?.roles.some(f=>f.role==="style"))return;let u=n.get("style");if(u){if(u.type==="expression"&&typeof u.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(u.raw)&&e.peek()?.value===":"){let f=je(e,u.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=je(e,h.raw);k&&(n.set("source",{type:"expression",raw:k}),this.tryAttachResponseTypeAfterStyle(e,r,t));return}}let s=P(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 D=je(e);if(!D){e.reset(k);return}n.set("style",{type:"expression",raw:D}),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&&B.RESPONSE_TYPE_WORDS.has(y[0].value.toLowerCase()))return;let E=new te(y,t),v=je(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")||!Q(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let u=c=>!!c&&B.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),o=e.peek();if(!o)return;let s=c=>{n.set("responseType",{type:"expression",raw:c});};if(B.AS_MARKERS_BEFORE[t]?.some(c=>o.value.toLowerCase()===c)){let c=e.peek(1);c&&u(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(u(o.value)){e.advance(),s(o.value);for(let c of B.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 u=r.roles,o=u.get(a.role);if(n==="go"&&o&&o.type==="expression"&&String(o.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"){u.set(a.role,k),u.set("method",{type:"literal",value:"url"}),e.advance();return}}let h=u.get("patient");if(h&&(h.type==="literal"||h.type==="selector")){u.set(a.role,h),u.set("method",{type:"literal",value:"url"}),u.delete("patient");return}}if(n==="go"&&o&&o.type==="expression"){let f=/^url\s+(\S+)$/i.exec(String(o.raw??""));if(f){let h=f[1].replace(/^["']|["']$/g,"");u.set(a.role,{type:"literal",value:h,dataType:"string"}),u.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!o){let f=u.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"){u.set(a.role,k),u.set("method",{type:"literal",value:"url"}),u.delete("patient"),e.advance();return}}}}if(o&&!(o.type==="reference"&&o.value==="me"))return;let s=P(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"){u.set(a.role,f),u.set("method",{type:"literal",value:"url"});let h=u.get("patient");h&&h.type==="reference"&&h.value==="me"&&!Q(n)?.roles.some(k=>k.role==="patient")&&u.delete("patient");for(let k=0;k<E;k++)e.advance();return}}let v=p;if(n==="js"){let f=s.keywords?.js,h=D=>[f?.primary,...f?.alternatives??[]].some(A=>!!A&&A.length>D.value.length&&A.includes(D.value)),k=0;for(;k<v.length&&h(v[k]);)k++;if(v=v.slice(k),v.length===0)return}if(u.set(a.role,{type:"expression",raw:this.joinTokenText(v,t)}),a.role!=="patient"){let f=u.get("patient");f&&f.type==="reference"&&f.value==="me"&&!Q(n)?.roles.some(h=>h.role==="patient")&&u.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 u of n.alternatives)r.has(u)||r.set(u,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=P(r);if(!t||t.wordOrder!=="SOV")return [];let n=B.buildVerbLookup(t),a=B.buildMarkerToRoleLookup(t),u=[],o=0;for(;o<e.length;){let s=-1,l="";for(let y=o;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(o,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(u.push(ie(l,d,{sourceLanguage:r,confidence:.7})),o=m,o<e.length){let y=e[o];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&o++;}}return u}extractRolesFromMarkedTokens(e,r,t,n,a){let u={},o=(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(o(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,u);E&&(u[E]=y);}c=[];}else c.push(p);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!u.duration&&Q(n)?.roles.some(p=>p.role==="duration"))u.duration={type:"literal",value:c[0].value,dataType:"string"};else {let p=this.tokensToSemanticValue(c,a);p&&(u.patient?u.destination||(u.destination=p):u.patient=p);}};return s(e),s(r),u}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(u=>u.kind!=="whitespace");if(t.length===0)return null;if(t.length>=2&&(t[0].kind==="selector"||/^[#.@*<]/.test(t[0].value))){let u=t.findIndex((o,s)=>s>0&&(o.normalized??o.value).toLowerCase()==="in");u>0&&(t=t.slice(0,u));}if(t.length===1)return this.tokenToSemanticValue(t[0]);let n=t.map(u=>u.value).join(""),a=t[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?Ee(n):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?W(Zr(n),"string"):a.kind==="reference"?ae(n):W(this.joinTokenText(t,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return Ee(r);if(r.startsWith('"')||r.startsWith("'"))return W(Zr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return W(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return W(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return W(false);if(r.length>1&&(r.startsWith(":")||r.startsWith("$")))return ae(r);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ae(t):e.kind==="reference"?ae(e.normalized||"me"):W(r)}parseBodyWithGrammarPatterns(e,r,t,n){let a=[],u=[],o=false,s=()=>{if(!o&&u.length>0){let m=this.parseSOVClauseByVerbAnchoring(u,n);a.push(...m),m.length===0&&this.recordDroppedTokens(u,n,"fused body walk");}else u.length>0&&this.recordDroppedTokens(u,n,"fused body walk");u=[],o=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(!_r(n,m.value,d?.value,y?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!o&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),n)){s();let d=this.tryParseConditionalBlock(e,r,n);if(d){a.push(d),o=true;continue}}let p=false;if(t.length>0){let d=ne.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=ie(y,E,{sourceLanguage:n,patternId:d.pattern.id});a.push(v),p=true,o=true;let f=d.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then")continue}}if(!p){let d=e.mark(),y=ne.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),o=true;continue}e.reset(v);}let E=this.buildCommand(y,n);a.push(E),this.tryAttachTrailingRole(e,E,n),p=true,o=true;}}p||(m&&u.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)),u=n.some(c=>this.isElseKeyword(c.value,t));if(!a&&!u)return null;let o=new te(n,t),s=this.coverageMark(),l=this.parseBodyWithClauses(o,r,t);return l.length===0?(this.coverageRollback(s),null):l[0]}matchEventMarkerPhrase(e,r,t){let n=B.SOV_EVENT_MARKER_PHRASES[t];if(!n)return 0;for(let a of n)if(a.every((u,o)=>e[r+o]?.value===u))return a.length;return 0}hasSOVEventMarkerHead(e,r){let t=B.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:n}=U(e,r),a=de[r],u=new Set;if(a)for(let o of Object.keys(a))u.add(o.toLowerCase());for(let o=0;o<n.length;o++){let s=n[o],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(B.KNOWN_EVENTS.has(c)||Be.has(c))||B.KNOWN_EVENTS.has(l)||Be.has(l)||u.has(l)))continue;let p=this.matchEventParamPhrase(n,o+1).len,d=n[o+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(n,o+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=U(e,r).tokens;if(n.length<3)return null;let a=de[r],u=new Set;if(a)for(let D of Object.keys(a))u.add(D.toLowerCase());let o=n.length-2,s=n[o];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&&B.KNOWN_EVENTS.has(p)||B.KNOWN_EVENTS.has(m)||u.has(m)))return null;let y=p&&B.KNOWN_EVENTS.has(p)?p:a?.[m]??m,E=n.slice(0,o);if(E.length===0)return null;let v=t.filter(D=>D.command!=="on"),f=new te(E,r),h=this.coverageMark(),k=this.parseBodyWithClauses(f,v,r);return k.length===0?(this.coverageRollback(h),null):Le({type:"literal",value:y},k,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let n=U(e,r).tokens;if(n.length<3)return null;let a=de[r],u=new Set;if(a)for(let o of Object.keys(a))u.add(o.toLowerCase());for(let o=0;o<n.length-1;o++){let s=n[o];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=n[o+1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&B.KNOWN_EVENTS.has(p)||B.KNOWN_EVENTS.has(m)||u.has(m)))continue;let y=p&&B.KNOWN_EVENTS.has(p)?p:a?.[m]??m,E=n.filter((D,A)=>A!==o&&A!==o+1);if(E.length===0)return null;let v=t.filter(D=>D.command!=="on"),f=new te(E,r),h=this.coverageMark(),k=this.parseBodyWithClauses(f,v,r);return k.length===0?(this.coverageRollback(h),null):Le({type:"literal",value:y},k,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let n=B.SOV_EVENT_MARKERS[r];if(!n)return null;let u=U(e,r).tokens,o=de[r],s=new Set;if(o)for(let z of Object.keys(o))s.add(z.toLowerCase());let l=B.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1,y=[];for(let z=0;z<u.length;z++){let g=u[z],C=g.value.toLowerCase(),b=C,w="",S=C.indexOf("[");S>0&&(b=C.slice(0,S),w=g.value.slice(S));let x=g.normalized?.toLowerCase(),R=x&&(B.KNOWN_EVENTS.has(x)||Be.has(x)),F=s.has(C)||s.has(b),O=B.KNOWN_EVENTS.has(b)||Be.has(b);if(R||F||O){let N=u[z-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let _;R?_=x:F?_=o?.[C]??o?.[b]??b:_=b;let H=this.matchEventParamPhrase(u,z+1);if(n.size>0){let G=1+H.len,pe=u[z+G];pe&&pe.kind==="selector"&&pe.value.startsWith("[")&&(G+=1);let ue=u[z+G];if(ue&&(ue.kind==="particle"||ue.kind==="keyword")&&n.has(ue.value)){c=z,m=_,p=w||(G===H.len+2?u[z+G-1].value:""),d=G+1,y=H.names;break}}else {c=z,m=_,p=w,d=1+H.len+this.matchEventMarkerPhrase(u,z+1+H.len,r),y=H.names;break}}}if(c===-1){let z=new Set(t.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<u.length;g++){let C=u[g];if(C.kind==="identifier")if(n.size>0){let b=1,w=u[g+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(b=2);let S=u[g+b];if(S&&(S.kind==="particle"||S.kind==="keyword")&&n.has(S.value)){c=g,m=C.value,p=b===2?u[g+1].value:"",d=b+1;break}}else {let b=this.matchEventMarkerPhrase(u,g+1,r);if(b>0){c=g,m=C.value,p="",d=1+b;break}let w=u[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<u.length){let g=u[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=u[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=u[c-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(u[c-2],l.windowTokens)&&(E.add(c-2),E.add(c-1));}for(let g=0;g<c;g++){let C=u[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=u.filter((z,g)=>!E.has(g));if(v.length===0)return null;let f=t.filter(z=>z.command!=="on"),h=new te(v,r),k=this.coverageMark(),D=this.parseBodyWithClauses(h,f,r);if(D.length===0)return this.coverageRollback(k),null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Le({type:"literal",value:m},D,void 0,A,y)}profileKeywordMatches(e,r,t){let n=P(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=P(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=Ma(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 u=e.peek();u&&t.position?.end!==void 0&&t.position.end===u.position?.start&&this.profileKeywordMatches(r,"js",`${t.value}${u.value}`.toLowerCase())&&e.advance();let o=false;for(;!e.isAtEnd();){let l=e.peek();if(!l)break;if(e.advance(),this.isEndKeyword(l.value,r)){o=true;break}a.push(l);}if(!o)return e.reset(n),null;let s=a.map(l=>l.value).join(" ").trim();return ie("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 u=e.mark(),o=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(u),this.coverageRollback(o),null;let c=P(t),m=c?.wordOrder==="SOV"?B.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(),S=(g.normalized??g.value).toLowerCase(),x=B.CONDITION_COPULAS.has(b)||B.CONDITION_COPULAS_SURFACE.has(w)&&B.CONDITION_PREDICATES.has(S),R=m!==null&&m.has(g.value.toLowerCase())&&!B.CONDITION_PREDICATES.has(S),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(!B.CONDITION_OPERATORS.has(S)&&!F&&(!x||R)&&(this.tokensBeginCommand(s.slice(p),r,t)||this.sovCommandStartsAt(s.slice(p),m)))break}y.push(g);}if(y.length===0)return e.reset(u),this.coverageRollback(o),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 D={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(u),this.coverageRollback(o),null):en(D,A,z,{sourceLanguage:t,patternId:`conditional-${t}-folded`,confidence:1})}joinTokenText(e,r){return yr(e,P(r))}tokensBeginCommand(e,r,t){if(e.length===0)return false;let n=new te(e,t);return ne.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=o=>r.has(o.value.toLowerCase())||!!o.normalized&&r.has(o.normalized.toLowerCase()),n=o=>o.kind==="identifier"||o.kind==="selector"||o.kind==="literal"||o.kind==="reference",a=0,u=0;for(;a+1<e.length;){let o=e[a],s=e[a+1];if(!n(o)||s.kind!=="particle")break;u+=1,a+=2;let l=e[a];if(u>=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=U(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let u=n[0].value.toLowerCase(),o=B.STANDALONE_MODIFIERS[u];if(!o)return {modifiers:null,remainingInput:null};let s={},l=1;if(o==="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[o]=v,l=d+1;}}}s[o]||(s[o]=o==="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=P(r)?.keywords?.async,n=new Set(["async"]);t?.primary&&n.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=U(e,r).tokens,u=a.findIndex(l=>n.has(l.value.toLowerCase()));if(u===-1)return {remainingInput:null};let o=a[u],s=(e.slice(0,o.position.start)+e.slice(o.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=U(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 u=t[n].position.start,o=t[a].position.end,s=(e.slice(0,u)+e.slice(o)).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=B.droppedTokenCount,a=B.unconsumedSpans(e);if(a.length===0)return null;let u=n(e),o=P(t)?.roleMarkers?.source,s=new Set;o?.primary&&s.add(o.primary),o?.alternatives?.forEach(c=>s.add(c));let l=U(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=o?.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)<u)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=B.unconsumedSpans(e);if(n.length===0)return null;let a=de[t];if(!a)return null;let u=e.roles,o=u.get("event"),s=o?.type==="literal"&&typeof o.value=="string"?o.value:null;if(!s)return null;let l=m=>m.replace(/\s+/g," ").trim(),c=U(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 u.set("event",{type:"literal",value:h,dataType:"string"}),{node:B.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,t){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=B.AS_MARKERS_BEFORE[t];if(!a)return null;let u=l=>l.replace(/\s+/g," ").trim(),o=B.droppedTokenCount(e),s=U(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)||!B.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let p=u(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(B.droppedTokenCount(E)>=o)continue;let v=B.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 u=n;if(Q(u.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!u.roles.has("responseType")){r=u;return}}let a=n;for(let u of ["body","statements","thenBranch","elseBranch","commands"]){let o=a[u];Array.isArray(o)&&o.forEach(s=>t(s));}};return t(e),r}reclaimCapturedDestinationTail(e,r,t){let n=B.unconsumedSpans(e);if(n.length===0)return null;let a=P(t)?.roleMarkers?.destination,u=new Set;if(a?.primary&&u.add(a.primary),a?.alternatives?.forEach(l=>u.add(l)),u.size===0)return null;let o=l=>l.replace(/\s+/g," ").trim(),s=U(r,t).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1],p=u.has(c.value)&&m.normalized==="me",d=c.normalized==="me"&&u.has(m.value);if(!p&&!d)continue;let y=o(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 D=h[k];Array.isArray(D)&&D.forEach(A=>v(A));}};if(v(e),!!E)return {node:B.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 u=(a.normalized||a.value).toLowerCase();if(!B.OR_KEYWORDS.has(u)){e.reset(n);break}e.advance();let o=e.peek();if(!o){e.reset(n);break}let s=(o.normalized||o.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};Z.coverageMarkerSurfaces=new Map;Z.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Z.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"]};Z.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Z.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Z.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Z.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"])};Z.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Z.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"])}};Z.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Z.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Z.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Z.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Z.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};Z.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 Du=Z,Su=new Du;function xu(i,e){return Su.parse(i,e)}function Bu(i,e){try{let r=U(i,e),t=ce(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"),u=ne.matchBest(r,a);if(u)return {confidence:u.confidence,parseSuccess:!0,patternId:u.pattern.id,action:u.pattern.command,tokensConsumed:u.consumedTokens};r.reset(r.mark());let o=n.filter(l=>l.command!=="on"),s=ne.matchBest(r,o);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 xt(i,e){try{let t=xu(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:U(i,e).tokens.length}}catch{}let r=Bu(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Bt(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,n)=>{let a=t[r]??99,u=n[r]??99;return a-u})}function Tu(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 Qe(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 u of n)u!==r&&!a.includes(u)&&a.push(u);t=a;}return {marker:r,alternatives:t}}function We(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 Fu(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 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 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 s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),a.push(...we(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} ${o?.primary||""} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function Ru(i,e,r,t,n){let a=[];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);}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=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o),a.push(...we(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} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function Ou(i,e,r,t,n){let a=[];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 o=e.roleMarkers.destination;if(o&&(a.push({type:"role",role:"destination",optional:false}),a.push(o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.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} ${u?.primary||""} {destination} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Pu(i,e,r,t,n){let a=[];a.push({type:"role",role:"event",optional:false});let u=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];u.length>0&&a.push({type:"literal",value:u[0],alternatives:u.slice(1)});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 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(...we(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}${u[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function Nu(i,e,r,t,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),t.position==="after"){let o=t.primary.split(/\s+/);if(o.length>1)for(let s of o)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 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-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 _u(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 u=e.roleMarkers.patient;if(u?.primary){let s=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.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-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 Mu(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 o=[...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 o){a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:d}=Qe(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=o.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(o.map(m=>[m.role,{fromRole:m.role}]))};return We(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 Lu(i,e,r,t,n){let a=[],o=[...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 o){a.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:p}=Qe(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=o.map(c=>`{${c.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(o.map(c=>[c.role,{fromRole:c.role}]))};return We(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 Iu(i,e,r,t,n){let a=[],o=[...i.roles.filter(v=>v.required)].sort((v,f)=>{let h=v.sovPosition??999,k=f.sovPosition??999;return h-k}),s=o[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=Qe(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=o[1];a.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:y}=Qe(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 We(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 Xr(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 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 o=e.roleMarkers.destination;return o&&a.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}]}),a.push(...we(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} ${o?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function ju(i,e,r,t,n){let a=[],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 o=e.roleMarkers.destination;if(o&&a.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}]}),a.push(...we(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} ${o?.primary||""} {destination?} ${t.primary} {event}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function $u(i,e,r,t,n){let a=[],u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u);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 We(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 Jr(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 u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u);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 We(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 Vu(i,e,r,t,n){let a=[],u=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(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};a.push(l);}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 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(...we(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} ${u?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}function qu(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 u=e.roleMarkers.destination;return u&&n.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}]}),n.push(...we(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} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ke(i),...be(i)}}}var Oe={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Xe(i,e,r=Oe){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 u=Hu(i,e,a),o=br(i,e),s=Ju(i,e,a);return {id:t,language:e.code,command:i.action,priority:n,template:{format:s,tokens:u},extraction:o}}function Wu(i,e,r=Oe){if(i.roles.filter(o=>!o.required).length===0)return null;let n=i.roles.filter(o=>o.required),a={...i,roles:n};return {...Xe(a,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:br(i,e)}}function Qr(i,e,r=Oe){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(o=>o.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},u=t.flatMap(o=>{let s=o.valuePrefixLiteral?.[e.code],l={type:"role",role:o.role,optional:false,expectedTypes:o.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,...u]},extraction:br(i,e)}}function Ku(i,e,r=Oe){let t=[];if(t.push(Xe(i,e,r)),r.generateSimpleVariants){let n=Wu(i,e,r);n&&t.push(n);}for(let n of i.omitRoleVariants??[]){let a={...i,roles:i.roles.filter(o=>o.role!==n)},u=Xe(a,e,r);t.push({...u,id:`${i.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let n=Qr(i,e,r);n&&t.push(n);}for(let n of i.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:u,...o}=i,s={...o,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=Xe(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=Qr(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 Tt(i,e=Oe){let r=[],t=ga();for(let n of t){if(!i.keywords[n.action])continue;let a=Ku(n,i,e);if(r.push(...a),i.eventHandler?.eventMarker){let u=Uu(n,i,e);r.push(...u);}}return r}function Uu(i,e,r=Oe){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 o=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(o)t.push(Mu(i,e,a,n,r)),t.push(Iu(i,e,a,n,r)),t.push(Lu(i,e,a,n,r));else {t.push(Fu(i,e,a,n,r)),t.push(Ru(i,e,a,n,r));let s=e.roleMarkers.destination;s&&s.primary!==n.primary&&t.push(Ou(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(Pu(i,e,a,n,r)),t.push(Nu(i,e,a,n,r));let m=_u(i,e,a,r);m&&t.push(m);}else e.wordOrder==="VSO"?o?(t.push(Jr(i,e,a,n,r)),t.push($u(i,e,a,n,r))):(t.push(Xr(i,e,a,n,r)),t.push(ju(i,e,a,n,r)),e.eventHandler?.negationMarker&&t.push(Vu(i,e,a,n,r)),e.tokenization?.prefixes&&t.push(qu(i,e,a,r))):o?t.push(Jr(i,e,a,n,r)):t.push(Xr(i,e,a,n,r));return t}function Hu(i,e,r){let t=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=Yu(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 Gu(t)}function Gu(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 Yu(i,e){let r=[],t=Bt(i.roles,e.wordOrder);for(let n of t){let a=Zu(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Zu(i,e){let r=[],t=i.markerOverride?.[e.code],n=e.roleMarkers[i.role],a=i.renderOverride?.[e.code]==="",u={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes},o=i.valuePrefixLiteral?.[e.code],s=()=>{o&&r.push({type:"literal",value:o}),r.push(u);};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 Xu(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 u=t.markerVariants?.[e.code]??[],o=[...new Set([...a.alternatives??[],...u])].filter(s=>s!==a.primary);r[t.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[t.role]={};}return r}function br(i,e){let r=Xu(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 Ju(i,e,r){let t=[],a=Bt(i.roles,e.wordOrder).map(u=>{let o=Tu(u,e),s="";return o&&o.primary?o.position==="before"?s=`${o.primary} {${u.role}}`:s=`{${u.role}} ${o.primary}`:s=`{${u.role}}`,u.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 Qu=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 Qu;function eo(i){return /[а-яА-ЯіІїЇєЄґҐьЬ']/.test(i)}var Ft=new Map([["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438","\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438"],["\u0434\u043E\u0434\u0430\u0439","\u0434\u043E\u0434\u0430\u0442\u0438"],["\u0432\u0438\u0434\u0430\u043B\u0438","\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438"],["\u043F\u0440\u0438\u0431\u0435\u0440\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438"],["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438"],["\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438"],["\u0432\u0441\u0442\u0430\u0432","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438"],["\u0432\u0456\u0437\u044C\u043C\u0438","\u0432\u0437\u044F\u0442\u0438"],["\u0441\u0442\u0432\u043E\u0440\u0438","\u0441\u0442\u0432\u043E\u0440\u0438\u0442\u0438"],["\u043A\u043B\u043E\u043D\u0443\u0439","\u043A\u043B\u043E\u043D\u0443\u0432\u0430\u0442\u0438"],["\u043F\u043E\u043C\u0456\u043D\u044F\u0439","\u043F\u043E\u043C\u0456\u043D\u044F\u0442\u0438"],["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0439","\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438"],["\u0437\u0430\u0434\u0430\u0439","\u0437\u0430\u0434\u0430\u0442\u0438"],["\u043E\u0442\u0440\u0438\u043C\u0430\u0439","\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438"],["\u0437\u0431\u0456\u043B\u044C\u0448","\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438"],["\u0437\u043C\u0435\u043D\u0448","\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438"],["\u0437\u0430\u043F\u0438\u0448\u0438","\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u0438"],["\u043F\u043E\u043A\u0430\u0436\u0438","\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438"],["\u0441\u0445\u043E\u0432\u0430\u0439","\u0441\u0445\u043E\u0432\u0430\u0442\u0438"],["\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438"],["\u0430\u043D\u0456\u043C\u0443\u0439","\u0430\u043D\u0456\u043C\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0438\u043A\u043B\u0438\u0447","\u0432\u0438\u043A\u043B\u0438\u043A\u0430\u0442\u0438"],["\u043D\u0430\u0434\u0456\u0448\u043B\u0438","\u043D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438"],["\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438"],["\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438"],["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u043F\u0435\u0440\u0435\u0439\u0442\u0438"],["\u0439\u0434\u0438","\u0439\u0442\u0438"],["\u0447\u0435\u043A\u0430\u0439","\u0447\u0435\u043A\u0430\u0442\u0438"],["\u0437\u0430\u0447\u0435\u043A\u0430\u0439","\u0437\u0430\u0447\u0435\u043A\u0430\u0442\u0438"],["\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436","\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438"],["\u043F\u043E\u0432\u0442\u043E\u0440\u0438","\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0438"],["\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0443\u0439","\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438"],["\u043A\u0438\u043D\u044C","\u043A\u0438\u043D\u0443\u0442\u0438"],["\u043F\u043E\u0432\u0435\u0440\u043D\u0438","\u043F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u0438"],["\u0441\u043A\u0430\u0436\u0438","\u0441\u043A\u0430\u0437\u0430\u0442\u0438"],["\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0439","\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438"],["\u0432\u0438\u043C\u0456\u0440\u044F\u0439","\u0432\u0438\u043C\u0456\u0440\u044F\u0442\u0438"]]),Ot=class{constructor(){this.language="uk";}isNormalizable(i){return i.length<3?false:eo(i)}normalize(i){let e=i.toLowerCase();if(e.endsWith("\u0441\u044F")||e.endsWith("\u0441\u044C")){let u=this.tryReflexiveNormalization(e);if(u)return u}if(e.endsWith("\u0442\u0438")||e.endsWith("\u0447\u0438"))return Se(i);let r=this.tryImperativeLookup(e);if(r)return r;let t=this.tryPastTenseNormalization(e);if(t)return t;let n=this.tryPresentTenseNormalization(e);if(n)return n;let a=this.tryGenericImperativeNormalization(e);return a||Se(i)}tryReflexiveNormalization(i){let e=i.slice(0,-2);if(i.endsWith("\u0442\u0438\u0441\u044F")||i.endsWith("\u0447\u0438\u0441\u044F"))return Se(i);let r=this.normalizeNonReflexive(e);if(r.confidence<1){let t=r.stem.endsWith("\u0442\u0438")?r.stem.slice(0,-2)+"\u0442\u0438\u0441\u044F":r.stem+"\u0441\u044F";return L(t,r.confidence*.95,{removedSuffixes:["\u0441\u044F",...r.metadata?.removedSuffixes||[]],conjugationType:"reflexive"})}return null}normalizeNonReflexive(i){if(i.endsWith("\u0442\u0438")||i.endsWith("\u0447\u0438"))return Se(i);let e=this.tryImperativeLookup(i);if(e)return e;let r=this.tryPastTenseNormalization(i);if(r)return r;let t=this.tryPresentTenseNormalization(i);if(t)return t;let n=this.tryGenericImperativeNormalization(i);return n||Se(i)}tryImperativeLookup(i){return Ft.has(i)?L(Ft.get(i),.95,{removedSuffixes:["imperative"],conjugationType:"imperative"}):null}tryGenericImperativeNormalization(i){return i.endsWith("\u0439\u0442\u0435")&&i.length>5?L(i.slice(0,-3)+"\u0442\u0438",.8,{removedSuffixes:["\u0439\u0442\u0435"],conjugationType:"imperative"}):i.endsWith("\u0456\u0442\u044C")&&i.length>5?L(i.slice(0,-3)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0456\u0442\u044C"],conjugationType:"imperative"}):i.endsWith("\u0439")&&i.length>3?L(i.slice(0,-1)+"\u0442\u0438",.75,{removedSuffixes:["\u0439"],conjugationType:"imperative"}):i.endsWith("\u0438")&&i.length>3?L(i+"\u0442\u0438",.7,{removedSuffixes:["\u0438\u2192\u0438\u0442\u0438"],conjugationType:"imperative"}):null}tryPastTenseNormalization(i){return i.endsWith("\u0430\u043B\u0430")&&i.length>4?L(i.slice(0,-3)+"\u0430\u0442\u0438",.85,{removedSuffixes:["\u0430\u043B\u0430"],conjugationType:"past"}):i.endsWith("\u0438\u043B\u0430")&&i.length>4?L(i.slice(0,-3)+"\u0438\u0442\u0438",.85,{removedSuffixes:["\u0438\u043B\u0430"],conjugationType:"past"}):i.endsWith("\u0430\u043B\u0438")&&i.length>4?L(i.slice(0,-3)+"\u0430\u0442\u0438",.85,{removedSuffixes:["\u0430\u043B\u0438"],conjugationType:"past"}):i.endsWith("\u0438\u043B\u0438")&&i.length>4?L(i.slice(0,-3)+"\u0438\u0442\u0438",.85,{removedSuffixes:["\u0438\u043B\u0438"],conjugationType:"past"}):i.endsWith("\u0430\u0432")&&i.length>3?L(i.slice(0,-2)+"\u0430\u0442\u0438",.82,{removedSuffixes:["\u0430\u0432"],conjugationType:"past"}):i.endsWith("\u0438\u0432")&&i.length>3?L(i.slice(0,-2)+"\u0438\u0442\u0438",.82,{removedSuffixes:["\u0438\u0432"],conjugationType:"past"}):null}tryPresentTenseNormalization(i){return i.endsWith("\u0438\u0448")&&i.length>3?L(i.slice(0,-2)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0438\u0448"],conjugationType:"present"}):i.endsWith("\u0438\u0442\u044C")&&i.length>4?L(i.slice(0,-3)+"\u0438\u0442\u0438",.78,{removedSuffixes:["\u0438\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0438\u043C\u043E")&&i.length>4?L(i.slice(0,-3)+"\u0438\u0442\u0438",.8,{removedSuffixes:["\u0438\u043C\u043E"],conjugationType:"present"}):i.endsWith("\u044F\u0442\u044C")&&i.length>4?L(i.slice(0,-3)+"\u0438\u0442\u0438",.78,{removedSuffixes:["\u044F\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0454\u0448")&&i.length>3?L(i.slice(0,-2)+"\u0430\u0442\u0438",.78,{removedSuffixes:["\u0454\u0448"],conjugationType:"present"}):i.endsWith("\u0435\u0448")&&i.length>3?L(i.slice(0,-2)+"\u0430\u0442\u0438",.75,{removedSuffixes:["\u0435\u0448"],conjugationType:"present"}):i.endsWith("\u0454")&&i.length>2?L(i.slice(0,-1)+"\u0430\u0442\u0438",.72,{removedSuffixes:["\u0454"],conjugationType:"present"}):i.endsWith("\u0454\u043C\u043E")&&i.length>4?L(i.slice(0,-3)+"\u0430\u0442\u0438",.8,{removedSuffixes:["\u0454\u043C\u043E"],conjugationType:"present"}):i.endsWith("\u044E\u0442\u044C")&&i.length>4?L(i.slice(0,-3)+"\u0430\u0442\u0438",.78,{removedSuffixes:["\u044E\u0442\u044C"],conjugationType:"present"}):i.endsWith("\u0443\u0442\u044C")&&i.length>4?L(i.slice(0,-3)+"\u0430\u0442\u0438",.75,{removedSuffixes:["\u0443\u0442\u044C"],conjugationType:"present"}):null}},Pt={code:"uk",name:"Ukrainian",nativeName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",direction:"ltr",script:"cyrillic",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"infinitive",verb:{position:"start",subjectDrop:true,suffixes:["\u0442\u0438","\u0442\u0438\u0441\u044F","\u0438\u0442\u0438","\u0438\u0442\u0438\u0441\u044F","\u0430\u0442\u0438","\u0430\u0442\u0438\u0441\u044F","\u0456\u0442\u0438","\u0456\u0442\u0438\u0441\u044F"]},references:{me:"\u044F",it:"\u0446\u0435",you:"\u0442\u0438",result:"\u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442",event:"\u043F\u043E\u0434\u0456\u044F",target:"\u0446\u0456\u043B\u044C",body:"\u0442\u0456\u043B\u043E",document:"\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442",window:"\u0432\u0456\u043A\u043D\u043E",detail:"\u0434\u0435\u0442\u0430\u043B\u0456"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u043C\u0456\u0439",it:"\u0439\u043E\u0433\u043E",you:"\u0442\u0432\u0456\u0439"},keywords:{\u043C\u0456\u0439:"me",\u043C\u043E\u044F:"me",\u043C\u043E\u0454:"me",\u043C\u043E\u0457:"me",\u0442\u0432\u0456\u0439:"you",\u0442\u0432\u043E\u044F:"you",\u0442\u0432\u043E\u0454:"you",\u0442\u0432\u043E\u0457:"you",\u0439\u043E\u0433\u043E:"it",\u0457\u0457:"it"}},roleMarkers:{destination:{primary:"\u0432",alternatives:["\u043D\u0430","\u0434\u043E"],position:"before"},source:{primary:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0437",alternatives:["\u0456\u0437"],position:"before"}},keywords:{toggle:{primary:"\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0443\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u043C\u043A\u043D\u0438"],normalized:"toggle",form:"infinitive"},add:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438",alternatives:["\u0434\u043E\u0434\u0430\u0439"],normalized:"add",form:"infinitive"},remove:{primary:"\u0432\u0438\u0434\u0430\u043B\u0438\u0442\u0438",alternatives:["\u0432\u0438\u0434\u0430\u043B\u0438","\u043F\u0440\u0438\u0431\u0440\u0430\u0442\u0438","\u043F\u0440\u0438\u0431\u0435\u0440\u0438"],normalized:"remove",form:"infinitive"},put:{primary:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",alternatives:["\u043F\u043E\u043A\u043B\u0430\u0434\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438\u0442\u0438","\u043F\u043E\u043C\u0456\u0441\u0442\u0438","\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0438","\u0432\u0441\u0442\u0430\u0432"],normalized:"put",form:"infinitive"},append:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438_\u0432_\u043A\u0456\u043D\u0435\u0446\u044C",alternatives:["\u0434\u043E\u043F\u0438\u0441\u0430\u0442\u0438"],normalized:"append",form:"infinitive"},prepend:{primary:"\u0434\u043E\u0434\u0430\u0442\u0438_\u043D\u0430_\u043F\u043E\u0447\u0430\u0442\u043E\u043A",normalized:"prepend",form:"infinitive"},take:{primary:"\u0432\u0437\u044F\u0442\u0438",alternatives:["\u0432\u0456\u0437\u044C\u043C\u0438"],normalized:"take",form:"infinitive"},make:{primary:"\u0441\u0442\u0432\u043E\u0440\u0438\u0442\u0438",alternatives:["\u0441\u0442\u0432\u043E\u0440\u0438"],normalized:"make",form:"infinitive"},clone:{primary:"\u043A\u043B\u043E\u043D\u0443\u0432\u0430\u0442\u0438",alternatives:["\u043A\u043B\u043E\u043D\u0443\u0439"],normalized:"clone",form:"infinitive"},swap:{primary:"\u043F\u043E\u043C\u0456\u043D\u044F\u0442\u0438",alternatives:["\u043F\u043E\u043C\u0456\u043D\u044F\u0439"],normalized:"swap",form:"infinitive"},morph:{primary:"\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0443\u0439"],normalized:"morph",form:"infinitive"},set:{primary:"\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0438",alternatives:["\u0432\u0441\u0442\u0430\u043D\u043E\u0432\u0438","\u0437\u0430\u0434\u0430\u0442\u0438","\u0437\u0430\u0434\u0430\u0439"],normalized:"set",form:"infinitive"},get:{primary:"\u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438",alternatives:["\u043E\u0442\u0440\u0438\u043C\u0430\u0439"],normalized:"get",form:"infinitive"},increment:{primary:"\u0437\u0431\u0456\u043B\u044C\u0448\u0438\u0442\u0438",alternatives:["\u0437\u0431\u0456\u043B\u044C\u0448"],normalized:"increment",form:"infinitive"},decrement:{primary:"\u0437\u043C\u0435\u043D\u0448\u0438\u0442\u0438",alternatives:["\u0437\u043C\u0435\u043D\u0448"],normalized:"decrement",form:"infinitive"},log:{primary:"\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u0438",alternatives:["\u0437\u0430\u043F\u0438\u0448\u0438"],normalized:"log",form:"infinitive"},show:{primary:"\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u043F\u043E\u043A\u0430\u0436\u0438"],normalized:"show",form:"infinitive"},hide:{primary:"\u0441\u0445\u043E\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0445\u043E\u0432\u0430\u0439","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0442\u0438","\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u0439"],normalized:"hide",form:"infinitive"},transition:{primary:"\u0430\u043D\u0456\u043C\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0430\u043D\u0456\u043C\u0443\u0439"],normalized:"transition",form:"infinitive"},on:{primary:"\u043F\u0440\u0438",normalized:"on"},trigger:{primary:"\u0456\u043D\u0456\u0446\u0456\u044E\u0432\u0430\u0442\u0438",alternatives:["\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0438","\u0437\u0430\u043F\u0443\u0441\u0442\u0438"],normalized:"trigger",form:"infinitive"},send:{primary:"\u043D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438",alternatives:["\u043D\u0430\u0434\u0456\u0448\u043B\u0438"],normalized:"send",form:"infinitive"},focus:{primary:"\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0441\u0444\u043E\u043A\u0443\u0441\u0443\u0439","\u0444\u043E\u043A\u0443\u0441"],normalized:"focus",form:"infinitive"},blur:{primary:"\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0440\u043E\u0437\u0444\u043E\u043A\u0443\u0441\u0443\u0439"],normalized:"blur",form:"infinitive"},empty:{primary:"\u0441\u043F\u043E\u0440\u043E\u0436\u043D\u0438\u0442\u0438",alternatives:["\u043F\u043E\u0440\u043E\u0436\u043D\u0456\u0439"],normalized:"empty"},open:{primary:"\u0432\u0456\u0434\u043A\u0440\u0438\u0442\u0438",normalized:"open"},close:{primary:"\u0437\u0430\u043A\u0440\u0438\u0442\u0438",normalized:"close"},select:{primary:"\u0432\u0438\u0434\u0456\u043B\u0438\u0442\u0438",normalized:"select"},clear:{primary:"\u043E\u0447\u0438\u0441\u0442\u0438\u0442\u0438",normalized:"clear"},reset:{primary:"\u0441\u043A\u0438\u043D\u0443\u0442\u0438",normalized:"reset"},breakpoint:{primary:"\u0442\u043E\u0447\u043A\u0430-\u0437\u0443\u043F\u0438\u043D\u043A\u0438",normalized:"breakpoint"},click:{primary:"\u043A\u043B\u0456\u043A\u0443",alternatives:["\u043A\u043B\u0456\u043A","\u043D\u0430\u0442\u0438\u0441\u043A\u0430\u043D\u043D\u0456"],normalized:"click"},hover:{primary:"\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u043D\u0456",alternatives:["\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u043D\u044F"],normalized:"hover"},submit:{primary:"\u0432\u0456\u0434\u043F\u0440\u0430\u0432\u0446\u0456",alternatives:["\u0432\u0456\u0434\u043F\u0440\u0430\u0432\u043A\u0430","\u043D\u0430\u0434\u0441\u0438\u043B\u0430\u043D\u043D\u044F"],normalized:"submit"},input:{primary:"\u0432\u0432\u0435\u0434\u0435\u043D\u043D\u0456",alternatives:["\u0432\u0432\u0435\u0434\u0435\u043D\u043D\u044F"],normalized:"input"},change:{primary:"\u0437\u043C\u0456\u043D\u0456",alternatives:["\u0437\u043C\u0456\u043D\u0430"],normalized:"change"},load:{primary:"\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0435\u043D\u043D\u044F",normalized:"load"},go:{primary:"\u043F\u0435\u0440\u0435\u0439\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0439\u0434\u0438","\u0439\u0442\u0438","\u0439\u0434\u0438"],normalized:"go",form:"infinitive"},scroll:{primary:"\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u0438\u0442\u0438",alternatives:["\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u0438"],normalized:"scroll",form:"infinitive"},push:{primary:"\u0448\u0442\u043E\u0432\u0445\u043D\u0443\u0442\u0438",alternatives:["\u0437\u0430\u0448\u0442\u043E\u0432\u0445\u043D\u0443\u0442\u0438"],normalized:"push",form:"infinitive"},replace:{primary:"\u0437\u0430\u043C\u0456\u043D\u0438\u0442\u0438",alternatives:["\u0437\u0430\u043C\u0456\u043D\u0438"],normalized:"replace",form:"infinitive"},process:{primary:"\u043E\u0431\u0440\u043E\u0431\u0438\u0442\u0438",alternatives:["\u043E\u0431\u0440\u043E\u0431\u043B\u044F\u0442\u0438"],normalized:"process",form:"infinitive"},wait:{primary:"\u0447\u0435\u043A\u0430\u0442\u0438",alternatives:["\u0447\u0435\u043A\u0430\u0439","\u0437\u0430\u0447\u0435\u043A\u0430\u0439"],normalized:"wait",form:"infinitive"},fetch:{primary:"\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438",alternatives:["\u0437\u0430\u0432\u0430\u043D\u0442\u0430\u0436"],normalized:"fetch",form:"infinitive"},settle:{primary:"\u0441\u0442\u0430\u0431\u0456\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438",normalized:"settle",form:"infinitive"},if:{primary:"\u044F\u043A\u0449\u043E",normalized:"if"},unless:{primary:"\u043A\u0440\u0456\u043C",normalized:"unless"},when:{primary:"\u043A\u043E\u043B\u0438",normalized:"when"},where:{primary:"\u0434\u0435",normalized:"where"},else:{primary:"\u0456\u043D\u0430\u043A\u0448\u0435",normalized:"else"},repeat:{primary:"\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0438",alternatives:["\u043F\u043E\u0432\u0442\u043E\u0440\u0438"],normalized:"repeat",form:"infinitive"},for:{primary:"\u0434\u043B\u044F",alternatives:["\u043A\u043E\u0436\u043D\u0438\u0439"],normalized:"for"},while:{primary:"\u043F\u043E\u043A\u0438",normalized:"while"},forever:{primary:"\u0437\u0430\u0432\u0436\u0434\u0438",normalized:"forever",alternatives:["forever"]},continue:{primary:"\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438",alternatives:["\u043F\u0440\u043E\u0434\u043E\u0432\u0436\u0443\u0439"],normalized:"continue",form:"infinitive"},halt:{primary:"\u0437\u0443\u043F\u0438\u043D\u0438\u0442\u0438",alternatives:["\u0437\u0443\u043F\u0438\u043D\u0438\u0441\u044C","\u0441\u0442\u043E\u043F"],normalized:"halt",form:"infinitive"},throw:{primary:"\u043A\u0438\u043D\u0443\u0442\u0438",alternatives:["\u043A\u0438\u043D\u044C"],normalized:"throw",form:"infinitive"},call:{primary:"\u0432\u0438\u043A\u043B\u0438\u043A\u0430\u0442\u0438",alternatives:["\u0432\u0438\u043A\u043B\u0438\u0447"],normalized:"call",form:"infinitive"},return:{primary:"\u043F\u043E\u0432\u0435\u0440\u043D\u0443\u0442\u0438",alternatives:["\u043F\u043E\u0432\u0435\u0440\u043D\u0438"],normalized:"return",form:"infinitive"},then:{primary:"\u043F\u043E\u0442\u0456\u043C",alternatives:["\u0434\u0430\u043B\u0456","\u0442\u043E\u0434\u0456"],normalized:"then"},and:{primary:"\u0456",alternatives:["\u0442\u0430"],normalized:"and"},matches:{primary:"\u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0454",normalized:"matches"},exists:{primary:"\u0456\u0441\u043D\u0443\u0454",normalized:"exists"},is:{primary:"\u0454",normalized:"is"},no:{primary:"\u043D\u0456",normalized:"no"},end:{primary:"\u043A\u0456\u043D\u0435\u0446\u044C",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"\u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u043E",alternatives:["async"],normalized:"async"},tell:{primary:"\u0441\u043A\u0430\u0437\u0430\u0442\u0438",alternatives:["\u0441\u043A\u0430\u0436\u0438"],normalized:"tell",form:"infinitive"},default:{primary:"\u0437\u0430_\u0437\u0430\u043C\u043E\u0432\u0447\u0443\u0432\u0430\u043D\u043D\u044F\u043C",normalized:"default"},init:{primary:"\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438",alternatives:["\u0456\u043D\u0456\u0446\u0456\u0430\u043B\u0456\u0437\u0443\u0439"],normalized:"init",form:"infinitive"},behavior:{primary:"\u043F\u043E\u0432\u0435\u0434\u0456\u043D\u043A\u0430",normalized:"behavior"},install:{primary:"\u0456\u043D\u0441\u0442\u0430\u043B\u044E\u0432\u0430\u0442\u0438",normalized:"install",form:"infinitive"},measure:{primary:"\u0432\u0438\u043C\u0456\u0440\u044F\u0442\u0438",alternatives:["\u0432\u0438\u043C\u0456\u0440\u044F\u0439"],normalized:"measure",form:"infinitive"},beep:{primary:"\u0437\u0432\u0443\u043A",normalized:"beep"},break:{primary:"\u043F\u0435\u0440\u0435\u0440\u0432\u0430\u0442\u0438",normalized:"break"},copy:{primary:"\u043A\u043E\u043F\u0456\u044E\u0432\u0430\u0442\u0438",normalized:"copy"},exit:{primary:"\u0432\u0438\u0439\u0442\u0438",normalized:"exit"},pick:{primary:"\u0432\u0438\u0431\u0440\u0430\u0442\u0438",normalized:"pick"},render:{primary:"\u0432\u0456\u0434\u043E\u0431\u0440\u0430\u0437\u0438\u0442\u0438",normalized:"render"},into:{primary:"\u0432",alternatives:["\u0443"],normalized:"into"},before:{primary:"\u0434\u043E",alternatives:["\u043F\u0435\u0440\u0435\u0434"],normalized:"before"},after:{primary:"\u043F\u0456\u0441\u043B\u044F",normalized:"after"},until:{primary:"\u043F\u043E\u043A\u0438_\u043D\u0435",normalized:"until"},event:{primary:"\u043F\u043E\u0434\u0456\u044F",normalized:"event"},from:{primary:"\u0437",alternatives:["\u0432\u0456\u0434","\u0456\u0437"],normalized:"from"},connect:{primary:"\u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438",alternatives:["\u0437\u02BC\u0454\u0434\u043D\u0430\u0442\u0438","\u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F"],normalized:"connect"},stream:{primary:"\u0442\u0440\u0430\u043D\u0441\u043B\u044E\u0432\u0430\u0442\u0438",alternatives:["\u043F\u043E\u0442\u0456\u043A","\u0441\u0442\u0440\u0456\u043C"],normalized:"stream"},live:{primary:"\u043D\u0430\u0436\u0438\u0432\u043E",alternatives:["\u0443-\u043F\u0440\u044F\u043C\u043E\u043C\u0443-\u0435\u0444\u0456\u0440\u0456","\u0432-\u0440\u0435\u0436\u0438\u043C\u0456-\u0440\u0435\u0430\u043B\u044C\u043D\u043E\u0433\u043E-\u0447\u0430\u0441\u0443","\u0436\u0438\u0432\u0438\u0439"],normalized:"live"},socket:{primary:"\u0441\u043E\u043A\u0435\u0442",alternatives:["\u0433\u043D\u0456\u0437\u0434\u043E","websocket","socket"],normalized:"socket"},bind:{primary:"\u043F\u0440\u0438\u0432'\u044F\u0437\u0430\u0442\u0438",alternatives:["\u0437\u0432'\u044F\u0437\u0430\u0442\u0438","\u043F\u0440\u0438\u0454\u0434\u043D\u0430\u0442\u0438","bind"],normalized:"bind"},intercept:{primary:"\u043F\u0435\u0440\u0435\u0445\u043E\u043F\u0438\u0442\u0438",alternatives:["\u043F\u0435\u0440\u0435\u0445\u043E\u043F\u043B\u0435\u043D\u043D\u044F","intercept"],normalized:"intercept"},worker:{primary:"\u0440\u043E\u0431\u0456\u0442\u043D\u0438\u043A",alternatives:["\u0432\u043E\u0440\u043A\u0435\u0440","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0434\u0436\u0435\u0440\u0435\u043B\u043E-\u043F\u043E\u0434\u0456\u0439"],normalized:"eventsource"}},eventHandler:{keyword:{primary:"\u043F\u0440\u0438",normalized:"on"},sourceMarker:{primary:"\u043D\u0430",alternatives:["\u0432","\u043F\u0440\u0438"],position:"before"},eventMarker:{primary:"\u043F\u0440\u0438",position:"before"},temporalMarkers:["\u043A\u043E\u043B\u0438","\u044F\u043A\u0449\u043E"]}},ro=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],to=class{constructor(i=ro){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}},io="()[]{},:;",no=class{constructor(i=io){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,u=n;for(;u<i.length;){if(i[u]==="(")a++;else if(i[u]===")"&&(a--,a===0)){u++;break}u++;}if(a!==0)break;n=u;}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 ao=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}},uo=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}}}},oo=["http://","https://","//","./","../","/"];function so(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 lo(i,e){let r=i.slice(e),t=oo.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 u=so(r,n+2);if(u!==-1){n=u;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var co=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=lo(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},mo=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 po(i){return {isLetter:t=>i.test(t),isIdentifierChar:t=>/[0-9]/.test(t)||i.test(t)}}var fo=class{constructor(i,e,r){this.name=i;let t=po(e);this.isLetter=t.isLetter,this.isIdentifierChar=t.isIdentifierChar,this.prepositions=r;}setContext(i){this.context=i;}canExtract(i,e){let r=i[e];return r==="'"?false:this.isLetter(r)}extract(i,e){if(!this.context)throw new Error(`${this.name}: context not set`);let r=e,t="";for(;r<i.length&&this.isIdentifierChar(i[r]);)t+=i[r++];if(!t)return null;let n=t.toLowerCase(),a=this.prepositions.has(n),u=this.context.lookupKeyword(n),o=u&&u.normalized!==u.native?u.normalized:void 0,s;if(!u&&this.context.normalizer){let l=this.context.normalizer.normalize(t);if(l.stem!==t&&l.confidence>=.7){let c=this.context.lookupKeyword(l.stem);c&&(s=c.normalized);}}return {value:t,length:r-e,metadata:{normalized:o||s,isPreposition:a}}}},yo=new Set(["\u0432","\u0443","\u043D\u0430","\u0437","\u0456\u0437","\u0437\u0456","\u0434\u043E","\u0432\u0456\u0434","\u043E","\u043E\u0431","\u043F\u0440\u0438","\u0434\u043B\u044F","\u043F\u0456\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043C\u0456\u0436","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u043F\u043E","\u0437\u0430","\u043F\u0440\u043E","\u043F\u0456\u0441\u043B\u044F","\u043D\u0430\u0432\u043A\u043E\u043B\u043E","\u043F\u0440\u043E\u0442\u0438","\u0437\u0430\u043C\u0456\u0441\u0442\u044C","\u043A\u0440\u0456\u043C","\u0441\u0435\u0440\u0435\u0434","\u043A"]);function ho(){return [new fo("ukrainian-keyword",/[a-zA-Zа-яА-ЯіІїЇєЄґҐьЬ']/,yo)]}function vo(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Eo(i){let e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var go=class{constructor(){this.name="ascii-identifier";}setContext(i){this.context=i;}canExtract(i,e){return vo(i[e])}extract(i,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,t="",n=e;for(;n<i.length&&Eo(i[n]);)t+=i[n],n++;if(!t)return null;let a=this.context.lookupKeyword(t),u=a&&a.normalized!==a.native?a.normalized:void 0;return {value:t,length:n-r,metadata:{normalized:u}}}};function zo(){return [new co,new uo,new mo,new ao]}var ko=new Set(["\u0432","\u0443","\u043D\u0430","\u0437","\u0456\u0437","\u0437\u0456","\u0434\u043E","\u0432\u0456\u0434","\u043E","\u043E\u0431","\u043F\u0440\u0438","\u0434\u043B\u044F","\u043F\u0456\u0434","\u043D\u0430\u0434","\u043F\u0435\u0440\u0435\u0434","\u043C\u0456\u0436","\u0447\u0435\u0440\u0435\u0437","\u0431\u0435\u0437","\u043F\u043E","\u0437\u0430","\u043F\u0440\u043E","\u043F\u0456\u0441\u043B\u044F","\u043D\u0430\u0432\u043A\u043E\u043B\u043E","\u043F\u0440\u043E\u0442\u0438","\u0437\u0430\u043C\u0456\u0441\u0442\u044C","\u043A\u0440\u0456\u043C","\u0441\u0435\u0440\u0435\u0434","\u043A"]),bo=[{native:"\u043C\u0438\u0448\u0430\u0432\u043D\u0438\u0437",normalized:"mousedown"},{native:"\u043C\u0438\u0448\u0430\u0432\u0433\u043E\u0440\u0443",normalized:"mouseup"},{native:"\u0437\u043C\u0456\u043D\u0430\u0440\u043E\u0437\u043C\u0456\u0440\u0443",normalized:"resize"},{native:"\u0456\u0441\u0442\u0438\u043D\u0430",normalized:"true"},{native:"\u043F\u0440\u0430\u0432\u0434\u0430",normalized:"true"},{native:"\u0445\u0438\u0431\u043D\u0456\u0441\u0442\u044C",normalized:"false"},{native:"null",normalized:"null"},{native:"\u043D\u0435\u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u043E",normalized:"undefined"},{native:"\u043D\u0456\u0447\u043E\u0433\u043E",normalized:"null"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434\u0438",normalized:"s"},{native:"\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"s"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0430",normalized:"ms"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0438",normalized:"ms"},{native:"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434",normalized:"ms"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D\u0430",normalized:"m"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D\u0438",normalized:"m"},{native:"\u0445\u0432\u0438\u043B\u0438\u043D",normalized:"m"},{native:"\u0433\u043E\u0434\u0438\u043D\u0430",normalized:"h"},{native:"\u0433\u043E\u0434\u0438\u043D\u0438",normalized:"h"},{native:"\u0433\u043E\u0434\u0438\u043D",normalized:"h"},{native:"\u043F\u0435\u0440\u0448\u0438\u0439",normalized:"first"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u0456\u0439",normalized:"last"},{native:"\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439",normalized:"next"},{native:"\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439",normalized:"previous"},{native:"\u043D\u0430\u0439\u0431\u043B\u0438\u0436\u0447\u0438\u0439",normalized:"closest"},{native:"\u0431\u0430\u0442\u044C\u043A\u0456\u0432\u0441\u044C\u043A\u0438\u0439",normalized:"parent"},{native:"\u0432\u0438\u043F\u0430\u0434\u043A\u043E\u0432\u0438\u0439",normalized:"random"},{native:"\u043F\u0435\u0440\u0448\u0430",normalized:"first"},{native:"\u043F\u0435\u0440\u0448\u0435",normalized:"first"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u044F",normalized:"last"},{native:"\u043E\u0441\u0442\u0430\u043D\u043D\u0454",normalized:"last"},{native:"\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0430",normalized:"next"},{native:"\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044F",normalized:"previous"},{native:"\u043F\u043E\u0440\u043E\u0436\u043D\u044F",normalized:"empty"},{native:"\u043F\u043E\u0440\u043E\u0436\u043D\u0454",normalized:"empty"},{native:"\u043C\u043E\u044F",normalized:"my"},{native:"\u043C\u043E\u0454",normalized:"my"},{native:"\u043C\u043E\u0457",normalized:"my"},{native:"\u0432\u043A\u043B\u044E\u0447\u043D\u043E",normalized:"inclusive"},{native:"\u0432\u0438\u043A\u043B\u044E\u0447\u043D\u043E",normalized:"exclusive"},{native:"\u0441\u0438\u043C\u0432\u043E\u043B\u0438",normalized:"characters"}],wo=class extends Rr{constructor(){super(),this.language="uk",this.direction="ltr",this.initializeKeywordsFromProfile(Pt,bo),this.setNormalizer(new Ot),this.registerExtractors([...zo(),...ho(),new Tr,new Fr,new go,new to,new no]);}classifyToken(i){let e=i.toLowerCase();return ko.has(e)?"particle":this.isKeyword(e)?"keyword":/^\.(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":i.startsWith("/")||i.startsWith("./")||i.startsWith("http")?"url":"identifier"}},Co=new wo;st("uk",Co,Pt);function ir(i){let e=i.getAttribute("data-lang");if(e)return Cr(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Cr(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?Cr(t):null}function Cr(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",""],["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 nr(i){switch(i.kind){case "event-handler":return Ao(i);case "compound":return Do(i);default:return So(i)}}function Ao(i){let e=["on"],r=i.roles.get("event");r&&e.push(Ke(r));let t=i.roles.get("source");if(t&&e.push("from",Ke(t)),i.body&&i.body.length>0){let n=i.body.map(nr);e.push(n.join(" then "));}return e.join(" ")}function Do(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(nr).join(` ${e} `)}function So(i){let e=Nt[i.action];if(e){let t=[i.action];for(let[n,a]of e){let u=i.roles.get(n);u&&((n==="destination"||n==="source")&&u.type==="reference"&&u.value==="me"||(a&&t.push(a),t.push(Ke(u))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(Ke(t));return r.join(" ")}function Ke(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 xo(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function xo(i){let e=Ke(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 Mt=.5,Bo={confidenceThreshold:Mt,strategy:"semantic",fallbackToOriginal:true};function To(i,e){return typeof i=="number"?i:i[e]??i["*"]??Mt}function Ar(i,e,r={}){let t={...Bo,...r},n=_t(i,e,t);if(n!==null)return n;let a=Ro(i);if(a){let u=_t(a.commands,e,t);if(u!==null)return a.prefix+u}return i}function _t(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=To(r.confidenceThreshold,e),n=Lt(i,e,t);if(n!==null)return n}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=Oo(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var Fo=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Ro(i){let e=i.match(Fo);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function Lt(i,e,r){try{let t=No(i,e);if(t.length>1)return _o(t,e,r);if(!ct(e))return null;let n=xt(i,e);return n.confidence<r||!n.node?null:nr(n.node)}catch{return null}}function Oo(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function Po(i){let e=["then"],r=P(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 No(i,e){let t=Po(e).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),a=i.split(`
|
|
5
|
+
`).map(o=>o.trim()).filter(o=>o.length>0),u=[];for(let o of a){let s=o.split(n);u.push(...s);}return u}function _o(i,e,r){let t=[];for(let n of i){let a=Lt(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(u){let o=a(u);if(!o)return null;let s=Mo(u,i);if(!s||s==="en")return o;let l=Ar(o,s,i);return i.debug&&l!==o&&console.log(`[hyperscript-i18n] ${s}: "${o}" \u2192 "${l}"`),l};}}function Mo(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=ir(i);return r||(e.defaultLanguage??null)}function It(i,e,r={}){return e==="en"?i:Ar(i,e,r)}lt(i=>Tt(i));function jt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Dr()),Lo());}function Lo(){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 sl=["uk"];jt();exports.plugin=Dr;exports.preprocess=It;exports.resolveLanguage=ir;exports.supportedLanguages=sl;return exports;})({});
|