@hyperscript-tools/multilingual 2.5.1 → 2.7.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 -4
- package/dist/hyperscript-i18n-bn.global.js +5 -4
- package/dist/hyperscript-i18n-de.global.js +5 -4
- package/dist/hyperscript-i18n-east-asian.global.js +5 -4
- package/dist/hyperscript-i18n-en.global.js +7 -6
- package/dist/hyperscript-i18n-es.global.js +5 -4
- package/dist/hyperscript-i18n-fr.global.js +5 -4
- package/dist/hyperscript-i18n-he.global.js +5 -4
- package/dist/hyperscript-i18n-hi.global.js +5 -4
- package/dist/hyperscript-i18n-id.global.js +5 -4
- package/dist/hyperscript-i18n-it.global.js +5 -4
- package/dist/hyperscript-i18n-ja.global.js +5 -4
- package/dist/hyperscript-i18n-ko.global.js +5 -4
- package/dist/hyperscript-i18n-ms.global.js +5 -4
- package/dist/hyperscript-i18n-pl.global.js +5 -4
- package/dist/hyperscript-i18n-pt.global.js +5 -4
- package/dist/hyperscript-i18n-qu.global.js +5 -4
- package/dist/hyperscript-i18n-ru.global.js +5 -4
- package/dist/hyperscript-i18n-slavic.global.js +5 -4
- package/dist/hyperscript-i18n-south-asian.global.js +5 -4
- package/dist/hyperscript-i18n-southeast-asian.global.js +5 -4
- package/dist/hyperscript-i18n-sw.global.js +5 -4
- package/dist/hyperscript-i18n-th.global.js +5 -4
- package/dist/hyperscript-i18n-tl.global.js +5 -4
- package/dist/hyperscript-i18n-tr.global.js +5 -4
- package/dist/hyperscript-i18n-uk.global.js +5 -4
- package/dist/hyperscript-i18n-vi.global.js +5 -4
- package/dist/hyperscript-i18n-western.global.js +5 -4
- package/dist/hyperscript-i18n-zh.global.js +5 -4
- package/dist/hyperscript-i18n.global.js +34 -30
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var HyperscriptI18n=(function(exports){'use strict';function x(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function ne(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function H(t){return {type:"reference",value:t}}function ue(t,e){return {type:"property-path",object:t,property:e}}var _e=new Set(["me","you","it","result","event","target","body"]);function ke(t,e=_e){return e.has(t)}var Pr=class{constructor(t){this.namespace=t,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let t=process.env.DEBUG||"";return t==="*"||t.includes("framework:*")||t.includes(`framework:${this.namespace}`)}return false}log(t,e,...r){if(!this.enabled)return;let i=`[framework:${this.namespace}]`,a=new Date().toISOString();switch(t){case "debug":console.debug(`${a} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${a} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${a} ${i} WARN:`,e,...r);break;case "error":console.error(`${a} ${i} ERROR:`,e,...r);break}}debug(t,...e){this.log("debug",t,...e);}info(t,...e){this.log("info",t,...e);}warn(t,...e){this.log("warn",t,...e);}error(t,...e){this.log("error",t,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Rr(t){return new Pr(t)}function j(t,e){return !e||e.length===0||e.includes(t)||e.includes("expression")?true:t==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function _r(t,e){return t?.possessive?.keywords?.[e]}var Y=class ${constructor(){this.logger=Rr("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,i){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:",i?.code);}this.currentProfile=i,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,i){let a=[];for(let u of r){let o=e.mark(),s=this.matchPattern(e,u,i);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,i,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 h=this.collectStopMarkers(r,l+1);if(a)for(let z of a)h.add(z);let E=[];for(;!e.isAtEnd();){let z=e.peek();if(!z||this.isStopMarker(z,h))break;E.push(z.value),e.advance();}if(E.length>0){i.set(c.role,{type:"expression",raw:E.join(" ")}),o=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let h=this.collectStopMarkers(r,l+1);if(a)for(let z of a)h.add(z);if(this.matchGroupToken(e,c,i,h)){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 h=l+1<r.length?r[l+1]:null;if(h?.type==="literal"){let E=e.peek();if(E&&this.getMatchType(E,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(o&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(o),i.delete(s),o=null,s=null;let z=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",z),z)continue}return false}}}let v=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",v),v){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),i.delete(s),o=null,s=null;let h=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,r,i){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,i);case "group":return this.matchGroupToken(e,r,i);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",i?JSON.stringify({type:i.type,value:i.value,kind:i.kind}):"null"),!i)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let a=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.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(i,n);if(u!=="none")return this.totalKeywordMatches++,u==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,i){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&&!j(n.type,r.expectedTypes)?r.optional||false:(i.set(r.role,n),true);let u=this.tryMatchMethodCallExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!j(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let o=this.tryMatchPossessiveSelectorExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!j(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!j(s.type,r.expectedTypes)?r.optional||false:(i.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!j(l.type,r.expectedTypes)?r.optional||false:(i.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&&!j(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),i.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=r.normalized||r.value,a=this.safeToLowerCase(i),n=_r(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()),ue(H(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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(i),null;e.advance();let u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(i),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<$.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(i),null;e.advance();let u=`${r.value}.${n.value}`,o=1;for(;!e.isAtEnd()&&o<$.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<$.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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(i),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(i),null):(e.advance(),ue(ne(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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(i),null;let n=e.peek(1);n&&n.kind,e.advance();let u=a.value.slice(1);return ue(ne(r.value),u)}matchGroupToken(e,r,i,a){let n=e.mark(),u=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,a))return true;e.reset(n);for(let l of i.keys())u.has(l)||i.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=$.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,i,a))return true;e.reset(n);for(let d of i.keys())u.has(d)||i.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 i=new Set;for(let a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(i.add(n.value.toLowerCase()),n.alternatives)for(let u of n.alternatives)i.add(u.toLowerCase());break}if(n.type==="group"){for(let u of n.tokens)if(u.type==="literal"){if(i.add(u.value.toLowerCase()),u.alternatives)for(let o of u.alternatives)i.add(o.toLowerCase());break}if(!n.optional)break}}return i}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 ne(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return x(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return H(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return x(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 x(a,"string")}if(e==="true")return x(true,"boolean");if(e==="false")return x(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?x(e,"duration"):x(a,"number")}let i=parseFloat(e);return isNaN(i)?x(e,"string"):x(i,"number")}applyExtractionRules(e,r){for(let[i,a]of Object.entries(e.extraction))r.has(i)||(a.value!==void 0?r.set(i,{type:"literal",value:a.value}):a.default&&r.set(i,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=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)&&(i+=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)?i+=p:m&&(i+=p*.6);}}let u=a>0?i/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 i=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(i.has(r.value))return .15;if(r.alternatives){for(let a of r.alternatives)if(i.has(a))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=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)?i+=.1:i-=.1;}}return Math.max(-0.1,Math.min(.1,i))}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=this.safeToLowerCase(r.value);if($.ENGLISH_NOISE_WORDS.has(i)){let a=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(a);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(i=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 i?r:void 0}};Y.MAX_MARKER_SCAN=3;Y.MAX_PROPERTY_DEPTH=10;Y.MAX_METHOD_ARGS=20;Y.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Or=Y;new Or;var oe=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(t,e){let r=t[e];if(r==="\u201C"){let n=1;for(;e+n<t.length;){if(t[e+n]==="\u201D")return n++,{value:t.substring(e,e+n),length:n};n++;}return null}if(r==="\u2018"){let n=1;for(;e+n<t.length;){if(t[e+n]==="\u2019")return n++,{value:t.substring(e,e+n),length:n};n++;}return null}let i=1,a=false;for(;e+i<t.length;){let n=t[e+i];if(a){a=false,i++;continue}if(n==="\\"){a=true,i++;continue}if(n===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},se=class{constructor(){this.name="number";}canExtract(t,e){return /\d/.test(t[e])}extract(t,e){let r=0,i=false;for(;e+r<t.length;){let u=t[e+r];if(/\d/.test(u))r++;else if(u==="."&&!i)i=true,r++;else break}if(r===0)return null;let a=t.substring(e,e+r),n=e+r;if(n<t.length){let u=t.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 Nr(t){return "setContext"in t&&typeof t.setContext=="function"}function Mr(t){let e={language:t.language,direction:t.direction,lookupKeyword:t.lookupKeyword.bind(t),isKeyword:t.isKeyword.bind(t),isKeywordStart:t.isKeywordStart.bind(t)};return t.normalizer?{...e,normalizer:t.normalizer}:e}var J=class{constructor(t,e){this.pos=0,this.tokens=t,this.language=e;}peek(t=0){let e=this.pos+t;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(t){this.pos=t.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(t){let e=[];for(;!this.isAtEnd()&&t(this.peek());)e.push(this.advance());return e}skipWhile(t){for(;!this.isAtEnd()&&t(this.peek());)this.advance();}};function k(t,e){return {start:t,end:e}}function A(t,e,r,i){if(typeof t=="object"){let{value:n,kind:u,position:o,normalized:s,stem:l,stemConfidence:c,metadata:m}=t;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=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:a,kind:e,position:r,normalized:i};if(i){let{normalized:n,stem:u,stemConfidence:o,metadata:s}=i;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 G(t){return /\s/.test(t)}function Lr(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Ir(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function O(t){return /\d/.test(t)}function jr(t){return /[a-zA-Z]/.test(t)}function w(t){return /[a-zA-Z0-9_-]/.test(t)}function $r(t,e){if(e>=t.length)return null;let r=t[e];if(!Lr(r))return null;let i=e,a="";if(r==="#"||r==="."){for(a+=t[i++];i<t.length&&w(t[i]);)a+=t[i++];if(a.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let u=i+1;for(;u<t.length&&w(t[u]);)u++;if(u<t.length&&t[u]==="(")return a}}else if(r==="["){let n=1,u=false,o=null,s=false;for(a+=t[i++];i<t.length&&n>0;){let l=t[i];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--,i++;}if(n!==0)return null}else if(r==="@"){for(a+=t[i++];i<t.length&&w(t[i]);)a+=t[i++];if(a.length<=1)return null}else if(r==="*"){for(a+=t[i++];i<t.length&&w(t[i]);)a+=t[i++];if(a.length<=1)return null}else if(r==="<"){if(a+=t[i++],i>=t.length||!jr(t[i]))return null;for(;i<t.length&&w(t[i]);)a+=t[i++];for(;i<t.length;){let n=t[i];if(n==="."){if(a+=t[i++],i>=t.length||!w(t[i]))return null;for(;i<t.length&&w(t[i]);)a+=t[i++];}else if(n==="#"){if(a+=t[i++],i>=t.length||!w(t[i]))return null;for(;i<t.length&&w(t[i]);)a+=t[i++];}else if(n==="["){let u=1,o=false,s=null,l=false;for(a+=t[i++];i<t.length&&u>0;){let c=t[i];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--,i++;}if(u!==0)return null}else break}for(;i<t.length&&G(t[i]);)a+=t[i++];if(i<t.length&&t[i]==="/")for(a+=t[i++];i<t.length&&G(t[i]);)a+=t[i++];if(i>=t.length||t[i]!==">")return null;a+=t[i++];}return a||null}function Vr(t,e){if(e>=t.length||t[e]!=="'"||e+1>=t.length||t[e+1].toLowerCase()!=="s")return false;if(e+2>=t.length)return true;let i=t[e+2];return G(i)||i==="*"||!w(i)}function qr(t,e){if(e>=t.length)return null;let r=t[e];if(!Ir(r)||r==="'"&&Vr(t,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,u=r,o=false;for(;n<t.length;){let s=t[n];if(u+=s,o)o=false;else if(s==="\\")o=true;else if(s===a)return u;n++;}return u}function Wr(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",a=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(a)||r==="."&&(i==="/"||i==="."&&a==="/"))return true;let n=t.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function Kr(t,e){if(!Wr(t,e))return null;let r=e,i="",a=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let n=t[r];if(n==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=n,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(a.test(n))i+=n,r++;else break}return i.length<2?null:i}function Ur(t,e){if(e>=t.length)return null;let r=t[e];if(!O(r)&&r!=="-"&&r!=="+")return null;let i=e,a="";if((t[i]==="-"||t[i]==="+")&&(a+=t[i++]),i>=t.length||!O(t[i]))return null;for(;i<t.length&&O(t[i]);)a+=t[i++];if(i<t.length&&t[i]===".")for(a+=t[i++];i<t.length&&O(t[i]);)a+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?a+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(a+=t[i])),a}var Hr=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Hr);var Me=class Le{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}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){Nr(e)&&e.setContext(Mr(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=[],i=0;for(;i<e.length;){for(;i<e.length&&G(e[i]);)i++;if(i>=e.length)break;let a=false;for(let n of this.extractors)if(n.canExtract(e,i)){let u=n.extract(e,i);if(u){let o=u.metadata?.normalized,s=u.metadata?.stem,l=u.metadata?.stemConfidence,c={};if(u.metadata)for(let[p,d]of Object.entries(u.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(c[p]=d);let m={};o&&(m.normalized=o),s&&(m.stem=s),l!==void 0&&(m.stemConfidence=l),Object.keys(c).length>0&&(m.metadata=c),r.push(A(u.value,this.classifyToken(u.value),k(i,i+u.length),Object.keys(m).length>0?m:void 0)),i+=u.length,a=true;break}}if(!a){let n=e[i],u=this.classifyUnknownChar(n);r.push(A(n,u,k(i,i+1))),i++;}}return new J(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,i){if(e[r]!==".")return false;let a=i[i.length-1],n=a&&a.position.end<r;if(a&&!n&&(a.kind==="identifier"||a.kind==="keyword"||a.kind==="selector"))return i.push(A(".","operator",k(r,r+1))),true;let s=r+1;for(;s<e.length&&w(e[s]);)s++;return s<e.length&&e[s]==="("?(i.push(A(".","operator",k(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let i=new Map;if(e.keywords){for(let[a,n]of Object.entries(e.keywords))if(i.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let u of n.alternatives)i.set(u,{native:u,normalized:n.normalized||a});}if(e.references){for(let[a,n]of Object.entries(e.references))i.set(n,{native:n,normalized:a});for(let a of Object.keys(e.references))i.has(a)||i.set(a,{native:a,normalized:a});}if(e.roleMarkers){for(let[a,n]of Object.entries(e.roleMarkers))if(n.primary&&i.set(n.primary,{native:n.primary,normalized:a}),n.alternatives)for(let u of n.alternatives)i.set(u,{native:u,normalized:a});}if(e.possessive?.keywords)for(let[a,n]of Object.entries(e.possessive.keywords))i.set(a,{native:a,normalized:n});for(let a of r)i.set(a.native,a);this.profileKeywords=Array.from(i.values()).sort((a,n)=>n.native.length-a.native.length),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 i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return A(i.native,"keyword",k(r,r+i.native.length),i.normalized);return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(a=>i.startsWith(a.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,i){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 A(e,"keyword",k(r,i),u)}trySelector(e,r){let i=$r(e,r);return i?A(i,"selector",k(r,r+i.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let i=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!i)return null;let a=i[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],u=i[1];return {...A(a,"event-modifier",k(r,r+a.length)),metadata:{modifierName:n,value:u?n==="queue"?u:parseInt(u,10):void 0}}}tryString(e,r){let i=qr(e,r);return i?A(i,"literal",k(r,r+i.length)):null}tryNumber(e,r){let i=Ur(e,r);return i?A(i,"literal",k(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,a=false){let n=r;if(a)for(;n<e.length&&G(e[n]);)n++;let u=e.slice(n);for(let o of i){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(w(c))continue}return {suffix:o.suffix,endPos:n+o.length}}}return null}parseBaseNumber(e,r,i=true){let a=r,n="";if(i&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!O(e[a]))return null;for(;a<e.length&&O(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&O(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,i,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=[...i,...Le.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,u);return m&&(s+=m.suffix,l=m.endPos),A(s,"literal",k(r,l))}tryUrl(e,r){let i=Kr(e,r);return i?A(i,"url",k(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!w(e[r+1]))return null;let i=r+1;for(;i<e.length&&w(e[i]);)i++;let a=e.slice(r,i);return A(a,"identifier",k(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return A(i,"operator",k(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?A(a,"operator",k(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?A(a,"punctuation",k(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let a of i)if(e.slice(r,r+a.length)===a)return A(a,"particle",k(r,r+a.length));return null}};Me.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 le=Me;function ce(t){return {stem:t,confidence:1}}function me(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var Gr=Object.defineProperty,Yr=Object.getOwnPropertyNames,Xe=(t,e)=>function(){return t&&(e=(0, t[Yr(t)[0]])(t=0)),e},Jr=(t,e)=>{for(var r in e)Gr(t,r,{get:e[r],enumerable:true});};function Ie(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function D(t,e,r={},i){let a=Qe[t],n=Ie(a,r),u=Ze[t],o=u?Ie(u,r):void 0;return {code:t,message:n,severity:e,...i&&{role:i},...o&&{suggestion:o}}}var f,Qe,Ze,Xr=Xe({"src/generators/schema-error-codes.ts"(){f={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"},Qe={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[f.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[f.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[f.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[f.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[f.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.",[f.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.",[f.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[f.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[f.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[f.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[f.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[f.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Ze={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[f.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[f.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[f.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[f.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[f.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[f.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[f.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[f.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[f.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),er={};Jr(er,{SchemaErrorCodes:()=>f,formatValidationResults:()=>at,getValidationStats:()=>nt,validateAllKeywordCollisions:()=>ot,validateAllSchemas:()=>it,validateCommandSchema:()=>rr,validateKeywordCollisions:()=>tr,validateRoleValues:()=>ut});function Qr(t,e){return {action:t,items:e}}function rr(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&be.has(t.action)?e.push(D(f.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(D(f.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!be.has(t.action)&&e.push(D(f.TOO_MANY_EXPECTED_TYPES,"warning",{role:i.role,count:i.expectedTypes.length},i.role));for(let i of t.roles)i.selectorKinds&&i.selectorKinds.length>0&&(i.expectedTypes.includes("selector")||e.push(D(f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":Zr(t,e);break;case "on":et(t,e);break;case "if":case "unless":rt(t,e);break;case "repeat":case "for":case "while":tt(t,e);break}return t.roles.filter(i=>i.required).length===0&&(ir.has(t.action)?e.push(D(f.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(D(f.NO_REQUIRED_ROLES,"warning",{}))),Qr(t.action,e)}function Zr(t,e){let r=t.roles.find(a=>a.role==="patient"),i=t.roles.find(a=>a.role==="goal");r&&r.expectedTypes.includes("selector")&&e.push(D(f.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),r&&!i&&e.push(D(f.TRANSITION_MISSING_GOAL,"error",{}));}function et(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(D(f.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(D(f.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function rt(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(D(f.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(D(f.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function tt(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(D(f.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(D(f.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function it(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[a,n]of Object.entries(t)){let u=rr(n),o=u.items.some(l=>l.severity==="warning"||l.severity==="error"),s=i&&u.items.some(l=>l.severity==="note");(o||s)&&r.set(a,u);}return r}function at(t,e={}){let r=[],{showNotes:i=false,showCodes:a=true}=e;for(let[n,u]of t){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(i&&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 nt(t){let e=0,r=0,i=0,a={};for(let n of t.values())for(let u of n.items)u.severity==="error"?e++:u.severity==="warning"?r++:u.severity==="note"&&i++,a[u.code]=(a[u.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:a}}function ut(t,e){let r=[];for(let i of e){let a=t.roles.find(n=>n.role===i.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(i.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${a.expectedTypes.join(", ")}], got '${i.type}'`,code:f.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:f.SELECTOR_KIND_MISMATCH})));}return r}function tr(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(t.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 i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>i[a.type]-i[n.type]),{language:t.code,collisions:e}}function ot(t){let e=[];for(let[,r]of Object.entries(t)){let i=tr(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var be,ir,st=Xe({"src/generators/schema-validator.ts"(){Xr(),be=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),ir=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 M=new Map,T=new Map,X=new Map,we=null;function ar(t,e){let r={...t};for(let i of Object.keys(e)){let a=e[i],n=t[i];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[i]=ar(n,a):r[i]=a);}return r}function lt(t,e){return ar(t,e)}function De(t){if(!t.extends)return t;let e=T.get(t.extends);if(!e)return console.warn(`[Registry] Profile '${t.code}' extends '${t.extends}' but base is not registered. Make sure to import the base language before the variant.`),t;let r=De(e);return lt(r,t)}function ye(t,e,r){M.set(t,e),T.set(t,r),X.delete(t);}function nr(t){we=t;}var je=new Map;function q(t){return t.split("-")[0]}function W(t){return t.includes("-")}function ct(t){let e=M.get(t);if(!e&&W(t)){let r=q(t);e=M.get(r);}if(!e){let r=Array.from(M.keys()).join(", ");throw new Error(`Language '${t}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${t}';`)}return e}function mt(t){let e=T.get(t);if(!e&&W(t)){let r=q(t);e=T.get(r);}if(!e){let r=Array.from(T.keys()).join(", ");throw new Error(`Language profile '${t}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${t}';`)}return De(e)}function L(t){let e=T.get(t);return !e&&W(t)&&(e=T.get(q(t))),e?De(e):void 0}function pt(){return Array.from(M.keys())}function ur(t){if(M.has(t)&&T.has(t))return true;if(W(t)){let e=q(t);return M.has(e)&&T.has(e)}return false}function dt(t,e){return ct(e).tokenize(t)}function V(t){let e=X.get(t);if(!e&&W(t)&&(e=X.get(q(t))),e)return e;let r=je.get(t);if(!r&&W(t)&&(r=je.get(q(t))),r)return X.set(t,r),r;if(!we)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=mt(t),a=we(i);return X.set(t,a),a}function Z(t){let e="complex";return t.startsWith("#")&&!t.includes(" ")?e="id":t.startsWith(".")&&!t.includes(" ")?e="class":t.startsWith("[")&&t.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(t)&&(e="element"),{type:"selector",value:t,selectorKind:e}}function C(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function $e(t){return ke(t)}function N(t){return {type:"reference",value:t}}function Ae(t,e){return {type:"property-path",object:t,property:e}}function pe(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function Ve(t,e,r,i,a,n){let u=new Map;u.set("event",t);let o={kind:"event-handler",action:"on",roles:u,body:e};return r!==void 0&&(o.eventModifiers=r),i!==void 0&&(o.metadata=i),o}function qe(t,e="then",r){let i={kind:"compound",action:"compound",roles:new Map,statements:t,chainType:e};return r!==void 0&&(i.metadata=r),i}function We(t,e){return !e||e.length===0||e.includes(t)||e.includes("expression")?true:t==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function It(t,e){return t.possessive?.keywords?.[e]}var Ce=.8,jt=.6,$t=.15,Vt=.5,Ke=.15,Ue=.1,He=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"]),qt={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"]},Wt=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),a=this.scoreLanguageAdjustment(t),n=e;return n=Math.max(Vt,n+r),n=Math.min(1,n+i),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:a,final:n}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=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)&&(i+=1);else if(u.type==="group")for(let o of u.tokens)o.type==="role"&&(a+=Ce,r.has(o.role)?i+=Ce:n(o.role)&&(i+=Ce*jt));return a>0?i/a:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*$t}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:He.has(r.value)||r.alternatives?.some(i=>He.has(i))?Ke:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[a,n]of r.entries()){let u=qt[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)?i+=.1:i-=.1);}return Math.max(-Ue,Math.min(Ue,i))}},Kt=new Wt,fe=class Q{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Kt;}matchPattern(e,r){let i=e.mark(),a=new Map;if(this.currentProfile=L(r.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(i),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()-i.position,confidence:u}}matchBest(e,r){this.matchCache.clear();let i=[],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&&i.push(l),e.reset(o);}if(i.length===0)return null;i.sort((u,o)=>{let s=o.pattern.priority-u.pattern.priority;return s!==0?s:o.confidence-u.confidence});let n=i[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,i){let a=r[0],n=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!n)for(;e.peek()?.kind==="conjunction";)e.advance();for(let u of r)if(!this.matchPatternToken(e,u,i)){if(this.isOptional(u))continue;return false}return true}matchPatternToken(e,r,i){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,i);case "group":return this.matchGroupToken(e,r,i);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let a=this.getMatchType(i,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(i,n);if(u!=="none")return this.totalKeywordMatches++,u==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,i){this.skipNoiseWords(e);let a=e.peek();if(!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(n.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,n),true);let u=this.tryMatchMethodCallExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(u.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,u),true);let o=this.tryMatchPossessiveSelectorExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!We(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!We(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);let c=this.tokenToSemanticValue(a);return !c||r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)?r.optional||false:(i.set(r.role,c),e.advance(),true)}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=(r.normalized||r.value).toLowerCase(),a=It(this.currentProfile,i);if(!a)return null;let n=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(n),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let o=u.value;u.kind==="selector"&&o.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o)&&(o=o.substring(1));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();return l?.kind==="literal"&&l.value.startsWith("(")&&(s+=l.value,e.advance()),Ae(N(a),s)}return e.reset(n),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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(i),null;e.advance();let u=e.peek();if(!u||u.kind!=="punctuation"||u.value!=="(")return e.reset(i),null;e.advance();let o=[];for(;!e.isAtEnd()&&o.length<Q.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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(i),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(i),null;e.advance();let u=`${r.value}.${n.value}`,o=1;for(;!e.isAtEnd()&&o<Q.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<Q.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 i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(i),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(i),null):(e.advance(),Ae(Z(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(i),null;let n=e.peek(1);n&&n.kind,e.advance();let u=a.value.slice(1);return Ae(Z(r.value),u)}matchGroupToken(e,r,i){let a=e.mark(),n=new Set(i.keys());if(!this.matchTokenSequence(e,r.tokens,i)){e.reset(a);for(let o of i.keys())n.has(o)||i.delete(o);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 Z(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return $e(r)?N(r):C(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return N(e.value);let i=e.value.toLowerCase();return $e(i)?N(i):{type:"expression",raw:e.value};case "url":return C(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 C(a,"string")}if(e==="true")return C(true,"boolean");if(e==="false")return C(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?C(e,"duration"):C(a,"number")}let i=parseFloat(e);return isNaN(i)?C(e,"string"):C(i,"number")}applyExtractionRules(e,r){for(let[i,a]of Object.entries(e.extraction))r.has(i)||(a.value!==void 0?r.set(i,{type:"literal",value:a.value}):a.default&&r.set(i,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(Q.ENGLISH_NOISE_WORDS.has(i)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;e.reset(a);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(i=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 i?r:void 0}};fe.MAX_PROPERTY_DEPTH=10;fe.MAX_METHOD_ARGS=20;fe.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ut=fe,_=new Ut;function ee(t,e){return dt(t,e)}function or(){return pt()}var Ht={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",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Yt={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}],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)"}},Jt={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"],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,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"}},Xt={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],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"}},Qt={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"}},Zt={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"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{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:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],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>"}},ei={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}]},ti={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}]},ii={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}]},ai={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}]},ni={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}]},ui={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"}}]},oi={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"}}]},si={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"}}]},li={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"}}]},ci={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}]},mi={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:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},pi={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}]},di={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},yi={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},fi={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}]},hi={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}]},vi={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"],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"}}]},Ei={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},gi={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"],svoPosition:1,sovPosition:1}]},zi={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ki={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"'},Ai={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"],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"}}]},Ci={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}]},bi={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},wi={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:""}}]},Di={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],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:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",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}]},Bi={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"}}]},xi={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}]},Si={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}]},Fi={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}]},Ti={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"}}]},Pi={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}]},Ri={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}]},_i={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}]},Oi={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}]},Ni={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[]},Mi={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},Li={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}]},Ii={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}]},ji={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},$i={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:""}}]},Vi={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:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{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:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},qi={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Wi={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}]},Ki={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required: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}]},Ui={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"}}]},Hi={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"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},Gi={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Yi={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}]},Ji={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Xi={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}]},Qi={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Zi={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}]},ea={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"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},sr={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"},ta={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:sr}]},ia={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:sr}]},aa={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}]},na={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}]},lr={toggle:Yt,add:Jt,remove:Xt,put:Qt,set:Zt,show:ei,hide:ri,on:ti,trigger:ii,wait:ai,fetch:ni,increment:ui,decrement:oi,append:si,prepend:li,log:ci,get:mi,take:pi,make:di,halt:yi,settle:fi,throw:hi,send:vi,if:Ei,unless:gi,else:zi,repeat:ki,for:Ai,while:Ci,continue:bi,go:wi,scroll:ea,push:ta,replace:ia,process:aa,transition:Di,clone:Bi,focus:xi,blur:Si,empty:Fi,open:Ti,close:Pi,select:Ri,clear:_i,reset:Oi,breakpoint:Ni,call:Mi,return:Li,js:Ii,async:ji,tell:$i,default:Vi,init:qi,behavior:Wi,install:Ki,measure:Ui,swap:Hi,morph:Gi,beep:Yi,break:Ji,copy:Xi,exit:Qi,pick:Zi,render:na,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function ua(){return Object.values(lr).filter(t=>t.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(st(),er)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(lr);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(t=>{console.debug("Schema validation skipped:",t);});var Ge=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function S(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function de(t,e){return e.length===0?t:{...t,diagnostics:e}}var K=class F{parse(e,r){let{modifiers:i,remainingInput:a}=this.extractStandaloneModifiers(e,r),n=a||e,u=[],o=ee(n,r),s=V(r);if(s.length===0)throw new Ge(`No patterns available for language: ${r}`,r,n,[S(`No patterns registered for language '${r}'`,"error","no-patterns")]);let l=[...s].sort((h,E)=>E.priority-h.priority),c=l.filter(h=>h.command==="on"),m=_.matchBest(o,c);if(m){u.push(S(`event pattern matched: ${m.pattern.id} (confidence: ${m.confidence.toFixed(2)})`,"info","pattern-match"));let h=this.buildEventHandler(m,o,r),E=i?this.applyModifiers(h,i):h;return de(E,u)}u.push(S(`event patterns: ${c.length} tried, no match`,"info","stage-event"));let p=l.filter(h=>h.command!=="on"),d=_.matchBest(o,p);if(d)return u.push(S(`command pattern matched: ${d.pattern.id} (confidence: ${d.confidence.toFixed(2)})`,"info","pattern-match")),de(this.buildCommand(d,r),u);u.push(S(`command patterns: ${p.length} tried, no match`,"info","stage-command"));let y=this.trySOVEventExtraction(n,r,l);if(y){u.push(S("SOV event extraction succeeded","info","stage-sov"));let h=i?this.applyModifiers(y,i):y;return de(h,u)}u.push(S("SOV event extraction: no event keyword found","info","stage-sov"));let v=this.tryCompoundCommandParsing(o,p,r);if(v)return u.push(S("compound command parsing succeeded","info","stage-compound")),de(v,u);throw u.push(S("compound parsing: no then-keywords or no command matches","info","stage-compound")),u.push(S(`all parse stages exhausted for "${n}"`,"error","parse-failed")),new Ge(`Could not parse input in ${r}: ${n}`,r,n,u)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return or()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[a,n]of e.captured)i[a]=n;return pe(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,r,i){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=_.extractEventModifiers(r),u=this.extractOrConjunctionEvents(r,i),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"){let c=l.value,m={};for(let[y,v]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(m[y]=v);let p=pe(c,m,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence}),d=e.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then"){let y=V(i).filter(E=>E.command!=="on").sort((E,z)=>z.priority-E.priority),v=V(i).filter(E=>E.id.startsWith("grammar-")&&E.id.includes("-continuation")).sort((E,z)=>z.priority-E.priority),h=this.parseBodyWithGrammarPatterns(r,y,v,i);h.length>0?s=[p,...h]:s=[p];}else s=[p];}else {let c=V(i).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,i);}return Ve(o,s,n,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let a=[],n=[];for(;!e.isAtEnd();){let u=e.peek();if(!u)break;let o=u.kind==="conjunction"||u.kind==="keyword"&&this.isThenKeyword(u.value,i),s=u.kind==="keyword"&&this.isEndKeyword(u.value,i);if(o){if(n.length>0){let l=this.parseClause(n,r,i);a.push(...l),n.length=0;}e.advance();continue}if(s){if(n.length>0){let l=this.parseClause(n,r,i);a.push(...l);}e.advance();break}n.push(u),e.advance();}if(n.length>0){let u=this.parseClause(n,r,i);a.push(...u);}return a.length>1?[qe(a,"then",{sourceLanguage:i})]:a}parseClause(e,r,i){if(e.length===0)return [];let a=new J(e,i),n=[];for(;!a.isAtEnd();){let u=_.matchBest(a,r);u?n.push(this.buildCommand(u,i)):a.advance();}if(n.length===0){let u=this.parseSOVClauseByVerbAnchoring(e,i);if(u.length>0)return u}return n}static buildVerbLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(i)&&(r.set(a.primary.toLowerCase(),i),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,a]of Object.entries(e.roleMarkers))if(a&&(r.set(a.primary,i),a.alternatives))for(let n of a.alternatives)r.has(n)||r.set(n,i);return r}parseSOVClauseByVerbAnchoring(e,r){let i=L(r);if(!i||i.wordOrder!=="SOV")return [];let a=F.buildVerbLookup(i),n=F.buildMarkerToRoleLookup(i),u=[],o=0;for(;o<e.length;){let s=-1,l="";for(let y=o;y<e.length;y++){let v=e[y],h=a.get(v.value.toLowerCase()),E=v.normalized?a.get(v.normalized.toLowerCase()):void 0,z=h||E;if(z){s=y,l=z;break}}if(s===-1)break;let c=e.slice(o,s),m=e.length;for(let y=s+1;y<e.length;y++){let v=e[y];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=y;break}if(y>s+1&&(a.get(v.value.toLowerCase())||(v.normalized?a.get(v.normalized.toLowerCase()):void 0))){m=y;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,n,l,r);if(u.push(pe(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,i,a,n){let u={},o=s=>{let l=[];for(let c of s){let m=i.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){let c=this.tokensToSemanticValue(l);c&&(u.patient?u.destination||(u.destination=c):u.patient=c);}};return o(e),o(r),u}mapRoleForCommand(e,r,i){return i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.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 i=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("*")?Z(i):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?C(i):a.kind==="reference"?N(i):C(i)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return Z(r);if(r.startsWith('"')||r.startsWith("'"))return C(r);if(/^-?\d+(\.\d+)?$/.test(r))return C(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return C(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return C(false);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?N(i):e.kind==="reference"?N(e.normalized||"me"):C(r)}parseBodyWithGrammarPatterns(e,r,i,a){let n=[];for(;!e.isAtEnd();){let u=e.peek();if(u&&this.isThenKeyword(u.value,a)){e.advance();continue}if(u&&this.isEndKeyword(u.value,a)){e.advance();break}let o=false;if(i.length>0){let s=_.matchBest(e,i);if(s){let l=s.pattern.command,c={};for(let[d,y]of s.captured)d!=="event"&&d!=="action"&&d!=="continues"&&(c[d]=y);let m=pe(l,c,{sourceLanguage:a,patternId:s.pattern.id});n.push(m),o=true;let p=s.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!o){let s=_.matchBest(e,r);s&&(n.push(this.buildCommand(s,a)),o=true);}o||e.advance();}return n}tryCompoundCommandParsing(e,r,i){let a=e.tokens;if(!a.some(s=>s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,i)))return null;let u=new J(a,i),o=this.parseBodyWithClauses(u,r,i);return o.length===0?null:o.length===1?o[0]:qe(o,"then",{sourceLanguage:i,confidence:.65})}trySOVEventExtraction(e,r,i){let a=F.SOV_EVENT_MARKERS[r];if(!a)return null;let u=ee(e,r).tokens,o=Ht[r],s=new Set;if(o)for(let g of Object.keys(o))s.add(g.toLowerCase());let l=F.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1;for(let g=0;g<u.length;g++){let b=u[g],P=b.value.toLowerCase(),R=P,I="",Ee=P.indexOf("[");Ee>0&&(R=P.slice(0,Ee),I=b.value.slice(Ee));let ge=b.normalized?.toLowerCase(),Pe=ge&&F.KNOWN_EVENTS.has(ge),Re=s.has(P)||s.has(R),Fr=F.KNOWN_EVENTS.has(R);if(Pe||Re||Fr){let U;if(Pe?U=ge:Re?U=o?.[P]??o?.[R]??R:U=R,a.size>0){let ie=1,ze=u[g+1];ze&&ze.kind==="selector"&&ze.value.startsWith("[")&&(ie=2);let ae=u[g+ie];if(ae&&(ae.kind==="particle"||ae.kind==="keyword")&&a.has(ae.value)){c=g,m=U,p=I||(ie===2?u[g+1].value:""),d=ie+1;break}}else {c=g,m=U,p=I,d=1;break}}}if(c===-1)return null;let y=new Set;for(let g=c;g<c+d;g++)y.add(g);if(l){let g=c+d;if(g<u.length){let b=u[g];(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&y.add(g);}for(let b=0;b<c;b++){let P=u[b],R=P.value.toLowerCase(),I=P.normalized?.toLowerCase();if(l.windowTokens.has(R)||I&&l.windowTokens.has(I)){y.add(b);break}}}let v=u.filter((g,b)=>!y.has(b));if(v.length===0)return null;let h=i.filter(g=>g.command!=="on"),E=new J(v,r),z=this.parseBodyWithClauses(E,h,r);if(z.length===0)return null;let Te={sourceLanguage:r,confidence:.75};return p&&(Te.keyFilter=p),Ve({type:"literal",value:m},z,void 0,Te)}isThenKeyword(e,r){let i={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (i[r]||i.en).has(e.toLowerCase())}isEndKeyword(e,r){let i={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),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"])};return (i[r]||i.en).has(e.toLowerCase())}extractStandaloneModifiers(e,r){let a=ee(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let u=a[0].value.toLowerCase(),o=F.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 y=a[d];(y.kind==="keyword"||y.kind==="particle")&&(d++,l++);}if(d<a.length){let y=a[d];if(y.kind==="literal"){let v=y.value.match(/^(\d+)(ms|s|m)?$/);if(v){let h=parseInt(v[1],10),E=v[2]||"ms";E==="s"?h*=1e3:E==="m"&&(h*=6e4),s[o]=h,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}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let i=[];for(;;){let a=e.mark(),n=e.peek();if(!n)break;let u=(n.normalized||n.value).toLowerCase();if(!F.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(),i.push({type:"literal",value:s});}return i}};K.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);K.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"])};K.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"])}};K.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};K.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"]);var oa=K,sa=new oa;function la(t,e){return sa.parse(t,e)}function ca(t,e){try{let r=ee(t,e),i=V(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...i].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),u=_.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=_.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: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function cr(t,e){try{let i=la(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:ee(t,e).tokens.length}}catch{}let r=ca(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function mr(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,a)=>{let n=i[r]??99,u=a[r]??99;return n-u})}function ma(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0)return {primary:r,position:i?.position??"before",isOverride:true};if(i&&i.primary){let a={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(a.alternatives=i.alternatives),a}return null}function pa(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {patient} ${o?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function da(t,e,r,i,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}),i.position==="after"){let s=i.primary.split(/\s+/);if(s.length>1)for(let l of s)n.push({type:"literal",value:l});else {let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ya(t,e,r,i,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}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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:`${t.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} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function fa(t,e,r,i,a){let n=[];n.push({type:"role",role:"event",optional:false});let u=i.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),{id:`${t.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:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ha(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let o=i.primary.split(/\s+/);if(o.length>1)for(let s of o)n.push({type:"literal",value:s});else {let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function va(t,e,r,i){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:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function Ea(t,e,r,i,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else {let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(m);}}let o=[...t.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 m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s);let l=o.map(c=>`{${c.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(o.map(c=>[c.role,{fromRole:c.role}]))}}}function ga(t,e,r,i,a){let n=[],o=[...t.roles.filter(y=>y.required)].sort((y,v)=>{let h=y.sovPosition??999,E=v.sovPosition??999;return h-E}),s=o[0];n.push({type:"role",role:s.role,optional:false});let l;if(s.markerOverride&&s.markerOverride[e.code]!==void 0)l=s.markerOverride[e.code];else {let y=e.roleMarkers[s.role];y&&(l=y.primary);}if(l&&n.push({type:"literal",value:l}),n.push({type:"role",role:"event",optional:false}),i.position==="after"){let y=i.primary.split(/\s+/);if(y.length>1)for(let v of y)n.push({type:"literal",value:v});else {let v=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(v);}}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(c);let m=o[1];n.push({type:"role",role:m.role,optional:false});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};n.push(y);}return {id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${s.role}} {event} ${i.primary} ${r.primary} {${m.role}}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[m.role]:{fromRole:m.role}}}}function Ye(t,e,r,i,a){let n=[];if(i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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}]}),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function za(t,e,r,i,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}]}),i.position==="before"){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(s);}return n.push({type:"role",role:"event",optional:false}),{id:`${t.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?} ${i.primary} {event}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ka(t,e,r,i,a){let n=[],u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u);let s=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}if(i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}n.push({type:"role",role:"event",optional:false});let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function Je(t,e,r,i,a){let n=[];if(i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};n.push(c);}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=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function Aa(t,e,r,i,a){let n=[],u=e.eventHandler?.negationMarker;if(i.position==="before"){let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.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}]}),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${i.primary} ${u?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Ca(t,e,r,i){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}]}),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var re={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function pr(t,e,r=re){let i=`${t.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[t.action];if(!n)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let u=Ba(t,e,n),o=yr(t,e),s=Ta(t,e,n);return {id:i,language:e.code,command:t.action,priority:a,template:{format:s,tokens:u},extraction:o}}function ba(t,e,r=re){if(t.roles.filter(o=>!o.required).length===0)return null;let a=t.roles.filter(o=>o.required),n={...t,roles:a};return {...pr(n,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:yr(t,e)}}function wa(t,e,r=re){let i=[];if(i.push(pr(t,e,r)),r.generateSimpleVariants){let a=ba(t,e,r);a&&i.push(a);}return i}function dr(t,e=re){let r=[],i=ua();for(let a of i){if(!t.keywords[a.action])continue;let n=wa(a,t,e);if(r.push(...n),t.eventHandler?.eventMarker){let u=Da(a,t,e);r.push(...u);}}return r}function Da(t,e,r=re){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],a=e.eventHandler.eventMarker,n=e.keywords[t.action];if(!n)return [];let o=t.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(o)i.push(Ea(t,e,n,a,r)),i.push(ga(t,e,n,a,r));else {i.push(pa(t,e,n,a,r)),i.push(da(t,e,n,a,r));let s=e.roleMarkers.destination;s&&s.primary!==a.primary&&i.push(ya(t,e,n,a,r));let l=a.primary.split(/\s+/),c=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&i.push(fa(t,e,n,a,r)),i.push(ha(t,e,n,a,r));let m=va(t,e,n,r);m&&i.push(m);}else e.wordOrder==="VSO"?o?(i.push(Je(t,e,n,a,r)),i.push(ka(t,e,n,a,r))):(i.push(Ye(t,e,n,a,r)),i.push(za(t,e,n,a,r)),e.eventHandler?.negationMarker&&i.push(Aa(t,e,n,a,r)),e.tokenization?.prefixes&&i.push(Ca(t,e,n,r))):o?i.push(Je(t,e,n,a,r)):i.push(Ye(t,e,n,a,r));return i}function Ba(t,e,r){let i=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=xa(t,e);switch(e.wordOrder){case "SVO":i.push(a),i.push(...n);break;case "SOV":i.push(...n),i.push(a);break;case "VSO":i.push(a),i.push(...n);break;default:i.push(a),i.push(...n);}return i}function xa(t,e){let r=[],i=mr(t.roles,e.wordOrder);for(let a of i){let n=Sa(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function Sa(t,e){let r=[],i=t.markerOverride?.[e.code],a=e.roleMarkers[t.role],n={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes};if(i!==void 0){let u=i?i.split(/\s+/).filter(Boolean):[];if((a?.position??"before")==="before"){for(let s of u)r.push({type:"literal",value:s});r.push(n);}else {r.push(n);for(let s of u)r.push({type:"literal",value:s});}}else if(a)if(a.position==="before"){if(a.primary){let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};r.push(u);}r.push(n);}else {r.push(n);let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};r.push(u);}else r.push(n);return r}function Fa(t,e){let r={};for(let i of t.roles){let a=i.markerOverride?.[e.code],n=e.roleMarkers[i.role];a!==void 0?r[i.role]=a?{marker:a}:{}:n&&n.primary?r[i.role]=n.alternatives?{marker:n.primary,markerAlternatives:n.alternatives}:{marker:n.primary}:r[i.role]={};}return r}function yr(t,e){let r=Fa(t,e),i={};for(let a of t.roles){let n=r[a.role]||{};!a.required&&a.default?i[a.role]={...n,default:a.default}:i[a.role]=n;}return i}function Ta(t,e,r){let i=[],n=mr(t.roles,e.wordOrder).map(u=>{let o=ma(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":i.push(r.primary,...n);break;case "SOV":i.push(...n,r.primary);break;default:i.push(r.primary,...n);}return i.join(" ")}var Pa=class{constructor(t={}){this.cache=new Map,this.config={maxSize:t.maxSize??1e3,ttlMs:t.ttlMs??0,enabled:t.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(t,e){return `${e}:${t}`}isExpired(t){return this.config.ttlMs===0?false:Date.now()-t.createdAt>this.config.ttlMs}evictLRU(){let t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++);}get(t,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(t,e),i=this.cache.get(r);if(!i){this.stats.misses++;return}if(this.isExpired(i)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),i.lastAccessed=Date.now(),this.cache.set(r,i),this.stats.hits++,i.result}set(t,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let i=this.makeKey(t,e),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:a,lastAccessed:a});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),i=this.cache.get(r);return i?this.isExpired(i)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(t,e){let r=this.makeKey(t,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let t=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:t>0?this.stats.hits/t:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(t){if(t.maxSize!==void 0)for(this.config.maxSize=t.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();t.ttlMs!==void 0&&(this.config.ttlMs=t.ttlMs),t.enabled!==void 0&&(this.config.enabled=t.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new Pa;function fr(t){return /[\u0900-\u097F\u0A8E-\u0A8F]/u.test(t)}var Ra=[{suffix:" \u0930\u0939\u093E \u0939\u0948",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:" \u0930\u0939\u0940 \u0939\u0948",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:" \u0930\u0939\u0947 \u0939\u0948\u0902",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u093E",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u0940",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u0947",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0942\u0902\u0917\u093E",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0942\u0902\u0917\u0940",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0917\u093E",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0917\u0940",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0902\u0917\u0947",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0924\u093E \u0939\u0948",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0940 \u0939\u0948",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0947 \u0939\u0948\u0902",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u093E",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0940",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0947",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0928\u093E",replacement:"",confidence:.9,type:"dictionary",minStemLength:1},{suffix:"\u093E\u092F\u093E",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093E\u092F\u0940",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093E\u092F\u0947",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u092F\u093E",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093F\u092F\u0947",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u093F\u090F",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u0908",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u090F",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u0947\u0902",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u094B",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u093E",replacement:"",confidence:.82,type:"past",minStemLength:2},{suffix:"\u0940",replacement:"",confidence:.82,type:"past",minStemLength:2},{suffix:"\u0947",replacement:"",confidence:.82,type:"past",minStemLength:2}],Er=class{constructor(){this.language="hi";}isNormalizable(t){return t.length<2?false:fr(t)}normalize(t){let e=this.tryConjugationNormalization(t);return e||ce(t)}tryConjugationNormalization(t){for(let e of Ra)if(t.endsWith(e.suffix)){let r=Array.from(t),i=Array.from(e.suffix),a=r.slice(0,r.length-i.length),n=a.join("")+e.replacement,u=e.minStemLength??1;if(a.length<u||n.length>0&&!fr(n))continue;return me(n,e.confidence,{removedSuffixes:[e.suffix],conjugationType:e.type})}return null}},gr={code:"hi",name:"Hindi",nativeName:"\u0939\u093F\u0928\u094D\u0926\u0940",direction:"ltr",script:"devanagari",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,defaultVerbForm:"imperative",verb:{position:"end",suffixes:["\u0947\u0902","\u093E","\u0940","\u0947","\u094B"],subjectDrop:true},references:{me:"\u092E\u0948\u0902",it:"\u092F\u0939",you:"\u0906\u092A",result:"\u092A\u0930\u093F\u0923\u093E\u092E",event:"\u0918\u091F\u0928\u093E",target:"\u0932\u0915\u094D\u0937\u094D\u092F",body:"\u092C\u0949\u0921\u0940"},possessive:{marker:"\u0915\u093E",markerPosition:"between",keywords:{\u092E\u0947\u0930\u093E:"me",\u092E\u0947\u0930\u0940:"me",\u092E\u0947\u0930\u0947:"me",\u0924\u0947\u0930\u093E:"you",\u0924\u0947\u0930\u0940:"you",\u0924\u0947\u0930\u0947:"you",\u0906\u092A\u0915\u093E:"you",\u0906\u092A\u0915\u0940:"you",\u0906\u092A\u0915\u0947:"you",\u0909\u0938\u0915\u093E:"it",\u0909\u0938\u0915\u0940:"it",\u0909\u0938\u0915\u0947:"it",\u0907\u0938\u0915\u093E:"it",\u0907\u0938\u0915\u0940:"it",\u0907\u0938\u0915\u0947:"it"}},roleMarkers:{patient:{primary:"\u0915\u094B",position:"after"},destination:{primary:"\u092E\u0947\u0902",alternatives:["\u0915\u094B","\u092A\u0930"],position:"after"},source:{primary:"\u0938\u0947",position:"after"},style:{primary:"\u0938\u0947",position:"after"},event:{primary:"\u092A\u0930",position:"after"}},keywords:{toggle:{primary:"\u091F\u0949\u0917\u0932",alternatives:["\u092C\u0926\u0932\u0947\u0902","\u092C\u0926\u0932"],normalized:"toggle"},add:{primary:"\u091C\u094B\u0921\u093C\u0947\u0902",alternatives:["\u091C\u094B\u0921\u093C"],normalized:"add"},remove:{primary:"\u0939\u091F\u093E\u090F\u0902",alternatives:["\u0939\u091F\u093E","\u092E\u093F\u091F\u093E\u090F\u0902"],normalized:"remove"},put:{primary:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],normalized:"put"},append:{primary:"\u091C\u094B\u0921\u093C\u0947\u0902_\u0905\u0902\u0924",alternatives:[],normalized:"append"},prepend:{primary:"\u091C\u094B\u0921\u093C\u0947\u0902_\u0936\u0941\u0930\u0942",alternatives:[],normalized:"prepend"},take:{primary:"\u0932\u0947\u0902",alternatives:["\u0932\u0947"],normalized:"take"},make:{primary:"\u092C\u0928\u093E\u090F\u0902",alternatives:["\u092C\u0928\u093E"],normalized:"make"},clone:{primary:"\u0915\u094D\u0932\u094B\u0928",alternatives:["\u092A\u094D\u0930\u0924\u093F\u0932\u093F\u092A\u093F"],normalized:"clone"},swap:{primary:"\u092C\u0926\u0932\u0947\u0902_\u0938\u094D\u0925\u093E\u0928",alternatives:[],normalized:"swap"},morph:{primary:"\u0930\u0942\u092A\u093E\u0902\u0924\u0930",alternatives:[],normalized:"morph"},set:{primary:"\u0938\u0947\u091F",alternatives:["\u0928\u093F\u0930\u094D\u0927\u093E\u0930\u093F\u0924"],normalized:"set"},get:{primary:"\u092A\u094D\u0930\u093E\u092A\u094D\u0924",alternatives:["\u092A\u093E\u090F\u0902"],normalized:"get"},increment:{primary:"\u092C\u0922\u093C\u093E\u090F\u0902",alternatives:["\u092C\u0922\u093C\u093E"],normalized:"increment"},decrement:{primary:"\u0918\u091F\u093E\u090F\u0902",alternatives:["\u0918\u091F\u093E"],normalized:"decrement"},log:{primary:"\u0932\u0949\u0917",alternatives:["\u0926\u0930\u094D\u091C"],normalized:"log"},show:{primary:"\u0926\u093F\u0916\u093E\u090F\u0902",alternatives:["\u0926\u093F\u0916\u093E"],normalized:"show"},hide:{primary:"\u091B\u093F\u092A\u093E\u090F\u0902",alternatives:["\u091B\u093F\u092A\u093E"],normalized:"hide"},transition:{primary:"\u0938\u0902\u0915\u094D\u0930\u092E\u0923",alternatives:[],normalized:"transition"},on:{primary:"\u092A\u0930",alternatives:[],normalized:"on"},trigger:{primary:"\u091F\u094D\u0930\u093F\u0917\u0930",alternatives:[],normalized:"trigger"},send:{primary:"\u092D\u0947\u091C\u0947\u0902",alternatives:["\u092D\u0947\u091C"],normalized:"send"},focus:{primary:"\u092B\u094B\u0915\u0938",alternatives:["\u0915\u0947\u0902\u0926\u094D\u0930\u093F\u0924"],normalized:"focus"},blur:{primary:"\u0927\u0941\u0902\u0927\u0932\u093E",alternatives:["\u092B\u094B\u0915\u0938_\u0939\u091F\u093E\u090F\u0902"],normalized:"blur"},empty:{primary:"\u0916\u093E\u0932\u0940-\u0915\u0930\u0947\u0902",normalized:"empty"},open:{primary:"\u0916\u094B\u0932\u0947\u0902",normalized:"open"},close:{primary:"\u092C\u0902\u0926-\u0915\u0930\u0947\u0902",normalized:"close"},select:{primary:"\u091A\u093F\u0939\u094D\u0928\u093F\u0924-\u0915\u0930\u0947\u0902",normalized:"select"},clear:{primary:"\u0938\u093E\u092B\u093C-\u0915\u0930\u0947\u0902",alternatives:["\u0938\u093E\u092B-\u0915\u0930\u0947\u0902"],normalized:"clear"},reset:{primary:"\u0930\u0940\u0938\u0947\u091F",normalized:"reset"},breakpoint:{primary:"\u092C\u094D\u0930\u0947\u0915\u092A\u094D\u0935\u093E\u0907\u0902\u091F",normalized:"breakpoint"},click:{primary:"\u0915\u094D\u0932\u093F\u0915",normalized:"click"},hover:{primary:"\u0939\u094B\u0935\u0930",alternatives:["\u090A\u092A\u0930_\u0930\u0916\u0947\u0902"],normalized:"hover"},submit:{primary:"\u0938\u092C\u092E\u093F\u091F",alternatives:["\u091C\u092E\u093E"],normalized:"submit"},input:{primary:"\u0907\u0928\u092A\u0941\u091F",alternatives:[],normalized:"input"},change:{primary:"\u092C\u0926\u0932\u093E\u0935",alternatives:["\u092A\u0930\u093F\u0935\u0930\u094D\u0924\u0928"],normalized:"change"},go:{primary:"\u091C\u093E\u090F\u0902",alternatives:["\u091C\u093E"],normalized:"go"},scroll:{primary:"\u0938\u094D\u0915\u094D\u0930\u0949\u0932",normalized:"scroll"},push:{primary:"\u0927\u0915\u0947\u0932\u0947\u0902",alternatives:["\u092A\u0941\u0936"],normalized:"push"},replace:{primary:"\u092C\u0926\u0932\u0947\u0902_\u092F\u0942\u0906\u0930\u090F\u0932",alternatives:["\u092A\u094D\u0930\u0924\u093F\u0938\u094D\u0925\u093E\u092A\u093F\u0924"],normalized:"replace"},process:{primary:"\u0938\u0902\u0938\u093E\u0927\u093F\u0924",alternatives:["\u092A\u094D\u0930\u0938\u0902\u0938\u094D\u0915\u0943\u0924"],normalized:"process"},wait:{primary:"\u092A\u094D\u0930\u0924\u0940\u0915\u094D\u0937\u093E",alternatives:["\u0930\u0941\u0915\u0947\u0902"],normalized:"wait"},fetch:{primary:"\u0932\u093E\u090F\u0902",alternatives:[],normalized:"fetch"},settle:{primary:"\u0938\u094D\u0925\u093F\u0930",alternatives:[],normalized:"settle"},if:{primary:"\u0905\u0917\u0930",alternatives:["\u092F\u0926\u093F"],normalized:"if"},when:{primary:"\u091C\u092C",normalized:"when"},where:{primary:"\u0915\u0939\u093E\u0901",normalized:"where"},else:{primary:"\u0935\u0930\u0928\u093E",alternatives:["\u0928\u0939\u0940\u0902 \u0924\u094B"],normalized:"else"},repeat:{primary:"\u0926\u094B\u0939\u0930\u093E\u090F\u0902",alternatives:["\u0926\u094B\u0939\u0930\u093E"],normalized:"repeat"},for:{primary:"\u0915\u0947 \u0932\u093F\u090F",alternatives:[],normalized:"for"},while:{primary:"\u091C\u092C \u0924\u0915",alternatives:[],normalized:"while"},continue:{primary:"\u091C\u093E\u0930\u0940",alternatives:[],normalized:"continue"},halt:{primary:"\u0930\u094B\u0915\u0947\u0902",alternatives:["\u0930\u094B\u0915"],normalized:"halt"},throw:{primary:"\u092B\u0947\u0902\u0915\u0947\u0902",alternatives:["\u092B\u0947\u0902\u0915"],normalized:"throw"},call:{primary:"\u0915\u0949\u0932",alternatives:["\u092C\u0941\u0932\u093E\u090F\u0902"],normalized:"call"},return:{primary:"\u0932\u094C\u091F\u093E\u090F\u0902",alternatives:["\u0932\u094C\u091F\u093E"],normalized:"return"},then:{primary:"\u092B\u093F\u0930",alternatives:["\u0924\u092C"],normalized:"then"},and:{primary:"\u0914\u0930",alternatives:[],normalized:"and"},end:{primary:"\u0938\u092E\u093E\u092A\u094D\u0924",alternatives:["\u0905\u0902\u0924"],normalized:"end"},js:{primary:"\u091C\u0947\u090F\u0938",alternatives:["js"],normalized:"js"},async:{primary:"\u0905\u0938\u093F\u0902\u0915",alternatives:[],normalized:"async"},tell:{primary:"\u092C\u0924\u093E\u090F\u0902",alternatives:["\u092C\u0924\u093E"],normalized:"tell"},default:{primary:"\u0921\u093F\u092B\u093C\u0949\u0932\u094D\u091F",alternatives:[],normalized:"default"},init:{primary:"\u092A\u094D\u0930\u093E\u0930\u0902\u092D",alternatives:[],normalized:"init"},behavior:{primary:"\u0935\u094D\u092F\u0935\u0939\u093E\u0930",alternatives:[],normalized:"behavior"},install:{primary:"\u0907\u0902\u0938\u094D\u091F\u0949\u0932",alternatives:[],normalized:"install"},measure:{primary:"\u092E\u093E\u092A\u0947\u0902",alternatives:[],normalized:"measure"},beep:{primary:"\u092C\u0940\u092A",alternatives:[],normalized:"beep"},break:{primary:"\u0924\u094B\u0921\u093C\u0947\u0902",alternatives:[],normalized:"break"},copy:{primary:"\u0915\u0949\u092A\u0940",alternatives:[],normalized:"copy"},exit:{primary:"\u092C\u093E\u0939\u0930",alternatives:[],normalized:"exit"},pick:{primary:"\u091A\u0941\u0928\u0947\u0902",alternatives:[],normalized:"pick"},render:{primary:"\u0930\u0947\u0902\u0921\u0930",alternatives:[],normalized:"render"},into:{primary:"\u092E\u0947\u0902",alternatives:["\u0915\u094B"],normalized:"into"},before:{primary:"\u0938\u0947 \u092A\u0939\u0932\u0947",alternatives:["\u092A\u0939\u0932\u0947"],normalized:"before"},after:{primary:"\u0915\u0947 \u092C\u093E\u0926",alternatives:["\u092C\u093E\u0926"],normalized:"after"},until:{primary:"\u0924\u0915",alternatives:[],normalized:"until"},event:{primary:"\u0918\u091F\u0928\u093E",alternatives:[],normalized:"event"},from:{primary:"\u0938\u0947",normalized:"from"},connect:{primary:"\u0915\u0928\u0947\u0915\u094D\u091F",alternatives:["\u0938\u0902\u092F\u094B\u091C\u093F\u0924"],normalized:"connect"},stream:{primary:"\u0938\u094D\u091F\u094D\u0930\u0940\u092E",alternatives:["\u0927\u093E\u0930\u093E","\u092A\u094D\u0930\u0935\u093E\u0939"],normalized:"stream"},live:{primary:"\u0932\u093E\u0907\u0935",alternatives:["\u0938\u091C\u0940\u0935","\u092A\u094D\u0930\u0924\u094D\u092F\u0915\u094D\u0937"],normalized:"live"},socket:{primary:"\u0938\u0949\u0915\u0947\u091F",alternatives:["\u0935\u0947\u092C\u0938\u0949\u0915\u0947\u091F"],normalized:"socket"}},tokenization:{particles:["\u0915\u094B","\u092E\u0947\u0902","\u092A\u0930","\u0938\u0947","\u0915\u093E","\u0915\u0940","\u0915\u0947","\u0924\u0915","\u0928\u0947"],boundaryStrategy:"space"},eventHandler:{keyword:{primary:"\u092A\u0930",alternatives:[],normalized:"on"},sourceMarker:{primary:"\u0938\u0947",position:"after"},eventMarker:{primary:"\u092A\u0930",alternatives:["\u092E\u0947\u0902"],position:"after"},temporalMarkers:["\u091C\u092C","\u091C\u092C \u092D\u0940"]}},_a=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Oa=class{constructor(t=_a){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},Na="()[]{},:;",Ma=class{constructor(t=Na){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function La(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="."){let i=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0))return t.slice(e,a+1);a++;}return null}if(r==="<"){let i=t.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return i?i[0]:null}return null}var Ia=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"}extract(t,e){let r=La(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},ja=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}};function $a(t,e){let r=t.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let i=r.match(/^https?:\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("//")){let i=r.match(/^\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("./")||r.startsWith("../")){let i=r.match(/^\.\.?\/[^\s]*/);return i?i[0]:null}if(r.startsWith("/")){let i=r.match(/^\/[^\s]*/);return i?i[0]:null}return null}var Va=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=$a(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},qa=class{constructor(){this.name="variable-ref";}canExtract(t,e){return t[e]===":"&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Be(t){let e=t.charCodeAt(0);return e>=2304&&e<=2431||e>=43232&&e<=43263}var Wa=class{constructor(){this.name="hindi-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Be(t[e])}extract(t,e){if(!this.context)throw new Error("HindiKeywordExtractor: context not set");let r=e,i="",a=e;for(;a<t.length&&(Be(t[a])||t[a]===" ");){if(t[a]===" "){if(a+1<t.length&&Be(t[a+1])){let s=t.slice(a),l=[" \u0915\u0947 \u0932\u093F\u090F"," \u0915\u0947 \u0938\u093E\u0925"," \u0915\u0947 \u092C\u093E\u0926"," \u0938\u0947 \u092A\u0939\u0932\u0947"," \u0928\u0939\u0940\u0902 \u0924\u094B"," \u091C\u092C \u0924\u0915"," \u0915\u0947 \u092C\u093E\u0930\u0947 \u092E\u0947\u0902"].find(c=>s.startsWith(c));if(l){i+=l,a+=l.length;continue}}break}i+=t[a],a++;}if(!i)return null;let n=this.context.lookupKeyword(i),u=n&&n.normalized!==n.native?n.normalized:void 0,o;if(!n&&this.context.normalizer){let s=this.context.normalizer.normalize(i);if(s.stem!==i&&s.confidence>=.7){let l=this.context.lookupKeyword(s.stem);l&&(o=l.normalized);}}return {value:i,length:a-r,metadata:{normalized:u||o}}}},hr=new Map([["\u0915\u094B",{role:"patient",confidence:.95}],["\u092E\u0947\u0902",{role:"destination",confidence:.9}],["\u092A\u0930",{role:"event",confidence:.85}],["\u0938\u0947",{role:"source",confidence:.9}],["\u0915\u093E",{role:"possessive",confidence:.95}],["\u0915\u0940",{role:"possessive",confidence:.95}],["\u0915\u0947",{role:"possessive",confidence:.95}],["\u0924\u0915",{role:"until",confidence:.9}],["\u0928\u0947",{role:"agent",confidence:.85}]]),vr=new Map([["\u0915\u0947 \u0932\u093F\u090F",{role:"purpose",confidence:.95}],["\u0915\u0947 \u0938\u093E\u0925",{role:"instrument",confidence:.95}],["\u0915\u0947 \u092C\u093E\u0926",{role:"temporal-after",confidence:.9}],["\u0938\u0947 \u092A\u0939\u0932\u0947",{role:"temporal-before",confidence:.9}],["\u0928\u0939\u0940\u0902 \u0924\u094B",{role:"conditional",confidence:.85}],["\u091C\u092C \u0924\u0915",{role:"temporal-until",confidence:.9}],["\u0915\u0947 \u092C\u093E\u0930\u0947 \u092E\u0947\u0902",{role:"about",confidence:.9}]]),Ka=class{constructor(){this.name="hindi-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){for(let[a]of vr)if(t.startsWith(a,e))return true;let r="",i=e;for(;i<t.length&&this.isDevanagari(t[i]);)r+=t[i],i++;return hr.has(r)}extract(t,e){for(let[n,u]of vr)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{role:u.role,confidence:u.confidence,variant:n}};let r="",i=e;for(;i<t.length&&this.isDevanagari(t[i]);)r+=t[i],i++;let a=hr.get(r);return a?{value:r,length:r.length,metadata:{role:a.role,confidence:a.confidence,variant:r}}:null}isDevanagari(t){let e=t.charCodeAt(0);return e>=2304&&e<=2431||e>=43232&&e<=43263}};function Ua(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Ha(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Ga=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Ua(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",a=e;for(;a<t.length&&Ha(t[a]);)i+=t[a],a++;if(!i)return null;let n=this.context.lookupKeyword(i),u=n&&n.normalized!==n.native?n.normalized:void 0;return {value:i,length:a-r,metadata:{normalized:u}}}};function Ya(){return [new Va,new ja,new qa,new Ia]}var Ja=new Set(["\u0915\u094B","\u092E\u0947\u0902","\u092A\u0930","\u0938\u0947","\u0915\u093E","\u0915\u0940","\u0915\u0947","\u0924\u0915","\u0928\u0947"]),Xa=[{native:"\u0938\u091A",normalized:"true"},{native:"\u0938\u0924\u094D\u092F",normalized:"true"},{native:"\u091D\u0942\u0920",normalized:"false"},{native:"\u0905\u0938\u0924\u094D\u092F",normalized:"false"},{native:"\u0916\u093E\u0932\u0940",normalized:"null"},{native:"\u0905\u092A\u0930\u093F\u092D\u093E\u0937\u093F\u0924",normalized:"undefined"},{native:"\u092A\u0939\u0932\u093E",normalized:"first"},{native:"\u0905\u0902\u0924\u093F\u092E",normalized:"last"},{native:"\u0905\u0917\u0932\u093E",normalized:"next"},{native:"\u092A\u093F\u091B\u0932\u093E",normalized:"previous"},{native:"\u0928\u093F\u0915\u091F\u0924\u092E",normalized:"closest"},{native:"\u092E\u0942\u0932",normalized:"parent"},{native:"\u0915\u094D\u0932\u093F\u0915",normalized:"click"},{native:"\u092A\u0930\u093F\u0935\u0930\u094D\u0924\u0928",normalized:"change"},{native:"\u091C\u092E\u093E",normalized:"submit"},{native:"\u0907\u0928\u092A\u0941\u091F",normalized:"input"},{native:"\u0932\u094B\u0921",normalized:"load"},{native:"\u0938\u094D\u0915\u094D\u0930\u0949\u0932",normalized:"scroll"},{native:"\u0915\u094B",normalized:"to"},{native:"\u0915\u0947 \u0938\u093E\u0925",normalized:"with"}],Qa=class extends le{constructor(){super(),this.language="hi",this.direction="ltr",this.initializeKeywordsFromProfile(gr,Xa),this.normalizer=new Er,this.registerExtractors(Ya()),this.registerExtractor(new oe),this.registerExtractor(new se),this.registerExtractor(new Ka),this.registerExtractor(new Wa),this.registerExtractor(new Ga),this.registerExtractor(new Oa),this.registerExtractor(new Ma);}classifyToken(t){return Ja.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":(t.startsWith(":"),"identifier")}},Za=new Qa;ye("hi",Za,gr);function zr(t){return /[\u0980-\u09FF]/u.test(t)}var en=[{suffix:"\u099A\u09CD\u099B\u09C7 \u0986\u099B\u09C7",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B \u0986\u099B\u09BF",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09C7\u09A8 \u0986\u099B\u09C7\u09A8",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u09C7\u099B\u09C7\u09A8",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09C7\u099B\u09C7",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09C7\u099B",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09AC\u09C7\u09A8",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09AC\u09C7",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09AC\u09CB",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09B2\u09C7\u09A8",replacement:"",confidence:.85,type:"past",minStemLength:1},{suffix:"\u09B2\u09CB",replacement:"",confidence:.85,type:"past",minStemLength:1},{suffix:"\u09B2",replacement:"",confidence:.85,type:"past",minStemLength:2},{suffix:"\u09C1\u09A8",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u09CB",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09C7",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09BF",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u09BE",replacement:"",confidence:.9,type:"dictionary",minStemLength:1},{suffix:"\u09C7",replacement:"",confidence:.85,type:"present",minStemLength:2},{suffix:"\u09BF",replacement:"",confidence:.85,type:"present",minStemLength:2},{suffix:"\u09CB",replacement:"",confidence:.85,type:"present",minStemLength:2}],rn=class{constructor(){this.language="bn";}isNormalizable(t){return t.length<2?false:zr(t)}normalize(t){let e=this.tryConjugationNormalization(t);return e||ce(t)}tryConjugationNormalization(t){for(let e of en)if(t.endsWith(e.suffix)){let r=Array.from(t),i=Array.from(e.suffix),a=r.slice(0,r.length-i.length),n=a.join("")+e.replacement,u=e.minStemLength??1;if(a.length<u||n.length>0&&!zr(n))continue;return me(n,e.confidence,{removedSuffixes:[e.suffix],conjugationType:e.type})}return null}},tn=new rn,Cr={code:"bn",name:"Bengali",nativeName:"\u09AC\u09BE\u0982\u09B2\u09BE",direction:"ltr",script:"bengali",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,defaultVerbForm:"imperative",verb:{position:"end",suffixes:["\u09C1\u09A8","\u09CB","\u09BE","\u09C7","\u09BF"],subjectDrop:true},references:{me:"\u0986\u09AE\u09BF",it:"\u098F\u099F\u09BF",you:"\u0986\u09AA\u09A8\u09BF",result:"\u09AB\u09B2\u09BE\u09AB\u09B2",event:"\u0998\u099F\u09A8\u09BE",target:"\u09B2\u0995\u09CD\u09B7\u09CD\u09AF",body:"\u09AC\u09A1\u09BF"},possessive:{marker:"\u09B0",markerPosition:"between",keywords:{\u0986\u09AE\u09BE\u09B0:"me",\u09A4\u09CB\u09AE\u09BE\u09B0:"you",\u0986\u09AA\u09A8\u09BE\u09B0:"you",\u09A4\u09BE\u09B0:"it",\u098F\u09B0:"it"}},roleMarkers:{patient:{primary:"\u0995\u09C7",position:"after"},destination:{primary:"\u09A4\u09C7",alternatives:["\u098F"],position:"after"},source:{primary:"\u09A5\u09C7\u0995\u09C7",position:"after"},style:{primary:"\u09A6\u09BF\u09AF\u09BC\u09C7",position:"after"},event:{primary:"\u09A4\u09C7",position:"after"}},keywords:{toggle:{primary:"\u099F\u0997\u09B2",normalized:"toggle"},add:{primary:"\u09AF\u09CB\u0997",alternatives:["\u09AF\u09CB\u0997 \u0995\u09B0\u09C1\u09A8"],normalized:"add"},remove:{primary:"\u09B8\u09B0\u09BE\u09A8",alternatives:["\u09B8\u09B0\u09BF\u09AF\u09BC\u09C7 \u09AB\u09C7\u09B2\u09C1\u09A8","\u09AE\u09C1\u099B\u09C1\u09A8"],normalized:"remove"},put:{primary:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"],normalized:"put"},append:{primary:"\u09B6\u09C7\u09B7\u09C7 \u09AF\u09CB\u0997",alternatives:[],normalized:"append"},prepend:{primary:"\u09B6\u09C1\u09B0\u09C1\u09A4\u09C7 \u09AF\u09CB\u0997",alternatives:[],normalized:"prepend"},take:{primary:"\u09A8\u09BF\u09A8",alternatives:["\u09A8\u09C7"],normalized:"take"},make:{primary:"\u09A4\u09C8\u09B0\u09BF \u0995\u09B0\u09C1\u09A8",alternatives:["\u09AC\u09BE\u09A8\u09BE\u09A8"],normalized:"make"},clone:{primary:"\u0995\u09CD\u09B2\u09CB\u09A8",alternatives:["\u09AA\u09CD\u09B0\u09A4\u09BF\u09B2\u09BF\u09AA\u09BF"],normalized:"clone"},swap:{primary:"\u09AC\u09A6\u09B2",alternatives:[],normalized:"swap"},morph:{primary:"\u09B0\u09C2\u09AA\u09BE\u09A8\u09CD\u09A4\u09B0",alternatives:[],normalized:"morph"},set:{primary:"\u09B8\u09C7\u099F",alternatives:["\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09A3"],normalized:"set"},get:{primary:"\u09AA\u09BE\u09A8",normalized:"get"},increment:{primary:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF",alternatives:["\u09AC\u09BE\u09A1\u09BC\u09BE\u09A8"],normalized:"increment"},decrement:{primary:"\u09B9\u09CD\u09B0\u09BE\u09B8",alternatives:["\u0995\u09AE\u09BE\u09A8"],normalized:"decrement"},log:{primary:"\u09B2\u0997",alternatives:["\u09B0\u09C7\u0995\u09B0\u09CD\u09A1"],normalized:"log"},show:{primary:"\u09A6\u09C7\u0996\u09BE\u09A8",alternatives:["\u09A6\u09C7\u0996\u09BE\u0993"],normalized:"show"},hide:{primary:"\u09B2\u09C1\u0995\u09BE\u09A8",alternatives:["\u09B2\u09C1\u0995\u09BE\u0993"],normalized:"hide"},transition:{primary:"\u09B8\u0982\u0995\u09CD\u09B0\u09AE\u09A3",alternatives:[],normalized:"transition"},on:{primary:"\u09A4\u09C7",alternatives:["\u098F"],normalized:"on"},trigger:{primary:"\u099F\u09CD\u09B0\u09BF\u0997\u09BE\u09B0",alternatives:[],normalized:"trigger"},send:{primary:"\u09AA\u09BE\u09A0\u09BE\u09A8",alternatives:["\u09AA\u09BE\u09A0\u09BE\u0993"],normalized:"send"},focus:{primary:"\u09AB\u09CB\u0995\u09BE\u09B8",alternatives:["\u09AE\u09A8\u09CB\u09AF\u09CB\u0997"],normalized:"focus"},blur:{primary:"\u099D\u09BE\u09AA\u09B8\u09BE",alternatives:["\u09AB\u09CB\u0995\u09BE\u09B8_\u09B8\u09B0\u09BE\u09A8"],normalized:"blur"},empty:{primary:"\u0996\u09BE\u09B2\u09BF-\u0995\u09B0\u09C1\u09A8",normalized:"empty"},open:{primary:"\u0996\u09C1\u09B2\u09C1\u09A8",normalized:"open"},close:{primary:"\u09AC\u09A8\u09CD\u09A7",normalized:"close"},select:{primary:"\u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8",normalized:"select"},clear:{primary:"\u09AA\u09B0\u09BF\u09B7\u09CD\u0995\u09BE\u09B0",normalized:"clear"},reset:{primary:"\u09B0\u09BF\u09B8\u09C7\u099F",normalized:"reset"},breakpoint:{primary:"\u09AC\u09CD\u09B0\u09C7\u0995\u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F",normalized:"breakpoint"},click:{primary:"\u0995\u09CD\u09B2\u09BF\u0995",normalized:"click"},hover:{primary:"\u09B9\u09CB\u09AD\u09BE\u09B0",alternatives:["\u0989\u09AA\u09B0\u09C7_\u09B0\u09BE\u0996\u09C1\u09A8"],normalized:"hover"},submit:{primary:"\u09B8\u09BE\u09AC\u09AE\u09BF\u099F",alternatives:["\u099C\u09AE\u09BE"],normalized:"submit"},input:{primary:"\u0987\u09A8\u09AA\u09C1\u099F",alternatives:["\u09AA\u09CD\u09B0\u09AC\u09C7\u09B6"],normalized:"input"},change:{primary:"\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8",normalized:"change"},go:{primary:"\u09AF\u09BE\u09A8",alternatives:["\u09AF\u09BE\u0993"],normalized:"go"},scroll:{primary:"\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2",normalized:"scroll"},push:{primary:"\u09AA\u09C1\u09B6",alternatives:["\u09A0\u09C7\u09B2\u09C1\u09A8"],normalized:"push"},replace:{primary:"\u09AA\u09CD\u09B0\u09A4\u09BF\u09B8\u09CD\u09A5\u09BE\u09AA\u09A8",normalized:"replace"},process:{primary:"\u09AA\u09CD\u09B0\u09B8\u09C7\u09B8",alternatives:["\u09AA\u09CD\u09B0\u0995\u09CD\u09B0\u09BF\u09AF\u09BC\u09BE"],normalized:"process"},wait:{primary:"\u0985\u09AA\u09C7\u0995\u09CD\u09B7\u09BE",normalized:"wait"},fetch:{primary:"\u0986\u09A8\u09C1\u09A8",alternatives:[],normalized:"fetch"},settle:{primary:"\u09B8\u09CD\u09A5\u09BF\u09B0",alternatives:[],normalized:"settle"},if:{primary:"\u09AF\u09A6\u09BF",alternatives:[],normalized:"if"},when:{primary:"\u09AF\u0996\u09A8",normalized:"when"},where:{primary:"\u0995\u09CB\u09A5\u09BE\u09AF\u09BC",normalized:"where"},else:{primary:"\u09A8\u09A4\u09C1\u09AC\u09BE",alternatives:["\u09A8\u09BE \u09B9\u09B2\u09C7"],normalized:"else"},repeat:{primary:"\u09AA\u09C1\u09A8\u09B0\u09BE\u09AC\u09C3\u09A4\u09CD\u09A4\u09BF",alternatives:["\u09AC\u09BE\u09B0 \u09AC\u09BE\u09B0"],normalized:"repeat"},for:{primary:"\u099C\u09A8\u09CD\u09AF",alternatives:[],normalized:"for"},while:{primary:"\u09AF\u09A4\u0995\u09CD\u09B7\u09A3",alternatives:[],normalized:"while"},continue:{primary:"\u099A\u09BE\u09B2\u09BF\u09AF\u09BC\u09C7 \u09AF\u09BE\u09A8",alternatives:[],normalized:"continue"},halt:{primary:"\u09A5\u09BE\u09AE\u09C1\u09A8",alternatives:["\u09A5\u09BE\u09AE\u09BE\u0993"],normalized:"halt"},throw:{primary:"\u09A8\u09BF\u0995\u09CD\u09B7\u09C7\u09AA",alternatives:["\u099B\u09C1\u0981\u09A1\u09BC\u09C7 \u09A6\u09BF\u09A8"],normalized:"throw"},call:{primary:"\u0995\u09B2",alternatives:["\u09A1\u09BE\u0995\u09C1\u09A8"],normalized:"call"},return:{primary:"\u09AB\u09BF\u09B0\u09C1\u09A8",alternatives:["\u09AB\u09C7\u09B0\u09A4 \u09A6\u09BF\u09A8"],normalized:"return"},then:{primary:"\u09A4\u09BE\u09B0\u09AA\u09B0",alternatives:["\u09A4\u0996\u09A8"],normalized:"then"},and:{primary:"\u098F\u09AC\u0982",alternatives:[],normalized:"and"},end:{primary:"\u09B6\u09C7\u09B7",alternatives:["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"],normalized:"end"},js:{primary:"\u099C\u09C7\u098F\u09B8",alternatives:["js"],normalized:"js"},async:{primary:"\u0985\u09CD\u09AF\u09BE\u09B8\u09BF\u0999\u09CD\u0995",alternatives:[],normalized:"async"},tell:{primary:"\u09AC\u09B2\u09C1\u09A8",alternatives:["\u09AC\u09B2"],normalized:"tell"},default:{primary:"\u09A1\u09BF\u09AB\u09B2\u09CD\u099F",alternatives:[],normalized:"default"},init:{primary:"\u09B6\u09C1\u09B0\u09C1",alternatives:[],normalized:"init"},behavior:{primary:"\u0986\u099A\u09B0\u09A3",alternatives:[],normalized:"behavior"},install:{primary:"\u0987\u09A8\u09B8\u09CD\u099F\u09B2",alternatives:[],normalized:"install"},measure:{primary:"\u09AE\u09BE\u09AA\u09C1\u09A8",alternatives:[],normalized:"measure"},beep:{primary:"\u09AC\u09C0\u09AA",alternatives:[],normalized:"beep"},break:{primary:"\u09AD\u09BE\u0999\u09C1\u09A8",alternatives:[],normalized:"break"},copy:{primary:"\u0995\u09AA\u09BF",alternatives:[],normalized:"copy"},exit:{primary:"\u09AC\u09C7\u09B0",alternatives:[],normalized:"exit"},pick:{primary:"\u09AC\u09BE\u099B\u09C1\u09A8",alternatives:[],normalized:"pick"},render:{primary:"\u09B0\u09C7\u09A8\u09CD\u09A1\u09BE\u09B0",alternatives:[],normalized:"render"},into:{primary:"\u09AD\u09BF\u09A4\u09B0\u09C7",normalized:"into"},before:{primary:"\u0986\u0997\u09C7",alternatives:[],normalized:"before"},after:{primary:"\u09AA\u09B0\u09C7",alternatives:[],normalized:"after"},until:{primary:"\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",alternatives:[],normalized:"until"},event:{primary:"\u0998\u099F\u09A8\u09BE",alternatives:[],normalized:"event"},from:{primary:"\u09A5\u09C7\u0995\u09C7",normalized:"from"},connect:{primary:"\u0995\u09BE\u09A8\u09C7\u0995\u09CD\u099F",alternatives:["\u09B8\u0982\u09AF\u09CB\u0997","\u09AF\u09C1\u0995\u09CD\u09A4"],normalized:"connect"},stream:{primary:"\u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u09AE",alternatives:["\u09B8\u09CD\u09B0\u09CB\u09A4","\u09AA\u09CD\u09B0\u09AC\u09BE\u09B9"],normalized:"stream"},live:{primary:"\u09B2\u09BE\u0987\u09AD",alternatives:["\u09B8\u09B0\u09BE\u09B8\u09B0\u09BF","\u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u0995\u09CD\u09B7"],normalized:"live"},socket:{primary:"\u09B8\u0995\u09C7\u099F",alternatives:["\u0993\u09AF\u09BC\u09C7\u09AC\u09B8\u0995\u09C7\u099F"],normalized:"socket"}},tokenization:{particles:["\u0995\u09C7","\u09A4\u09C7","\u09A5\u09C7\u0995\u09C7","\u09B0","\u098F\u09B0","\u09A6\u09BF\u09AF\u09BC\u09C7","\u099C\u09A8\u09CD\u09AF","\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4"],boundaryStrategy:"space"},eventHandler:{keyword:{primary:"\u09A4\u09C7",alternatives:["\u098F","\u09AF\u0996\u09A8"],normalized:"on"},sourceMarker:{primary:"\u09A5\u09C7\u0995\u09C7",position:"after"},eventMarker:{primary:"\u09A4\u09C7",alternatives:["\u098F"],position:"after"},temporalMarkers:["\u09AF\u0996\u09A8","\u09AF\u0996\u09A8\u0987"]}},an=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],nn=class{constructor(t=an){this.name="operator",this.operators=[...t].sort((e,r)=>r.length-e.length);}canExtract(t,e){return this.operators.some(r=>t.startsWith(r,e))}extract(t,e){for(let r of this.operators)if(t.startsWith(r,e))return {value:r,length:r.length};return null}},un="()[]{},:;",on=class{constructor(t=un){this.punctuation=t,this.name="punctuation";}canExtract(t,e){return this.punctuation.includes(t[e])}extract(t,e){let r=t[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function sn(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="."){let i=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return i?i[0]:null}if(r==="["){let i=0,a=e;for(;a<t.length;){if(t[a]==="["&&i++,t[a]==="]"&&(i--,i===0))return t.slice(e,a+1);a++;}return null}if(r==="<"){let i=t.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return i?i[0]:null}return null}var ln=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"}extract(t,e){let r=sn(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},cn=class{constructor(){this.name="event-modifier";}canExtract(t,e){if(t[e]!==".")return false;let r=t.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(t,e){let r=t.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let i=r[0],a=i.slice(1).split("(")[0],n=r[1];return {value:i,length:i.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}};function mn(t,e){let r=t.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let i=r.match(/^https?:\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("//")){let i=r.match(/^\/\/[^\s]*/);return i?i[0]:null}if(r.startsWith("./")||r.startsWith("../")){let i=r.match(/^\.\.?\/[^\s]*/);return i?i[0]:null}if(r.startsWith("/")){let i=r.match(/^\/[^\s]*/);return i?i[0]:null}return null}var pn=class{constructor(){this.name="url";}canExtract(t,e){let r=t.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(t,e){let r=mn(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},dn=class{constructor(){this.name="variable-ref";}canExtract(t,e){return t[e]===":"&&e+1<t.length&&/[a-zA-Z_]/.test(t[e+1])}extract(t,e){if(!this.canExtract(t,e))return null;let r=1;for(;e+r<t.length&&/[a-zA-Z0-9_]/.test(t[e+r]);)r++;return {value:t.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function kr(t){let e=t.charCodeAt(0);return e>=2432&&e<=2559}var yn=class{constructor(){this.name="bengali-keyword";}setContext(t){this.context=t;}canExtract(t,e){return kr(t[e])}extract(t,e){if(!this.context)throw new Error("BengaliKeywordExtractor: context not set");let r=e,i="",a=e;for(;a<t.length&&kr(t[a]);)i+=t[a],a++;if(!i)return null;let n=this.context.lookupKeyword(i),u=n&&n.normalized!==n.native?n.normalized:void 0,o;if(!n&&this.context.normalizer){let s=this.context.normalizer.normalize(i);if(s.stem!==i&&s.confidence>=.7){let l=this.context.lookupKeyword(s.stem);l&&(o=l.normalized);}}return {value:i,length:a-r,metadata:{normalized:u||o}}}},Ar=new Map([["\u0995\u09C7",{role:"patient",confidence:.95}],["\u09A4\u09C7",{role:"destination",confidence:.9}],["\u098F",{role:"event",confidence:.85}],["\u09A5\u09C7\u0995\u09C7",{role:"source",confidence:.95}],["\u09B0",{role:"possessive",confidence:.95}],["\u098F\u09B0",{role:"possessive",confidence:.95}],["\u09A6\u09BF\u09AF\u09BC\u09C7",{role:"instrument",confidence:.9}],["\u099C\u09A8\u09CD\u09AF",{role:"purpose",confidence:.9}],["\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",{role:"until",confidence:.9}],["\u09AE\u09A7\u09CD\u09AF\u09C7",{role:"location",confidence:.85}]]),fn=class{constructor(){this.name="bengali-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){let r="",i=e;for(;i<t.length&&this.isBengali(t[i]);)r+=t[i],i++;return Ar.has(r)}extract(t,e){let r="",i=e;for(;i<t.length&&this.isBengali(t[i]);)r+=t[i],i++;let a=Ar.get(r);return a?{value:r,length:r.length,metadata:{role:a.role,confidence:a.confidence,variant:r}}:null}isBengali(t){let e=t.charCodeAt(0);return e>=2432&&e<=2559}};function hn(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function vn(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var En=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return hn(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",a=e;for(;a<t.length&&vn(t[a]);)i+=t[a],a++;if(!i)return null;let n=this.context.lookupKeyword(i),u=n&&n.normalized!==n.native?n.normalized:void 0;return {value:i,length:a-r,metadata:{normalized:u}}}};function gn(){return [new pn,new cn,new dn,new ln]}var zn=new Set(["\u0995\u09C7","\u09A4\u09C7","\u09A5\u09C7\u0995\u09C7","\u09B0","\u098F\u09B0","\u09A6\u09BF\u09AF\u09BC\u09C7","\u099C\u09A8\u09CD\u09AF","\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4","\u098F","\u09AE\u09A7\u09CD\u09AF\u09C7"]),kn=[{native:"\u09B8\u09A4\u09CD\u09AF",normalized:"true"},{native:"\u09AE\u09BF\u09A5\u09CD\u09AF\u09BE",normalized:"false"},{native:"\u09B6\u09C2\u09A8\u09CD\u09AF",normalized:"null"},{native:"\u0985\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09BF\u09A4",normalized:"undefined"},{native:"\u09AA\u09CD\u09B0\u09A5\u09AE",normalized:"first"},{native:"\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0",normalized:"next"},{native:"\u0986\u0997\u09C7\u09B0",normalized:"previous"},{native:"\u09A8\u09BF\u0995\u099F\u09A4\u09AE",normalized:"closest"},{native:"\u09AE\u09C2\u09B2",normalized:"parent"},{native:"\u0995\u09CD\u09B2\u09BF\u0995",normalized:"click"},{native:"\u099C\u09AE\u09BE",normalized:"submit"},{native:"\u0987\u09A8\u09AA\u09C1\u099F",normalized:"input"},{native:"\u09B2\u09CB\u09A1",normalized:"load"},{native:"\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2",normalized:"scroll"},{native:"\u0995\u09C7",normalized:"to"},{native:"\u09B8\u09BE\u09A5\u09C7",normalized:"with"}],An=class extends le{constructor(){super(),this.language="bn",this.direction="ltr",this.initializeKeywordsFromProfile(Cr,kn),this.setNormalizer(tn),this.registerExtractors(gn()),this.registerExtractor(new oe),this.registerExtractor(new se),this.registerExtractor(new fn),this.registerExtractor(new yn),this.registerExtractor(new En),this.registerExtractor(new nn),this.registerExtractor(new on);}classifyToken(t){return zn.has(t)?"particle":this.isKeyword(t)?"keyword":t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||t.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(t)?"event-modifier":t.startsWith("#")||t.startsWith(".")||t.startsWith("[")||t.startsWith("*")||t.startsWith("<")?"selector":t.startsWith('"')||t.startsWith("'")||/^\d/.test(t)?"literal":(t.startsWith(":"),"identifier")}},Cn=new An;ye("bn",Cn,Cr);function he(t){let e=t.getAttribute("data-lang");if(e)return xe(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return xe(r);let i=typeof document<"u"?document.documentElement?.lang:null;return i&&i!=="en"?xe(i):null}function xe(t){return t.split("-")[0].toLowerCase()}var br={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],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",""]],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"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","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"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],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",""]]};function ve(t){switch(t.kind){case "event-handler":return bn(t);case "compound":return wn(t);default:return Dn(t)}}function bn(t){let e=["on"],r=t.roles.get("event");r&&e.push(te(r));let i=t.roles.get("source");if(i&&e.push("from",te(i)),t.body&&t.body.length>0){let a=t.body.map(ve);e.push(a.join(" then "));}return e.join(" ")}function wn(t){let e=t.chainType==="async"?"async":t.chainType;return t.statements.map(ve).join(` ${e} `)}function Dn(t){let e=br[t.action];if(e){let i=[t.action];for(let[a,n]of e){let u=t.roles.get(a);u&&(a==="destination"&&u.type==="reference"&&u.value==="me"||(n&&i.push(n),i.push(te(u))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(te(i));return r.join(" ")}function te(t){switch(t.type){case "literal":return typeof t.value=="string"&&t.dataType==="string"?`"${t.value}"`:String(t.value);case "selector":return t.value;case "reference":return t.value;case "property-path":return Bn(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Bn(t){let e=te(t.object),r=t.property;if(t.object.type==="reference")switch(t.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var Dr=.5,xn={confidenceThreshold:Dr,strategy:"semantic",fallbackToOriginal:true};function Sn(t,e){return typeof t=="number"?t:t[e]??t["*"]??Dr}function Se(t,e,r={}){let i={...xn,...r},a=wr(t,e,i);if(a!==null)return a;let n=Tn(t);if(n){let u=wr(n.commands,e,i);if(u!==null)return n.prefix+u}return t}function wr(t,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let i=Sn(r.confidenceThreshold,e),a=Br(t,e,i);if(a!==null)return a}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let i=Pn(t,e,r.i18nToEnglish);if(i!==null)return i}return null}var Fn=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Tn(t){let e=t.match(Fn);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function Br(t,e,r){try{let i=_n(t,e);if(i.length>1)return On(i,e,r);if(!ur(e))return null;let a=cr(t,e);return a.confidence<r||!a.node?null:ve(a.node)}catch{return null}}function Pn(t,e,r){try{let i=r(t,e);return i!==t?i:null}catch{return null}}function Rn(t){let e=["then"],r=L(t);if(r?.keywords?.then){let i=r.keywords.then;if(i.primary&&i.primary!=="then"&&e.push(i.primary),i.alternatives)for(let a of i.alternatives)e.includes(a)||e.push(a);}return e}function _n(t,e){let i=Rn(e).map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a=new RegExp(`\\s+(?:${i.join("|")})\\s+`,"i"),n=t.split(`
|
|
4
|
-
`).map(o=>o.trim()).filter(o=>o.length>0),u=[];for(let o of n){let s=o.split(a);u.push(...s);}return u}function On(t,e,r){let i=[];for(let a of t){let n=Br(a.trim(),e,r);if(n===null)return null;i.push(n);}return i.join(" then ")}function Fe(t={}){return function(r){let{internals:i}=r,a=i.runtime,n=a.getScript.bind(a);a.getScript=function(u){let o=n(u);if(!o)return null;let s=Nn(u,t);if(!s||s==="en")return o;let l=Se(o,s,t);return t.debug&&l!==o&&console.log(`[hyperscript-i18n] ${s}: "${o}" \u2192 "${l}"`),l};}}function Nn(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=he(t);return r||(e.defaultLanguage??null)}function xr(t,e,r={}){return e==="en"?t:Se(t,e,r)}nr(t=>dr(t));function Sr(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Fe()),Mn());}function Mn(){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(i=>{let a=e.getInternalData(i);a.initialized&&(a.initialized=false);}),e.processNode(document.body);}var xo=["hi","bn"];Sr();exports.plugin=Fe;exports.preprocess=xr;exports.resolveLanguage=he;exports.supportedLanguages=xo;return exports;})({});
|
|
1
|
+
var HyperscriptI18n=(function(exports){'use strict';function re(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function Me(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function Fe(i){return {type:"reference",value:i}}function _e(i,e){return {type:"property-path",object:i,property:e}}var dr=new Set(["me","you","it","result","event","target","body"]);function Qe(i,e=dr){return e.has(i)}var vt=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 Et(i){return new vt(i)}function ke(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function gt(i,e){return i?.possessive?.keywords?.[e]}var Oe=class Ce{constructor(){this.logger=Et("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 o=this.matchTokenSequence(e,r.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(a),null;let u=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-a.position,confidence:u}}matchBest(e,r,t){let a=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&a.push(s),e.reset(u);}if(a.length===0)return null;a.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let h=this.collectStopMarkers(r,l+1);if(a)for(let C of a)h.add(C);let g=[];for(;!e.isAtEnd();){let C=e.peek();if(!C||this.isStopMarker(C,h))break;g.push(C.value),e.advance();}if(g.length>0){t.set(c.role,{type:"expression",raw:g.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let h=this.collectStopMarkers(r,l+1);if(a)for(let C of a)h.add(C);if(this.matchGroupToken(e,c,t,h)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let p=c.type==="role"&&c.optional===true,d=p?e.mark():null;if(c.type==="role"&&!p){let h=l+1<r.length?r[l+1]:null;if(h?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let C=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",C),C)continue}return false}}}let E=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",E),E){p?(u=d,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let 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 o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let 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&&!ke(n.type,r.expectedTypes)?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(s.type,r.expectedTypes)?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!ke(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",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&&!ke(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=gt(this.currentProfile,a);if(!n)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),_e(Fe(n),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let 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 o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<Ce.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let 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 o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<Ce.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<Ce.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let 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(),_e(Me(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 o=a.value.slice(1);return _e(Me(r.value),o)}matchGroupToken(e,r,t,a){let n=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=Ce.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())o.has(d)||t.delete(d);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let t=new Set;for(let a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(t.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)t.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!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 Me(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return re(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return Fe(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return re(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return re(a,"string")}if(e==="true")return re(true,"boolean");if(e==="false")return re(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?re(e,"duration"):re(a,"number")}let t=parseFloat(e);return isNaN(t)?re(e,"string"):re(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 o=a>0?t/a:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let t=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(t.has(r.value))return .15;if(r.alternatives){for(let 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,o]of r.entries()){let u=a[n];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if(Ce.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}};Oe.MAX_MARKER_SCAN=3;Oe.MAX_PROPERTY_DEPTH=10;Oe.MAX_METHOD_ARGS=20;Oe.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var zt=Oe;new zt;var Ie=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}},je=class{constructor(){this.name="number";}canExtract(i,e){return /\d/.test(i[e])}extract(i,e){let r=0,t=false;for(;e+r<i.length;){let o=i[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let a=i.substring(e,e+r),n=e+r;if(n<i.length){let o=i.slice(n),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.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(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:a+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:a,length:r}}};function kt(i){return "setContext"in i&&typeof i.setContext=="function"}function Ct(i){let e={language:i.language,direction:i.direction,lookupKeyword:i.lookupKeyword.bind(i),isKeyword:i.isKeyword.bind(i),isKeywordStart:i.isKeywordStart.bind(i),...i.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:i.isKeywordStartAtBoundary.bind(i)}:{}};return i.normalizer?{...e,normalizer:i.normalizer}:e}var te=class{constructor(i,e){this.pos=0,this.tokens=i,this.language=e;}peek(i=0){let e=this.pos+i;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(i){this.pos=i.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(i){let e=[];for(;!this.isAtEnd()&&i(this.peek());)e.push(this.advance());return e}skipWhile(i){for(;!this.isAtEnd()&&i(this.peek());)this.advance();}};function I(i,e){return {start:i,end:e}}function j(i,e,r,t){if(typeof i=="object"){let{value:n,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:n,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let 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:o,stemConfidence:u,metadata:s}=t;return {value:a,kind:e,position:r,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:a,kind:e,position:r}}function Te(i){return /\s/.test(i)}function bt(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function wt(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function pe(i){return /\d/.test(i)}function At(i){return /[a-zA-Z]/.test(i)}function W(i){return /[a-zA-Z0-9_-]/.test(i)}function Dt(i,e){if(e>=i.length)return null;let r=i[e];if(!bt(r))return null;let t=e,a="";if(r==="#"||r==="."){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let o=t+1;for(;o<i.length&&W(i[o]);)o++;if(o<i.length&&i[o]==="(")return a}}else if(r==="["){let n=1,o=false,u=null,s=false;for(a+=i[t++];t<i.length&&n>0;){let l=i[t];a+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?n++:l==="]"&&n--,t++;}if(n!==0)return null}else if(r==="@"){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="*"){for(a+=i[t++];t<i.length&&W(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="<"){if(a+=i[t++],t>=i.length||!At(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];for(;t<i.length;){let n=i[t];if(n==="."){if(a+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];}else if(n==="#"){if(a+=i[t++],t>=i.length||!W(i[t]))return null;for(;t<i.length&&W(i[t]);)a+=i[t++];}else if(n==="["){let o=1,u=false,s=null,l=false;for(a+=i[t++];t<i.length&&o>0;){let c=i[t];a+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<i.length&&Te(i[t]);)a+=i[t++];if(t<i.length&&i[t]==="/")for(a+=i[t++];t<i.length&&Te(i[t]);)a+=i[t++];if(t>=i.length||i[t]!==">")return null;a+=i[t++];}return a||null}function Bt(i,e){if(e>=i.length||i[e]!=="'"||e+1>=i.length||i[e+1].toLowerCase()!=="s")return false;if(e+2>=i.length)return true;let t=i[e+2];return Te(t)||t==="*"||!W(t)}function St(i,e){if(e>=i.length)return null;let r=i[e];if(!wt(r)||r==="'"&&Bt(i,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,o=r,u=false;for(;n<i.length;){let s=i[n];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===a)return o;n++;}return o}function xt(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 Ft(i,e){if(!xt(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 Tt(i,e){if(e>=i.length)return null;let r=i[e];if(!pe(r)&&r!=="-"&&r!=="+")return null;let t=e,a="";if((i[t]==="-"||i[t]==="+")&&(a+=i[t++]),t>=i.length||!pe(i[t]))return null;for(;t<i.length&&pe(i[t]);)a+=i[t++];if(t<i.length&&i[t]===".")for(a+=i[t++];t<i.length&&pe(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 Ot=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Ot);var Pt=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"]),Rt=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],hr=class vr{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){kt(e)&&e.setContext(Ct(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&&Te(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 o of this.extractors)if(o.canExtract(e,t)){let u=o.extract(e,t);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,m={};if(u.metadata)for(let[d,f]of Object.entries(u.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(j(u.value,this.classifyToken(u.value),I(t,t+u.length),Object.keys(p).length>0?p:void 0)),t+=u.length,n=true;break}}if(!n){let o=e[t],u=this.classifyUnknownChar(o);r.push(j(o,u,I(t,t+1))),t++;}}return new te(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let 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(j(".","operator",I(r,r+1))),true;let s=r+1;for(;s<e.length&&W(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(j(".","operator",I(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[a,n]of Object.entries(e.keywords))if(t.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,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 o of n.alternatives)t.set(o,{native:o,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 Rt)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(" ")&&!Pt.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 j(t.native,"keyword",I(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 o=e[r+n.native.length];if(!(o!==void 0&&t(o)))return j(n.native,"keyword",I(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 o=e[r+n.native.length];return o===void 0||!t(o)})}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,t){let a=this.tryNormalize(e);if(!a)return null;let n=this.lookupKeyword(a.stem);if(!n)return null;let o={normalized:n.normalized,stem:a.stem,stemConfidence:a.confidence};return j(e,"keyword",I(r,t),o)}trySelector(e,r){let t=Dt(e,r);return t?j(t,"selector",I(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let a=t[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],o=t[1];return {...j(a,"event-modifier",I(r,r+a.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=St(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryNumber(e,r){let t=Tt(e,r);return t?j(t,"literal",I(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,a=false){let n=r;if(a)for(;n<e.length&&Te(e[n]);)n++;let o=e.slice(n);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(W(c))continue}return {suffix:u.suffix,endPos:n+u.length}}}return null}parseBaseNumber(e,r,t=true){let a=r,n="";if(t&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!pe(e[a]))return null;for(;a<e.length&&pe(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&pe(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,t,a={}){let{allowSign:n=true,skipWhitespace:o=false}=a,u=this.parseBaseNumber(e,r,n);if(!u)return null;let{number:s,endPos:l}=u,c=[...t,...vr.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),j(s,"literal",I(r,l))}tryUrl(e,r){let t=Ft(e,r);return t?j(t,"url",I(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!W(e[r+1]))return null;let t=r+1;for(;t<e.length&&W(e[t]);)t++;let a=e.slice(r,t);return j(a,"identifier",I(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return j(t,"operator",I(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?j(a,"operator",I(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?j(a,"punctuation",I(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let a of t)if(e.slice(r,r+a.length)===a)return j(a,"particle",I(r,r+a.length));return null}};hr.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 Ve=hr;function $e(i){return {stem:i,confidence:1}}function qe(i,e,r){return r?{stem:i,confidence:e,metadata:r}:{stem:i,confidence:e}}var Nt=Object.defineProperty,Lt=Object.getOwnPropertyNames,Tr=(i,e)=>function(){return i&&(e=(0, i[Lt(i)[0]])(i=0)),e},Mt=(i,e)=>{for(var r in e)Nt(i,r,{get:e[r],enumerable:true});};function Er(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function G(i,e,r={},t){let a=Or[i],n=Er(a,r),o=Pr[i],u=o?Er(o,r):void 0;return {code:i,message:n,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var S,Or,Pr,_t=Tr({"src/generators/schema-error-codes.ts"(){S={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"},Or={[S.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[S.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[S.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[S.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[S.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[S.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.",[S.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.",[S.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[S.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[S.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[S.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[S.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[S.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[S.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[S.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[S.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Pr={[S.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[S.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[S.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[S.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[S.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[S.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[S.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[S.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[S.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[S.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[S.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[S.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[S.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Rr={};Mt(Rr,{SchemaErrorCodes:()=>S,formatValidationResults:()=>Kt,getValidationStats:()=>Ut,validateAllKeywordCollisions:()=>Gt,validateAllSchemas:()=>Wt,validateCommandSchema:()=>Nr,validateKeywordCollisions:()=>Lr,validateRoleValues:()=>Ht});function It(i,e){return {action:i,items:e}}function Nr(i){let e=[];for(let t of i.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&rr.has(i.action)?e.push(G(S.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(G(S.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!rr.has(i.action)&&e.push(G(S.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of i.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(G(S.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":jt(i,e);break;case "on":Vt(i,e);break;case "if":case "unless":$t(i,e);break;case "repeat":case "for":case "while":qt(i,e);break}return i.roles.filter(t=>t.required).length===0&&(Mr.has(i.action)?e.push(G(S.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(G(S.NO_REQUIRED_ROLES,"warning",{}))),It(i.action,e)}function jt(i,e){let r=i.roles.find(a=>a.role==="patient"),t=i.roles.find(a=>a.role==="goal");r&&!t&&e.push(G(S.TRANSITION_MISSING_GOAL,"error",{}));}function Vt(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(G(S.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(G(S.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function $t(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(G(S.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(G(S.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function qt(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(G(S.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(G(S.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Wt(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[a,n]of Object.entries(i)){let o=Nr(n),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(a,o);}return r}function Kt(i,e={}){let r=[],{showNotes:t=false,showCodes:a=true}=e;for(let[n,o]of i){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${n}:`);for(let c of u){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 Ut(i){let e=0,r=0,t=0,a={};for(let n of i.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,a[o.code]=(a[o.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:a}}function Ht(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:S.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:S.SELECTOR_KIND_MISMATCH})));}return r}function Lr(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 o=r.get(n.primary)||[];if(o.push({command:a,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let u of n.alternatives){let s=r.get(u)||[];s.push({command:a,isPrimary:false}),r.set(u,s);}}for(let[a,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1)continue;let u=n.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:a,commands:o.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 Gt(i){let e=[];for(let[,r]of Object.entries(i)){let t=Lr(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var rr,Mr,Yt=Tr({"src/generators/schema-validator.ts"(){_t(),rr=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Mr=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint"]);}});var ye=new Map,oe=new Map,Re=new Map,tr=null;function _r(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]=_r(n,a):r[t]=a);}return r}function Zt(i,e){return _r(i,e)}function or(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=or(e);return Zt(r,i)}function He(i,e,r){ye.set(i,e),oe.set(i,r),Re.delete(i);}function Ir(i){tr=i;}var gr=new Map;function Be(i){return i.split("-")[0]}function Se(i){return i.includes("-")}function Xt(i){let e=ye.get(i);if(!e&&Se(i)){let r=Be(i);e=ye.get(r);}if(!e){let r=Array.from(ye.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return e}function Jt(i){let e=oe.get(i);if(!e&&Se(i)){let r=Be(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 or(e)}function L(i){let e=oe.get(i);return !e&&Se(i)&&(e=oe.get(Be(i))),e?or(e):void 0}function Qt(){return Array.from(ye.keys())}function jr(i){if(ye.has(i)&&oe.has(i))return true;if(Se(i)){let e=Be(i);return ye.has(e)&&oe.has(e)}return false}function ei(i,e){return Xt(e).tokenize(i)}function ne(i){let e=Re.get(i);if(!e&&Se(i)&&(e=Re.get(Be(i))),e)return e;let r=gr.get(i);if(!r&&Se(i)&&(r=gr.get(Be(i))),r)return Re.set(i,r),r;if(!tr)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let t=Jt(i),a=tr(t);return Re.set(i,a),a}function fe(i){let e="complex";return i.startsWith("#")&&!i.includes(" ")?e="id":i.startsWith(".")&&!i.includes(" ")?e="class":i.startsWith("[")&&i.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(e="element"),{type:"selector",value:i,selectorKind:e}}function _(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function be(i){return Qe(i)}function ie(i){return {type:"reference",value:i}}function de(i,e){return {type:"property-path",object:i,property:e}}function Z(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Pe(i,e,r,t,a,n){let o=new Map;o.set("event",i);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),a!==void 0&&a.length>0&&(u.parameterNames=a),u}function Di(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 Bi(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 ir(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 Si(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 We(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):i==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ve(i){let e=i.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Ee(i){let e=i.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function ge(i,e){return Vr(i,e,"source")}function ur(i,e){return Vr(i,e,"destination")}function Vr(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 xi={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)"}},Fi={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"}},Ti={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"}},Oi={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"}},Pi={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>"}},Ri={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>"}},Ni={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Li={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Mi={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},_i={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Ii={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},ji={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}]},Vi={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}]},$i={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}]},qi={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}]},Wi={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}]},Ki={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}]},Ui={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"}}]},Hi={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"}}]},Gi={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"}}]},Yi={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"}}]},Zi={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}]},Xi={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}]},Ji={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}]},Qi={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}]},ea={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}]},ra={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}]},ta={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}]},ia={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"}}]},aa={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}]},na={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}]},oa={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ua={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"'},sa={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"}}]},la={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}]},ca={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},ma={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"]}}]},pa={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}]},da={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"}}]},fa={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}]},ya={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}]},ha={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}]},va={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"}}]},Ea={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}]},ga={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}]},za={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}]},ka={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}]},Ca={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},ba={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}]},wa={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}]},Aa={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}]},Da={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Ba={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"}}]},Sa={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"}}]},xa={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Fa={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}]},Ta={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}]},Oa={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"}}]},Pa={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"}}]},Ra={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"}}]},Na={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:[]},Ma={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}]},_a={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ia={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}]},ja={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"}}]},$r={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"},Va={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},$a={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:$r}]},qa={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:$r}]},Wa={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Va}]},Ka={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},he={toggle:xi,add:Fi,remove:Ti,put:Oi,set:Pi,show:ji,hide:Vi,on:$i,trigger:qi,wait:Wi,fetch:Ki,increment:Ui,decrement:Hi,append:Gi,prepend:Yi,log:Zi,get:Xi,take:Ji,make:Qi,halt:ea,settle:ra,throw:ta,send:ia,if:aa,unless:na,else:oa,repeat:ua,for:sa,while:la,continue:ca,go:ma,scroll:ja,push:$a,replace:qa,process:Wa,transition:pa,clone:da,focus:fa,blur:ya,empty:ha,open:va,close:Ea,select:ga,clear:za,reset:ka,breakpoint:Ca,call:ba,return:wa,js:Aa,async:Da,tell:Ba,default:Sa,init:xa,behavior:Fa,install:Ta,measure:Oa,swap:Pa,morph:Ra,beep:Na,break:La,copy:Ma,exit:_a,pick:Ia,render:Ka,bind:Ri,live:Ni,eventsource:Li,socket:Mi,worker:_i,intercept:Ii,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function le(i){return he[i]}function Ua(){return Object.values(he).filter(i=>i.roles.length>0||i.bareKeyword===true)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Yt(),Rr)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(he);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
|
|
3
|
+
These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(i=>{console.debug("Schema validation skipped:",i);});function se(i,e){let r=i.possessive?.keywords?.[e];if(r)return r;let t=i.possessive?.specialForms;if(t){for(let[a,n]of Object.entries(t))if(n===e)return a}}var qr=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function zr(i,e,r,t){let a=qr.find(o=>o.lang===i);if(!a)return false;let n=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return n(e,a.end)&&n(r,a.at)&&n(t,a.of)}function Ha(i,e){let r=qr.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 er=.8,Ga=.6,Ya=.15,Za=.5,kr=.15,Cr=.1,br=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"]),Xa={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"]},Ja=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(Za,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=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")a+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(a+=er,r.has(u.role)?t+=er:n(u.role)&&(t+=er*Ga));return a>0?t/a:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*Ya}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:br.has(r.value)||r.alternatives?.some(t=>br.has(t))?kr: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 o=Xa[a];if(!o||o.length===0)continue;let u="metadata"in n?n.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-Cr,Math.min(Cr,t))}},Qa=new Ja,en=new Set(Object.values(he).filter(i=>i.bareKeyword===true).map(i=>i.action)),U=class R{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Qa;}matchPattern(e,r){let t=e.mark(),a=new Map;if(this.currentProfile=L(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 o=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:o}}matchBest(e,r){this.matchCache.clear();let t=[],a=e.position();for(let o of r){let u=e.mark(),s=`${a}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let n=t[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,t,l);let c=this.matchPatternToken(e,l,t,r[s+1]??a);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,t){if(r.has("source"))return;let a=e.peek(),n=e.peek(1);if(!a||!n||this.patternTokenWouldMatch(t,a))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(m=>m.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(a)&&n.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&a.kind==="selector"&&u(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 o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let n of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(n.includes(o)&&this.tryMatchShatteredCompound(e,n,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let t=e.mark(),a=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;a.push(o.value),e.advance();let u=e.peek();if(!u||u.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[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===n||u.alternatives?.some(s=>s.toLowerCase()===n))return _(o);return e.reset(t),null}tryMatchShatteredCompound(e,r,t){let a=r.split(t);if(a.length<2||a.some(o=>o.length===0))return false;let n=e.mark();for(let o=0;o<a.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==t)return e.reset(n),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==a[o].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(!R.tokenLooksLikeEvent(n))return r.optional||false;let g=(n.normalized??n.value).toLowerCase();if(R.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||this.currentProfile&&(se(this.currentProfile,n.value)??se(this.currentProfile,g))!==void 0||n.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(n.normalized??n.value).toLowerCase();if(R.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(r.role==="duration"){let g=(n.normalized??n.value).toLowerCase();if(R.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 o=this.tryMatchPositionalExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!We(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!We(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),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 C=this.tryMatchPostNominalPossessiveExpression(e);if(C)return t.set(r.role,C),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"||R.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&&!We(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&&!We(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 h=this.tokenToSemanticValue(n);if(!h)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(h.type)){let g=h.type==="selector"&&String(h.value).startsWith("@"),C=r.expectedTypes.some(w=>w==="expression"||w==="reference");if(!(g&&C))return r.optional||false}if(t.set(r.role,h),e.advance(),r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&"value"in h&&(t.set(r.role,_(`${String(h.value)}${g.value}`)),e.advance());let C=e.peek();if(C&&(C.kind==="particle"||C.kind==="keyword")&&(C.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(a,C)){let w=e.peek(1);if(w&&(w.kind==="selector"||w.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!t.has("source")&&t.set("source",A);}}}return true}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(t=>this.getMatchType(r,t)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e){let r=e.peek();if(!r)return null;let t=(r.normalized??r.value).toLowerCase();if(!R.POSITIONAL_KEYWORDS.has(t)&&!R.POSITIONAL_KEYWORDS.has(r.value.toLowerCase()))return null;let a=e.mark(),n=[r.normalized??r.value];e.advance();let o=e.peek();if(!o||o.kind!=="selector")return e.reset(a),null;n.push(o.value),e.advance();let u=0;for(;u++<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")&&!R.POSITIONAL_KEYWORDS.has((s.normalized??s.value).toLowerCase())&&!R.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(),o=!!t&&(t.value.toLowerCase()==="on"||n==="destination"||n==="on");return !t||!a||a.kind!=="selector"||!o?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?R.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 o=e.peek();if(!o||!R.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}a++;}if(a<2)return e.reset(r),null;let n=e.tokens.slice(t,e.position()).map(o=>o.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")&&!R.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let 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(),de(fe(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=se(this.currentProfile,s)??se(this.currentProfile,s.toLowerCase()),a)break;if(!a)return null;let n=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||Ha(this.currentProfile.code,u.value))return e.reset(n),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();if(c&&c.value.startsWith("(")){let m="",p=0,d=0;for(;!e.isAtEnd()&&d++<R.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 de(ie(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(se(this.currentProfile,p)??se(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 o=e.mark(),u=t.value;a&&(u=u.substring(1)),e.advance();let s=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let l=e.peek();if(!l)return e.reset(o),null;let c;for(let m of [l.value,l.normalized].filter(Boolean))if(c=se(this.currentProfile,m)??se(this.currentProfile,m.toLowerCase()),c)break;return c?(e.advance(),de(ie(c),s)):(e.reset(o),null)}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]).has(e.toLowerCase())}static tokenLooksLikeEvent(e){if(e.kind==="selector"||e.kind==="url"||e.kind==="literal")return false;let r=e.value;if(/[/#@*]/.test(r)||r.startsWith('"')||r.startsWith("'")||r.startsWith("`"))return false;let t=e.normalized?.toLowerCase();return !(t&&en.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,o=0;for(;!e.isAtEnd()&&o++<R.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")n++;else if(u.value==="}"&&(n--,n===0))return a.push("}"),_(a.join(" "));a.push(u.value);}return e.reset(t),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let t=e.peek(1);if(!t||t.value!=="(")return null;let a=e.mark();e.advance(),e.advance();let n=[],o=false,u=0;for(;!e.isAtEnd()&&u++<R.MAX_METHOD_ARGS+2;){let s=e.peek();if(!s)break;if(s.value===")"){e.advance(),o=true;break}if(s.value===","){e.advance();continue}n.push(s.value),e.advance();}return o?{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 o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<R.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${u.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(),o=e.peek();if((t.kind==="identifier"||R.PROPERTY_ACCESS_BASES.has(n))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let d=t.value,f=[],E=0;for(;E<R.MAX_PROPERTY_DEPTH;){let C=e.peek();if(C&&C.kind==="selector"&&/^\.[a-zA-Z_]/.test(C.value))d+=`.${C.value.slice(1)}`,f.push(C.value.slice(1)),e.advance(),E++;else break}let h=e.peek(),g=!!h&&h.value.startsWith("(");if(r&&!g&&f.length>0&&be(n))return de(ie(n),f.join("."));if(g){let C=e.mark(),w=[],A=0,z=false;for(;!e.isAtEnd();){let v=e.peek();if(!v)break;if(v.value==="(")A++;else if(v.value===")"){if(w.push(v.value),e.advance(),A--,A===0&&(z=true),z)break;continue}w.push(v.value),e.advance();}z?d+=w.join(""):e.reset(C);}return {type:"expression",raw:d}}let u=e.peek();if(!u||u.kind!=="operator"||u.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<R.MAX_PROPERTY_DEPTH;){let d=e.peek();if(!d||d.kind!=="operator"||d.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let m=e.peek();if(m&&m.kind==="punctuation"&&m.value==="("){e.advance();let d=[],f=0;for(;!e.isAtEnd()&&d.length<R.MAX_METHOD_ARGS;){let h=e.peek();if(!h)break;if(h.kind==="punctuation"&&h.value===")"){if(f===0){e.advance();break}f--;}if(h.kind==="punctuation"&&h.value==="("&&f++,h.kind==="punctuation"&&h.value===","){e.advance();continue}d.push(h.value),e.advance();}return {type:"expression",raw:`${l}(${d.join(", ")})`}}let p=t.value.toLowerCase();if(r&&be(p)){let d=l.split(".").slice(1).join(".");return de(ie(p),d)}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek(),n=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!a&&a.kind==="punctuation"&&a.value==="'s",u=!!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(!o&&!l&&!u)return e.reset(t),null;e.advance(),u&&e.advance();let c=e.peek();return !c||!(c.kind==="identifier"||(o||u)&&(c.kind==="selector"||c.kind==="keyword"))?(e.reset(t),null):(e.advance(),de(fe(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 o=a.value.slice(1);return de(fe(r.value),o)}matchGroupToken(e,r,t,a){let n=e.mark(),o=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t,a)){e.reset(n);for(let s of t.keys())o.has(s)||t.delete(s);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return fe(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return be(r)?ie(r):_(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return fe(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ie(e.value);let t=e.value.toLowerCase();return be(t)?ie(t):{type:"expression",raw:e.value};case "url":return _(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return _(a,"string")}if(e==="true")return _(true,"boolean");if(e==="false")return _(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?_(e,"duration"):_(a,"number")}let t=parseFloat(e);return isNaN(t)?_(e,"string"):_(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(R.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 o=e.peek(1);if(n&&n.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let u=n?(n.normalized??n.value).toLowerCase():"";if(n&&R.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&R.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||R.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(n&&n.kind==="keyword"&&this.currentProfile?.code!=="en"&&be(u)&&m||n&&n.kind==="keyword"&&this.currentProfile?.code==="en"&&be(u))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}};U.POSITIONAL_KEYWORDS=new Set(["first","last","next","previous","random","closest"]);U.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);U.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then"]);U.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);U.COMMAND_ACTION_KEYWORDS=new Set(Object.keys(he).map(i=>i.toLowerCase()));U.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);U.OF_POSSESSIVE_MARKERS={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin"])};U.RUN_OPERATORS=new Set(["+","-","*","/"]);U.MAX_BRACE_RUN_TOKENS=64;U.MAX_PROPERTY_DEPTH=10;U.MAX_METHOD_ARGS=20;U.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);U.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var rn=U,Q=new rn;function H(i,e){return ei(i,e)}function Wr(){return Qt()}var Ge=["if","unless","repeat","for","while"];function ae(i,e){let r=new Set([e]),a=L(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 X(i,e){return e.has(i.value.toLowerCase())?true:i.normalized?e.has(i.normalized.toLowerCase()):false}var tn=new Set(Ge);function sr(i,e){let r=i.normalized?.toLowerCase();return r?tn.has(r):e.some(t=>X(i,t))}var wr=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),an=new Set(["destination","source","style","patient","on","from","to"]);function nn(i){if(!i||i.kind==="selector")return false;let e=(i.normalized??i.value).toLowerCase(),r=i.value.toLowerCase();return !(wr.has(e)||wr.has(r)||an.has(e))}var Ar=new Set(["ja","ko"]);function ar(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 Kr(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 o=n.trim();o&&r.push(o);}}return {parameters:r,headerEnd:t}}function Ur(i,e,r){let t=e+1;if(t>=i.length)return -1;let a=ar(L(r)?.roleMarkers?.patient);return a.size>0&&X(i[t],a)&&t++,t<i.length?t:-1}function on(i,e,r){if(!L(e))return null;let t=ae(e,"behavior"),a=ae(e,"def"),n=i.toLowerCase(),o=[...t].some(c=>n.includes(c)),u=/\bdef\b/.test(n)||[...a].some(c=>c!=="def"&&n.includes(c));if(!o&&!u)return null;let s=H(i,e).tokens;if(s.length<2)return null;if(X(s[0],t))return Dr(i,e,s,r,0);let l=s.findIndex((c,m)=>m>0&&X(c,t));return l>0&&/^[A-Z][A-Za-z0-9_]*$/.test(s[0].value)?Dr(i,e,s,r,l):X(s[0],a)?sn(i,e,s,r):null}function un(i,e,r){let t=L(e);if(!t)return null;let a=t.wordOrder!=="SOV",n=Ar.has(e)?ar(t.roleMarkers?.event):new Set,o=Ar.has(e)?ar(t.keywords?.on):new Set,u=n.size>0&&o.size>0,s=ae(e,"end"),l=ae(e,"on"),c=i.toLowerCase(),m=[...s].some(v=>c.includes(v)),p=(a||u)&&(()=>{let v=0;for(let b of l)if(b){for(let y=c.indexOf(b);y>=0;y=c.indexOf(b,y+b.length))if(++v>=2)return true}return false})();if(!m&&!p)return null;let d=H(i,e).tokens;if(d.length<2)return null;let f=Ge.map(v=>ae(e,v)),E=v=>sr(v,f),h=v=>X(v,s),g=[],C=0,w=0;for(let v=0;v<d.length;v++){let b=d[v];if(h(b)){if(C>0){C--;continue}let y=i.slice(d[w].position.start,b.position.start).trim();y&&g.push(y),w=v+1;}else if(E(b))C++;else if(a&&C===0&&v>w&&X(b,l)&&nn(d[v+1])){let y=i.slice(d[w].position.start,b.position.start).trim();y&&g.push(y),w=v;}else if(u&&C===0&&v-1>w&&X(b,n)&&d[v+1]!==void 0&&X(d[v+1],o)){let y=d[v-1],k=i.slice(d[w].position.start,y.position.start).trim();k&&g.push(k),w=v-1;}}if(w<d.length){let v=i.slice(d[w].position.start).trim();v&&g.push(v);}if(g.length<2)return null;let A=[],z=[];for(let v of g){let b;try{b=r.statement(v,e);}catch{return null}if(!b||b.kind!=="event-handler")return null;let y=b;A.push(y);let k=!y.body||y.body.length===0;z.push(k?.2:y.metadata?.confidence??.75);}return ir(A,"then",{sourceLanguage:e,confidence:Ke(z),sourceText:i})}function Ke(i){return i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0}function Hr(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 Dr(i,e,r,t,a){let n=a>0,o=n?0:Ur(r,a,e);if(o<0)return null;let u=r[o],s=u.value;if(!/^[A-Z][A-Za-z0-9_]*$/.test(s))return null;let{parameters:l,headerEnd:c}=Kr(i,u),m=n?a+1:r.findIndex(y=>y.position.start>=c);m<=o&&(m=o+1);let p=ae(e,"init"),d=ae(e,"end"),f=Ge.map(y=>ae(e,y)),E=y=>sr(y,f),h=y=>X(y,d),g=[],C=[],w=[],A=false,z=0,v=m;for(let y=m;y<r.length;y++){let k=r[y];if(h(k)){if(z>0){z--;continue}if(y===v){A=true;break}if(X(r[v],p)){let B=i.slice(r[v].position.end,k.position.start).trim();if(B)try{let D=Hr(t.body(B,e));C.push(...D),w.push(Ke(D.map(O=>O.metadata?.confidence??.75)));}catch{w.push(0);}}else {let B=i.slice(r[v].position.start,k.position.start).trim();try{let D=t.statement(B,e);if(D&&D.kind==="event-handler"){let O=D;g.push(O);let x=!O.body||O.body.length===0;w.push(x?.2:O.metadata?.confidence??.75);}else w.push(0);}catch{w.push(0);}}v=y+1;}else E(k)&&z++;}if(g.length===0&&C.length===0)return null;let b=(A?1:.8)*Ke(w);return Di(s,l,g,C.length>0?C:void 0,{sourceLanguage:e,confidence:b,sourceText:i})}function sn(i,e,r,t){let a=Ur(r,0,e);if(a<0)return null;let n=r[a],o=n.value;if(!/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/.test(o))return null;let{parameters:u,headerEnd:s}=Kr(i,n),l=r.findIndex(z=>z.position.start>=s);l<=a&&(l=a+1);let c=ae(e,"end"),m=Ge.map(z=>ae(e,z)),p=z=>sr(z,m),d=z=>X(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 h=r[l]?.position.start??s,g=E>=0?r[E].position.start:i.length,C=i.slice(h,g).trim();if(!C)return null;let w;try{w=Hr(t.body(C,e));}catch{return null}if(w.length===0)return null;let A=Ke(w.map(z=>z.metadata?.confidence??.75));return E<0&&(A*=.8),Bi(o,u,w,{sourceLanguage:e,confidence:A,sourceText:i})}var Ae={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};Object.fromEntries(Object.entries(Ae).map(([i,e])=>{let r={};for(let[t,a]of Object.entries(e))a in r||(r[a]=t);return [i,r]}));var we=new Set(["if","unless","while","repeat","for"]),dn=new Set(["then","end","else","if","unless","while","for","repeat","and"]),fn=new Set(["first","last","next","previous","random","closest"]),De=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Br=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function M(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function K(i,e){return e.length===0?i:{...i,diagnostics:e}}function Sr(i){if(i.length>=2){let e=i[0];if((e==='"'||e==="'")&&i.endsWith(e))return i.slice(1,-1)}return i}var yn=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function Gr(i,e){if(!i||typeof i!="object")return i;if(i.action&&i.roles instanceof Map){let t=le(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,o=n.get("patient");o!==void 0&&(n.delete("patient"),n.set(a,o));}if(i.action==="tell"){let n=i.roles,o=n.get("patient"),u=n.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(n.delete("patient"),n.set("destination",o));}if(i.action==="transition"){let n=i.roles,o=n.get("destination");o&&o.type==="literal"&&!n.has("goal")&&(n.delete("destination"),n.set("goal",o));let u=n.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&n.set("patient",{type:"expression",raw:u.value});}if(i.action==="morph"){let n=i.roles,o=n.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&n.set("patient",{type:"expression",raw:o.value});}if(i.action==="wait"){let n=i.roles;if(!n.has("event")){let o=n.get("duration"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&De.has(u.toLowerCase())&&(n.delete("duration"),n.set("event",{type:"literal",value:u,dataType:"string"}));}}if(i.kind==="command"&&i.action!=="on"){let n=i.roles,o=n.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&n.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let n=i.roles;for(let o of ["destination","source"]){let u=n.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&n.set(o,{type:"expression",raw:u.value});}}}let r=i;for(let t of yn){let a=r[t];if(Array.isArray(a))for(let n of a)Gr(n,e);}return i}var J=class T{constructor(){this.parseDepth=0,this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++;try{return Gr(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=on(e,r,{statement:(y,k)=>this.parse(y,k),body:(y,k)=>this.parseStatements(y,k)});if(t)return t;let a=un(e,r,{statement:(y,k)=>this.parse(y,k),body:(y,k)=>this.parseStatements(y,k)});if(a)return a;let{modifiers:n,remainingInput:o}=this.extractStandaloneModifiers(e,r),u=o||e,l=this.stripAsyncModifier(u,r).remainingInput??u,m=this.stripDoNotThrowModifier(l,r).remainingInput??l,p=[],d=H(m,r),f=ne(r);if(f.length===0)throw new Br(`No patterns available for language: ${r}`,r,m,[M(`No patterns registered for language '${r}'`,"error","no-patterns")]);let E=[...f].sort((y,k)=>k.priority-y.priority);{let y=d.tokens;if(L(r)?.wordOrder==="VSO"&&y.length>=4&&y[0]?.normalized==="source"){let k=y.findIndex(B=>B.normalized==="on");if(k>=2&&k+1<y.length){let B=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)+" "+B+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 K(F,p)}}catch{}}}}{let y=d.tokens;for(let k=1;k<y.length-1;k++){let B=y[k],D=B.value,O=(B.normalized??B.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 P=k+1,$=y[k+2];$&&$.kind==="selector"&&$.value.startsWith("[")&&(P=k+2);let q=y[k].position.start,ce=y[P].position.end,ee=(m.slice(0,q).trimEnd()+" "+m.slice(ce).trimStart()).trim();if(ee&&ee!==m)try{let me=this.parse(ee,r);if(me&&me.kind==="event-handler"){me.additionalEvents=[{type:"literal",value:N}];let Je=n?this.applyModifiers(me,n):me;return K(Je,p)}}catch{}break}}let h=E.filter(y=>y.command==="on"),g=d.mark(),C=Q.matchBest(d,h);if(C){p.push(M(`event pattern matched: ${C.pattern.id} (confidence: ${C.confidence.toFixed(2)})`,"info","pattern-match"));let y=false;if(/^event-[a-z]+-bare$/.test(C.pattern.id)){let k=C.captured.get("event"),B=(k?.raw??k?.value??"").toString().toLowerCase(),D=Ae[r],O=T.KNOWN_EVENTS.has(B)||!!D&&Object.keys(D).some(x=>x.toLowerCase()===B);if(B&&!O){let x=this.trySOVEventExtraction(m,r,E);if(x){p.push(M(`bare-event mis-anchor on "${B}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let F=n?this.applyModifiers(x,n):x;return K(F,p)}if(k?.type==="reference"||k?.type==="expression"){d.reset(g);let F=E.filter(P=>P.command!=="on"),N=Q.matchBest(d,F);d.reset(g),N&&N.pattern.command!=="on"?(y=true,p.push(M(`bare-event mis-anchor on reference "${B}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):Q.matchBest(d,h);}}}if(!y){let k=this.buildEventHandler(C,d,r),B=n?this.applyModifiers(k,n):k;return K(B,p)}}p.push(M(`event patterns: ${h.length} tried, no match`,"info","stage-event"));let w=this.tryTrailingEventExtraction(m,r,E);if(w){p.push(M("trailing event extraction succeeded","info","stage-trailing-event"));let y=n?this.applyModifiers(w,n):w;return K(y,p)}let A=E.filter(y=>y.command!=="on"),z=Q.matchBest(d,A);if(z){if(we.has(z.pattern.command)){let y=this.trySOVEventExtraction(m,r,E);if(y){p.push(M(`SOV event extraction preferred over bare ${z.pattern.command} command`,"info","stage-sov-loop"));let B=n?this.applyModifiers(y,n):y;return K(B,p)}let k=this.tryMidStreamEventExtraction(m,r,E);if(k){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-loop"));let B=n?this.applyModifiers(k,n):k;return K(B,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(M(`SOV event extraction preferred over command-homonym event ${z.pattern.command}`,"info","stage-sov-homonym"));let k=n?this.applyModifiers(y,n):y;return K(k,p)}}else if(L(r)?.wordOrder==="VSO"){let y=this.tryMidStreamEventExtraction(m,r,E);if(y){p.push(M(`mid-stream event extraction preferred over bare ${z.pattern.command} command`,"info","stage-midstream-cmd"));let k=n?this.applyModifiers(y,n):y;return K(k,p)}}if(z.consumedTokens<d.tokens.length&&L(r)?.wordOrder==="SOV"){let y=this.trySOVEventExtraction(m,r,E);if(y){p.push(M(`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 K(k,p)}}return p.push(M(`command pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match")),K(this.buildCommand(z,r),p)}if(p.push(M(`command patterns: ${A.length} tried, no match`,"info","stage-command")),!m.includes(`
|
|
4
|
+
`)&&L(r)?.wordOrder==="VSO"){let y=this.tryMidStreamEventExtraction(m,r,E);if(y){p.push(M("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let k=n?this.applyModifiers(y,n):y;return K(k,p)}}let v=this.trySOVEventExtraction(m,r,E);if(v){p.push(M("SOV event extraction succeeded","info","stage-sov"));let y=n?this.applyModifiers(v,n):v;return K(y,p)}p.push(M("SOV event extraction: no event keyword found","info","stage-sov"));let b=this.tryCompoundCommandParsing(d,A,r);if(b)return p.push(M("compound command parsing succeeded","info","stage-compound")),K(b,p);throw p.push(M("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(M(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Br(`Could not parse input in ${r}: ${m}`,r,m,p)}parseStatements(e,r){let t=H(e,r),a=ne(r).filter(n=>n.command!=="on").sort((n,o)=>o.priority-n.priority);return this.parseBodyWithClauses(t,a,r)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Wr()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[n,o]of e.captured)t[n]=o;let a=Z(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=Q.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,t),u=a;o.length>0&&a.type==="literal"&&(u={type:"literal",value:[String(a.value),...o.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=ne(t).filter(h=>h.command!=="on").sort((h,g)=>g.priority-h.priority),d=new te(c.slice(m),t),f=this.parseBodyWithClauses(d,p,t);if(f.some(h=>h.kind==="conditional")||f.length===1&&f[0]?.kind==="compound"&&f[0].statements.some(h=>h.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return Pe(u,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=b=>(b.normalized??b.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 b=r.peek();if(b)for(m.event={type:"literal",value:z(b)},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 v=m.patient;v&&v.type==="reference"&&v.value==="me"&&delete m.patient;}let p=Z(c,m,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence});if(this.registerBoundIdentifiers(p),!we.has(c)||c==="repeat"){let A=e.pattern.id.includes("verb-first"),z=r.tokens,v=r.position(),b=k=>k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,t)||this.isEndKeyword(k.value,t)),y=-1;for(let k=v-1;k>=0;k--){let B=z[k];if(b(B))break;if((B.normalized??B.value).toLowerCase()===c){y=k;break}}if(y>=0){let k=v;for(;k<z.length&&!b(z[k]);)k++;let B=z.slice(y,k),D=B;if(A){let O=String(a.value??"").toLowerCase(),x=B.findIndex(F=>(F.normalized??F.value).toLowerCase()===O);if(x<0)D=null;else {let F=B[x-1],N=F&&F.kind==="keyword"&&F.normalized?.toLowerCase()==="on"?x-1:x;D=[...B.slice(0,N),...B.slice(x+1)];}}if(D&&D.length>1){let O=ne(t).filter(V=>V.command!=="on").sort((V,ue)=>ue.priority-V.priority),x=this.parseClause(D,O,t),F=x[0],N=V=>V!==null&&typeof V=="object"&&typeof V.type=="string"?V.type:typeof V,P=le(c),$=P?.primaryRole,q=V=>V==="patient"&&$&&$!=="patient"&&!P?.roles.some(ue=>ue.role==="patient")?$:V,ce=(V,ue)=>{if(!we.has(c)||!P)return false;let ze=P.roles.find(yt=>yt.role===q(V));return ze?ze.expectedTypes.length>0&&!ze.expectedTypes.includes(N(ue)):true},ee=!!F&&F.kind==="command"&&Object.entries(m).every(([V,ue])=>{if(ce(V,ue))return true;let ze=F.roles.get(q(V));return ze!==void 0&&N(ze)===N(ue)}),me=F?.metadata?.patternId??"",Je=!we.has(c)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(me);if(x.length===1&&F&&F.kind==="command"&&F.action===c&&ee&&Je&&F.roles.size>Object.keys(m).length)for(p=F;r.position()<k;)r.advance();}}}if(!we.has(c)){let A=p;if(le(c)?.roles.some(D=>D.role==="quantity"&&!D.required)&&!A.roles.has("quantity")){let D=r.peek();D&&/^-?\d+(\.\d+)?$/.test(D.value)&&(p=Z(c,{...Object.fromEntries(A.roles),quantity:{type:"literal",value:parseFloat(D.value),dataType:"number"}},A.metadata),r.advance());}let v=p;if(le(c)?.roles.some(D=>D.role==="duration"&&!D.required)&&!v.roles.has("duration")){let D=r.peek();D&&/^\d+(\.\d+)?(ms|s)$/i.test(D.value)&&(p=Z(c,{...Object.fromEntries(v.roles),duration:{type:"literal",value:D.value,dataType:"string"}},v.metadata),r.advance(),this.consumeForPostposition(r,t));}let y=p,k=le(c);if(k?.roles.find(D=>D.role==="responseType"&&!D.required)&&!y.roles.has("responseType")){let D=P=>typeof P=="string"&&T.RESPONSE_TYPE_WORDS.has(P.toLowerCase()),O=(P,$)=>{let q=Object.fromEntries(y.roles);$&&delete q.destination,q.responseType={type:"expression",raw:P},p=Z(c,q,y.metadata);},x=y.roles.get("destination"),F=k?.roles.find(P=>P.role==="destination"),N=x?.raw??x?.value;if(x&&F&&!F.expectedTypes.includes(x.type)&&D(N))O(N,true);else {let P=r.peek();P&&D(P.value)&&(O(P.value,false),r.advance());}}if(c==="wait"){let D=p;if(!D.roles.has("event")){let O=r.peek();if(O&&De.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=Z(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(),h=!!E&&this.isThenKeyword(E.value,t),C=we.has(c)&&!!E&&!this.isEndKeyword(E.value,t),w=!!E&&!this.isEndKeyword(E.value,t);if(f||h||C||w){let A=ne(t).filter(b=>b.command!=="on").sort((b,y)=>y.priority-b.priority),z=ne(t).filter(b=>b.id.startsWith("grammar-")&&b.id.includes("-continuation")).sort((b,y)=>y.priority-b.priority),v=this.parseBodyWithGrammarPatterns(r,A,z,t);v.length>0?s=[p,...v]:s=[p];}else s=[p];}else {let c=ne(t).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,t);}return Pe(u,s,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let a=[],n=[],o=0,u=[];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"||zr(t,s.value,c?.value,m?.value),d=s.kind==="keyword"&&this.isEndKeyword(s.value,t)&&!p;if(d&&o>0){o--,u.pop(),n.push(s),e.advance();continue}if(l&&u.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,o=f.filter(E=>{let h=E;return (h.action==="for"||h.action==="repeat"||h.action==="while")&&(!Array.isArray(h.body)||h.body.length===0)}).length,u.length=0;for(let E=0;E<o;E++)u.push("other");}e.advance();continue}if(d){e.advance();let 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")&&(o++,u.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?[ir(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 o=a.roles.get("condition");if(!o||n.roles.has("condition")||Array.isArray(a.body)||Array.isArray(n.body))continue;let u=new Map(n.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(t,2,{...n,roles:u,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,o=e[e.length-1];if(o&&e.length>=2){let h=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(h,t)&&(a="unless",n=e.slice(0,-1));}let u=null;if(a&&n.length>=3){let h=L(t),g=h?T.buildVerbLookup(h):null;if(g)for(let C=1;C<n.length-1;C++){let w=n[C],A=g.get(w.value.toLowerCase())??(w.normalized?g.get(w.normalized.toLowerCase()):void 0);if(A&&!T.CONDITION_OPERATORS.has(A)){u=n.slice(0,C),n=n.slice(C);break}}}let s=new te(n,t),l=[],c=0,m=[],p=u,d=()=>{if(m.length===0)return;let h=m.slice();if(m.length=0,a&&l.length===0&&p===null){p=h;return}let g=h[0];if(g&&(g.kind==="identifier"||g.kind==="selector"||g.kind==="literal"||g.kind==="reference"))for(let w of this.parseSOVClauseByVerbAnchoring(h,t)){let A=w.action,z=w.roles;A&&le(A)&&z instanceof Map&&z.size>0&&l.push(w);}};for(;!s.isAtEnd();){let h=s.peek(),g=!!h&&h.normalized?.toLowerCase()==="repeat",C=s.mark(),w=Q.matchBest(s,r);if(g&&w&&w.pattern.command!=="repeat"){s.reset(C),d(),l.push(Z("repeat",{},{sourceLanguage:t,confidence:.6})),c++,s.advance();continue}if(w&&w.pattern.command==="if"){let A=s.mark(),z=m.length;for(s.reset(C);!s.isAtEnd();){let b=s.peek();if(!b||this.isIfKeyword((b.normalized??b.value).toLowerCase(),t))break;m.push(b),s.advance();}let v=this.tryParseConditionalBlock(s,r,t);if(v){d(),l.push(v),c++;continue}m.length=z,s.reset(A);}if(w){d();let A=this.buildCommand(w,t);l.push(A),c++,this.tryAttachTrailingRole(s,A,t);}else {let A=s.peek();A&&A.normalized?.toLowerCase()==="repeat"?(d(),l.push(Z("repeat",{},{sourceLanguage:t,confidence:.6})),c++):A&&m.push(A),s.advance();}}d();let f=l;if(c===0){let h=this.parseSOVClauseByVerbAnchoring(n,t);h.length>0&&(f=h);}let E=p;return a&&f.length>0&&E&&E.length>0?[Z(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=le(r.action);if(!a)return;let n=L(t);if(!n)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return dn.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(h=>h.role===l))continue;let m=n.roleMarkers?.[l];if(!m)continue;let p=o.get(l);if(p&&!(p.type==="reference"&&p.value==="me"))continue;let d=h=>{if(!h||h.kind!=="particle"&&h.kind!=="keyword")return false;let g=h.value.toLowerCase();return m.primary?.toLowerCase()===g?true:c?false:(h.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(C=>C.toLowerCase()===g)},f=e.peek(),E=e.peek(1);if(!f||!E)return;if(c&&m.position==="after"){let h=e.peek(2),g=(f.normalized??f.value).toLowerCase();if(fn.has(g)&&E.kind==="selector"&&d(h)){o.set(l,{type:"expression",raw:`${g} ${E.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(u(f,c)&&d(E)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),h&&o.set(l,h);return}}else if(d(f)&&u(E,c)){e.advance();let h=this.tokenToSemanticValue(e.advance());h&&o.set(l,h);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 o of a.alternatives)r.has(o)||r.set(o,t);}return r}parseSOVClauseByVerbAnchoring(e,r){let t=L(r);if(!t||t.wordOrder!=="SOV")return [];let a=T.buildVerbLookup(t),n=T.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let E=e[f];if(n.has(E.value))continue;let h=a.get(E.value.toLowerCase()),g=E.normalized?a.get(E.normalized.toLowerCase()):void 0,C=h||g;if(C){s=f,l=C;break}}if(s===-1)break;let c=e.slice(u,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(o.push(Z(l,d,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let f=e[u];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,a,n){let o={},u=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,o);d&&(o[d]=p);}l=[];}else l.push(c);}if(l.length>0)if(l.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(l[0].value)&&!o.duration&&le(a)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:l[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(l);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return u(e),u(r),o}mapRoleForCommand(e,r,t){return t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(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("*")?fe(t):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?_(Sr(t),"string"):a.kind==="reference"?ie(t):_(t)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return fe(r);if(r.startsWith('"')||r.startsWith("'"))return _(Sr(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return _(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return _(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return _(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?ie(t):e.kind==="reference"?ie(e.normalized||"me"):_(r)}parseBodyWithGrammarPatterns(e,r,t,a){let n=[],o=[],u=false,s=()=>{!u&&o.length>0&&n.push(...this.parseSOVClauseByVerbAnchoring(o,a)),o=[],u=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(!zr(a,m.value,d?.value,f?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!u&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),a)){s();let d=this.tryParseConditionalBlock(e,r,a);if(d){n.push(d),u=true;continue}}let p=false;if(t.length>0){let d=Q.matchBest(e,t);if(d){let f=d.pattern.command,E={};for(let[C,w]of d.captured)C!=="event"&&C!=="action"&&C!=="continues"&&(E[C]=w);let h=Z(f,E,{sourceLanguage:a,patternId:d.pattern.id});n.push(h),p=true,u=true;let g=d.captured.get("continues");if(g&&g.type==="literal"&&g.value==="then")continue}}if(!p){let d=e.mark(),f=Q.matchBest(e,r);if(f){if(f.pattern.command==="if"){let h=e.mark();for(e.reset(d);!e.isAtEnd();){let C=e.peek();if(!C||this.isIfKeyword((C.normalized??C.value).toLowerCase(),a))break;e.advance();}let g=this.tryParseConditionalBlock(e,r,a);if(g){s(),n.push(g),u=true;continue}e.reset(h);}let E=this.buildCommand(f,a);n.push(E),this.tryAttachTrailingRole(e,E,a),p=true,u=true;}}p||(m&&o.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)),o=a.some(l=>this.isElseKeyword(l.value,t));if(!n&&!o)return null;let u=new te(a,t),s=this.parseBodyWithClauses(u,r,t);return s.length===0?null:s.length===1?s[0]:ir(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((o,u)=>e[r+u]?.value===o))return n.length;return 0}hasSOVEventMarkerHead(e,r){let t=T.SOV_EVENT_MARKERS[r];if(t===void 0)return false;let{tokens:a}=H(e,r),n=Ae[r],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<a.length;u++){let s=a[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(T.KNOWN_EVENTS.has(c)||De.has(c))||T.KNOWN_EVENTS.has(l)||De.has(l)||o.has(l)))continue;let p=this.matchEventParamPhrase(a,u+1).len,d=a[u+1+p];if(d&&(d.kind==="particle"||d.kind==="keyword")&&t.has(d.value)||this.matchEventMarkerPhrase(a,u+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=H(e,r).tokens;if(a.length<3)return null;let n=Ae[r],o=new Set;if(n)for(let w of Object.keys(n))o.add(w.toLowerCase());let u=a.length-2,s=a[u];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)||o.has(m)))return null;let f=p&&T.KNOWN_EVENTS.has(p)?p:n?.[m]??m,E=a.slice(0,u);if(E.length===0)return null;let h=t.filter(w=>w.command!=="on"),g=new te(E,r),C=this.parseBodyWithClauses(g,h,r);return C.length===0?null:Pe({type:"literal",value:f},C,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,t){let a=H(e,r).tokens;if(a.length<3)return null;let n=Ae[r],o=new Set;if(n)for(let u of Object.keys(n))o.add(u.toLowerCase());for(let u=0;u<a.length-1;u++){let s=a[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=a[u+1],m=c.value.toLowerCase(),p=c.normalized?.toLowerCase();if(!(!!p&&T.KNOWN_EVENTS.has(p)||T.KNOWN_EVENTS.has(m)||o.has(m)))continue;let f=p&&T.KNOWN_EVENTS.has(p)?p:n?.[m]??m,E=a.filter((w,A)=>A!==u&&A!==u+1);if(E.length===0)return null;let h=t.filter(w=>w.command!=="on"),g=new te(E,r),C=this.parseBodyWithClauses(g,h,r);return C.length===0?null:Pe({type:"literal",value:f},C,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,t){let a=T.SOV_EVENT_MARKERS[r];if(!a)return null;let o=H(e,r).tokens,u=Ae[r],s=new Set;if(u)for(let z of Object.keys(u))s.add(z.toLowerCase());let l=T.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1,f=[];for(let z=0;z<o.length;z++){let v=o[z],b=v.value.toLowerCase(),y=b,k="",B=b.indexOf("[");B>0&&(y=b.slice(0,B),k=v.value.slice(B));let D=v.normalized?.toLowerCase(),O=D&&(T.KNOWN_EVENTS.has(D)||De.has(D)),x=s.has(b)||s.has(y),F=T.KNOWN_EVENTS.has(y)||De.has(y);if(O||x||F){let N=o[z-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let P;O?P=D:x?P=u?.[b]??u?.[y]??y:P=y;let $=this.matchEventParamPhrase(o,z+1);if(a.size>0){let q=1+$.len,ce=o[z+q];ce&&ce.kind==="selector"&&ce.value.startsWith("[")&&(q+=1);let ee=o[z+q];if(ee&&(ee.kind==="particle"||ee.kind==="keyword")&&a.has(ee.value)){c=z,m=P,p=k||(q===$.len+2?o[z+q-1].value:""),d=q+1,f=$.names;break}}else {c=z,m=P,p=k,d=1+$.len+this.matchEventMarkerPhrase(o,z+1+$.len,r),f=$.names;break}}}if(c===-1){let z=new Set(t.filter(v=>v.command!=="on").map(v=>v.command));for(let v=0;v<o.length;v++){let b=o[v];if(b.kind==="identifier")if(a.size>0){let y=1,k=o[v+1];k&&k.kind==="selector"&&k.value.startsWith("[")&&(y=2);let B=o[v+y];if(B&&(B.kind==="particle"||B.kind==="keyword")&&a.has(B.value)){c=v,m=b.value,p=y===2?o[v+1].value:"",d=y+1;break}}else {let y=this.matchEventMarkerPhrase(o,v+1,r);if(y>0){c=v,m=b.value,p="",d=1+y;break}let k=o[v+1];if(k&&k.kind==="keyword"&&k.normalized!=null&&z.has(k.normalized)){c=v,m=b.value,p="",d=1;break}}}}if(c===-1)return null;let E=new Set;for(let z=c;z<c+d;z++)E.add(z);if(l){let z=c+d;if(z<o.length){let v=o[z];if((v.kind==="particle"||v.kind==="keyword")&&l.markers.has(v.value))E.add(z);else if(this.isStrippableSourceRef(v,l.windowTokens)){let b=o[z+1];b&&(b.kind==="particle"||b.kind==="keyword")&&l.markers.has(b.value)&&(E.add(z),E.add(z+1));}}if(c>=2){let v=o[c-1];(v.kind==="particle"||v.kind==="keyword")&&l.markers.has(v.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(E.add(c-2),E.add(c-1));}for(let v=0;v<c;v++){let b=o[v],y=b.value.toLowerCase(),k=b.normalized?.toLowerCase();if(l.windowTokens.has(y)||k&&l.windowTokens.has(k)){E.add(v);break}}}let h=o.filter((z,v)=>!E.has(v));if(h.length===0)return null;let g=t.filter(z=>z.command!=="on"),C=new te(h,r),w=this.parseBodyWithClauses(C,g,r);if(w.length===0)return null;let A={sourceLanguage:r,confidence:.75};return p&&(A.keyFilter=p),Pe({type:"literal",value:m},w,void 0,A,f)}profileKeywordMatches(e,r,t){let a=L(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=L(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 o=false;for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(e.advance(),this.isEndKeyword(s.value,r)){o=true;break}n.push(s);}if(!o)return e.reset(a),null;let u=n.map(s=>s.value).join(" ").trim();return Z("js",{patient:{type:"expression",raw:u||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}isIfKeyword(e,r){let t=e.toLowerCase();return t==="if"?true:this.profileKeywordMatches(r,"if",t)}isUnlessKeyword(e,r){let t=e.toLowerCase();return t==="unless"?true:this.profileKeywordMatches(r,"unless",t)}isBlockEndToken(e,r,t){return this.isEndKeyword(e.value,t)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,t){let a=e.peek();if(!a)return null;let n=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(n,t))return null;let o=e.mark();e.advance();let u=[],s=0;for(;!e.isAtEnd();){let v=e.peek();if(!v)break;let b=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(b,t)||this.isUnlessKeyword(b,t)){s++,u.push(v),e.advance();continue}if(this.isBlockEndToken(v,e.peek(1)??void 0,t)){if(s===0){e.advance();break}s--,u.push(v),e.advance();continue}u.push(v),e.advance();}if(u.length===0)return e.reset(o),null;let l=L(t),c=l?.wordOrder==="SOV"?T.buildVerbLookup(l):null,m=0,p=0,d=[];for(;m<u.length;m++){let v=u[m],b=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(b,t)||this.isUnlessKeyword(b,t)?p++:this.isBlockEndToken(v,u[m+1],t)&&p--,p===0&&this.isThenKeyword(v.value,t)){m++;break}if(p===0&&d.length>0){let y=(u[m-1].normalized??u[m-1].value).toLowerCase(),k=u[m-1].value.toLowerCase(),B=(v.normalized??v.value).toLowerCase(),D=T.CONDITION_COPULAS.has(y)||T.CONDITION_COPULAS_SURFACE.has(k)&&T.CONDITION_PREDICATES.has(B),O=c!==null&&c.has(v.value.toLowerCase())&&!T.CONDITION_PREDICATES.has(B);if(!T.CONDITION_OPERATORS.has(B)&&(!D||O)&&(this.tokensBeginCommand(u.slice(m),r,t)||this.sovCommandStartsAt(u.slice(m),c)))break}d.push(v);}if(d.length===0)return e.reset(o),null;let E=[],h=[],g=false,C=0;for(;m<u.length;m++){let v=u[m],b=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(b,t)||this.isUnlessKeyword(b,t)?C++:this.isBlockEndToken(v,u[m+1],t)&&C--,C===0&&!g&&this.isElseKeyword(v.value,t)){g=true;continue}(g?h:E).push(v);}let w={type:"expression",raw:this.joinTokenText(d)},A=this.parseBranch(E,r,t),z=h.length>0?this.parseBranch(h,r,t):void 0;return A.length===0&&(!z||z.length===0)?(e.reset(o),null):Si(w,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 te(e,t);return Q.matchBest(a,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let t=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),a=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",n=0,o=0;for(;n+1<e.length;){let u=e[n],s=e[n+1];if(!a(u)||s.kind!=="particle")break;o+=1,n+=2;let l=e[n];if(o>=1&&l&&t(l))return true}return false}parseBranch(e,r,t){if(e.length===0)return [];let a=new te(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=H(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let o=a[0].value.toLowerCase(),u=T.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let d=1;if(d<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 h=parseInt(E[1],10),g=E[2]||"ms";g==="s"?h*=1e3:g==="m"&&(h*=6e4),s[u]=h,l=d+1;}}}s[u]||(s[u]=u==="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=L(r)?.keywords?.async,a=new Set(["async"]);t?.primary&&a.add(t.primary.toLowerCase()),t?.alternatives?.forEach(l=>a.add(l.toLowerCase()));let n=H(e,r).tokens,o=n.findIndex(l=>a.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=n[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let t=H(e,r).tokens;for(let 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 o=t[a].position.start,u=t[n].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let a=e.mark(),n=e.peek();if(!n)break;let o=(n.normalized||n.value).toLowerCase();if(!T.OR_KEYWORDS.has(o)){e.reset(a);break}e.advance();let u=e.peek();if(!u){e.reset(a);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};J.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);J.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);J.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])};J.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};J.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};J.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);J.CONDITION_COPULAS_SURFACE=new Set(["est","\u0435\u0441\u0442\u044C","\u0454","\xE9","ay","\u0647\u0648","adalah","\u0E40\u0E1B\u0E47\u0E19","\u09B9\u09AF\u09BC","\u0939\u0948","dir","kanqa"]);J.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);J.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);J.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};J.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o","\u092F\u093E","\u0985\u09A5\u09AC\u09BE"]);var hn=J,vn=new hn;function En(i,e){return vn.parse(i,e)}function gn(i,e){try{let r=H(i,e),t=ne(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"),o=Q.matchBest(r,n);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=a.filter(l=>l.command!=="on"),s=Q.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${i}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Yr(i,e){try{let t=En(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:H(i,e).tokens.length}}catch{}let r=gn(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function Zr(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,a)=>{let n=t[r]??99,o=a[r]??99;return n-o})}function zn(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 Ue(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 o of a)o!==r&&!n.includes(o)&&n.push(o);t=n;}return {marker:r,alternatives:t}}function Ne(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 kn(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 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 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 s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),n.push(...ge(i,e.roleMarkers.source)),n.push(...ur(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} ${u?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function Cn(i,e,r,t,a){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};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 u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),n.push(...ge(i,e.roleMarkers.source)),n.push(...ur(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} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function bn(i,e,r,t,a){let n=[];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 u=e.roleMarkers.destination;if(u&&(n.push({type:"role",role:"destination",optional:false}),n.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.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} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function wn(i,e,r,t,a){let n=[];n.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});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 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(...ge(i,e.roleMarkers.source)),n.push(...ur(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}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function An(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)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 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-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 Dn(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 o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.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-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 Bn(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 u=[...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 u){n.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:d}=Ue(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=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Ne(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 Sn(i,e,r,t,a){let n=[],u=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.sovPosition??999,d=m.sovPosition??999;return p-d});for(let c of u){n.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:p}=Ue(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=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Ne(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 xn(i,e,r,t,a){let n=[],u=[...i.roles.filter(h=>h.required)].sort((h,g)=>{let C=h.sovPosition??999,w=g.sovPosition??999;return C-w}),s=u[0];n.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=Ue(s,e);if(l){let h=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};n.push(h);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let h=t.primary.split(/\s+/);if(h.length>1)for(let g of h)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=u[1];n.push({type:"role",role:p.role,optional:false});let{marker:d,alternatives:f}=Ue(p,e);if(d){let h=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};n.push(h);}let E={action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[p.role]:{fromRole:p.role}};return Ne(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 xr(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 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 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(...ge(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} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function Fn(i,e,r,t,a){let n=[],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 u=e.roleMarkers.destination;if(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(...ge(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} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function Tn(i,e,r,t,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);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 Ne(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 Fr(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 o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);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 Ne(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 On(i,e,r,t,a){let n=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}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 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(...ge(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} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}function Pn(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 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(...ge(i,e.roleMarkers.source)),{id:`${i.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...ve(i),...Ee(i)}}}var xe={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function nr(i,e,r=xe){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 o=_n(i,e,n),u=lr(i,e),s=qn(i,e,n);return {id:t,language:e.code,command:i.action,priority:a,template:{format:s,tokens:o},extraction:u}}function Rn(i,e,r=xe){if(i.roles.filter(u=>!u.required).length===0)return null;let a=i.roles.filter(u=>u.required),n={...i,roles:a};return {...nr(n,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:lr(i,e)}}function Nn(i,e,r=xe){if(e.wordOrder!=="SOV")return null;let t=i.roles.filter(u=>u.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},o=t.map(u=>({type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes}));return {id:`${i.action}-${e.code}-generated-verb-first`,language:e.code,command:i.action,priority:(r.basePriority??100)-20,template:{format:`${a.primary} <${t[0].role}>`,tokens:[n,...o]},extraction:lr(i,e)}}function Ln(i,e,r=xe){let t=[];if(t.push(nr(i,e,r)),r.generateSimpleVariants){let a=Rn(i,e,r);a&&t.push(a);}for(let a of i.omitRoleVariants??[]){let n={...i,roles:i.roles.filter(u=>u.role!==a)},o=nr(n,e,r);t.push({...o,id:`${i.action}-${e.code}-generated-no-${a}`,priority:(r.basePriority??100)-8});}if(r.generateVerbFirstVariants!==false){let a=Nn(i,e,r);a&&t.push(a);}return t}function Xr(i,e=xe){let r=[],t=Ua();for(let a of t){if(!i.keywords[a.action])continue;let n=Ln(a,i,e);if(r.push(...n),i.eventHandler?.eventMarker){let o=Mn(a,i,e);r.push(...o);}}return r}function Mn(i,e,r=xe){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 u=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push(Bn(i,e,n,a,r)),t.push(xn(i,e,n,a,r)),t.push(Sn(i,e,n,a,r));else {t.push(kn(i,e,n,a,r)),t.push(Cn(i,e,n,a,r));let s=e.roleMarkers.destination;s&&s.primary!==a.primary&&t.push(bn(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(wn(i,e,n,a,r)),t.push(An(i,e,n,a,r));let m=Dn(i,e,n,r);m&&t.push(m);}else e.wordOrder==="VSO"?u?(t.push(Fr(i,e,n,a,r)),t.push(Tn(i,e,n,a,r))):(t.push(xr(i,e,n,a,r)),t.push(Fn(i,e,n,a,r)),e.eventHandler?.negationMarker&&t.push(On(i,e,n,a,r)),e.tokenization?.prefixes&&t.push(Pn(i,e,n,r))):u?t.push(Fr(i,e,n,a,r)):t.push(xr(i,e,n,a,r));return t}function _n(i,e,r){let t=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=jn(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 In(t)}function In(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 jn(i,e){let r=[],t=Zr(i.roles,e.wordOrder);for(let a of t){let n=Vn(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function Vn(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 o=t?t.split(/\s+/).filter(Boolean):[],u=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(u==="before"){for(let c of o)l(c);r.push(n);}else {r.push(n);for(let c of o)l(c);}}else if(a){let o=i.markerVariants?.[e.code]??[],u=()=>{let l=[...new Set([...a.alternatives??[],...o])].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(u()),r.push(n)):(r.push(n),s(u()));}else r.push(n);return r}function $n(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 o=t.markerVariants?.[e.code]??[],u=[...new Set([...n.alternatives??[],...o])].filter(s=>s!==n.primary);r[t.role]=u.length?{marker:n.primary,markerAlternatives:u}:{marker:n.primary};}else r[t.role]={};}return r}function lr(i,e){let r=$n(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 qn(i,e,r){let t=[],n=Zr(i.roles,e.wordOrder).map(o=>{let u=zn(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":t.push(r.primary,...n);break;case "SOV":t.push(...n,r.primary);break;default:t.push(r.primary,...n);}return t.join(" ")}var Wn=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 Wn;function Jr(i){return /[\u0900-\u097F\u0A8E-\u0A8F]/u.test(i)}var Kn=[{suffix:" \u0930\u0939\u093E \u0939\u0948",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:" \u0930\u0939\u0940 \u0939\u0948",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:" \u0930\u0939\u0947 \u0939\u0948\u0902",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u093E",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u0940",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0930\u0939\u0947",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u0942\u0902\u0917\u093E",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0942\u0902\u0917\u0940",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0917\u093E",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0917\u0940",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0947\u0902\u0917\u0947",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u0924\u093E \u0939\u0948",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0940 \u0939\u0948",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0947 \u0939\u0948\u0902",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u093E",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0940",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0924\u0947",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u0928\u093E",replacement:"",confidence:.9,type:"dictionary",minStemLength:1},{suffix:"\u093E\u092F\u093E",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093E\u092F\u0940",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093E\u092F\u0947",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u092F\u093E",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u093F\u092F\u0947",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u093F\u090F",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u0908",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u090F",replacement:"",confidence:.82,type:"past",minStemLength:1},{suffix:"\u0947\u0902",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u094B",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u093E",replacement:"",confidence:.82,type:"past",minStemLength:2},{suffix:"\u0940",replacement:"",confidence:.82,type:"past",minStemLength:2},{suffix:"\u0947",replacement:"",confidence:.82,type:"past",minStemLength:2}],tt=class{constructor(){this.language="hi";}isNormalizable(i){return i.length<2?false:Jr(i)}normalize(i){let e=this.tryConjugationNormalization(i);return e||$e(i)}tryConjugationNormalization(i){for(let e of Kn)if(i.endsWith(e.suffix)){let r=Array.from(i),t=Array.from(e.suffix),a=r.slice(0,r.length-t.length),n=a.join("")+e.replacement,o=e.minStemLength??1;if(a.length<o||n.length>0&&!Jr(n))continue;return qe(n,e.confidence,{removedSuffixes:[e.suffix],conjugationType:e.type})}return null}},it={code:"hi",name:"Hindi",nativeName:"\u0939\u093F\u0928\u094D\u0926\u0940",direction:"ltr",script:"devanagari",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,defaultVerbForm:"imperative",verb:{position:"end",suffixes:["\u0947\u0902","\u093E","\u0940","\u0947","\u094B"],subjectDrop:true},references:{me:"\u092E\u0948\u0902",it:"\u092F\u0939",you:"\u0906\u092A",result:"\u092A\u0930\u093F\u0923\u093E\u092E",event:"\u0918\u091F\u0928\u093E",target:"\u0932\u0915\u094D\u0937\u094D\u092F",body:"\u092C\u0949\u0921\u0940"},possessive:{marker:"\u0915\u093E",markerPosition:"between",keywords:{\u092E\u0947\u0930\u093E:"me",\u092E\u0947\u0930\u0940:"me",\u092E\u0947\u0930\u0947:"me",\u0924\u0947\u0930\u093E:"you",\u0924\u0947\u0930\u0940:"you",\u0924\u0947\u0930\u0947:"you",\u0906\u092A\u0915\u093E:"you",\u0906\u092A\u0915\u0940:"you",\u0906\u092A\u0915\u0947:"you",\u0909\u0938\u0915\u093E:"it",\u0909\u0938\u0915\u0940:"it",\u0909\u0938\u0915\u0947:"it",\u0907\u0938\u0915\u093E:"it",\u0907\u0938\u0915\u0940:"it",\u0907\u0938\u0915\u0947:"it"}},roleMarkers:{patient:{primary:"\u0915\u094B",position:"after"},destination:{primary:"\u092E\u0947\u0902",alternatives:["\u092A\u0930"],position:"after"},source:{primary:"\u0938\u0947",position:"after"},style:{primary:"\u0938\u0947",position:"after"},event:{primary:"\u092A\u0930",position:"after"}},keywords:{toggle:{primary:"\u091F\u0949\u0917\u0932",alternatives:["\u092C\u0926\u0932\u0947\u0902","\u092C\u0926\u0932"],normalized:"toggle"},add:{primary:"\u091C\u094B\u0921\u093C\u0947\u0902",alternatives:["\u091C\u094B\u0921\u093C"],normalized:"add"},remove:{primary:"\u0939\u091F\u093E\u090F\u0902",alternatives:["\u0939\u091F\u093E","\u092E\u093F\u091F\u093E\u090F\u0902"],normalized:"remove"},put:{primary:"\u0930\u0916\u0947\u0902",alternatives:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],normalized:"put"},append:{primary:"\u0938\u0902\u0932\u0917\u094D\u0928",alternatives:[],normalized:"append"},prepend:{primary:"\u091C\u094B\u0921\u093C\u0947\u0902_\u0936\u0941\u0930\u0942",alternatives:[],normalized:"prepend"},take:{primary:"\u0932\u0947\u0902",alternatives:["\u0932\u0947"],normalized:"take"},make:{primary:"\u092C\u0928\u093E\u090F\u0902",alternatives:["\u092C\u0928\u093E"],normalized:"make"},clone:{primary:"\u0915\u094D\u0932\u094B\u0928",alternatives:["\u092A\u094D\u0930\u0924\u093F\u0932\u093F\u092A\u093F"],normalized:"clone"},swap:{primary:"\u0935\u093F\u0928\u093F\u092E\u092F",alternatives:[],normalized:"swap"},morph:{primary:"\u0930\u0942\u092A\u093E\u0902\u0924\u0930",alternatives:[],normalized:"morph"},set:{primary:"\u0938\u0947\u091F",alternatives:["\u0928\u093F\u0930\u094D\u0927\u093E\u0930\u093F\u0924"],normalized:"set"},get:{primary:"\u092A\u094D\u0930\u093E\u092A\u094D\u0924",alternatives:["\u092A\u093E\u090F\u0902"],normalized:"get"},increment:{primary:"\u092C\u0922\u093C\u093E\u090F\u0902",alternatives:["\u092C\u0922\u093C\u093E"],normalized:"increment"},decrement:{primary:"\u0918\u091F\u093E\u090F\u0902",alternatives:["\u0918\u091F\u093E"],normalized:"decrement"},log:{primary:"\u0932\u0949\u0917",alternatives:["\u0926\u0930\u094D\u091C"],normalized:"log"},show:{primary:"\u0926\u093F\u0916\u093E\u090F\u0902",alternatives:["\u0926\u093F\u0916\u093E"],normalized:"show"},hide:{primary:"\u091B\u093F\u092A\u093E\u090F\u0902",alternatives:["\u091B\u093F\u092A\u093E"],normalized:"hide"},transition:{primary:"\u0938\u0902\u0915\u094D\u0930\u092E\u0923",alternatives:[],normalized:"transition"},on:{primary:"\u092A\u0930",alternatives:[],normalized:"on"},trigger:{primary:"\u091F\u094D\u0930\u093F\u0917\u0930",alternatives:[],normalized:"trigger"},send:{primary:"\u092D\u0947\u091C\u0947\u0902",alternatives:["\u092D\u0947\u091C"],normalized:"send"},focus:{primary:"\u092B\u094B\u0915\u0938",alternatives:["\u0915\u0947\u0902\u0926\u094D\u0930\u093F\u0924"],normalized:"focus"},blur:{primary:"\u0927\u0941\u0902\u0927\u0932\u093E",alternatives:["\u092B\u094B\u0915\u0938_\u0939\u091F\u093E\u090F\u0902"],normalized:"blur"},empty:{primary:"\u0916\u093E\u0932\u0940-\u0915\u0930\u0947\u0902",alternatives:["\u0916\u093E\u0932\u0940"],normalized:"empty"},open:{primary:"\u0916\u094B\u0932\u0947\u0902",normalized:"open"},close:{primary:"\u092C\u0902\u0926-\u0915\u0930\u0947\u0902",normalized:"close"},select:{primary:"\u091A\u093F\u0939\u094D\u0928\u093F\u0924-\u0915\u0930\u0947\u0902",normalized:"select"},clear:{primary:"\u0938\u093E\u092B\u093C-\u0915\u0930\u0947\u0902",alternatives:["\u0938\u093E\u092B-\u0915\u0930\u0947\u0902"],normalized:"clear"},reset:{primary:"\u0930\u0940\u0938\u0947\u091F",normalized:"reset"},breakpoint:{primary:"\u092C\u094D\u0930\u0947\u0915\u092A\u094D\u0935\u093E\u0907\u0902\u091F",normalized:"breakpoint"},click:{primary:"\u0915\u094D\u0932\u093F\u0915",normalized:"click"},hover:{primary:"\u0939\u094B\u0935\u0930",alternatives:["\u090A\u092A\u0930_\u0930\u0916\u0947\u0902"],normalized:"hover"},submit:{primary:"\u0938\u092C\u092E\u093F\u091F",alternatives:["\u091C\u092E\u093E"],normalized:"submit"},input:{primary:"\u0907\u0928\u092A\u0941\u091F",alternatives:[],normalized:"input"},change:{primary:"\u092C\u0926\u0932\u093E\u0935",alternatives:["\u092A\u0930\u093F\u0935\u0930\u094D\u0924\u0928"],normalized:"change"},go:{primary:"\u091C\u093E\u090F\u0902",alternatives:["\u091C\u093E"],normalized:"go"},scroll:{primary:"\u0938\u094D\u0915\u094D\u0930\u0949\u0932",normalized:"scroll"},push:{primary:"\u0927\u0915\u0947\u0932\u0947\u0902",alternatives:["\u092A\u0941\u0936"],normalized:"push"},replace:{primary:"\u092C\u0926\u0932\u0947\u0902_\u092F\u0942\u0906\u0930\u090F\u0932",alternatives:["\u092A\u094D\u0930\u0924\u093F\u0938\u094D\u0925\u093E\u092A\u093F\u0924"],normalized:"replace"},process:{primary:"\u0938\u0902\u0938\u093E\u0927\u093F\u0924",alternatives:["\u092A\u094D\u0930\u0938\u0902\u0938\u094D\u0915\u0943\u0924"],normalized:"process"},wait:{primary:"\u092A\u094D\u0930\u0924\u0940\u0915\u094D\u0937\u093E",alternatives:["\u0930\u0941\u0915\u0947\u0902"],normalized:"wait"},fetch:{primary:"\u0932\u093E\u090F\u0902",alternatives:[],normalized:"fetch"},settle:{primary:"\u0938\u094D\u0925\u093F\u0930",alternatives:[],normalized:"settle"},if:{primary:"\u0905\u0917\u0930",alternatives:["\u092F\u0926\u093F"],normalized:"if"},when:{primary:"\u091C\u092C",normalized:"when"},where:{primary:"\u0915\u0939\u093E\u0901",normalized:"where"},else:{primary:"\u0935\u0930\u0928\u093E",alternatives:["\u0928\u0939\u0940\u0902 \u0924\u094B"],normalized:"else"},repeat:{primary:"\u0926\u094B\u0939\u0930\u093E\u090F\u0902",alternatives:["\u0926\u094B\u0939\u0930\u093E"],normalized:"repeat"},for:{primary:"\u0915\u0947 \u0932\u093F\u090F",alternatives:["\u0939\u0947\u0924\u0941"],normalized:"for"},while:{primary:"\u091C\u092C \u0924\u0915",alternatives:[],normalized:"while"},forever:{primary:"\u0939\u092E\u0947\u0936\u093E",normalized:"forever",alternatives:["forever"]},unless:{primary:"\u091C\u092C \u0924\u0915 \u0928\u0939\u0940\u0902",normalized:"unless"},continue:{primary:"\u091C\u093E\u0930\u0940",alternatives:[],normalized:"continue"},halt:{primary:"\u0930\u094B\u0915\u0947\u0902",alternatives:["\u0930\u094B\u0915"],normalized:"halt"},throw:{primary:"\u092B\u0947\u0902\u0915\u0947\u0902",alternatives:["\u092B\u0947\u0902\u0915"],normalized:"throw"},call:{primary:"\u0915\u0949\u0932",alternatives:["\u092C\u0941\u0932\u093E\u090F\u0902"],normalized:"call"},return:{primary:"\u0932\u094C\u091F\u093E\u090F\u0902",alternatives:["\u0932\u094C\u091F\u093E"],normalized:"return"},then:{primary:"\u092B\u093F\u0930",alternatives:["\u0924\u092C"],normalized:"then"},and:{primary:"\u0914\u0930",alternatives:[],normalized:"and"},matches:{primary:"\u092E\u0947\u0932 \u0916\u093E\u0924\u093E",normalized:"matches"},end:{primary:"\u0938\u092E\u093E\u092A\u094D\u0924",alternatives:["\u0905\u0902\u0924"],normalized:"end"},js:{primary:"\u091C\u0947\u090F\u0938",alternatives:["js"],normalized:"js"},async:{primary:"\u0905\u0938\u093F\u0902\u0915",alternatives:[],normalized:"async"},tell:{primary:"\u092C\u0924\u093E\u090F\u0902",alternatives:["\u092C\u0924\u093E"],normalized:"tell"},default:{primary:"\u0921\u093F\u092B\u093C\u0949\u0932\u094D\u091F",alternatives:[],normalized:"default"},init:{primary:"\u092A\u094D\u0930\u093E\u0930\u0902\u092D",alternatives:[],normalized:"init"},behavior:{primary:"\u0935\u094D\u092F\u0935\u0939\u093E\u0930",alternatives:[],normalized:"behavior"},install:{primary:"\u0907\u0902\u0938\u094D\u091F\u0949\u0932",alternatives:[],normalized:"install"},measure:{primary:"\u092E\u093E\u092A\u0947\u0902",alternatives:[],normalized:"measure"},beep:{primary:"\u092C\u0940\u092A",alternatives:[],normalized:"beep"},break:{primary:"\u0924\u094B\u0921\u093C\u0947\u0902",alternatives:[],normalized:"break"},copy:{primary:"\u0915\u0949\u092A\u0940",alternatives:[],normalized:"copy"},exit:{primary:"\u092C\u093E\u0939\u0930",alternatives:[],normalized:"exit"},pick:{primary:"\u091A\u0941\u0928\u0947\u0902",alternatives:[],normalized:"pick"},render:{primary:"\u0930\u0947\u0902\u0921\u0930",alternatives:[],normalized:"render"},into:{primary:"\u092E\u0947\u0902",alternatives:[],normalized:"into"},before:{primary:"\u0938\u0947 \u092A\u0939\u0932\u0947",alternatives:["\u092A\u0939\u0932\u0947"],normalized:"before"},after:{primary:"\u0915\u0947 \u092C\u093E\u0926",alternatives:["\u092C\u093E\u0926"],normalized:"after"},until:{primary:"\u0924\u0915",alternatives:[],normalized:"until"},event:{primary:"\u0918\u091F\u0928\u093E",alternatives:[],normalized:"event"},from:{primary:"\u0938\u0947",normalized:"from"},connect:{primary:"\u0915\u0928\u0947\u0915\u094D\u091F",alternatives:["\u0938\u0902\u092F\u094B\u091C\u093F\u0924"],normalized:"connect"},stream:{primary:"\u0938\u094D\u091F\u094D\u0930\u0940\u092E",alternatives:["\u0927\u093E\u0930\u093E","\u092A\u094D\u0930\u0935\u093E\u0939"],normalized:"stream"},live:{primary:"\u0932\u093E\u0907\u0935",alternatives:["\u0938\u091C\u0940\u0935","\u092A\u094D\u0930\u0924\u094D\u092F\u0915\u094D\u0937"],normalized:"live"},socket:{primary:"\u0938\u0949\u0915\u0947\u091F",alternatives:["\u0935\u0947\u092C\u0938\u0949\u0915\u0947\u091F"],normalized:"socket"},worker:{primary:"worker",alternatives:["\u0935\u0930\u094D\u0915\u0930"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0907\u0935\u0947\u0902\u091F\u0938\u094B\u0930\u094D\u0938"],normalized:"eventsource"},bind:{primary:"bind",alternatives:["\u092C\u093E\u0907\u0902\u0921","\u092C\u093E\u0902\u0927\u0947\u0902"],normalized:"bind"},intercept:{primary:"intercept",alternatives:["\u0907\u0902\u091F\u0930\u0938\u0947\u092A\u094D\u091F"],normalized:"intercept"}},tokenization:{particles:["\u0915\u094B","\u092E\u0947\u0902","\u092A\u0930","\u0938\u0947","\u0915\u093E","\u0915\u0940","\u0915\u0947","\u0924\u0915","\u0928\u0947"],boundaryStrategy:"space"},eventHandler:{keyword:{primary:"\u092A\u0930",alternatives:[],normalized:"on"},sourceMarker:{primary:"\u0938\u0947",position:"after"},eventMarker:{primary:"\u092A\u0930",alternatives:[],position:"after"},temporalMarkers:["\u091C\u092C","\u091C\u092C \u092D\u0940"]}},Un=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Hn=class{constructor(i=Un){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}},Gn="()[]{},:;",Yn=class{constructor(i=Gn){this.punctuation=i,this.name="punctuation";}canExtract(i,e){return this.punctuation.includes(i[e])}extract(i,e){let r=i[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Qr(i,e){let r=i[e];if(r==="#"){let t=i.slice(e).match(/^#[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="."){let t=i.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(t)return t[0];let 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 Zn=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Qr(i,e)!==null:false}extract(i,e){let r=Qr(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Xn=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 Jn(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 Qn=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=Jn(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},eo=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 Ye(i){let e=i.charCodeAt(0);return e>=2304&&e<=2431||e>=43232&&e<=43263}var ro=class{constructor(){this.name="hindi-keyword";}setContext(i){this.context=i;}canExtract(i,e){return Ye(i[e])}extract(i,e){if(!this.context)throw new Error("HindiKeywordExtractor: context not set");let r=e,t="",a=e;for(;a<i.length&&Ye(i[a]);)t+=i[a],a++;if(this.context&&i[a]==="-"&&a+1<i.length&&Ye(i[a+1])){let s=a,l=t;for(;s<i.length&&(i[s]==="-"||Ye(i[s]));)l+=i[s++];this.context.lookupKeyword(l)&&(t=l,a=s);}if(!t)return null;let n=this.context.lookupKeyword(t),o=n&&n.normalized!==n.native?n.normalized:void 0,u;if(!n&&this.context.normalizer){let s=this.context.normalizer.normalize(t);if(s.stem!==t&&s.confidence>=.7){let l=this.context.lookupKeyword(s.stem);l&&(u=l.normalized);}}return {value:t,length:a-r,metadata:{normalized:o||u}}}},et=new Map([["\u0915\u094B",{role:"patient",confidence:.95}],["\u092E\u0947\u0902",{role:"destination",confidence:.9}],["\u092A\u0930",{role:"event",confidence:.85}],["\u0938\u0947",{role:"source",confidence:.9}],["\u0915\u093E",{role:"possessive",confidence:.95}],["\u0915\u0940",{role:"possessive",confidence:.95}],["\u0915\u0947",{role:"possessive",confidence:.95}],["\u0924\u0915",{role:"until",confidence:.9}],["\u0928\u0947",{role:"agent",confidence:.85}]]),rt=new Map([["\u0915\u0947 \u0938\u093E\u0925",{role:"instrument",confidence:.95}],["\u0915\u0947 \u092C\u093E\u0930\u0947 \u092E\u0947\u0902",{role:"about",confidence:.9}]]),to=class{constructor(){this.name="hindi-particle";}setContext(i){this._context=i,this._context;}canExtract(i,e){for(let[a]of rt)if(i.startsWith(a,e))return true;let r="",t=e;for(;t<i.length&&this.isDevanagari(i[t]);)r+=i[t],t++;return et.has(r)}extract(i,e){for(let[n,o]of rt)if(i.startsWith(n,e))return {value:n,length:n.length,metadata:{role:o.role,confidence:o.confidence,variant:n}};let r="",t=e;for(;t<i.length&&this.isDevanagari(i[t]);)r+=i[t],t++;let a=et.get(r);return a?{value:r,length:r.length,metadata:{role:a.role,confidence:a.confidence,variant:r}}:null}isDevanagari(i){let e=i.charCodeAt(0);return e>=2304&&e<=2431||e>=43232&&e<=43263}};function io(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function ao(i){let e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var no=class{constructor(){this.name="ascii-identifier";}setContext(i){this.context=i;}canExtract(i,e){return io(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&&ao(i[a]);)t+=i[a],a++;if(!t)return null;let n=this.context.lookupKeyword(t),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:t,length:a-r,metadata:{normalized:o}}}};function oo(){return [new Qn,new Xn,new eo,new Zn]}var uo=new Set(["\u0915\u094B","\u092E\u0947\u0902","\u092A\u0930","\u0938\u0947","\u0915\u093E","\u0915\u0940","\u0915\u0947","\u0924\u0915","\u0928\u0947"]),so=[{native:"\u092E\u093E\u0909\u0938\u0928\u0940\u091A\u0947",normalized:"mousedown"},{native:"\u092E\u093E\u0909\u0938\u090A\u092A\u0930",normalized:"mouseup"},{native:"\u0938\u091A",normalized:"true"},{native:"\u0938\u0924\u094D\u092F",normalized:"true"},{native:"\u091D\u0942\u0920",normalized:"false"},{native:"\u0905\u0938\u0924\u094D\u092F",normalized:"false"},{native:"\u0916\u093E\u0932\u0940",normalized:"null"},{native:"\u0905\u092A\u0930\u093F\u092D\u093E\u0937\u093F\u0924",normalized:"undefined"},{native:"\u092A\u0939\u0932\u093E",normalized:"first"},{native:"\u0905\u0902\u0924\u093F\u092E",normalized:"last"},{native:"\u0905\u0917\u0932\u093E",normalized:"next"},{native:"\u092A\u093F\u091B\u0932\u093E",normalized:"previous"},{native:"\u0928\u093F\u0915\u091F\u0924\u092E",normalized:"closest"},{native:"\u092E\u0942\u0932",normalized:"parent"},{native:"\u0915\u094D\u0932\u093F\u0915",normalized:"click"},{native:"\u092A\u0930\u093F\u0935\u0930\u094D\u0924\u0928",normalized:"change"},{native:"\u091C\u092E\u093E",normalized:"submit"},{native:"\u0907\u0928\u092A\u0941\u091F",normalized:"input"},{native:"\u0932\u094B\u0921",normalized:"load"},{native:"\u0938\u094D\u0915\u094D\u0930\u0949\u0932",normalized:"scroll"},{native:"\u0915\u094B",normalized:"to"},{native:"\u0915\u0947 \u0938\u093E\u0925",normalized:"with"}],lo=class extends Ve{constructor(){super(),this.language="hi",this.direction="ltr",this.initializeKeywordsFromProfile(it,so),this.normalizer=new tt,this.registerExtractors(oo()),this.registerExtractor(new Ie),this.registerExtractor(new je),this.registerExtractor(new to),this.registerExtractor(new ro),this.registerExtractor(new no),this.registerExtractor(new Hn),this.registerExtractor(new Yn);}classifyToken(i){return uo.has(i)?"particle":this.isKeyword(i)?"keyword":i.startsWith("/")||i.startsWith("./")||i.startsWith("../")||i.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||i.startsWith("'")||/^\d/.test(i)?"literal":(i.startsWith(":"),"identifier")}},co=new lo;He("hi",co,it);function at(i){return /[\u0980-\u09FF]/u.test(i)}var mo=[{suffix:"\u099A\u09CD\u099B\u09C7 \u0986\u099B\u09C7",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B \u0986\u099B\u09BF",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09C7\u09A8 \u0986\u099B\u09C7\u09A8",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u09C7\u099B\u09C7\u09A8",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09C7\u099B\u09C7",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09C7\u099B",replacement:"",confidence:.85,type:"present",minStemLength:1},{suffix:"\u09AC\u09C7\u09A8",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09AC\u09C7",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09AC\u09CB",replacement:"",confidence:.85,type:"future",minStemLength:1},{suffix:"\u09B2\u09C7\u09A8",replacement:"",confidence:.85,type:"past",minStemLength:1},{suffix:"\u09B2\u09CB",replacement:"",confidence:.85,type:"past",minStemLength:1},{suffix:"\u09B2",replacement:"",confidence:.85,type:"past",minStemLength:2},{suffix:"\u09C1\u09A8",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u09CB",replacement:"",confidence:.85,type:"imperative",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09C7",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u099A\u09CD\u099B\u09BF",replacement:"",confidence:.82,type:"progressive",minStemLength:1},{suffix:"\u09BE",replacement:"",confidence:.9,type:"dictionary",minStemLength:1},{suffix:"\u09C7",replacement:"",confidence:.85,type:"present",minStemLength:2},{suffix:"\u09BF",replacement:"",confidence:.85,type:"present",minStemLength:2},{suffix:"\u09CB",replacement:"",confidence:.85,type:"present",minStemLength:2}],po=class{constructor(){this.language="bn";}isNormalizable(i){return i.length<2?false:at(i)}normalize(i){let e=this.tryConjugationNormalization(i);return e||$e(i)}tryConjugationNormalization(i){for(let e of mo)if(i.endsWith(e.suffix)){let r=Array.from(i),t=Array.from(e.suffix),a=r.slice(0,r.length-t.length),n=a.join("")+e.replacement,o=e.minStemLength??1;if(a.length<o||n.length>0&&!at(n))continue;return qe(n,e.confidence,{removedSuffixes:[e.suffix],conjugationType:e.type})}return null}},fo=new po,st={code:"bn",name:"Bengali",nativeName:"\u09AC\u09BE\u0982\u09B2\u09BE",direction:"ltr",script:"bengali",wordOrder:"SOV",markingStrategy:"postposition",usesSpaces:true,defaultVerbForm:"imperative",verb:{position:"end",suffixes:["\u09C1\u09A8","\u09CB","\u09BE","\u09C7","\u09BF"],subjectDrop:true},references:{me:"\u0986\u09AE\u09BF",it:"\u098F\u099F\u09BF",you:"\u0986\u09AA\u09A8\u09BF",result:"\u09AB\u09B2\u09BE\u09AB\u09B2",event:"\u0998\u099F\u09A8\u09BE",target:"\u09B2\u0995\u09CD\u09B7\u09CD\u09AF",body:"\u09AC\u09A1\u09BF"},possessive:{marker:"\u09B0",markerPosition:"between",keywords:{\u0986\u09AE\u09BE\u09B0:"me",\u09A4\u09CB\u09AE\u09BE\u09B0:"you",\u0986\u09AA\u09A8\u09BE\u09B0:"you",\u09A4\u09BE\u09B0:"it",\u098F\u09B0:"it"}},roleMarkers:{patient:{primary:"\u0995\u09C7",position:"after"},destination:{primary:"\u09A4\u09C7",alternatives:["\u098F"],position:"after"},source:{primary:"\u09A5\u09C7\u0995\u09C7",position:"after"},style:{primary:"\u09A6\u09BF\u09AF\u09BC\u09C7",position:"after"},event:{primary:"\u09A4\u09C7",position:"after"}},keywords:{toggle:{primary:"\u099F\u0997\u09B2",normalized:"toggle"},add:{primary:"\u09AF\u09CB\u0997",alternatives:["\u09AF\u09CB\u0997 \u0995\u09B0\u09C1\u09A8"],normalized:"add"},remove:{primary:"\u09B8\u09B0\u09BE\u09A8",alternatives:["\u09B8\u09B0\u09BF\u09AF\u09BC\u09C7 \u09AB\u09C7\u09B2\u09C1\u09A8","\u09AE\u09C1\u099B\u09C1\u09A8"],normalized:"remove"},put:{primary:"\u09B0\u09BE\u0996\u09C1\u09A8",alternatives:["\u09B0\u09BE\u0996"],normalized:"put"},append:{primary:"\u099C\u09C1\u09A1\u09BC\u09C1\u09A8",alternatives:[],normalized:"append"},prepend:{primary:"\u09B6\u09C1\u09B0\u09C1\u09A4\u09C7 \u09AF\u09CB\u0997",alternatives:[],normalized:"prepend"},take:{primary:"\u09A8\u09BF\u09A8",alternatives:["\u09A8\u09C7"],normalized:"take"},make:{primary:"\u09A4\u09C8\u09B0\u09BF \u0995\u09B0\u09C1\u09A8",alternatives:["\u09AC\u09BE\u09A8\u09BE\u09A8"],normalized:"make"},clone:{primary:"\u0995\u09CD\u09B2\u09CB\u09A8",alternatives:["\u09AA\u09CD\u09B0\u09A4\u09BF\u09B2\u09BF\u09AA\u09BF"],normalized:"clone"},swap:{primary:"\u09AC\u09A6\u09B2",alternatives:[],normalized:"swap"},morph:{primary:"\u09B0\u09C2\u09AA\u09BE\u09A8\u09CD\u09A4\u09B0",alternatives:[],normalized:"morph"},set:{primary:"\u09B8\u09C7\u099F",alternatives:["\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09A3"],normalized:"set"},get:{primary:"\u09AA\u09BE\u09A8",normalized:"get"},increment:{primary:"\u09AC\u09C3\u09A6\u09CD\u09A7\u09BF",alternatives:["\u09AC\u09BE\u09A1\u09BC\u09BE\u09A8"],normalized:"increment"},decrement:{primary:"\u09B9\u09CD\u09B0\u09BE\u09B8",alternatives:["\u0995\u09AE\u09BE\u09A8"],normalized:"decrement"},log:{primary:"\u09B2\u0997",alternatives:["\u09B0\u09C7\u0995\u09B0\u09CD\u09A1"],normalized:"log"},show:{primary:"\u09A6\u09C7\u0996\u09BE\u09A8",alternatives:["\u09A6\u09C7\u0996\u09BE\u0993"],normalized:"show"},hide:{primary:"\u09B2\u09C1\u0995\u09BE\u09A8",alternatives:["\u09B2\u09C1\u0995\u09BE\u0993"],normalized:"hide"},transition:{primary:"\u09B8\u0982\u0995\u09CD\u09B0\u09AE\u09A3",alternatives:[],normalized:"transition"},on:{primary:"\u09A4\u09C7",alternatives:["\u098F"],normalized:"on"},trigger:{primary:"\u099F\u09CD\u09B0\u09BF\u0997\u09BE\u09B0",alternatives:[],normalized:"trigger"},send:{primary:"\u09AA\u09BE\u09A0\u09BE\u09A8",alternatives:["\u09AA\u09BE\u09A0\u09BE\u0993"],normalized:"send"},focus:{primary:"\u09AB\u09CB\u0995\u09BE\u09B8",alternatives:["\u09AE\u09A8\u09CB\u09AF\u09CB\u0997"],normalized:"focus"},blur:{primary:"\u099D\u09BE\u09AA\u09B8\u09BE",alternatives:["\u09AB\u09CB\u0995\u09BE\u09B8_\u09B8\u09B0\u09BE\u09A8"],normalized:"blur"},empty:{primary:"\u0996\u09BE\u09B2\u09BF-\u0995\u09B0\u09C1\u09A8",alternatives:["\u0996\u09BE\u09B2\u09BF"],normalized:"empty"},open:{primary:"\u0996\u09C1\u09B2\u09C1\u09A8",normalized:"open"},close:{primary:"\u09AC\u09A8\u09CD\u09A7",normalized:"close"},select:{primary:"\u09A8\u09BF\u09B0\u09CD\u09AC\u09BE\u099A\u09A8",normalized:"select"},clear:{primary:"\u09AA\u09B0\u09BF\u09B7\u09CD\u0995\u09BE\u09B0",normalized:"clear"},reset:{primary:"\u09B0\u09BF\u09B8\u09C7\u099F",normalized:"reset"},breakpoint:{primary:"\u09AC\u09CD\u09B0\u09C7\u0995\u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F",normalized:"breakpoint"},click:{primary:"\u0995\u09CD\u09B2\u09BF\u0995",normalized:"click"},hover:{primary:"\u09B9\u09CB\u09AD\u09BE\u09B0",alternatives:["\u0989\u09AA\u09B0\u09C7_\u09B0\u09BE\u0996\u09C1\u09A8"],normalized:"hover"},submit:{primary:"\u09B8\u09BE\u09AC\u09AE\u09BF\u099F",alternatives:["\u099C\u09AE\u09BE"],normalized:"submit"},input:{primary:"\u0987\u09A8\u09AA\u09C1\u099F",alternatives:["\u09AA\u09CD\u09B0\u09AC\u09C7\u09B6"],normalized:"input"},change:{primary:"\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8",normalized:"change"},go:{primary:"\u09AF\u09BE\u09A8",alternatives:["\u09AF\u09BE\u0993"],normalized:"go"},scroll:{primary:"\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2",normalized:"scroll"},push:{primary:"\u09AA\u09C1\u09B6",alternatives:["\u09A0\u09C7\u09B2\u09C1\u09A8"],normalized:"push"},replace:{primary:"\u09AA\u09CD\u09B0\u09A4\u09BF\u09B8\u09CD\u09A5\u09BE\u09AA\u09A8",normalized:"replace"},process:{primary:"\u09AA\u09CD\u09B0\u09B8\u09C7\u09B8",alternatives:["\u09AA\u09CD\u09B0\u0995\u09CD\u09B0\u09BF\u09AF\u09BC\u09BE"],normalized:"process"},wait:{primary:"\u0985\u09AA\u09C7\u0995\u09CD\u09B7\u09BE",normalized:"wait"},fetch:{primary:"\u0986\u09A8\u09C1\u09A8",alternatives:[],normalized:"fetch"},settle:{primary:"\u09B8\u09CD\u09A5\u09BF\u09B0",alternatives:[],normalized:"settle"},if:{primary:"\u09AF\u09A6\u09BF",alternatives:[],normalized:"if"},when:{primary:"\u09AF\u0996\u09A8",normalized:"when"},where:{primary:"\u0995\u09CB\u09A5\u09BE\u09AF\u09BC",normalized:"where"},else:{primary:"\u09A8\u09A4\u09C1\u09AC\u09BE",alternatives:["\u09A8\u09BE \u09B9\u09B2\u09C7"],normalized:"else"},repeat:{primary:"\u09AA\u09C1\u09A8\u09B0\u09BE\u09AC\u09C3\u09A4\u09CD\u09A4\u09BF",alternatives:["\u09AC\u09BE\u09B0 \u09AC\u09BE\u09B0"],normalized:"repeat"},for:{primary:"\u099C\u09A8\u09CD\u09AF",alternatives:[],normalized:"for"},while:{primary:"\u09AF\u09A4\u0995\u09CD\u09B7\u09A3",alternatives:[],normalized:"while"},forever:{primary:"\u099A\u09BF\u09B0\u0995\u09BE\u09B2",normalized:"forever",alternatives:["forever"]},continue:{primary:"\u099A\u09BE\u09B2\u09BF\u09AF\u09BC\u09C7 \u09AF\u09BE\u09A8",alternatives:[],normalized:"continue"},halt:{primary:"\u09A5\u09BE\u09AE\u09C1\u09A8",alternatives:["\u09A5\u09BE\u09AE\u09BE\u0993"],normalized:"halt"},throw:{primary:"\u09A8\u09BF\u0995\u09CD\u09B7\u09C7\u09AA",alternatives:["\u099B\u09C1\u0981\u09A1\u09BC\u09C7 \u09A6\u09BF\u09A8"],normalized:"throw"},call:{primary:"\u0995\u09B2",alternatives:["\u09A1\u09BE\u0995\u09C1\u09A8"],normalized:"call"},return:{primary:"\u09AB\u09BF\u09B0\u09C1\u09A8",alternatives:["\u09AB\u09C7\u09B0\u09A4 \u09A6\u09BF\u09A8"],normalized:"return"},then:{primary:"\u09A4\u09BE\u09B0\u09AA\u09B0",alternatives:["\u09A4\u0996\u09A8"],normalized:"then"},and:{primary:"\u098F\u09AC\u0982",alternatives:[],normalized:"and"},end:{primary:"\u09B6\u09C7\u09B7",alternatives:["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"],normalized:"end"},js:{primary:"\u099C\u09C7\u098F\u09B8",alternatives:["js"],normalized:"js"},async:{primary:"\u0985\u09CD\u09AF\u09BE\u09B8\u09BF\u0999\u09CD\u0995",alternatives:[],normalized:"async"},tell:{primary:"\u09AC\u09B2\u09C1\u09A8",alternatives:["\u09AC\u09B2"],normalized:"tell"},default:{primary:"\u09A1\u09BF\u09AB\u09B2\u09CD\u099F",alternatives:[],normalized:"default"},init:{primary:"\u09B6\u09C1\u09B0\u09C1",alternatives:[],normalized:"init"},behavior:{primary:"\u0986\u099A\u09B0\u09A3",alternatives:[],normalized:"behavior"},install:{primary:"\u0987\u09A8\u09B8\u09CD\u099F\u09B2",alternatives:[],normalized:"install"},measure:{primary:"\u09AE\u09BE\u09AA\u09C1\u09A8",alternatives:[],normalized:"measure"},beep:{primary:"\u09AC\u09C0\u09AA",alternatives:[],normalized:"beep"},break:{primary:"\u09AD\u09BE\u0999\u09C1\u09A8",alternatives:[],normalized:"break"},copy:{primary:"\u0995\u09AA\u09BF",alternatives:[],normalized:"copy"},exit:{primary:"\u09AC\u09C7\u09B0",alternatives:[],normalized:"exit"},pick:{primary:"\u09AC\u09BE\u099B\u09C1\u09A8",alternatives:[],normalized:"pick"},render:{primary:"\u09B0\u09C7\u09A8\u09CD\u09A1\u09BE\u09B0",alternatives:[],normalized:"render"},into:{primary:"\u09AD\u09BF\u09A4\u09B0\u09C7",normalized:"into"},before:{primary:"\u0986\u0997\u09C7",alternatives:[],normalized:"before"},after:{primary:"\u09AA\u09B0\u09C7",alternatives:[],normalized:"after"},until:{primary:"\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",alternatives:[],normalized:"until"},event:{primary:"\u0998\u099F\u09A8\u09BE",alternatives:[],normalized:"event"},from:{primary:"\u09A5\u09C7\u0995\u09C7",normalized:"from"},connect:{primary:"\u0995\u09BE\u09A8\u09C7\u0995\u09CD\u099F",alternatives:["\u09B8\u0982\u09AF\u09CB\u0997","\u09AF\u09C1\u0995\u09CD\u09A4"],normalized:"connect"},stream:{primary:"\u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u09AE",alternatives:["\u09B8\u09CD\u09B0\u09CB\u09A4","\u09AA\u09CD\u09B0\u09AC\u09BE\u09B9"],normalized:"stream"},live:{primary:"\u09B2\u09BE\u0987\u09AD",alternatives:["\u09B8\u09B0\u09BE\u09B8\u09B0\u09BF","\u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u0995\u09CD\u09B7"],normalized:"live"},socket:{primary:"\u09B8\u0995\u09C7\u099F",alternatives:["\u0993\u09AF\u09BC\u09C7\u09AC\u09B8\u0995\u09C7\u099F"],normalized:"socket"},bind:{primary:"\u09AC\u09BE\u0987\u09A8\u09CD\u09A1",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\u0986\u099F\u0995\u09BE\u0993",alternatives:["\u0987\u09A8\u09CD\u099F\u09BE\u09B0\u09B8\u09C7\u09AA\u09CD\u099F","intercept"],normalized:"intercept"},worker:{primary:"\u0995\u09B0\u09CD\u09AE\u09C0",alternatives:["\u0993\u09AF\u09BC\u09BE\u09B0\u09CD\u0995\u09BE\u09B0","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u0987\u09AD\u09C7\u09A8\u09CD\u099F\u09B8\u09CB\u09B0\u09CD\u09B8"],normalized:"eventsource"}},tokenization:{particles:["\u0995\u09C7","\u09A4\u09C7","\u09A5\u09C7\u0995\u09C7","\u09B0","\u098F\u09B0","\u09A6\u09BF\u09AF\u09BC\u09C7","\u099C\u09A8\u09CD\u09AF","\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4"],boundaryStrategy:"space"},eventHandler:{keyword:{primary:"\u09A4\u09C7",alternatives:["\u098F","\u09AF\u0996\u09A8"],normalized:"on"},sourceMarker:{primary:"\u09A5\u09C7\u0995\u09C7",position:"after"},eventMarker:{primary:"\u09A4\u09C7",alternatives:["\u098F"],position:"after"},temporalMarkers:["\u09AF\u0996\u09A8","\u09AF\u0996\u09A8\u0987"]}},yo=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],ho=class{constructor(i=yo){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}},vo="()[]{},:;",Eo=class{constructor(i=vo){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 nt(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 go=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?nt(i,e)!==null:false}extract(i,e){let r=nt(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},zo=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 ko(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 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=ko(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},bo=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 ot(i){let e=i.charCodeAt(0);return e>=2432&&e<=2559}var wo=class{constructor(){this.name="bengali-keyword";}setContext(i){this.context=i;}canExtract(i,e){return ot(i[e])}extract(i,e){if(!this.context)throw new Error("BengaliKeywordExtractor: context not set");let r=e,t="",a=e;for(;a<i.length&&ot(i[a]);)t+=i[a],a++;if(!t)return null;let n=this.context.lookupKeyword(t),o=n&&n.normalized!==n.native?n.normalized:void 0,u;if(!n&&this.context.normalizer){let s=this.context.normalizer.normalize(t);if(s.stem!==t&&s.confidence>=.7){let l=this.context.lookupKeyword(s.stem);l&&(u=l.normalized);}}return {value:t,length:a-r,metadata:{normalized:o||u}}}},ut=new Map([["\u0995\u09C7",{role:"patient",confidence:.95}],["\u09A4\u09C7",{role:"destination",confidence:.9}],["\u098F",{role:"event",confidence:.85}],["\u09A5\u09C7\u0995\u09C7",{role:"source",confidence:.95}],["\u09B0",{role:"possessive",confidence:.95}],["\u098F\u09B0",{role:"possessive",confidence:.95}],["\u09A6\u09BF\u09AF\u09BC\u09C7",{role:"instrument",confidence:.9}],["\u099C\u09A8\u09CD\u09AF",{role:"purpose",confidence:.9}],["\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4",{role:"until",confidence:.9}],["\u09AE\u09A7\u09CD\u09AF\u09C7",{role:"location",confidence:.85}]]),Ao=class{constructor(){this.name="bengali-particle";}setContext(i){this._context=i,this._context;}canExtract(i,e){let r="",t=e;for(;t<i.length&&this.isBengali(i[t]);)r+=i[t],t++;return ut.has(r)}extract(i,e){let r="",t=e;for(;t<i.length&&this.isBengali(i[t]);)r+=i[t],t++;let a=ut.get(r);return a?{value:r,length:r.length,metadata:{role:a.role,confidence:a.confidence,variant:r}}:null}isBengali(i){let e=i.charCodeAt(0);return e>=2432&&e<=2559}};function Do(i){let e=i.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Bo(i){let e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var So=class{constructor(){this.name="ascii-identifier";}setContext(i){this.context=i;}canExtract(i,e){return Do(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&&Bo(i[a]);)t+=i[a],a++;if(!t)return null;let n=this.context.lookupKeyword(t),o=n&&n.normalized!==n.native?n.normalized:void 0;return {value:t,length:a-r,metadata:{normalized:o}}}};function xo(){return [new Co,new zo,new bo,new go]}var Fo=new Set(["\u0995\u09C7","\u09A4\u09C7","\u09A5\u09C7\u0995\u09C7","\u09B0","\u098F\u09B0","\u09A6\u09BF\u09AF\u09BC\u09C7","\u099C\u09A8\u09CD\u09AF","\u09AA\u09B0\u09CD\u09AF\u09A8\u09CD\u09A4","\u098F","\u09AE\u09A7\u09CD\u09AF\u09C7"]),To=[{native:"\u09B8\u09A4\u09CD\u09AF",normalized:"true"},{native:"\u09AE\u09BF\u09A5\u09CD\u09AF\u09BE",normalized:"false"},{native:"\u09B6\u09C2\u09A8\u09CD\u09AF",normalized:"null"},{native:"\u0985\u09A8\u09BF\u09B0\u09CD\u09A7\u09BE\u09B0\u09BF\u09A4",normalized:"undefined"},{native:"\u09AA\u09CD\u09B0\u09A5\u09AE",normalized:"first"},{native:"\u09AA\u09B0\u09AC\u09B0\u09CD\u09A4\u09C0",normalized:"next"},{native:"\u0986\u0997\u09C7\u09B0",normalized:"previous"},{native:"\u09A8\u09BF\u0995\u099F\u09A4\u09AE",normalized:"closest"},{native:"\u09AE\u09C2\u09B2",normalized:"parent"},{native:"\u0995\u09CD\u09B2\u09BF\u0995",normalized:"click"},{native:"\u099C\u09AE\u09BE",normalized:"submit"},{native:"\u0987\u09A8\u09AA\u09C1\u099F",normalized:"input"},{native:"\u09B2\u09CB\u09A1",normalized:"load"},{native:"\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2",normalized:"scroll"},{native:"\u0995\u09C7",normalized:"to"},{native:"\u09B8\u09BE\u09A5\u09C7",normalized:"with"}],Oo=class extends Ve{constructor(){super(),this.language="bn",this.direction="ltr",this.initializeKeywordsFromProfile(st,To),this.setNormalizer(fo),this.registerExtractors(xo()),this.registerExtractor(new Ie),this.registerExtractor(new je),this.registerExtractor(new Ao),this.registerExtractor(new wo),this.registerExtractor(new So),this.registerExtractor(new ho),this.registerExtractor(new Eo);}classifyToken(i){return Fo.has(i)?"particle":this.isKeyword(i)?"keyword":i.startsWith("/")||i.startsWith("./")||i.startsWith("../")||i.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||i.startsWith("'")||/^\d/.test(i)?"literal":(i.startsWith(":"),"identifier")}},Po=new Oo;He("bn",Po,st);function Ze(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 lt={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 Xe(i){switch(i.kind){case "event-handler":return Ro(i);case "compound":return No(i);default:return Lo(i)}}function Ro(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(Xe);e.push(a.join(" then "));}return e.join(" ")}function No(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(Xe).join(` ${e} `)}function Lo(i){let e=lt[i.action];if(e){let t=[i.action];for(let[a,n]of e){let o=i.roles.get(a);o&&(a==="destination"&&o.type==="reference"&&o.value==="me"||(n&&t.push(n),t.push(Le(o))));}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 Mo(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function Mo(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 mt=.5,_o={confidenceThreshold:mt,strategy:"semantic",fallbackToOriginal:true};function Io(i,e){return typeof i=="number"?i:i[e]??i["*"]??mt}function mr(i,e,r={}){let t={..._o,...r},a=ct(i,e,t);if(a!==null)return a;let n=Vo(i);if(n){let o=ct(n.commands,e,t);if(o!==null)return n.prefix+o}return i}function ct(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=Io(r.confidenceThreshold,e),a=pt(i,e,t);if(a!==null)return a}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=$o(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var jo=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Vo(i){let e=i.match(jo);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function pt(i,e,r){try{let t=Wo(i,e);if(t.length>1)return Ko(t,e,r);if(!jr(e))return null;let a=Yr(i,e);return a.confidence<r||!a.node?null:Xe(a.node)}catch{return null}}function $o(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function qo(i){let e=["then"],r=L(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 Wo(i,e){let t=qo(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),n=i.split(`
|
|
5
|
+
`).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of n){let s=u.split(a);o.push(...s);}return o}function Ko(i,e,r){let t=[];for(let a of i){let n=pt(a.trim(),e,r);if(n===null)return null;t.push(n);}return t.join(" then ")}function pr(i={}){return function(r){let{internals:t}=r,a=t.runtime,n=a.getScript.bind(a);a.getScript=function(o){let u=n(o);if(!u)return null;let s=Uo(o,i);if(!s||s==="en")return u;let l=mr(u,s,i);return i.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function Uo(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=Ze(i);return r||(e.defaultLanguage??null)}function dt(i,e,r={}){return e==="en"?i:mr(i,e,r)}Ir(i=>Xr(i));function ft(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(pr()),Ho());}function Ho(){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 a=e.getInternalData(t);a.initialized&&(a.initialized=false);}),e.processNode(document.body);}var Ms=["hi","bn"];ft();exports.plugin=pr;exports.preprocess=dt;exports.resolveLanguage=Ze;exports.supportedLanguages=Ms;return exports;})({});
|