@hyperscript-tools/multilingual 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +23 -20
  3. package/dist/hyperscript-i18n-ar.global.js +6 -5
  4. package/dist/hyperscript-i18n-bn.global.js +6 -5
  5. package/dist/hyperscript-i18n-de.global.js +6 -5
  6. package/dist/hyperscript-i18n-east-asian.global.js +6 -5
  7. package/dist/hyperscript-i18n-en.global.js +8 -7
  8. package/dist/hyperscript-i18n-es.global.js +6 -5
  9. package/dist/hyperscript-i18n-fr.global.js +6 -5
  10. package/dist/hyperscript-i18n-he.global.js +6 -5
  11. package/dist/hyperscript-i18n-hi.global.js +6 -5
  12. package/dist/hyperscript-i18n-id.global.js +6 -5
  13. package/dist/hyperscript-i18n-it.global.js +6 -5
  14. package/dist/hyperscript-i18n-ja.global.js +6 -5
  15. package/dist/hyperscript-i18n-ko.global.js +6 -5
  16. package/dist/hyperscript-i18n-lite.global.js +2 -2
  17. package/dist/hyperscript-i18n-ms.global.js +6 -5
  18. package/dist/hyperscript-i18n-pl.global.js +6 -5
  19. package/dist/hyperscript-i18n-pt.global.js +6 -5
  20. package/dist/hyperscript-i18n-qu.global.js +6 -5
  21. package/dist/hyperscript-i18n-ru.global.js +6 -5
  22. package/dist/hyperscript-i18n-slavic.global.js +6 -5
  23. package/dist/hyperscript-i18n-south-asian.global.js +6 -5
  24. package/dist/hyperscript-i18n-southeast-asian.global.js +6 -5
  25. package/dist/hyperscript-i18n-sw.global.js +6 -5
  26. package/dist/hyperscript-i18n-th.global.js +6 -5
  27. package/dist/hyperscript-i18n-tl.global.js +6 -5
  28. package/dist/hyperscript-i18n-tr.global.js +6 -5
  29. package/dist/hyperscript-i18n-uk.global.js +6 -5
  30. package/dist/hyperscript-i18n-vi.global.js +6 -5
  31. package/dist/hyperscript-i18n-western.global.js +6 -5
  32. package/dist/hyperscript-i18n-zh.global.js +6 -5
  33. package/dist/hyperscript-i18n.global.js +28 -27
  34. package/package.json +5 -3
@@ -1,5 +1,6 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function le(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function rr(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function qe(t){return {type:"reference",value:t}}function tr(t,e){return {type:"property-path",object:t,property:e}}var rt=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function gr(t,e=rt){return e.has(t)}var qi=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}]`,n=new Date().toISOString();switch(t){case "debug":console.debug(`${n} ${i} DEBUG:`,e,...r);break;case "info":console.info(`${n} ${i} INFO:`,e,...r);break;case "warn":console.warn(`${n} ${i} WARN:`,e,...r);break;case "error":console.error(`${n} ${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 Wi(t){return new qi(t)}function De(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 Ki(t,e){return t?.possessive?.keywords?.[e]}var Ke=class Be{constructor(){this.logger=Wi("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 n=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",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 o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(n),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-n.position,confidence:u}}matchBest(e,r,i){let n=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,i);s&&n.push(s),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let E=this.collectStopMarkers(r,l+1);if(n)for(let h of n)E.add(h);let y=[];for(;!e.isAtEnd();){let h=e.peek();if(!h||this.isStopMarker(h,E))break;y.push(h.value),e.advance();}if(y.length>0){i.set(c.role,{type:"expression",raw:y.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let E=this.collectStopMarkers(r,l+1);if(n)for(let h of n)E.add(h);if(this.matchGroupToken(e,c,i,E)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let d=c.type==="role"&&c.optional===true,p=d?e.mark():null;if(c.type==="role"&&!d){let E=l+1<r.length?r[l+1]:null;if(E?.type==="literal"){let y=e.peek();if(y&&this.getMatchType(y,E.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),i.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}}let v=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Match result:",v),v){d?(u=p,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),i.delete(s),u=null,s=null;let E=this.matchPatternToken(e,c,i);if(this.logger.debug(" >> Backtrack retry result:",E),E)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 n=this.getMatchType(i,r.value);if(this.logger.debug(" >>> matchType for",i.value,"vs",r.value,":",n),n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="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 n=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null"),!n)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!De(a.type,r.expectedTypes)?r.optional||false:(i.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!De(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!De(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!De(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&&!De(l.type,r.expectedTypes)?r.optional||false:(i.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",n?JSON.stringify({value:n.value,kind:n.kind}):"null");let c=this.tokenToSemanticValue(n);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!De(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,n=this.safeToLowerCase(i),a=Ki(this.currentProfile,n);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),tr(qe(a),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<Be.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=`${r.value}.${a.value}`,u=1;for(;!e.isAtEnd()&&u<Be.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let 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<Be.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(c===0){e.advance();break}c--;}if(d.kind==="punctuation"&&d.value==="("&&c++,d.kind==="punctuation"&&d.value===","){e.advance();continue}l.push(d.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 i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="punctuation"||n.value!=="'s")return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(i),null):(e.advance(),tr(rr(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return tr(rr(r.value),o)}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Set(i.keys());if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let l of i.keys())o.has(l)||i.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=Be.MAX_MARKER_SCAN;l++){let 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 p=0;p<l;p++)e.advance();if(this.matchTokenSequence(e,r.tokens,i,n))return true;e.reset(a);for(let p of i.keys())o.has(p)||i.delete(p);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 n=r;n<e.length;n++){let a=e[n];if(a.type==="literal"){if(i.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)i.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(i.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)i.add(u.toLowerCase());break}if(!a.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 rr(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return le(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return qe(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return le(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return le(n,"string")}if(e==="true")return le(true,"boolean");if(e==="false")return le(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?le(e,"duration"):le(n,"number")}let i=parseFloat(e);return isNaN(i)?le(e,"string"):le(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction))r.has(i)||(n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,n.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")n+=1,r.has(l.role)&&(i+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=a(c.role),d=.8;n+=d,r.has(c.role)?i+=d:m&&(i+=d*.6);}}let o=n>0?i/n:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let 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 n of r.alternatives)if(i.has(n))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let i=0,n={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[a,o]of r.entries()){let u=n[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?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(Be.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};Ke.MAX_MARKER_SCAN=3;Ke.MAX_PROPERTY_DEPTH=10;Ke.MAX_METHOD_ARGS=20;Ke.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Hi=Ke;new Hi;var Se=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==="'"&&e>0&&/[\p{L}\p{N}_)\]]/u.test(t[e-1])?false:r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(t,e){let r=t[e];if(r==="\u201C"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u201D")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u2019")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}let i=1,n=false;for(;e+i<t.length;){let a=t[e+i];if(n){n=false,i++;continue}if(a==="\\"){n=true,i++;continue}if(a===r)return i++,{value:t.substring(e,e+i),length:i};i++;}return null}},xe=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 o=t[e+r];if(/\d/.test(o))r++;else if(o==="."&&!i)i=true,r++;else break}if(r===0)return null;let n=t.substring(e,e+r),a=e+r;if(a<t.length){let o=t.slice(a),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:n+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:n+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:n+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:n,length:r}}};function Ui(t){return "setContext"in t&&typeof t.setContext=="function"}function Gi(t){let e={language:t.language,direction:t.direction,lookupKeyword:t.lookupKeyword.bind(t),isKeyword:t.isKeyword.bind(t),isKeywordStart:t.isKeywordStart.bind(t),...t.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:t.isKeywordStartAtBoundary.bind(t)}:{}};return t.normalizer?{...e,normalizer:t.normalizer}:e}var ie=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 U(t,e){return {start:t,end:e}}function G(t,e,r,i){if(typeof t=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=t;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let n=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof i=="string")return {value:n,kind:e,position:r,normalized:i};if(i){let{normalized:a,stem:o,stemConfidence:u,metadata:s}=i;return {value:n,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:n,kind:e,position:r}}function We(t){return /\s/.test(t)}function Yi(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Zi(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function ge(t){return /\d/.test(t)}function nr(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Ji(t){return /[a-zA-Z]/.test(t)}function te(t){return /[a-zA-Z0-9_-]/.test(t)}function Xi(t,e){if(e>=t.length)return null;let r=t[e];if(!Yi(r))return null;let i=e,n="";if(r==="#"||r==="."){for(n+=t[i++];i<t.length&&te(t[i]);)n+=t[i++];if(n.length<=1)return null;if(i<t.length&&t[i]==="."&&r==="#"){let o=i+1;for(;o<t.length&&te(t[o]);)o++;if(o<t.length&&t[o]==="(")return n}}else if(r==="["){let a=1,o=false,u=null,s=false;for(n+=t[i++];i<t.length&&a>0;){let l=t[i];n+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,i++;}if(a!==0)return null}else if(r==="@"){for(n+=t[i++];i<t.length&&te(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="*"){for(n+=t[i++];i<t.length&&te(t[i]);)n+=t[i++];if(n.length<=1)return null}else if(r==="<"){if(n+=t[i++],i>=t.length||!Ji(t[i]))return null;for(;i<t.length&&te(t[i]);)n+=t[i++];for(;i<t.length;){let a=t[i];if(a==="."){if(n+=t[i++],i>=t.length||!te(t[i]))return null;for(;i<t.length&&te(t[i]);)n+=t[i++];}else if(a==="#"){if(n+=t[i++],i>=t.length||!te(t[i]))return null;for(;i<t.length&&te(t[i]);)n+=t[i++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(n+=t[i++];i<t.length&&o>0;){let c=t[i];n+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,i++;}if(o!==0)return null}else break}for(;i<t.length&&We(t[i]);)n+=t[i++];if(i<t.length&&t[i]==="/")for(n+=t[i++];i<t.length&&We(t[i]);)n+=t[i++];if(i>=t.length||t[i]!==">")return null;n+=t[i++];}return n||null}function Qi(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 We(i)||i==="*"||!te(i)}function en(t,e){if(e>=t.length)return null;let r=t[e];if(!Zi(r)||r==="'"&&Qi(t,e))return null;let n={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!n)return null;let a=e+1,o=r,u=false;for(;a<t.length;){let s=t[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===n)return o;a++;}return o}function rn(t,e){if(e>=t.length)return false;let r=t[e],i=t[e+1]||"",n=t[e+2]||"";if(r==="/"&&i!=="/"&&/[a-zA-Z0-9._-]/.test(i)||r==="/"&&i==="/"&&/[a-zA-Z]/.test(n)||r==="."&&(i==="/"||i==="."&&n==="/"))return true;let a=t.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function tn(t,e){if(!rn(t,e))return null;let r=e,i="",n=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let a=t[r];if(a==="#"){if(i.length>0&&/[a-zA-Z0-9/.]$/.test(i))for(i+=a,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)i+=t[r++];break}if(n.test(a))i+=a,r++;else break}return i.length<2?null:i}function nn(t,e){if(e>=t.length)return null;let r=t[e];if(!ge(r)&&r!=="-"&&r!=="+")return null;let i=e,n="";if((t[i]==="-"||t[i]==="+")&&(n+=t[i++]),i>=t.length||!ge(t[i]))return null;for(;i<t.length&&ge(t[i]);)n+=t[i++];if(i<t.length&&t[i]===".")for(n+=t[i++];i<t.length&&ge(t[i]);)n+=t[i++];return i<t.length&&(t.slice(i,i+2)==="ms"?n+="ms":(t[i]==="s"||t[i]==="m"||t[i]==="h")&&(n+=t[i])),n}var an=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(an);var on=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"]);function un(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var sn=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],ar=class ir{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){Ui(e)&&e.setContext(Gi(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&&We(e[i]);)i++;if(i>=e.length)break;let n=this.tryMultiWordKeyword(e,i);if(n){r.push(n),i=n.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,i)){let u=o.extract(e,i);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,m={};if(u.metadata)for(let[p,f]of Object.entries(u.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(m[p]=f);let d={};s&&(d.normalized=s),l&&(d.stem=l),c!==void 0&&(d.stemConfidence=c),Object.keys(m).length>0&&(d.metadata=m),r.push(G(u.value,this.classifyToken(u.value),U(i,i+u.length),Object.keys(d).length>0?d:void 0)),i+=u.length,a=true;break}}if(!a){let o=e[i],u=this.classifyUnknownChar(o);r.push(G(o,u,U(i,i+1))),i++;}}return new ie(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let i of e){let n=r[r.length-1];if(n&&ir.ASCII_WORD.test(n.value)&&ir.COLON_QUALIFIER.test(i.value)&&n.position.end===i.position.start){let a=n.value+i.value;r[r.length-1]=G(a,this.classifyToken(a),U(n.position.start,i.position.end));continue}r.push(i);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,i){if(e[r]!==".")return false;let n=i[i.length-1],a=n&&n.position.end<r;if(n&&!a&&(n.kind==="identifier"||n.kind==="keyword"||n.kind==="selector"))return i.push(G(".","operator",U(r,r+1))),true;let s=r+1;for(;s<e.length&&te(e[s]);)s++;return s<e.length&&e[s]==="("?(i.push(G(".","operator",U(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let i=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[n,a]of Object.entries(e.keywords))if(i.set(a.primary,{native:a.primary,normalized:a.normalized||n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:a.normalized||n});}if(e.references){for(let[n,a]of Object.entries(e.references))i.set(a,{native:a,normalized:n});for(let n of Object.keys(e.references))i.has(n)||i.set(n,{native:n,normalized:n});}if(e.roleMarkers){for(let[n,a]of Object.entries(e.roleMarkers))if(a.primary&&i.set(a.primary,{native:a.primary,normalized:n}),a.alternatives)for(let o of a.alternatives)i.set(o,{native:o,normalized:n});}if(e.possessive?.keywords)for(let[n,a]of Object.entries(e.possessive.keywords))i.set(n,{native:n,normalized:a});for(let n of sn)i.has(n)||i.set(n,{native:n,normalized:n});for(let n of r)i.set(n.native,n);this.profileKeywords=Array.from(i.values()).sort((n,a)=>a.native.length-n.native.length),this.multiWordKeywords=this.profileKeywords.filter(n=>(n.native.includes(" ")||un(n.native))&&!on.has(n.normalized)),this.profileKeywordMap=new Map;for(let n of this.profileKeywords){this.profileKeywordMap.set(n.native.toLowerCase(),n);let a=this.removeDiacritics(n.native);a!==n.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),n);}}removeDiacritics(e){return nr(e)}tryProfileKeyword(e,r){for(let i of this.profileKeywords)if(e.slice(r).startsWith(i.native))return G(i.native,"keyword",U(r,r+i.native.length),i.normalized);return null}tryMultiWordKeyword(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){if(this.multiWordKeywords.length===0)return null;let n=e.slice(r);for(let a of this.multiWordKeywords){if(!n.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&i(o)))return G(a.native,"keyword",U(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let i=e.slice(r);return this.profileKeywords.some(n=>i.startsWith(n.native))}isKeywordStartAtBoundary(e,r,i=n=>/[\p{L}\p{N}_]/u.test(n)){let n=e.slice(r);return this.profileKeywords.some(a=>{if(!n.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!i(o)})}lookupKeyword(e){let r=this.profileKeywordMap.get(e.toLowerCase());if(r)return r;let i=this.removeDiacritics(e);if(i!==e)return this.profileKeywordMap.get(i.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}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 n=this.tryNormalize(e);if(!n)return null;let a=this.lookupKeyword(n.stem);if(!a)return null;let o={normalized:a.normalized,stem:n.stem,stemConfidence:n.confidence};return G(e,"keyword",U(r,i),o)}trySelector(e,r){let i=Xi(e,r);return i?G(i,"selector",U(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 n=i[0].replace(/(\s|\.)$/,""),a=n.slice(1).split("(")[0],o=i[1];return {...G(n,"event-modifier",U(r,r+n.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let i=en(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryNumber(e,r){let i=nn(e,r);return i?G(i,"literal",U(r,r+i.length)):null}tryMatchTimeUnit(e,r,i,n=false){let a=r;if(n)for(;a<e.length&&We(e[a]);)a++;let o=e.slice(a);for(let u of i){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(te(c))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,i=true){let n=r,a="";if(i&&(e[n]==="-"||e[n]==="+")&&(a+=e[n++]),n>=e.length||!ge(e[n]))return null;for(;n<e.length&&ge(e[n]);)a+=e[n++];if(n<e.length&&e[n]===".")for(a+=e[n++];n<e.length&&ge(e[n]);)a+=e[n++];return !a||a==="-"||a==="+"?null:{number:a,endPos:n}}tryNumberWithTimeUnits(e,r,i,n={}){let{allowSign:a=true,skipWhitespace:o=false}=n,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,c=[...i,...ir.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),G(s,"literal",U(r,l))}tryUrl(e,r){let i=tn(e,r);return i?G(i,"url",U(r,r+i.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!te(e[r+1]))return null;let i=r+1;for(;i<e.length&&te(e[i]);)i++;let n=e.slice(r,i);return G(n,"identifier",U(r,i))}tryOperator(e,r){let i=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(i))return G(i,"operator",U(r,r+2));let n=e[r];return ["<",">","!","+","-","*","/","="].includes(n)?G(n,"operator",U(r,r+1)):["(",")","{","}",",",";",":"].includes(n)?G(n,"punctuation",U(r,r+1)):null}tryMultiCharParticle(e,r,i){for(let n of i)if(e.slice(r,r+n.length)===n)return G(n,"particle",U(r,r+n.length));return null}};ar.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;ar.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;ar.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 Fe=ar;function or(t){return {stem:t,confidence:1}}function he(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var ln=Object.defineProperty,cn=Object.getOwnPropertyNames,At=(t,e)=>function(){return t&&(e=(0, t[cn(t)[0]])(t=0)),e},mn=(t,e)=>{for(var r in e)ln(t,r,{get:e[r],enumerable:true});};function nt(t,e){return t.replace(/\{(\w+)\}/g,(r,i)=>String(e[i]??`{${i}}`))}function ne(t,e,r={},i){let n=Dt[t],a=nt(n,r),o=Bt[t],u=o?nt(o,r):void 0;return {code:t,message:a,severity:e,...i&&{role:i},...u&&{suggestion:u}}}var T,Dt,Bt,dn=At({"src/generators/schema-error-codes.ts"(){T={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Dt={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[T.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[T.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[T.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[T.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[T.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[T.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[T.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[T.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[T.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[T.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[T.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[T.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Bt={[T.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[T.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[T.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[T.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[T.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[T.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[T.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[T.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[T.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[T.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[T.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[T.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[T.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),St={};mn(St,{SchemaErrorCodes:()=>T,formatValidationResults:()=>gn,getValidationStats:()=>Cn,validateAllKeywordCollisions:()=>wn,validateAllSchemas:()=>En,validateCommandSchema:()=>xt,validateKeywordCollisions:()=>Ft,validateRoleValues:()=>zn});function pn(t,e){return {action:t,items:e}}function xt(t){let e=[];for(let i of t.roles)i.expectedTypes.includes("literal")&&i.expectedTypes.includes("selector")&&(i.role==="patient"&&Ar.has(t.action)?e.push(ne(T.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:i.role,command:t.action},i.role)):e.push(ne(T.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:i.role},i.role))),i.expectedTypes.length>3&&!Ar.has(t.action)&&e.push(ne(T.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(ne(T.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:i.role},i.role)));switch(t.action){case "transition":fn(t,e);break;case "on":yn(t,e);break;case "if":case "unless":hn(t,e);break;case "repeat":case "for":case "while":vn(t,e);break}return t.roles.filter(i=>i.required).length===0&&(Tt.has(t.action)?e.push(ne(T.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(ne(T.NO_REQUIRED_ROLES,"warning",{}))),pn(t.action,e)}function fn(t,e){let r=t.roles.find(n=>n.role==="patient"),i=t.roles.find(n=>n.role==="goal");r&&!i&&e.push(ne(T.TRANSITION_MISSING_GOAL,"error",{}));}function yn(t,e){let r=t.roles.find(i=>i.role==="event");r||e.push(ne(T.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(ne(T.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function hn(t,e){let r=t.roles.find(i=>i.role==="condition");r||e.push(ne(T.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(ne(T.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function vn(t,e){t.action==="for"?t.roles.find(i=>i.role==="source")||e.push(ne(T.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(i=>i.role==="condition")||e.push(ne(T.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function En(t,e={}){let r=new Map,{includeNotes:i=false}=e;for(let[n,a]of Object.entries(t)){let o=xt(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=i&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(n,o);}return r}function gn(t,e={}){let r=[],{showNotes:i=false,showCodes:n=true}=e;for(let[a,o]of t){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let c of u){let m=n?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of s){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(i&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let m=n?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
- `)}function Cn(t){let e=0,r=0,i=0,n={};for(let a of t.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&i++,n[o.code]=(n[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:i,byCode:n}}function zn(t,e){let r=[];for(let i of e){let n=t.roles.find(a=>a.role===i.role);n&&(n.expectedTypes.length>0&&!n.expectedTypes.includes(i.type)&&(n.expectedTypes.includes("expression")||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects type [${n.expectedTypes.join(", ")}], got '${i.type}'`,code:T.VALUE_TYPE_MISMATCH})),i.type==="selector"&&i.selectorKind&&n.selectorKinds&&n.selectorKinds.length>0&&(n.selectorKinds.includes(i.selectorKind)||r.push({level:"error",role:i.role,message:`${t.action}.${i.role} expects selector kind [${n.selectorKinds.join(", ")}], got '${i.selectorKind}'`,code:T.SELECTOR_KIND_MISMATCH})));}return r}function kn(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return Rt.some(([i,n])=>i===e&&n===r)}function Ft(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[n,a]of Object.entries(t.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:n,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let u of a.alternatives){let s=r.get(u)||[];s.push({command:n,isPrimary:false}),r.set(u,s);}}for(let[n,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1||kn(o))continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:n,commands:o.sort(),type:s});}let i={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((n,a)=>i[n.type]-i[a.type]),{language:t.code,collisions:e}}function wn(t){let e=[];for(let[,r]of Object.entries(t)){let i=Ft(r);i.collisions.length>0&&e.push(i);}return e.sort((r,i)=>r.language.localeCompare(i.language))}var Ar,Tt,Rt,bn=At({"src/generators/schema-validator.ts"(){dn(),Ar=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Tt=new Set(["compound","else","halt","continue","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),Rt=[["change","changes"]];}});function we(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function be(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function Ae(t,e){return Or(t,e,"source")}function Rr(t,e){return Or(t,e,"destination")}function An(t,e){return Or(t,e,"patient")}function Or(t,e,r){if(!e||!t.roles.some(a=>a.role===r))return [];let i=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},n={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[n,i]:[i,n]}]}var Dn={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination",for:"duration"}},argSkipTokens:["on"],roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2,markerOptional:{zh:true}},{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"]}},{role:"duration",description:"How long the class stays on before reverting (`toggle .a for 2s`)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3,valueShape:"time",markerOverride:{en:"for",ja:"\u9593",ko:"\uB3D9\uC548"}}],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)"}},Bn={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},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",es:"a",ar:"\u0625\u0644\u0649",zh:"\u5230",fr:"\xE0",de:"zu",pt:"a",he:"\u05D0\u05DC",id:"ke",it:"a",sw:"kwa"},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","dans"],de:["auf","in"],pt:["em","para"],he:["\u05E2\u05DC","\u05D1","\u05DC"],id:["pada","di"],it:["in","su"],sw:["kwenye"]}}],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"}},Sn={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source"}},targetRole:"source",argSkipTokens:["from"],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"}},xn={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",ar:"\u0641\u064A",zh:"\u5230",fr:"dans",de:"in",he:"\u05D1",id:"ke",sw:"kwa"},markerVariants:{en:["before","after"]},markerLegacy:{ar:["\u0639\u0644\u0649","\u0625\u0644\u0649","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","\xE0"],de:["auf","zu"],he:["\u05E2\u05DC","\u05D0\u05DC","\u05DC"],id:["pada","di"],sw:["kwenye"]},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"}},Fn={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient",on:"scope"}},argSkipTokens:["to"],roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",th:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B",zh:"\u628A"},markerOptional:{zh:true}},{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",th:"\u0E43\u0E19",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902",zh:"\u5230"},markerVariants:{tr:["e","a","ye","ya"],zh:["\u4E3A","\u70BA","\u6210"]}},{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>"}},Tn={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Rn={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},On={action:"when",description:"Reactive observer: re-run the body when a watched expression changes",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,structuralOnly:true,roles:[{role:"condition",description:"The watched expression (`or`-separated expressions watch each)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1}]},Ln={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Pn={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Nn={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Mn={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},_n={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},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}]},In={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:"duration"}},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}]},jn={action:"on",description:"Handle an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{from:"source"}},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}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},$n={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{on:"destination"}},argSkipTokens:["on"],roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]},markerOverride:{bn:"\u0995\u09C7",hi:"\u0915\u094B"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Vn={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},qn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",ast:{args:["source"],modifiers:{with:["style","method"],as:"responseType",body:"patient"},isBlocking:true},roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},Wn={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},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"}}]},Kn={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},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"}}]},Hn={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Un={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Gn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Yn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",ast:{args:[["source","patient"]]},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}]},Zn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source",for:"recipient"}},argSkipTokens:["from"],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 all current holders)",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1},{role:"recipient",description:"The element the class moves ONTO (`take .active from .tab for me`)",required:false,expectedTypes:["reference"],svoPosition:3,sovPosition:3,valueShape:"reference",markerOverride:{en:"for"}}]},Jn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Xn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",ast:{args:[],modifiers:{the:"patient"}},argSkipTokens:["the"],roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Qn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",ast:{args:[["destination","patient"]],isBlocking:true},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}]},ea={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},ra={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{to:"destination",detail:"patient"}},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"}}]},ta={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},ia={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",ast:{args:["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}]},na={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},aa={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",ast:{args:[["quantity","patient"]]},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"'},oa={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{in:"source"}},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"}}]},ua={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},sa={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Lr={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"},la={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",es:"a",ar:"\u0625\u0644\u0649",fr:"\xE0",de:"zu",pt:"para",he:"\u05D0\u05DC",hi:"\u092A\u0930",id:"ke",it:"a",ru:"\u043D\u0430",sw:"kwa",uk:"\u043D\u0430"},renderOverride:{en:"",zh:"",vi:"",th:""},markerOptional:{en:true,zh:true,vi:true,th:true},markerVariants:{zh:["\u628A"]},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],fr:["sur","dans"],de:["auf","in"],pt:["em","a"],he:["\u05E2\u05DC","\u05D1","\u05DC","\u05D0\u05EA"],hi:["\u092E\u0947\u0902"],id:["pada","di"],it:["in","su"],ru:["\u0432","\u043A"],sw:["kwenye"],uk:["\u0432","\u0434\u043E"]}}],rolePrefixLiteralVariants:[{role:"destination",literal:Lr,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},ca={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"goal",over:"duration",on:"destination"}},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}]},ma={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",ast:{args:[["source","patient"]],modifiers:{into:"destination"}},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"}}]},da={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","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}]},pa={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","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}]},fa={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}]},ya={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{as:"style"}},roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}}]},ha={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}]},va={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}]},Ea={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}]},ga={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},za={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},ka={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},wa={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},ba={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",ast:{args:[["destination","patient"]]},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"}}]},Aa={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient"}},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"}}]},Da={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},Ba={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Sa={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination"}},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}]},xa={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{of:["destination","source"]}},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"}}]},Fa={en:"using view",es:"using view",pt:"using view",fr:"using view",de:"using view",it:"using view",ja:"using view",ko:"using view",zh:"using view",ar:"using view",he:"using view",hi:"using view",bn:"using view",tr:"using view",ru:"using view",uk:"using view",pl:"using view",id:"using view",vi:"using view",th:"using view",ms:"using view",tl:"using view",sw:"using view",qu:"using view"},Pr={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:Fa},Ta={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",ast:{args:["method","destination","patient"],modifiers:{viewTransition:"manner"}},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",tl:""}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}},{...Pr,svoPosition:4,sovPosition:4}]},Ra={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",ast:{args:[["source","destination"]],modifiers:{on:"patient",viewTransition:"manner"}},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"}},{...Pr,svoPosition:3,sovPosition:3}]},Oa={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:[]},Pa={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}]},Na={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ma={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},_a={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",ast:{args:["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"}}]},Ia={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"},ja={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:Lr}]},$a={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:Lr}]},Va={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Ia},{...Pr,svoPosition:2,sovPosition:2}]},qa={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"],valueShape:"object",svoPosition:2,sovPosition:1}]},se={toggle:Dn,add:Bn,remove:Sn,put:xn,set:Fn,show:_n,hide:In,on:jn,trigger:$n,wait:Vn,fetch:qn,increment:Wn,decrement:Kn,append:Hn,prepend:Un,log:Gn,get:Yn,take:Zn,make:Jn,halt:Xn,settle:Qn,throw:ea,send:ra,if:ta,unless:ia,else:na,repeat:aa,for:oa,while:ua,continue:sa,go:la,scroll:_a,push:ja,replace:$a,process:Va,transition:ca,clone:ma,focus:da,blur:pa,empty:fa,open:ya,close:ha,select:va,clear:Ea,reset:ga,breakpoint:Ca,call:za,return:ka,js:wa,tell:ba,default:Aa,init:Da,behavior:Ba,install:Sa,measure:xa,swap:Ta,morph:Ra,beep:Oa,break:La,copy:Pa,exit:Na,pick:Ma,render:qa,bind:Tn,live:Rn,when:On,eventsource:Ln,socket:Pn,worker:Nn,intercept:Mn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function re(t){return se[t]}function Wa(){return Object.values(se).filter(t=>t.structuralOnly!==true&&(t.roles.length>0||t.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(bn(),St)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(se);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 ke=new Map,pe=new Map,Ue=new Map,Dr=null;function Ot(t,e){let r={...t};for(let i of Object.keys(e)){let n=e[i],a=t[i];n!==void 0&&(typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[i]=Ot(a,n):r[i]=n);}return r}function Ka(t,e){return Ot(t,e)}function Nr(t){if(!t.extends)return t;let e=pe.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=Nr(e);return Ka(r,t)}function Ie(t,e,r){ke.set(t,e),pe.set(t,r),Ue.delete(t);}function Lt(t){Dr=t;}var at=new Map;function Le(t){return t.split("-")[0]}function Pe(t){return t.includes("-")}function Ha(t){let e=ke.get(t);if(!e&&Pe(t)){let r=Le(t);e=ke.get(r);}if(!e){let r=Array.from(ke.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 Ua(t){let e=pe.get(t);if(!e&&Pe(t)){let r=Le(t);e=pe.get(r);}if(!e){let r=Array.from(pe.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 Nr(e)}function L(t){let e=pe.get(t);return !e&&Pe(t)&&(e=pe.get(Le(t))),e?Nr(e):void 0}function Ga(){return Array.from(ke.keys())}function Pt(t){if(ke.has(t)&&pe.has(t))return true;if(Pe(t)){let e=Le(t);return ke.has(e)&&pe.has(e)}return false}function Ya(t,e){return Ha(e).tokenize(t)}function de(t){let e=Ue.get(t);if(!e&&Pe(t)&&(e=Ue.get(Le(t))),e)return e;let r=at.get(t);if(!r&&Pe(t)&&(r=at.get(Le(t))),r)return Ue.set(t,r),r;if(!Dr)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let i=Ua(t),n=Dr(i);return Ue.set(t,n),n}var Nt={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Ee(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 W(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Te(t){return gr(t)}function ue(t){return {type:"reference",value:t}}function ko(t,e){return e?{...t,position:e}:t}function Ce(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function ee(t,e,r){let i={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...i,metadata:r}:i}function He(t,e,r,i,n,a){let o=new Map;o.set("event",t);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),i!==void 0&&(u.metadata=i),n!==void 0&&n.length>0&&(u.parameterNames=n),u}function wo(t,e,r,i,n){let a={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return i!==void 0&&i.length>0&&(a.initBlock=i),n!==void 0&&(a.metadata=n),a}function bo(t,e,r,i){let n={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return i!==void 0&&(n.metadata=i),n}function Br(t,e,r,i,n){let a={kind:"feature",action:t,roles:n??new Map,body:e};return r!==void 0&&(a.name=r),i!==void 0&&(a.metadata=i),a}function Ge(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 Ao(t,e,r,i){let n=new Map;n.set("condition",t);let a={kind:"conditional",action:"if",roles:n,thenBranch:e};return r!==void 0&&(a.elseBranch=r),i!==void 0&&(a.metadata=i),a}function ur(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)):t==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Do(t,e){let r=t.markerOverride?.[e.code],i=e.roleMarkers[t.role];if(r!==void 0){let n=Bo(t,e.code,r);return {primary:r,...n&&{alternatives:n},position:i?.position??"before",isOverride:true}}if(i&&i.primary){let n={primary:i.primary,position:i.position,isOverride:false};return i.alternatives&&(n.alternatives=i.alternatives),n}return null}function Bo(t,e,r){let i=t.markerLegacy?.[e];if(!i?.length)return;let n=[...new Set(i)].filter(a=>a&&a!==r);return n.length?n:void 0}function fe(t,e,r){let i=t.markerLegacy?.[e]??[],n=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...i,...n])].filter(o=>o&&o!==r);return a.length?a:void 0}var Mt=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument"]);function ce(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let i=t.possessive?.specialForms;if(i){for(let[n,a]of Object.entries(i))if(a===e)return n}}function Cr(t){return Nt.possessive?.specialForms?.[t]??`${t}'s`}var Mr={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},So={ar:{\u0643\u0640:"as"},bn:{\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as"},es:{como:"as"},fr:{comme:"as"},hi:{\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as"},id:{sebagai:"as"},it:{come:"as"},ja:{\u3068\u3057\u3066:"as"},ko:{\uB85C:"as"},ms:{sebagai:"as"},pl:{jako:"as"},pt:{como:"as"},qu:{hina:"as"},ru:{\u043A\u0430\u043A:"as"},sw:{kuwa:"as"},tl:{bilang:"as"},tr:{olarak:"as"},uk:{\u044F\u043A:"as"},vi:{nh\u01B0:"as"},zh:{\u4F5C\u4E3A:"as"}},_t={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ar:new Set(["\u0644\u0640"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin","n\u0131n","nun","n\xFCn","in","\u0131n","un","\xFCn"])};function Sr(t,e){let r=e.value.toLowerCase(),i=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||i==="of"||i==="source")return true;let n=t?.code?_t[t.code]:void 0;return !!n&&n.has(r)}var Fo={destination:"in",source:"from"},To={ar:new Set(["\u0639\u0646\u062F","\u0641\u064A"]),bn:new Set(["\u098F","\u09A4\u09C7"]),de:new Set(["bei"]),es:new Set(["en"]),fr:new Set(["dans","en","\xE0"]),he:new Set(["\u05DC\u05EA\u05D5\u05DA"]),hi:new Set(["\u092A\u0930","\u092E\u0947\u0902"]),id:new Set(["dalam","di","ke_dalam"]),it:new Set(["a"]),ja:new Set(["\u3067","\u306E\u4E2D","\u3078"]),ko:new Set(["\uC548\uC5D0","\uC5D0","\uC73C\uB85C"]),ms:new Set(["dalam","di","ke_dalam"]),pl:new Set(["do","przy","w"]),pt:new Set(["dentro","em"]),qu:new Set(["pi","ukupi"]),ru:new Set(["\u0432","\u0443"]),sw:new Set(["katika","ndani"]),th:new Set(["\u0E17\u0E35\u0E48","\u0E43\u0E19"]),tl:new Set(["papasok_sa","sa","sa_loob"]),tr:new Set(["de","i\xE7inde","i\xE7ine"]),uk:new Set(["\u0432","\u0443"]),vi:new Set(["trong","t\u1EA1i","v\xE0o"]),zh:new Set(["\u5728","\u8FDB\u5165"])},Ro=new Set(["in","into","at","within","inside"]);function Oo(t,e){let r=e.value.toLowerCase();if((t?.code?To[t.code]:void 0)?.has(r))return "in";let n=e.normalized??e.value,a=n.toLowerCase();return Ro.has(a)?"in":Fo[a]??n}var zr=new Set(["first","last","next","previous","random","closest"]),Lo={bn:{\u09B6\u09C7\u09B7:"last"}},_r=new Set(Object.keys(se).map(t=>t.toLowerCase()));function It(t,e,r,i){let n=t[e];if(!n)return null;let a=(n.normalized??n.value).toLowerCase(),o=t[e+1],u=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Lo[r.code]?.[n.value.toLowerCase()]:void 0;if(!zr.has(a)&&!zr.has(n.value.toLowerCase())&&u===void 0)return null;let s=[{text:u??n.normalized??n.value,token:n}],l=e+1,c=t[l];if(!c||c.kind!=="selector")return null;s.push({text:c.value,token:c}),l++;let m=0;for(;m++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))s.push({text:f.value,token:f}),l++;else break}let d=t[l],p=t[l+1];return d&&p&&p.kind==="selector"&&(d.kind==="keyword"||d.kind==="particle"||d.kind==="identifier")&&!zr.has((d.normalized??d.value).toLowerCase())&&!_r.has((d.normalized??d.value).toLowerCase())&&!(i?.(d)===true&&i(t[l+2])!==true)&&(s.push({text:Oo(r,d),token:d}),s.push({text:p.value,token:p}),l+=2),{parts:s,consumed:l-e}}function Po(t,e){let r=So[t];return r?r[e.toLowerCase()]??e:e}function me(t,e){let r=Mr[t];return r?r[e.toLowerCase()]??e:e}function No(t,e){return Mr[t]?.[e.toLowerCase()]!==void 0}function Mo(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let i of r){let n=ce(t,i)??ce(t,i.toLowerCase());if(n)return n}}function jt(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function _o(t,e){let r=t?.references;if(!r)return false;let i=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>i.includes(a.toLowerCase()))}function ut(t,e){return jt(t)?me(e,t.value)!==t.value?true:t.kind==="identifier":false}var Io={ar:{\u0647\u0648:{beforePredicate:"is"}},hi:{\u0939\u0948:{beforePredicate:"is"},\u0928\u0939\u0940\u0902:{beforeBareIdentifier:"no"}},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is"}},ja:{\u7A7A:{afterCopula:"empty"}},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no"}},tl:{walang:{beforeBareIdentifier:"no"},may:{afterSubject:"exists"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists"}},tr:{var:{afterSubject:"exists"}}},jo=new Set(["empty","null","undefined","true","false"]),$t=new Set(["Number","Int","Float","String","Date","Array","Object","JSON","json","FormData","HTML","Fragment","Values"]);function $o(t,e,r,i){let n=Io[t],a=n?.[e.value]??n?.[e.value.toLowerCase()];if(a){if(a.beforeTypeName&&i?.kind==="identifier"&&$t.has(i.value))return a.beforeTypeName;if(a.beforePredicate&&i&&(i.kind==="literal"||i.kind==="keyword"&&jo.has((i.normalized??"").toLowerCase())))return a.beforePredicate;if(a.beforeBareIdentifier&&i?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(i.value))return a.beforeBareIdentifier;if(a.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return a.afterSubject;if(a.afterCopula&&r?.kind==="keyword"&&(r.normalized??"").toLowerCase()==="is")return a.afterCopula}}function Oe(t,e){let r=e?.code??"en",i="",n,a=(u,s)=>{if(n===void 0){i=u,n=s;return}let c=n.position?.end!==void 0&&s.position?.start!==void 0&&n.position.end===s.position.start&&(u.startsWith(".")||u.startsWith("!"));i+=(c?"":" ")+u,n=s;},o=u=>u.kind==="keyword"?u.normalized??u.value:u.value;for(let u=0;u<t.length;u++){let s=t[u],l=e?Mo(e,s):void 0,c=t[u+1];if(s.value==="'"&&n!==void 0&&c?.value==="s"&&s.position?.end!==void 0&&c.position?.start===s.position.end){i+="'s",n=c;let v=t[u+2];v&&me(r,v.value)!==v.value?(a(me(r,v.value),v),u+=2):u+=1;continue}if(l!==void 0&&c){let v=e?.possessive?.connectors,E=!!v?.length&&v.some(z=>{let A=z.toLowerCase();return A===c.value.toLowerCase()||A===(c.normalized??"").toLowerCase()}),y=E?u+2:u+1,h=t[y];if(h&&ut(h,r)){a(Cr(l),s),a(me(r,h.value),h),u=y;continue}if(E&&h&&/^\.[a-zA-Z_]\w*$/.test(h.value)&&c.position?.end!==void 0&&h.position?.start!==void 0&&c.position.end===h.position.start){a(Cr(l),s),a(me(r,h.value.slice(1)),h),u=y;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(c.value)&&s.position?.end!==void 0&&c.position?.start!==void 0&&s.position.end===c.position.start&&!_o(e,s)){a(Cr(l),s),a(me(r,c.value.slice(1)),c),u+=1;continue}}let m=t[u+2];if(c&&m&&m.kind==="selector"&&Sr(e,c)&&jt(s)){a(me(r,s.value),s),a("of",c),a(m.value,m),u+=2;continue}if(s.kind==="selector"&&c&&m&&Sr(e,c)&&ut(m,r)&&me(r,m.value)!==m.value){a(me(r,m.value),m),a("of",c),a(s.value,s),u+=2;continue}let d=It(t,u,e);if(d){for(let v of d.parts)a(v.text,v.token);u+=d.consumed-1;continue}let p=$o(r,s,t[u-1],c);if(p!==void 0){a(p,s);continue}let f=Po(r,s.value);if(f!==s.value){a(f,s);continue}a(o(s),s);}return i.trim()}var Vt=[{lang:"es",verb:"poner",verbAlts:["pon","colocar","put"],at:"en",end:"fin",of:"de"},{lang:"fr",verb:"mettre",at:"\xE0",end:"fin",of:"de"},{lang:"pt",verb:"colocar",at:"em",end:"fim",of:"de"},{lang:"it",verb:"mettere",at:"a",end:"fine",of:"di"},{lang:"de",verb:"setzen",at:"bei",end:"ende",of:"von"},{lang:"sw",verb:"weka",at:"katika",end:"mwisho",of:"ya"},{lang:"id",verb:"taruh",verbAlts:["letakkan","masukkan","tempatkan"],at:"di",end:"akhir",of:"dari"},{lang:"ms",verb:"letak",at:"di",end:"tamat",of:"daripada"},{lang:"vi",verb:"\u0111\u1EB7t",at:"t\u1EA1i",end:"k\u1EBFt th\xFAc",of:"c\u1EE7a"},{lang:"pl",verb:"umie\u015B\u0107",at:"przy",end:"koniec",of:"z"},{lang:"ru",verb:"\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",at:"\u0443",end:"\u043A\u043E\u043D\u0435\u0446",of:"\u0438\u0437"},{lang:"uk",verb:"\u043F\u043E\u043A\u043B\u0430\u0441\u0442\u0438",at:"\u0432",end:"\u043A\u0456\u043D\u0435\u0446\u044C",of:"\u0437"},{lang:"th",verb:"\u0E43\u0E2A\u0E48",at:"\u0E17\u0E35\u0E48",end:"\u0E08\u0E1A",of:"\u0E02\u0E2D\u0E07"},{lang:"tl",verb:"ilagay",at:"sa",end:"wakas",of:"ng"},{lang:"ar",verb:"\u0636\u0639",at:"\u0639\u0646\u062F",end:"\u0627\u0644\u0646\u0647\u0627\u064A\u0629",of:"\u0645\u0646"},{lang:"zh",verb:"\u653E\u7F6E",verbAlts:["\u653E","\u653E\u5165"],patientPrefix:"\u628A",at:"\u5728",end:"\u7ED3\u675F",of:"\u7684"},{lang:"he",verb:"\u05E9\u05D9\u05DD",patientPrefix:"\u05D0\u05EA",at:"at",end:"\u05E1\u05D5\u05E3",of:"of"},{lang:"tr",verb:"koy",sov:true,objMarker:"i",at:"de",end:"son",of:"nin"},{lang:"ja",verb:"\u7F6E\u304F",sov:true,objMarker:"\u3092",at:"\u3067",end:"\u7D42\u308F\u308A",of:"\u306E"},{lang:"ko",verb:"\uB123\uB2E4",sov:true,objMarker:"\uB97C",at:"\uC5D0",end:"\uB05D",of:"\uC758"},{lang:"hi",verb:"\u0930\u0916\u0947\u0902",verbAlts:["\u0930\u0916","\u0921\u093E\u0932\u0947\u0902","\u0921\u093E\u0932"],sov:true,objMarker:"\u0915\u094B",at:"\u092A\u0930",end:"\u0938\u092E\u093E\u092A\u094D\u0924",of:"\u0915\u093E"},{lang:"bn",verb:"\u09B0\u09BE\u0996\u09C1\u09A8",verbAlts:["\u09B0\u09BE\u0996"],sov:true,objMarker:"\u0995\u09C7",at:"\u098F",end:"\u09B6\u09C7\u09B7",of:"\u09B0"},{lang:"qu",verb:"churay",sov:true,objMarker:"ta",at:"pi",end:"tukuy",of:"pa"}];function st(t,e,r,i){let n=Vt.find(o=>o.lang===t);if(!n)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,n.end)&&a(r,n.at)&&a(i,n.of)}function Vo(t,e){let r=Vt.find(n=>n.lang===t);if(!r)return false;let i=e.toLowerCase();return i===r.at.toLowerCase()||i===r.of.toLowerCase()||i===r.end.toLowerCase()}var qt={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};function qo(t){return qt[t]}function lt(t,e){return qt[e]?.has(t.toLowerCase())??false}var Wt=96,Wo=/^[A-Za-z_][\w-]*$/,Ko=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function Kt(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&Ko.test(r.value)}function Ht(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Wo.test(r.value))return false;let i=t.peek(e+1),n=t.peek(e+2);return !!i&&i.value===":"&&!!n}function ct(t,e=0){return Kt(t,e)||Ht(t,e)}function Ho(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",i=-1,n=0,a=0;for(;!t.isAtEnd()&&a++<Wt;){let o=t.advance();if(!o)break;if(i>=0&&o.position.start>i&&(r+=" ".repeat(o.position.start-i)),r+=o.value,i=o.position.end,o.value==="{"||o.value==="(")n++;else if((o.value==="}"||o.value===")")&&(n--,n===0))return r}return null}function mt(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Ho(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function Ye(t,e){let r=t.mark(),i=[];if(e!==void 0){let a=t.peek();if(!a||a.value!==":"||!t.peek(1))return null;t.advance();let o=mt(t);if(o===null)return t.reset(r),null;i.push(`${e}:${o}`);}else if(!ct(t))return null;let n=0;for(;n++<Wt;){let a=t.peek();if(!a)break;if(a.value===","){if(i.length===0||!ct(t,1))break;t.advance();continue}if(Kt(t,0)){i.push(t.advance().value);continue}if(!Ht(t,0))break;let o=t.advance().value;t.advance();let u=mt(t);if(u===null)return t.reset(r),null;i.push(`${o}:${u}`);}return i.length===0?(t.reset(r),null):`{${i.join(", ")}}`}var sr=.8,Uo=.6,Go=.15,Yo=.5,dt=.15,pt=.1,ft=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"]),Zo={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"]},Jo=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),i=this.scoreLanguageBoost(t),n=this.scoreLanguageAdjustment(t),a=e;return a=Math.max(Yo,a+r),a=Math.min(1,a+i),a=Math.max(0,Math.min(1,a+n)),{roleCoverage:e,stemPenalty:r,languageBoost:i,languageAdjustment:n,final:a}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,i=0,n=0,a=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,u=se[o??e.command]?.roles,s=l=>u?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")r.has(l.role)?(n+=1,i+=1):s(l.role)||(n+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(n+=sr,i+=sr):s(c.role)||(n+=sr,a(c.role)&&(i+=sr*Uo)));return n>0?i/n:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*Go}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:ft.has(r.value)||r.alternatives?.some(i=>ft.has(i))?dt:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let i=0;for(let[n,a]of r.entries()){let o=Zo[n];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?i+=.1:i-=.1);}return Math.max(-pt,Math.min(pt,i))}},Xo=new Jo,Qo=new Set(Object.values(se).filter(t=>t.bareKeyword===true).map(t=>t.action));function eu(t){return t.startsWith("*")||t.startsWith("@")}var X=class M{constructor(e){this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Xo;}matchPattern(e,r){let i=e.mark(),n=new Map;if(this.currentProfile=L(r.language),this.currentPatternCommand=r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,!this.matchTokenSequence(e,r.template.tokens,n))return e.reset(i),null;let o=this.confidenceModel.calculate({pattern:r,captured:n,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-i.position,confidence:o,roleStarts:this.roleStarts}}matchBest(e,r){this.matchCache.clear();let i=[],n=e.position();for(let o of r){let u=e.mark(),s=`${n}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&i.push(l),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let a=i[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,i,n){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];if(u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,i,l),this.shouldTrySkippingVerbSlot(l,e,r[s+1]??n)){let m=e.mark(),d=new Map(i);if(this.matchTokenSequence(e,r.slice(s+1),d,n)&&this.atClauseEnd(e)){i.clear();for(let[p,f]of d)i.set(p,f);return true}e.reset(m);}let c=this.matchPatternToken(e,l,i,r[s+1]??n);if(u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!c){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,i){if(r.has("source"))return;let n=e.peek(),a=e.peek(1);if(!n||!a||this.patternTokenWouldMatch(i,n))return;let o=this.currentProfile?.roleMarkers?.source,u=l=>{if(l.kind!=="particle"&&l.kind!=="keyword")return false;if((l.normalized??"").toLowerCase()==="source")return true;if(!o)return false;let c=l.value.toLowerCase();return o.primary?.toLowerCase()===c?true:!!o.alternatives?.some(m=>m.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(n)&&a.kind==="selector"){e.advance();let l=this.tokenToSemanticValue(e.advance());l&&r.set("source",l);return}if(s==="after"&&n.kind==="selector"&&u(a)){let l=this.tokenToSemanticValue(n);e.advance(),e.advance(),l&&r.set("source",l);}}matchPatternToken(e,r,i,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let a=e.position(),o=this.matchRoleToken(e,r,i,n);return o&&i.has(r.role)&&this.roleStarts.set(r.role,a),o}case "group":return this.matchGroupToken(e,r,i,n);default:return false}}matchLiteralToken(e,r){let i=e.peek();if(!i)return false;let n=this.getMatchType(i,r.value);if(n!=="none")return this.totalKeywordMatches++,n==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(i,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let i=e.mark(),n=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;n.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),n.push("-");}if(n.length<3||n[n.length-1]==="-")return e.reset(i),null;let a=n.join("").toLowerCase();for(let[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.toLowerCase()===a))return W(o);return e.reset(i),null}tryMatchShatteredCompound(e,r,i){let n=r.split(i);if(n.length<2||n.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<n.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==i)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==n[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,i,n){let a=e.position(),o=i.get(r.role);return this.matchRoleTokenCore(e,r,i,n)?(this.absorbTrailingConversion(e,r,i,n,a),this.absorbTrailingConditionOperand(e,r,i,n,a),this.stampCaptureSpan(e,r.role,i,a,o),true):false}stampCaptureSpan(e,r,i,n,a){let o=i.get(r);if(!o||o===a||o.position||e.position()<=n)return;let u=e.tokens[n],s=e.tokens[e.position()-1];!u||!s||i.set(r,ko(o,{start:u.position.start,end:s.position.end}));}absorbTrailingConditionOperand(e,r,i,n,a){if(r.role!=="condition"||!i.has("condition")||e.position()<=a||n!==void 0||this.currentPatternCommand!=="on")return;let o=e.peek();if(!o)return;let u=M.CONDITION_OPERATOR_WORDS;if(!u.has((o.normalized??"").toLowerCase())&&!u.has(o.value.toLowerCase())||this.patternTokenWouldMatch(n,o))return;e.advance();let s=e.peek();s&&(s.kind==="selector"||s.kind==="identifier"||s.kind==="literal")&&!_r.has((s.normalized??s.value).toLowerCase())&&e.advance();let l=Oe(e.tokens.slice(a,e.position()),this.currentProfile);i.set("condition",{type:"expression",raw:l,value:l});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let n=e.peek(1);return !n||!$t.has(n.value)?0:2}absorbTrailingConversion(e,r,i,n,a){if(r.role==="event"||r.role==="action"||!i.has(r.role)||e.position()<=a||this.conversionRunLength(e)!==2||this.patternTokenWouldMatch(n,e.peek()))return;e.advance(),e.advance();let o=Oe(e.tokens.slice(a,e.position()),this.currentProfile);i.set(r.role,{type:"expression",raw:o,value:o});}matchRoleTokenCore(e,r,i,n){this.skipNoiseWords(e);let a=e.peek();if(!a)return r.optional||false;if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let y=this.tryFoldHyphenActionKeyword(e);if(y)return i.set(r.role,y),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!M.tokenLooksLikeEvent(a))return r.optional||false;let y=(a.normalized??a.value).toLowerCase();if(M.POSITIONAL_OR_SCOPE_KEYWORDS.has(y)||this.currentProfile&&(ce(this.currentProfile,a.value)??ce(this.currentProfile,y))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let y=(a.normalized??a.value).toLowerCase();if(M.STRUCTURAL_NEVER_EVENT.has(y))return r.optional||false}if(a.kind==="keyword"){let y=(a.normalized??a.value).toLowerCase();if(y==="then"||y==="end"&&e.peek(1)?.kind!=="selector"||lt(a.value,this.currentProfile?.code??"")||(r.role==="quantity"||r.role==="event"&&this.currentPatternCommand==="repeat")&&(a.normalized??a.value).toLowerCase()in se)return r.optional||false}if(r.role==="duration"){let y=(a.normalized??a.value).toLowerCase();if(M.POSITIONAL_OR_SCOPE_KEYWORDS.has(y))return r.optional||false}if(r.optional&&r.role!=="event"&&r.role!=="action"&&r.valueShape!=="keyword"&&a.kind==="keyword"&&(a.normalized??a.value).toLowerCase()in se&&(n===void 0||this.patternTokenWouldMatch(n,a)))return true;let o=this.tryMatchPositionalExpression(e,n);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!ur(o.type,r.expectedTypes)?r.optional||false:(i.set(r.role,o),true);let u=this.tryMatchCaretScopeExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!ur(u.type,r.expectedTypes)?r.optional||false:(i.set(r.role,u),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchBeepPrefixExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchHyphenatedWord(e);if(h)return i.set(r.role,h),true;let z=this.tryMatchOperatorRunExpression(e);if(z)return i.set(r.role,z),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let y=this.tryMatchPickRangeExpression(e);if(y)return i.set(r.role,y),true}if(r.expectedTypes?.includes("property-path")){let y=this.tryMatchOfPossessiveExpression(e);if(y)return i.set(r.role,y),true;let h=this.tryMatchPostNominalPossessiveExpression(e);if(h)return i.set(r.role,h),true}let s=this.tryMatchPossessiveExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.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:(i.set(r.role,l),true);let m=r.role==="event"&&this.currentPatternCommand==="on"||M.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")?null:this.tryMatchBareCallExpression(e);if(m)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(m.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,m),true);let d=this.tryMatchPossessiveSelectorExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!ur(d.type,r.expectedTypes)?r.optional||false:(i.set(r.role,d),true);let p=r.role!=="condition",f=this.tryMatchPropertyAccessExpression(e,p);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(f.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(i.set(r.role,f),true);let v=this.tryMatchSelectorPropertyExpression(e);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!ur(v.type,r.expectedTypes)?r.optional||false:(i.set(r.role,v),true);if(a.kind==="identifier"&&a.value==="{"){let y=r.expectedTypes,z=y?.length===1&&y[0]==="expression"?this.tryMatchBraceRunExpression(e):!y?.length||y.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(z)return i.set(r.role,z),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let y=Ye(e);if(y)return i.set(r.role,{type:"expression",raw:y}),true}let E=this.tokenToSemanticValue(a);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let y=E.type==="selector"&&String(E.value).startsWith("@"),h=r.expectedTypes.some(z=>z==="expression"||z==="reference");if(!(y&&h))return r.optional||false}if(r.valueShape==="keyword"&&E.type==="expression"?i.set(r.role,W(String(E.raw??""))):i.set(r.role,E),e.advance(),r.role==="event"){let y=e.peek();y&&y.kind==="selector"&&y.value.startsWith("[")&&"value"in E&&(i.set(r.role,W(`${String(E.value)}${y.value}`)),e.advance());let h=e.peek();if(h&&(h.kind==="particle"||h.kind==="keyword")&&(h.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(n,h)){let z=e.peek(1);if(z&&(z.kind==="selector"||z.kind==="identifier")){e.advance();let A=this.tokenToSemanticValue(e.advance());A&&!i.has("source")&&i.set("source",A);}}}return true}shouldTrySkippingVerbSlot(e,r,i){let n=e.type==="group"&&e.optional?e.tokens.every(u=>u.type==="role")?e.tokens[0]:void 0:e;if(!n||n.type!=="role"||!n.optional||n.role==="event"||n.role==="action"||n.valueShape==="keyword")return false;let a=r.peek();if(!a||a.kind!=="keyword"||i===void 0)return false;let o=this.patternTokenWouldMatch(i,a);return (a.normalized??a.value).toLowerCase()in se?!o:o}atClauseEnd(e){let r=e.peek();if(!r||r.kind==="conjunction")return true;if(r.kind!=="keyword")return false;let i=(r.normalized??r.value).toLowerCase();return i==="then"||i==="end"?true:lt(r.value,this.currentProfile?.code??"")}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(i=>this.getMatchType(r,i)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e,r){let i=It(e.tokens,e.position(),this.currentProfile,n=>n===void 0?false:this.patternTokenWouldMatch(r,n));if(!i)return null;for(let n=0;n<i.consumed;n++)e.advance();return {type:"expression",raw:i.parts.map(n=>n.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let i=e.peek(1),n=e.peek(2),a=(i?.normalized??"").toLowerCase(),o=!!i&&(i.value.toLowerCase()==="on"||a==="destination"||a==="on");return !i||!n||n.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${n.value}`})}isOfPossessiveMarker(e){return Sr(this.currentProfile,e)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}static tokensAdjacent(e,r){return e?.position?.end!==void 0&&r?.position?.start!==void 0&&e.position.end===r.position.start}tryMatchBeepPrefixExpression(e){let r=e.peek(),i=e.peek(1);if(!r||!i||i.value!=="!"||(r.normalized??r.value).toLowerCase()!=="beep"||!(r.position?.end!==void 0&&i.position?.start!==void 0&&r.position.end===i.position.start))return null;let a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let s=e.peek();if(!s||!M.RUN_OPERATORS.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(l);break}}let u=Oe(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}tryMatchHyphenatedWord(e){let r=e.peek();if(!M.isBareWordToken(r))return null;let i=1,n=[r.value];for(;;){let a=e.peek(i),o=e.peek(i+1);if(!a||a.value!=="-"||!M.isBareWordToken(o)||!M.tokensAdjacent(e.peek(i-1),a)||!M.tokensAdjacent(a,o))break;n.push(o.value),i+=2;}if(n.length<2)return null;for(let a=0;a<i;a++)e.advance();return W(n.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let n=1;for(;;){let o=e.peek();if(!o||!M.RUN_OPERATORS.has(o.value))break;let u=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e)){e.reset(u);break}n++;}if(n<2)return e.reset(r),null;let a=Oe(e.tokens.slice(i,e.position()),this.currentProfile);return {type:"expression",raw:a,value:a}}static rangeSeparatorFor(e){let[r]=M.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(M.PICK_RANGE_SEPARATORS.has(r))return true;let i=this.currentProfile?.code;return i?M.PICK_RANGE_SEPARATORS_BY_LANG[i]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),i=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let n=e.peek();if(!n||!this.isPickRangeSeparator(n)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&M.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(i,e.position()),[u,,s,l]=o,c=d=>d.kind==="keyword"?d.normalized??d.value:d.value,m=`${c(u)} to ${c(s)}`;return l&&(m+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:m,value:m}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let i=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let n=i==="start"||i==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&n?(e.advance(),true):false}tryConsumeRunOperand(e){let r=e.peek();if(!r)return false;if(r.value==="("){let i=e.mark(),n=0;for(;!e.isAtEnd();){let a=e.advance();if(a.value==="(")n++;else if(a.value===")"&&(n--,n===0))return true}return e.reset(i),false}return this.tryMatchPossessiveExpression(e)?true:(r.kind==="literal"||r.kind==="identifier"||r.kind==="selector"||r.kind==="keyword")&&!M.RUN_OPERATORS.has(r.value)&&r.value!==")"?(e.advance(),true):false}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(ce(this.currentProfile,r)??ce(this.currentProfile,r.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?me(this.currentProfile.code,e):e}tryMatchOfPossessiveExpression(e){let r=e.peek();if(!r||r.kind!=="selector"&&!this.isBareWordPropertyHead(r))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||!this.isOfPossessiveMarker(n))return e.reset(i),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"||eu(a.value)?(e.reset(i),null):(e.advance(),Ce(Ee(a.value),this.toEnglishProperty(r.value),"possessive"))}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let i=[r.value,r.normalized].filter(Boolean),n;for(let s of i)if(n=ce(this.currentProfile,s)??ce(this.currentProfile,s.toLowerCase()),n)break;if(!n)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(m=>m.toLowerCase()===l||m.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||Vo(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))&&!(u.normalized&&M.COMMAND_ACTION_KEYWORDS.has(u.normalized.toLowerCase()))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1)),s=this.toEnglishProperty(s);let l=s;for(;;){let m=e.peek();if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=m.value,e.advance();continue}if(m?.value==="?"){let d=e.peek(1);if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=`?${d.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let m="",d=0,p=0;for(;!e.isAtEnd()&&p++<M.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;m+=f.value,e.advance();for(let v of f.value)v==="("?d++:v===")"&&d--;if(d<=0)break}l+=m;}return Ce(ue(n),l,"possessive")}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let i=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||i)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;i&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let u=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let s=e.peek();if(!s)return e.reset(a),null;let l;for(let c of [s.value,s.normalized].filter(Boolean))if(l=ce(this.currentProfile,c)??ce(this.currentProfile,c.toLowerCase()),l)break;return l?(e.advance(),Ce(ue(l),u,"possessive")):(e.reset(a),null)}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}isRoleMarkerConcept(e){return Mt.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 i=e.normalized?.toLowerCase();return !(i&&Qo.has(i)||i==="me"||i==="it"||i==="you")}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark();e.advance();let n=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<M.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return n.push("}"),W(n.join(" "));n.push(u.value);}return e.reset(i),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let i=e.mark(),n="",a=-1,o=0,u=0;for(;!e.isAtEnd()&&u++<M.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(a>=0&&s.position.start>a&&(n+=" ".repeat(s.position.start-a)),n+=s.value,a=s.position.end,s.value==="{")o++;else if(s.value==="}"&&(o--,o===0))return {type:"expression",raw:n}}return e.reset(i),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let i=e.peek(1);if(!i||i.value!=="(")return null;let n=e.mark();e.advance();let a=e.advance(),o="",u=a.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<M.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let m=u!==void 0&&c.position?.start===u;o+=(o===""||m?"":" ")+c.value,u=c.position?.end,e.advance();}return s?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(n),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="operator"||n.value!==".")return e.reset(i),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(i),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(i),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<M.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e,r=true){let i=e.peek();if(!i||i.kind!=="identifier"&&i.kind!=="keyword")return null;let n=e.mark();e.advance();let a=i.value.toLowerCase(),o=e.peek();if((i.kind==="identifier"||M.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)){let p=i.value,f=[],v=0;for(;v<M.MAX_PROPERTY_DEPTH;){let h=e.peek();if(h&&h.kind==="selector"&&/^\.[a-zA-Z_]/.test(h.value))p+=`.${h.value.slice(1)}`,f.push(h.value.slice(1)),e.advance(),v++;else break}let E=e.peek(),y=!!E&&E.value.startsWith("(");if(r&&!y&&f.length>0&&Te(a))return Ce(ue(a),f.join("."),"dot");if(y){let h=e.mark(),z=[],A=0,D=false;for(;!e.isAtEnd();){let b=e.peek();if(!b)break;if(b.value==="(")A++;else if(b.value===")"){if(z.push(b.value),e.advance(),A--,A===0&&(D=true),D)break;continue}z.push(b.value),e.advance();}D?p+=z.join(""):e.reset(h);}return {type:"expression",raw:p}}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(n),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(n),null;e.advance();let l=`${i.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<M.MAX_PROPERTY_DEPTH;){let p=e.peek();if(!p||p.kind!=="operator"||p.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 p=[],f=0;for(;!e.isAtEnd()&&p.length<M.MAX_METHOD_ARGS;){let E=e.peek();if(!E)break;if(E.kind==="punctuation"&&E.value===")"){if(f===0){e.advance();break}f--;}if(E.kind==="punctuation"&&E.value==="("&&f++,E.kind==="punctuation"&&E.value===","){e.advance();continue}p.push(E.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let d=i.value.toLowerCase();if(r&&Te(d)){let p=l.split(".").slice(1).join(".");return Ce(ue(d),p,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let i=e.mark();e.advance();let n=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!n&&n.kind==="punctuation"&&n.value==="'s",u=!!n&&n.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(n?.normalized??"").toLowerCase()!=="source")return false;let f=se[this.currentPatternCommand];return !!f&&f.roles.some(v=>v.role==="source")})(),l=!!n&&!!a&&a!=="'s"&&n.value===a&&(n.kind==="particle"||n.kind==="punctuation"||n.kind==="identifier")&&!s;if(!o&&!l&&!u)return e.reset(i),null;e.advance(),u&&e.advance();let c=e.peek();if(!c)return e.reset(i),null;let m=c.kind==="selector"&&c.value.startsWith("*"),d=c.kind==="keyword"&&!!this.currentProfile&&No(this.currentProfile.code,c.value);return c.kind==="identifier"||m||d||(o||u)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),Ce(Ee(r.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(i),null)}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let i=e.mark();e.advance();let n=e.peek();if(!n||n.kind!=="selector"||!n.value.startsWith("."))return e.reset(i),null;let a=e.peek(1);a&&a.kind,e.advance();let o=n.value.slice(1);return Ce(Ee(r.value),o,"dot")}matchGroupToken(e,r,i,n){let a=e.mark(),o=new Map(i),u=this.matchTokenSequence(e,r.tokens,i,n);if(u){let s=[];for(let l of r.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&s.push(c.value,...c.alternatives??[]);s.length>0&&[...i.keys()].some(c=>!o.has(c))&&(e.tokens.slice(a.position,e.position()).some(d=>s.some(p=>this.getMatchType(d,p)!=="none"))||(u=false));}if(!u){e.reset(a);for(let s of i.keys())o.has(s)||i.delete(s);for(let[s,l]of o)i.get(s)!==l&&i.set(s,l);return r.optional||false}return true}getMatchType(e,r){if(e.value===r)return "exact";if(e.normalized===r)return "normalized";if(e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let i=nr(e.value).toLowerCase();if(i&&i===nr(r).toLowerCase())return "case-insensitive"}return "none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return Ee(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Te(r)?ue(r):W(e.normalized||e.value);case "identifier":if(e.value.startsWith("@"))return Ee(e.value);if(e.value.startsWith(":")||e.value.startsWith("$"))return ue(e.value);let i=e.value.toLowerCase();return Te(i)?ue(i):{type:"expression",raw:e.value};case "url":return W(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let n=e.slice(1,-1);return W(n,"string")}if(e==="true")return W(true,"boolean");if(e==="false")return W(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let n=parseFloat(r[1]);return r[2]?W(e,"duration"):W(n,"number")}let i=parseFloat(e);return isNaN(i)?W(e,"string"):W(i,"number")}applyExtractionRules(e,r){for(let[i,n]of Object.entries(e.extraction)){let a=r.get(i);if(a){if(n.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(i,n.transform(o));}}else n.value!==void 0?r.set(i,{type:"literal",value:n.value}):n.default&&r.set(i,{...n.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let i=r.value.toLowerCase();if(M.ENGLISH_NOISE_WORDS.has(i)){let n=e.mark();e.advance();let a=e.peek();if(a&&(a.kind==="selector"||a.kind==="identifier"))return;let o=e.peek(1);if(a&&a.kind==="keyword"&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value))return;let u=a?(a.normalized??a.value).toLowerCase():"";if(a&&M.POSITIONAL_OR_SCOPE_KEYWORDS.has(u))return;let s=e.peek(1),l=s?(s.normalized??s.value).toLowerCase():"",c=this.currentProfile?.wordOrder!=="SOV"&&M.COMMAND_ACTION_KEYWORDS.has(l),m=!s||s.kind==="particle"||M.CLAUSE_BOUNDARY_KEYWORDS.has(l)||c;if(a&&a.kind==="keyword"&&this.currentProfile?.code!=="en"&&Te(u)&&m||a&&a.kind==="keyword"&&this.currentProfile?.code==="en"&&Te(u))return;e.reset(n);}i==="class"&&e.advance();}extractEventModifiers(e){let r={},i=false;for(;!e.isAtEnd();){let n=e.peek();if(!n||n.kind!=="event-modifier")break;let a=n.metadata;if(!a)break;switch(i=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return i?r:void 0}};X.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);X.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);X.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);X.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);X.COMMAND_ACTION_KEYWORDS=_r;X.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);X.RUN_OPERATORS=new Set(["+","-","*","/"]);X.PICK_RANGE_SEPARATORS=new Set(["to"]);X.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};X.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);X.MAX_BRACE_RUN_TOKENS=64;X.MAX_PROPERTY_DEPTH=10;X.MAX_METHOD_ARGS=20;X.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);X.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ut=X,oe=new Ut;function Y(t,e){return Ya(t,e)}function Gt(){return Ga()}var Yt={ar:new Set(["\u0623\u0648"]),bn:new Set(["\u0985\u09A5\u09AC\u09BE"]),de:new Set(["oder"]),en:new Set(["or"]),es:new Set(["o"]),fr:new Set(["ou"]),he:new Set(["\u05D0\u05D5"]),hi:new Set(["\u092F\u093E"]),id:new Set(["atau"]),it:new Set(["o"]),ja:new Set(["\u307E\u305F\u306F"]),ko:new Set(["\uB610\uB294"]),ms:new Set(["atau"]),pl:new Set(["lub"]),pt:new Set(["ou"]),qu:new Set(["utaq"]),ru:new Set(["\u0438\u043B\u0438"]),sw:new Set(["au"]),th:new Set(["\u0E2B\u0E23\u0E37\u0E2D"]),tl:new Set(["o"]),tr:new Set(["veya"]),uk:new Set(["\u0430\u0431\u043E"]),vi:new Set(["ho\u1EB7c"]),zh:new Set(["\u6216"])},ru=new Set(Object.values(Yt).flatMap(t=>[...t]));function xr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let i=e===void 0?ru:Yt[e];return i?i.has(t.value)||i.has(r):false}var je=["if","unless","repeat","for","while"],cr=/^[A-Z][A-Za-z0-9_]*$/;function K(t,e){let r=new Set([e]),n=L(t)?.keywords?.[e];if(n){n.primary&&r.add(n.primary.toLowerCase());for(let a of n.alternatives??[])r.add(a.toLowerCase());}return r}function $(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var tu=new Set(je);function Xe(t,e){let r=t.normalized?.toLowerCase();return r?tu.has(r):e.some(i=>$(t,i))}var yt=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),iu=new Set(["destination","source","style","patient","on","from","to"]);function Ze(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(yt.has(e)||yt.has(r)||iu.has(e))}var ht=new Set(["ja","ko"]);function Ne(t){let e=new Set;t?.primary&&e.add(t.primary.toLowerCase());for(let r of t?.alternatives??[])e.add(r.toLowerCase());return e}function Zt(t,e){let r=[],i=e.position.end,n=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(n){i=e.position.end+n[0].length;for(let a of n[1].split(/[,\u060c\u3001]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:i}}function mr(t,e,r){let i=e+1;if(i>=t.length)return -1;let n=Ne(L(r)?.roleMarkers?.patient);return n.size>0&&$(t[i],n)&&i++,i<t.length?i:-1}var Jt=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function nu(t){let e=1;if(t[1]?.value==="("){let r=0,i=1;for(;i<t.length;i++)if(t[i].value==="(")r++;else if(t[i].value===")"&&--r===0)break;if(i>=t.length)return -1;e=i+1;}return e+1}function au(t,e,r){let i=L(r);if(i?.wordOrder!=="SOV"||!Jt.test(t[0].value)||e!==nu(t))return false;let n=Ne(i.roleMarkers?.patient);return n.size===0?false:$(t[e-1],n)}function ou(t,e,r){if(!L(e))return null;let i=K(e,"behavior"),n=K(e,"def"),a=t.toLowerCase(),o=[...i].some(m=>a.includes(m)),u=/\bdef\b/.test(a)||[...n].some(m=>m!=="def"&&a.includes(m));if(!o&&!u)return null;let s=Y(t,e).tokens;if(s.length<2)return null;if($(s[0],i))return vt(t,e,s,r,0);let l=s.findIndex((m,d)=>d>0&&$(m,i));if(l>0&&cr.test(s[0].value))return vt(t,e,s,r,l);if($(s[0],n))return Et(t,e,s,r,0);let c=s.findIndex((m,d)=>d>0&&$(m,n));return c>0&&au(s,c,e)?Et(t,e,s,r,c):null}function uu(t,e,r){let i=L(e);if(!i)return null;let n=i.wordOrder!=="SOV",a=ht.has(e)?Ne(i.roleMarkers?.event):new Set,o=ht.has(e)?Ne(i.keywords?.on):new Set,u=a.size>0&&o.size>0,s=K(e,"end"),l=K(e,"on"),c=t.toLowerCase(),m=[...s].some(b=>c.includes(b)),d=(n||u)&&(()=>{let b=0;for(let g of l)if(g){for(let w=c.indexOf(g);w>=0;w=c.indexOf(g,w+g.length))if(++b>=2)return true}return false})();if(!m&&!d)return null;let p=Y(t,e).tokens;if(p.length<2)return null;let f=je.map(b=>K(e,b)),v=b=>Xe(b,f),E=b=>$(b,s),y=[],h=0,z=0;for(let b=0;b<p.length;b++){let g=p[b];if(E(g)){if(h>0){h--;continue}let w=t.slice(p[z].position.start,g.position.start).trim();w&&y.push(w),z=b+1;}else if(v(g))h++;else if(n&&h===0&&b>z&&$(g,l)&&Ze(p[b+1])){let w=t.slice(p[z].position.start,g.position.start).trim();w&&y.push(w),z=b;}else if(u&&h===0&&b-1>z&&$(g,a)&&p[b+1]!==void 0&&$(p[b+1],o)){let w=p[b-1],S=t.slice(p[z].position.start,w.position.start).trim();S&&y.push(S),z=b-1;}}if(z<p.length){let b=t.slice(p[z].position.start).trim();b&&y.push(b);}if(y.length<2)return null;let A=[],D=[];for(let b of y){let g;try{g=r.statement(b,e);}catch{return null}if(!g||g.kind!=="event-handler")return null;let w=g;if(A.push(w),!w.body||w.body.length===0)return null;D.push(w.metadata?.confidence??.75);}return Ge(A,"then",{sourceLanguage:e,confidence:Me(D),sourceText:t})}function Me(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function dr(t){let e=[];for(let r of t){let i=r.statements;r.kind==="compound"&&Array.isArray(i)?e.push(...i):e.push(r);}return e}function vt(t,e,r,i,n){let a=n>0,o=a?0:mr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!cr.test(s))return null;let{parameters:l,headerEnd:c}=Zt(t,u),m=a?n+1:r.findIndex(w=>w.position.start>=c);m<=o&&(m=o+1);let d=K(e,"init"),p=K(e,"end"),f=je.map(w=>K(e,w)),v=w=>Xe(w,f),E=w=>$(w,p),y=[],h=[],z=[],A=false,D=0,b=m;for(let w=m;w<r.length;w++){let S=r[w];if(E(S)){if(D>0){D--;continue}if(w===b){A=true;break}if($(r[b],d)){let C=t.slice(r[b].position.end,S.position.start).trim();if(C)try{let k=dr(i.body(C,e));h.push(...k),z.push(Me(k.map(B=>B.metadata?.confidence??.75)));}catch{z.push(0);}}else {let C=t.slice(r[b].position.start,S.position.start).trim();try{let k=i.statement(C,e);if(k&&k.kind==="event-handler"){let B=k;y.push(B);let R=!B.body||B.body.length===0;z.push(R?.2:B.metadata?.confidence??.75);}else z.push(0);}catch{z.push(0);}}b=w+1;}else v(S)&&D++;}if(y.length===0&&h.length===0)return null;let g=(A?1:.8)*Me(z);return wo(s,l,y,h.length>0?h:void 0,{sourceLanguage:e,confidence:g,sourceText:t})}function Et(t,e,r,i,n){let a=n>0,o=a?0:mr(r,n,e);if(o<0)return null;let u=r[o],s=u.value;if(!Jt.test(s))return null;let{parameters:l,headerEnd:c}=Zt(t,u),m=a?n+1:r.findIndex(g=>g.position.start>=c);m<=o&&(m=o+1);let d=K(e,"end"),p=je.map(g=>K(e,g)),f=g=>Xe(g,p),v=g=>$(g,d),E=0,y=-1;for(let g=m;g<r.length;g++)if(v(r[g])){if(E===0){y=g;break}E--;}else f(r[g])&&E++;let h=r[m]?.position.start??c,z=y>=0?r[y].position.start:t.length,A=t.slice(h,z).trim();if(!A)return null;let D;try{D=dr(i.body(A,e));}catch{return null}if(D.length===0)return null;let b=Me(D.map(g=>g.metadata?.confidence??.75));return y<0&&(b*=.8),bo(s,l,D,{sourceLanguage:e,confidence:b,sourceText:t})}var Fr=["live","eventsource","socket","worker","intercept"],su=new Set(["intercept"]),Ir=new Set(["eventsource","socket","worker"]),lu=new Set(["eventsource","socket"]),cu=new Set(["worker"]),mu=6,du=2;function pu(t,e){for(let i of Fr)if($(t[0],K(e,i)))return {action:i,keywordIdx:0};if(L(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,mu);for(let i=1;i<r;i++)for(let n of Fr)if(n!=="live"&&$(t[i],K(e,n))&&!(Ir.has(n)&&!cr.test(t[0].value))&&!(n==="intercept"&&i>du))return {action:n,keywordIdx:i};return null}function fu(t,e,r){let i=Ne(L(r)?.roleMarkers?.source);return i.size===0||e+1>=t.length?0:$(t[e],i)||$(t[e+1],i)?2:0}function Xt(t){let e=K(t,"on");e.add("when");let r=L(t)?.eventHandler;if(r?.keyword){e.add(r.keyword.primary.toLowerCase());for(let i of r.keyword.alternatives??[])e.add(i.toLowerCase());}for(let i of r?.temporalMarkers??[])e.add(i.toLowerCase());return e}function yu(t,e,r){let i=L(r)?.eventHandler,n=[i?.eventMarker?.primary,...i?.eventMarker?.alternatives??[],...i?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),a=1;for(let o of n){let u=o.toLowerCase().split(/\s+/),s=e-u.length+1;s<0||u.every((l,c)=>t[s+c]?.value.toLowerCase()===l)&&(a=Math.max(a,u.length));}return a}function hu(t,e,r,i,n){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=fu(e,l,i)),l}let a=mr(e,r,i);if(a<0)return -1;if(t==="worker")return a+1;let o=Xt(i),u=Ne(L(i)?.roleMarkers?.event),s=n>=0?n:e.length;for(let l=a+1;l<s;l++){if(!$(e[l],o))continue;if(Ze(e[l+1]))return l;if(l>a+2&&u.size>0&&$(e[l-1],u)&&Ze(e[l-2]))return l-2;let c=yu(e,l,i);if(c>1&&l-c>a&&Ze(e[l-c]))return l-c;if(l>a+1&&Ze(e[l-1]))return l-1}return s}function vu(t,e,r,i){if(!Ir.has(t))return;let n=r>0?0:mr(e,r,i);if(!(n<0))return e[n].value}function Eu(t,e,r){if(!L(e))return null;let i=t.toLowerCase(),n=false;for(let s of [...Fr,"changes"]){for(let l of K(e,s))if(l&&i.includes(l)){n=true;break}if(n)break}if(!n)return null;let a=Y(t,e).tokens;if(a.length<2)return null;let o=ku(a,e);if(o>=0)return bu(t,e,a,r,o);let u=pu(a,e);return u?gu(t,e,a,r,u.action,u.keywordIdx):null}function gu(t,e,r,i,n,a){let o=K(e,"end"),u=je.map(A=>K(e,A)),s=A=>Xe(A,u),l=A=>$(A,o),c=vu(n,r,a,e);if(Ir.has(n)&&(!c||!cr.test(c)))return null;let m=A=>({sourceLanguage:e,confidence:A,sourceText:t}),d=Tr(r,a+1,l,s);if(su.has(n))return d>=0&&d!==r.length-1?null:Br(n,[],c,m(d>=0?1:.8));let p=hu(n,r,a,e,d);if(p<0||p>r.length)return null;let f=[],v=[],E=false,y=cu.has(n);if(y||lu.has(n)){let A=y?"def":"event-handler",D=0,b=p;for(let g=p;g<r.length;g++){let w=r[g];if(l(w)){if(D>0){D--;continue}if(E=true,g===b)break;let S=y?w.position.end:w.position.start,C=t.slice(r[b].position.start,S).trim();try{let k=i.statement(C,e);if(k&&k.kind===A){let B=k;f.push(B);let R=!B.body||B.body.length===0;v.push(R?.2:B.metadata?.confidence??.75);}else v.push(0);}catch{v.push(0);}b=g+1;}else s(w)&&D++;}}else {let A=Tr(r,p,l,s);E=A>=0;let D=A>=0?r[A].position.start:t.length,b=t.slice(r[p].position.start,D).trim();if(!b)return null;try{f.push(...dr(i.body(b,e)));}catch{return null}if(f.length===0)return null;v.push(...f.map(g=>g.metadata?.confidence??.75));}if(f.length===0&&!E)return null;let h=E?1:.8,z=v.length>0?h*Me(v):h;return Br(n,f,c,m(z))}var Cu=new Set([...Object.keys(se),"then","else"]);function zu(t){let e=K(t,"when");for(let r of Xt(t))e.add(r);return e}function ku(t,e){if(t.length<3||!$(t[0],zu(e)))return -1;let r=K(e,"changes"),i=K(e,"end");for(let n=2;n<t.length;n++){let a=t[n];if(a.kind==="literal")continue;if($(a,r))return n;if($(a,i))return -1;let o=(a.normalized??a.value).toLowerCase();if(a.kind==="keyword"&&Cu.has(o))return -1}return -1}function wu(t,e,r){if(r==="en"){let n=e[0],a=e[e.length-1];return {type:"expression",raw:t.slice(n.position.start,a.position.end).trim()}}let i=e.map(n=>xr(n,r)?{...n,kind:"keyword",normalized:"or"}:n);return {type:"expression",raw:Oe(i,L(r))}}function bu(t,e,r,i,n){let a=K(e,"end"),o=je.map(h=>K(e,h)),u=h=>Xe(h,o),s=h=>$(h,a),l=n+1;if(l>=r.length)return null;let c=Tr(r,l,s,u),m=c>=0;if(m&&c!==r.length-1)return null;let d=m?r[c].position.start:t.length,p=t.slice(r[l].position.start,d).trim();if(!p)return null;let f;try{f=dr(i.body(p,e));}catch{return null}if(f.length===0)return null;let v=wu(t,r.slice(1,n),e),y=(m?1:.8)*Me(f.map(h=>h.metadata?.confidence??.75));return Br("when",f,void 0,{sourceLanguage:e,confidence:y,sourceText:t},new Map([["condition",v]]))}function Tr(t,e,r,i){let n=0;for(let a=e;a<t.length;a++)if(r(t[a])){if(n===0)return a;n--;}else i(t[a])&&n++;return -1}var ve={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll",\u307C\u304B\u3057:"blur"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};Object.fromEntries(Object.entries(ve).map(([t,e])=>{let r={};for(let[i,n]of Object.entries(e))n in r||(r[n]=i);return [t,r]}));var Su={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},xu=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],Fu=/^(\d+)(ms|s|m)?$/,Tu=new Set(["selector","literal","url","event-modifier"]);function Ru(t){let e=t.match(Fu);if(!e)return null;let r=parseInt(e[1],10),i=e[2]||"ms";return i==="s"?r*=1e3:i==="m"&&(r*=6e4),r}function Ou(t){for(let e=1;e<t.length;e++){let r=t[e];if(Tu.has(r.kind))continue;let i=r.value.toLowerCase(),n=Su[i];if(n){let a=0;for(let o=e+1;o<t.length;o++){let u=t[o],s=Ru(u.value);if(s!==null)return {modifiers:{[n]:s},start:r.position.start,end:u.position.end};if(u.kind==="selector"||u.kind==="literal"||u.kind==="url"||++a>2)break}continue}for(let a of xu){if(a[0]!==i||e+a.length>t.length)continue;let o=true;for(let u=1;u<a.length;u++)if(t[e+u].value.toLowerCase()!==a[u]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}new Set(Object.values(Mr).flatMap(t=>Object.values(t)));var ze=new Set(["if","unless","while","repeat","for"]),wr=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Uu=new Set(["first","last","next","previous","random","closest"]),Re=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu","transitionend","transitionstart","transitionrun","transitioncancel","animationend","animationstart","animationiteration","animationcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","pointerout","touchstart","touchend","touchmove","touchcancel","mousemove","mouseenter","mouseleave","wheel","dragstart","dragend","dragover","dragenter","dragleave","drop","drag","loadend","loadstart","error","abort","close","open","message","popstate","hashchange","storage","online","offline","visibilitychange"]),Ct=class extends Error{constructor(t,e,r,i){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=i;}};function V(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function q(t,e){return e.length===0?t:{...t,diagnostics:e}}var lr=120;function Gu(t,e,r){let i=e.tokens.length;if(t.consumedTokens>=i)return null;let n=e.tokens[t.consumedTokens],a=e.tokens[i-1];if(!n||!a)return null;let o=r.slice(n.position.start,a.position.end);if(!o.trim())return null;let u=o.length>lr?`${o.slice(0,lr)}\u2026`:o,s=i-t.consumedTokens;return `pattern ${t.pattern.id} left ${s} token(s) unconsumed: "${u}"`}var Yu=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function br(t){let e=[],r=new Set((t.diagnostics??[]).map(n=>`${n.code}|${n.message}`)),i=n=>{if(!n||typeof n!="object")return;if(n!==t)for(let o of n.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let u=`${o.code}|${o.message}`;r.has(u)||(r.add(u),e.push(o));}let a=n;for(let o of ei){let u=a[o];if(Array.isArray(u))for(let s of u)i(s);}};return i(t),e.length===0?t:q(t,[...t.diagnostics??[],...e])}function zt(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var ei=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function ri(t,e){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=re(t.action),n=i?.primaryRole;if(i&&n&&n!=="patient"&&!i.roles.some(a=>a.role==="patient")&&t.roles.has("patient")&&!t.roles.has(n)){let a=t.roles,o=a.get("patient");o!==void 0&&(a.delete("patient"),a.set(n,o));}if(t.action==="tell"){let a=t.roles,o=a.get("patient"),u=a.get("destination");o&&(o.type==="selector"||o.type==="reference")&&(!u||u.type==="literal")&&(a.delete("patient"),a.set("destination",o));}if(t.action==="transition"){let a=t.roles,o=a.get("goal");o&&o.type==="literal"&&o.dataType==="duration"&&!a.has("duration")&&(a.delete("goal"),a.set("duration",o));}if(t.action==="fetch"){let a=t.roles,o=a.get("patient"),u=a.get("source");o&&u&&(o.type==="literal"||o.type==="expression")&&u.type==="expression"&&!a.has("style")&&(a.delete("patient"),a.set("style",u),a.set("source",o));}if(t.action==="transition"){let a=t.roles,o=a.get("destination");o&&o.type==="literal"&&!a.has("goal")&&(a.delete("destination"),a.set("goal",o));let u=a.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(u.value)&&a.set("patient",{type:"expression",raw:u.value});}if(t.action==="morph"){let a=t.roles,o=a.get("patient");o&&o.type==="literal"&&typeof o.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(o.value)&&a.set("patient",{type:"expression",raw:o.value});}if(t.action==="wait"){let a=t.roles;if(!a.has("event")){let o=a.get("duration"),u=o?.type==="expression"?o.raw:o?.type==="literal"?o.value:void 0;typeof u=="string"&&Re.has(u.toLowerCase())&&(a.delete("duration"),a.set("event",{type:"literal",value:u,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let a=t.roles,o=a.get("event");if(o&&o.type==="expression"){let u=o.raw;typeof u=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(u)&&a.set("event",{type:"literal",value:u,dataType:"string"});}}if(e?.size){let a=t.roles;for(let o of ["destination","source"]){let u=a.get(o);u&&u.type==="literal"&&typeof u.value=="string"&&e.has(u.value)&&a.set(o,{type:"expression",raw:u.value});}}}let r=t;for(let i of ei){let n=r[i];if(Array.isArray(n))for(let a of n)ri(a,e);}return t}var Q=class x{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let i=ri(this.parseInternal(e,r),this.boundIdentifiers),n=this.coverageFrames[this.coverageFrames.length-1];if(n.length>0&&(i=q(i,[...i.diagnostics??[],...n])),this.parseDepth===1&&(i=br(i),i.kind==="event-handler")){let a={node:i,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let s=0;s<4;s++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let u=this.reclaimEventCompoundTail(a.node,a.input,r);u&&(a=u),i=a.node;}return i}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=x.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let i=L(e)?.roleMarkers;if(i){for(let n of Object.values(i))if(n){if(n.primary)for(let a of n.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of n.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let n of x.LEAKED_RENDER_MARKERS[e]??[])r.add(n.toLowerCase());x.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let i=(e.normalized??e.value).toLowerCase();return Yu.has(i)?true:x.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,i){if(e.length===0)return;let n=this.coverageFrames[this.coverageFrames.length-1];if(!n||!e.some(u=>!this.isCoverageResidueToken(u,r)))return;let a=e.map(u=>u.value).join(" ").trim();if(!a)return;let o=a.length>lr?`${a.slice(0,lr)}\u2026`:a;n.push(V(`${i} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let i=e.roles.get(r);i?.type==="expression"&&typeof i.raw=="string"&&/^[A-Za-z_]\w*$/.test(i.raw)&&this.boundIdentifiers.add(i.raw);}parseInternal(e,r){let i=ou(e,r,{statement:(C,k)=>this.parse(C,k),body:(C,k)=>this.parseStatements(C,k)});if(i)return i;let n=Eu(e,r,{statement:(C,k)=>this.parse(C,k),body:(C,k)=>this.parseStatements(C,k)});if(n)return n;let a=uu(e,r,{statement:(C,k)=>this.parse(C,k),body:(C,k)=>this.parseStatements(C,k)});if(a)return a;let{modifiers:o,remainingInput:u}=this.extractStandaloneModifiers(e,r),s=u||e,c=this.stripAsyncModifier(s,r).remainingInput??s,d=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Y(d,r);this.positionSource=d;{let C=f.mark(),k=this.consumeJsBlock(f,r);if(k&&f.isAtEnd())return q(k,p);f.reset(C);}let v=de(r);if(v.length===0)throw new Ct(`No patterns available for language: ${r}`,r,d,[V(`No patterns registered for language '${r}'`,"error","no-patterns")]);let E=[...v].sort((C,k)=>k.priority-C.priority);{let C=f.tokens;if(L(r)?.wordOrder==="VSO"&&C.length>=4&&C[0]?.normalized==="source"){let k=C.findIndex(B=>B.normalized==="on");if(k>=2&&k+1<C.length){let B=d.slice(C[0].position.start,C[k].position.start).trim(),R=C[k+1].position.end,F=d.slice(C[k].position.start,R)+" "+B+d.slice(R);if(F!==d)try{let O=this.parse(F,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return q(N,p)}}catch{}}}}{let C=f.tokens,k=C[0]?.normalized==="if";for(let B=0;k&&B+3<C.length;B++){let R=(C[B+3]?.normalized??C[B+3]?.value??"").toLowerCase();if(C[B]?.normalized==="source"&&C[B+2]?.normalized==="on"&&x.KNOWN_EVENTS.has(R)){let F=(d.slice(0,C[B].position.start).trimEnd()+" "+d.slice(C[B+1].position.end).trimStart()).trim();if(F&&F!==d)try{let O=this.parse(F,r);if(O&&O.kind==="event-handler"){let N=o?this.applyModifiers(O,o):O;return q(N,p)}}catch{}break}}}{let C=f.tokens;for(let k=1;k<C.length-1;k++){let B=C[k];if(!xr(B,r))continue;let R=C[k+1],F=(R.normalized??R.value).toLowerCase();if(!x.KNOWN_EVENTS.has(F))break;let O=k+1,N=C[k+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(O=k+2);let I=C[k].position.start,j=C[O].position.end,P=(d.slice(0,I).trimEnd()+" "+d.slice(j).trimStart()).trim();if(P&&P!==d)try{let Z=this.parse(P,r);if(Z&&Z.kind==="event-handler"){Z.additionalEvents=[{type:"literal",value:F}];let J=o?this.applyModifiers(Z,o):Z;return q(J,p)}}catch{}break}}{let C=Ou(f.tokens);if(C){let k=(d.slice(0,C.start).trimEnd()+" "+d.slice(C.end).trimStart()).trim();if(k&&k!==d)try{let B=this.parse(k,r);if(B&&B.kind==="event-handler"){let R=this.applyModifiers(B,{...o??{},...C.modifiers});return q(R,p)}}catch{}}}let y=E.filter(C=>C.command==="on"),h=f.mark(),z=oe.matchBest(f,y);if(z){p.push(V(`event pattern matched: ${z.pattern.id} (confidence: ${z.confidence.toFixed(2)})`,"info","pattern-match"));let C=false;if(/^event-[a-z]+-bare$/.test(z.pattern.id)){let k=z.captured.get("event"),B=(k?.raw??k?.value??"").toString().toLowerCase(),R=ve[r],F=x.KNOWN_EVENTS.has(B)||!!R&&Object.keys(R).some(O=>O.toLowerCase()===B);if(B&&!F){let O=this.trySOVEventExtraction(d,r,E);if(O){p.push(V(`bare-event mis-anchor on "${B}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let N=o?this.applyModifiers(O,o):O;return q(N,p)}if(k?.type==="reference"||k?.type==="expression"){f.reset(h);let N=E.filter(j=>j.command!=="on"),I=oe.matchBest(f,N);f.reset(h),I&&I.pattern.command!=="on"?(C=true,p.push(V(`bare-event mis-anchor on reference "${B}" rejected; command ${I.pattern.command} preferred`,"info","stage-bare-event-guard"))):oe.matchBest(f,y);}}}if(!C){let k=this.buildEventHandler(z,f,r),B=o?this.applyModifiers(k,o):k;return q(B,p)}}p.push(V(`event patterns: ${y.length} tried, no match`,"info","stage-event"));let A=this.tryTrailingEventExtraction(d,r,E);if(A){p.push(V("trailing event extraction succeeded","info","stage-trailing-event"));let C=o?this.applyModifiers(A,o):A;return q(C,p)}let D=E.filter(C=>C.command!=="on"),b=this.tryParseUnlessGuard(f,D,r);if(b&&b.length>0){let C=b.length===1?b[0]:Ge(b,"then",{sourceLanguage:r,confidence:1});return q(C,p)}let g=oe.matchBest(f,D);if(g){if(ze.has(g.pattern.command)){let k=this.trySOVEventExtraction(d,r,E);if(k){p.push(V(`SOV event extraction preferred over bare ${g.pattern.command} command`,"info","stage-sov-loop"));let R=o?this.applyModifiers(k,o):k;return q(R,p)}let B=this.tryMidStreamEventExtraction(d,r,E);if(B){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-loop"));let R=o?this.applyModifiers(B,o):B;return q(R,p)}}else if(x.KNOWN_EVENTS.has(g.pattern.command)&&this.hasSOVEventMarkerHead(d,r)){let k=this.trySOVEventExtraction(d,r,E);if(k){p.push(V(`SOV event extraction preferred over command-homonym event ${g.pattern.command}`,"info","stage-sov-homonym"));let B=o?this.applyModifiers(k,o):k;return q(B,p)}}else if(L(r)?.wordOrder==="VSO"){let k=this.tryMidStreamEventExtraction(d,r,E);if(k){p.push(V(`mid-stream event extraction preferred over bare ${g.pattern.command} command`,"info","stage-midstream-cmd"));let B=o?this.applyModifiers(k,o):k;return q(B,p)}}if(g.consumedTokens<f.tokens.length&&L(r)?.wordOrder==="SOV"){let k=this.trySOVEventExtraction(d,r,E);if(k){p.push(V(`SOV event extraction preferred over partial ${g.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let B=o?this.applyModifiers(k,o):k;return q(B,p)}}if(g.consumedTokens<f.tokens.length&&!ze.has(g.pattern.command)){let k=this.tryTopLevelCommandSequence(f,D,r);if(k)return p.push(V(`top-level command sequence: ${k.statements.length} commands`,"info","stage-top-level-sequence")),q(k,p)}p.push(V(`command pattern matched: ${g.pattern.id} (confidence: ${g.confidence.toFixed(2)})`,"info","pattern-match"));let C=Gu(g,f,d);return C&&p.push(V(C,"warning","unconsumed-input")),q(this.buildCommand(g,r),p)}if(p.push(V(`command patterns: ${D.length} tried, no match`,"info","stage-command")),!d.includes(`
4
- `)&&L(r)?.wordOrder==="VSO"){let C=this.tryMidStreamEventExtraction(d,r,E);if(C){p.push(V("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let k=o?this.applyModifiers(C,o):C;return q(k,p)}}let w=this.trySOVEventExtraction(d,r,E);if(w){p.push(V("SOV event extraction succeeded","info","stage-sov"));let C=o?this.applyModifiers(w,o):w;return q(C,p)}p.push(V("SOV event extraction: no event keyword found","info","stage-sov"));let S=this.tryCompoundCommandParsing(f,D,r);if(S)return p.push(V("compound command parsing succeeded","info","stage-compound")),q(S,p);throw p.push(V("compound parsing: no then-keywords or no command matches","info","stage-compound")),p.push(V(`all parse stages exhausted for "${d}"`,"error","parse-failed")),new Ct(`Could not parse input in ${r}: ${d}`,r,d,p)}parseStatements(e,r){let i=Y(e,r),n=de(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(i,n,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let u=a[a.length-1];a[a.length-1]=q(u,[...u.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Gt()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let i={};for(let[a,o]of e.captured)i[a]=o;let n=ee(e.pattern.command,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(n),n}buildEventHandler(e,r,i){if(!e)throw new Error("No match to build event handler from");let n=e.captured.get("event");if(!n)throw new Error("Event handler pattern matched but no event captured");{let d=n.type==="expression"?n.raw:n.type==="literal"?n.value:void 0;if(typeof d=="string"&&/^[^\s()[\]{}:]+$/.test(d)){let p=ve[i]?.[d];p?n={type:"literal",value:p,dataType:"string"}:n.type==="expression"&&x.KNOWN_EVENTS.has(d.toLowerCase())&&(n={type:"literal",value:d.toLowerCase(),dataType:"string"});}}let a=oe.extractEventModifiers(r),o=e.captured.get("source");o&&e.pattern.id.endsWith("source")&&!(o.type==="reference"&&o.value==="me")&&(a={...a??{},from:o});let u=this.extractOrConjunctionEvents(r,i),s=n;u.length>0&&n.type==="literal"&&(s={type:"literal",value:[String(n.value),...u.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"&&c.value==="if"){let d=r.tokens,p=-1;for(let f=r.position()-1;f>=0;f--){let v=d[f],E=(v.normalized??v.value).toLowerCase();if(this.isIfKeyword(E,i)){p=f;break}}if(p>=0){let f=de(i).filter(A=>A.command!=="on").sort((A,D)=>D.priority-A.priority),v=d.slice(p);if(e.pattern.id.endsWith("vso-verb-first")&&s.type==="literal"){let A=String(s.value??"").split("[")[0].trim().toLowerCase(),D=v.findIndex((b,g)=>{if(g===0||A==="")return false;let w=(b.normalized??b.value).toLowerCase(),S=v[g-1];return w===A&&S.kind==="keyword"&&(S.normalized??"").toLowerCase()==="on"});if(D>0){let b=v[D+1],g=b&&b.kind==="selector"&&b.value.startsWith("[")?1:0;v=[...v.slice(0,D-1),...v.slice(D+1+g)];}}let E=new ie(v,i),y=this.coverageMark(),h=this.parseBodyWithClauses(E,f,i);if(h.some(A=>A.kind==="conditional")||h.length===1&&h[0]?.kind==="compound"&&h[0].statements.some(A=>A.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return He(s,h,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(y);}}if(c&&c.type==="literal"&&String(c.value)!=="js"&&re(String(c.value))!==void 0){let d=c.value,p={};for(let[g,w]of e.captured)g!=="event"&&g!=="action"&&g!=="continues"&&(p[g]=w);if(d==="repeat"){let g=r.peek(),w=C=>(C.normalized??C.value).toLowerCase();if(g&&g.kind==="keyword"&&w(g)==="forever")p.loopType={type:"literal",value:"forever"},delete p.patient,r.advance();else if(g&&g.kind==="keyword"&&w(g)==="event"){r.advance();let C=r.peek();if(C)for(p.event={type:"literal",value:w(C)},p.loopType={type:"literal",value:"until-event"},delete p.patient;!r.isAtEnd();){let k=r.peek();if(!k||k.kind==="conjunction"||k.kind==="keyword"&&(this.isThenKeyword(k.value,i)||this.isEndKeyword(k.value,i)))break;r.advance();}}let S=p.patient;S&&S.type==="reference"&&S.value==="me"&&delete p.patient;}let f=ee(d,p,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(f);let v=[];if(!ze.has(d)||d==="repeat"||d==="while"){let g=e.pattern.id.includes("verb-first"),w=r.tokens,S=r.position(),C=R=>R.kind==="conjunction"||R.kind==="keyword"&&(this.isThenKeyword(R.value,i)||this.isEndKeyword(R.value,i)),k=new Set;{let R=L(i)?.keywords?.[d];R?.primary&&k.add(R.primary.toLowerCase());for(let F of R?.alternatives??[])k.add(F.toLowerCase());}let B=-1;for(let R=S-1;R>=0;R--){let F=w[R];if(C(F))break;if((F.normalized??F.value).toLowerCase()===d||k.has(F.value.toLowerCase())){B=R;break}}if(B>=0){let R=S;for(;R<w.length&&!C(w[R]);)R++;let F=w.slice(B,R),O=F;if(g){let N=String(n.value??"").toLowerCase(),I=F.findIndex(j=>(j.normalized??j.value).toLowerCase()===N);if(I<0)O=null;else {let j=F[I-1],P=j&&j.kind==="keyword"&&j.normalized?.toLowerCase()==="on"?I-1:I;O=[...F.slice(0,P),...F.slice(I+1)];}}if(O&&O.length>1){let N=de(i).filter(_=>_.command!=="on").sort((_,H)=>H.priority-_.priority),I=this.coverageMark(),j=this.parseClause(O,N,i),P=j[0],Z=_=>_!==null&&typeof _=="object"&&typeof _.type=="string"?_.type:typeof _,J=re(d),hr=J?.primaryRole,Jr=_=>_==="patient"&&hr&&hr!=="patient"&&!J?.roles.some(H=>H.role==="patient")?hr:_,Mi=(_,H)=>{if(!ze.has(d)||!J)return false;let ye=J.roles.find(Ve=>Ve.role===Jr(_));return ye?ye.expectedTypes.length>0&&!ye.expectedTypes.includes(Z(H)):true},vr=(_,H)=>_==="patient"&&!!J&&!J.roles.some(ye=>ye.role==="patient")&&Z(H)==="literal"&&Mt.has(String(H.value??"").toLowerCase()),Er=_=>_!==null&&typeof _=="object"&&_.implicit===true,_i=!!P&&P.kind==="command"&&Object.entries(p).every(([_,H])=>{if(Er(H)||Mi(_,H)||vr(_,H))return true;let ye=P.roles.get(Jr(_));if(ye!==void 0&&Z(ye)===Z(H))return true;if(_==="patient"&&d==="pick"&&Z(H)==="literal"){let Ve=P.roles.get("method"),Qr=Z(Ve),et=Qr==="literal"?String(Ve.value):Qr==="expression"?String(Ve.raw):void 0;return et!==void 0&&et===String(H.value)}return false}),Xr=P?.metadata?.patternId??"",Ii=!ze.has(d)||/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Xr),ji=/^repeat-.*-(times|for-in|while-head|until-head)$/.test(Xr);if((j.length===1||ji&&j.length>1)&&P&&P.kind==="command"&&(P.action===d||d==="while"&&P.action==="repeat"&&/-while-head$/.test(P.metadata?.patternId??""))&&_i&&Ii&&(P.roles.size>Object.entries(p).filter(([_,H])=>!vr(_,H)).length||[...P.roles.values()].filter(_=>!Er(_)).length>Object.entries(p).filter(([_,H])=>!vr(_,H)&&!Er(H)).length))for(f=P,v=j.slice(1);r.position()<R;)r.advance();else this.coverageRollback(I);}}}if(!ze.has(d)){let g=f;if(re(d)?.roles.some(F=>F.role==="quantity"&&!F.required)&&!g.roles.has("quantity")){let F=r.peek();F&&/^-?\d+(\.\d+)?$/.test(F.value)&&(f=ee(d,{...Object.fromEntries(g.roles),quantity:{type:"literal",value:parseFloat(F.value),dataType:"number"}},g.metadata),r.advance());}let S=f;if(re(d)?.roles.some(F=>F.role==="duration"&&!F.required)&&!S.roles.has("duration")){let F=/^\d+(\.\d+)?(ms|s)$/i,O=r.peek(),N=false;if(O&&O.kind==="particle"){let I=r.peek(1);I&&F.test(I.value)&&(N=true,O=I);}O&&F.test(O.value)&&(f=ee(d,{...Object.fromEntries(S.roles),duration:{type:"literal",value:O.value,dataType:"string"}},S.metadata),N&&r.advance(),r.advance(),this.consumeForPostposition(r,i));}let k=f,B=re(d);if(B?.roles.find(F=>F.role==="responseType"&&!F.required)&&!k.roles.has("responseType")){let F=P=>typeof P=="string"&&x.RESPONSE_TYPE_WORDS.has(P.toLowerCase()),O=(P,Z)=>{let J=Object.fromEntries(k.roles);Z&&delete J.destination,J.responseType={type:"expression",raw:P},f=ee(d,J,k.metadata);},N=k.roles.get("destination"),I=B?.roles.find(P=>P.role==="destination"),j=N?.raw??N?.value;if(N&&I&&!I.expectedTypes.includes(N.type)&&F(j))O(j,true);else {let P=r.peek();P&&F(P.value)&&(O(P.value,false),r.advance());}}if(d==="wait"){let F=f;if(!F.roles.has("event")){let O=r.peek();if(O&&Re.has(O.value.toLowerCase())){let N=Object.fromEntries(F.roles),I=N.duration;I&&I.type!=="literal"&&I.type!=="expression"&&delete N.duration;let j=N.patient;j&&j.type==="reference"&&j.value==="me"&&delete N.patient,N.event={type:"literal",value:O.value,dataType:"string"},f=ee(d,N,F.metadata),r.advance(),this.consumeForPostposition(r,i);}}}this.tryAttachTrailingRole(r,f,i),this.tryAttachTrailingStyle(r,f,i),this.tryAttachTrailingExpressionRole(r,f,i);}let E=e.captured.get("continues"),y=E?.type==="literal"&&E.value==="then",h=r.peek(),z=!!h&&this.isThenKeyword(h.value,i),D=ze.has(d)&&!!h&&!this.isEndKeyword(h.value,i),b=!!h&&!this.isEndKeyword(h.value,i);if(y||z||D||b){let g=de(i).filter(C=>C.command!=="on").sort((C,k)=>k.priority-C.priority),w=de(i).filter(C=>C.id.startsWith("grammar-")&&C.id.includes("-continuation")).sort((C,k)=>k.priority-C.priority),S=this.parseBodyWithGrammarPatterns(r,g,w,i);S.length>0?l=[f,...v,...S]:l=[f,...v];}else l=[f,...v],r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),i,"handler body tail");}else {let d=de(i).filter(f=>f.command!=="on").sort((f,v)=>v.priority-f.priority),p=c?e.roleStarts?.get("action"):void 0;if(p!==void 0&&p<r.position()){let f=new ie(r.tokens.slice(p),i);for(l=this.parseBodyWithClauses(f,d,i);!r.isAtEnd();)r.advance();}else l=this.parseBodyWithClauses(r,d,i);}let m=l.length>1?[Ge(l,"then",{sourceLanguage:i})]:l;return He(s,m,a,{sourceLanguage:i,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,i){let n=[],a=[],o=0,u=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;if(a.length===0){let f=this.consumeJsBlock(e,i)??this.consumeVerbFinalJsBlock(e,i);if(f){n.push(f);continue}let v=this.tryParseConditionalBlock(e,r,i);if(v){n.push(v);continue}let E=this.tryParseUnlessGuard(e,r,i);if(E){n.push(...E);continue}}let l=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,i),c=a[a.length-1],m=e.peek(1),d=c?.value.toLowerCase()==="at"&&m?.value.toLowerCase()==="of"||st(i,s.value,c?.value,m?.value),p=s.kind==="keyword"&&this.isEndKeyword(s.value,i)&&!d;if(p&&o>0){o--,u.pop(),a.push({...s,metadata:{...s.metadata,closesTrackedBlock:true}}),e.advance();continue}if(l&&u.includes("if")){a.push(s),e.advance();continue}if(l){if(a.length>0){let f=this.parseClause(a,r,i);n.push(...f),a.length=0,o=f.filter(v=>{let E=v;return (E.action==="for"||E.action==="repeat"||E.action==="while")&&(!Array.isArray(E.body)||E.body.length===0)}).length,u.length=0;for(let v=0;v<o;v++)u.push("other");}e.advance();continue}if(p){e.advance();let f=[];for(;!e.isAtEnd();){let v=e.peek();if(!v||v.kind==="conjunction"||v.kind==="keyword"&&(this.isThenKeyword(v.value,i)||this.isEndKeyword(v.value,i)))break;f.push(v),e.advance();}if(f.length>0){let v=this.coverageMark(),E=a.length>0?this.parseClause(a,r,i):[];E.length===0&&a.length>0?(this.coverageRollback(v),n.push(...this.parseClause([...a,...f],r,i))):(n.push(...E),n.push(...this.parseClause(f,r,i)));}else if(a.length>0){let v=this.parseClause(a,r,i);n.push(...v);}a.length=0;break}if(s.kind==="keyword"){let f=(s.normalized??s.value).toLowerCase();(this.isIfKeyword(f,i)||this.isUnlessKeyword(f,i)||f==="while"||f==="for"||f==="repeat")&&(o++,u.push(this.isIfKeyword(f,i)?"if":"other"));}a.push(s),e.advance();}if(a.length>0){let s=this.parseClause(a,r,i);n.push(...s);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"body stream tail"),this.foldFrontedWhileIntoRepeat(n,i);for(let s=n.length-1;s>=0;s--){let l=n[s];l.kind==="command"&&l.action==="for"&&(!(l.roles instanceof Map)||l.roles.size===0)&&(!Array.isArray(l.body)||l.body.length===0)&&n.splice(s,1);}return n.length>1?[Ge(n,"then",{sourceLanguage:i})]:n}tryTopLevelCommandSequence(e,r,i){let n=this.coverageMark(),a;try{let l=new ie(e.tokens,i);a=this.parseBodyWithClauses(l,r,i);}catch{return this.coverageRollback(n),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(n),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(n),null;let u=o.statements.map(l=>l.metadata?.confidence??.75),s=u.reduce((l,c)=>l+c,0)/u.length;return Ge(o.statements,o.chainType,{sourceLanguage:i,confidence:s})}foldFrontedWhileIntoRepeat(e,r){for(let i=0;i+1<e.length;i++){let n=e[i],a=e[i+1];if(n.kind!=="command"||n.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=n.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(n.body)||Array.isArray(a.body))continue;let u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(i,2,{...a,roles:u,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,n.metadata?.confidence??0)}});}}parseClause(e,r,i){if(e.length===0)return [];let n=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let y=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(y,i)&&(n="unless",a=e.slice(0,-1));}let u=null;if(n&&a.length>=3){let y=L(i),h=y?x.buildVerbLookup(y):null;if(h)for(let z=1;z<a.length-1;z++){let A=a[z],D=h.get(A.value.toLowerCase())??(A.normalized?h.get(A.normalized.toLowerCase()):void 0);if(D&&!x.CONDITION_OPERATORS.has(D)){u=a.slice(0,z),a=a.slice(z);break}}}let s=new ie(a,i),l=[],c=this.coverageMark(),m=0,d=[],p=u,f=()=>{if(d.length===0)return;let y=d.slice();if(d.length=0,n&&l.length===0&&p===null){p=y;return}let h=y[0];if(!(h&&(h.kind==="identifier"||h.kind==="selector"||h.kind==="literal"||h.kind==="reference"))){this.recordDroppedTokens(y,i,"body clause");return}let A=false;for(let D of this.parseSOVClauseByVerbAnchoring(y,i)){let b=D.action,g=D.roles;b&&re(b)&&g instanceof Map&&g.size>0&&(l.push(D),A=true);}A||this.recordDroppedTokens(y,i,"body clause");};for(;!s.isAtEnd();){let y=s.peek(),h=!!y&&y.normalized?.toLowerCase()==="repeat",z=s.mark(),A=oe.matchBest(s,r);if(h&&A&&A.pattern.command!=="repeat"){s.reset(z),f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++,s.advance();continue}if(A&&A.pattern.command==="if"){let D=s.mark(),b=d.length;for(s.reset(z);!s.isAtEnd();){let w=s.peek();if(!w||this.isIfKeyword((w.normalized??w.value).toLowerCase(),i))break;d.push(w),s.advance();}let g=this.tryParseConditionalBlock(s,r,i);if(g){f(),l.push(g),m++;continue}d.length=b,s.reset(D);}if(A){f();let D=this.buildCommand(A,i);l.push(D),m++,this.tryAttachTrailingRole(s,D,i),this.tryAttachTrailingStyle(s,D,i),this.tryAttachTrailingExpressionRole(s,D,i),this.tryAttachTrailingDuration(s,D);}else {let D=s.peek();D&&D.normalized?.toLowerCase()==="repeat"?(f(),l.push(ee("repeat",{},{sourceLanguage:i,confidence:.6})),m++):D&&d.push(D),s.advance();}}f();let v=l;if(m===0){let y=this.parseSOVClauseByVerbAnchoring(a,i);y.length>0&&(this.coverageRollback(c),v=y);}let E=p;return n&&v.length>0&&E&&E.length>0?[ee(n,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85}),...v]:n&&E&&E.length>0&&v.length===0?[ee(n,{condition:{type:"expression",raw:this.joinTokenText(E,i)}},{sourceLanguage:i,patternId:`${n}-${i}-trailing-guard`,confidence:.85})]:v}tryAttachTrailingDuration(e,r){let i=r.roles;if(i.has("duration")||!re(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let a=e.peek();!a||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(a.value)||(i.set("duration",W(a.value,"duration")),e.advance());}tryAttachTrailingRole(e,r,i){let n=re(r.action);if(!n)return;let a=L(i);if(!a)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let m=(l.normalized??l.value).toLowerCase();return wr.has(m)?false:m==="body"||m==="it"||m==="you"||m==="result"||m==="document"||m==="window"||this.boundIdentifiers.has(l.value)?true:c?false:l.kind==="identifier"||l.kind==="reference"},s=[{role:"source",strict:false},{role:"destination",strict:true}];for(let{role:l,strict:c}of s){if(!n.roles.some(E=>E.role===l))continue;let m=a.roleMarkers?.[l];if(!m)continue;let d=o.get(l);if(d&&!(d.type==="reference"&&d.value==="me"))continue;let p=E=>{if(!E||E.kind!=="particle"&&E.kind!=="keyword")return false;let y=E.value.toLowerCase();return m.primary?.toLowerCase()===y?true:c?false:(E.normalized??"").toLowerCase()===l?true:!!m.alternatives?.some(h=>h.toLowerCase()===y)},f=e.peek(),v=e.peek(1);if(!f||!v)return;if(c&&m.position==="after"){let E=e.peek(2),y=(f.normalized??f.value).toLowerCase();if(Uu.has(y)&&v.kind==="selector"&&p(E)){o.set(l,{type:"expression",raw:`${y} ${v.value}`}),e.advance(),e.advance(),e.advance();return}}if(m.position==="after"){if(u(f,c)&&p(v)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),E&&o.set(l,E);return}if(c&&u(f,c)){let E=e.peek(2),y=e.peek(3);if((v.normalized??v.value).toLowerCase()==="in"&&E&&!p(E)&&p(y)){let h=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),h&&o.set(l,h);return}}}else if(p(f)&&u(v,c)){e.advance();let E=this.tokenToSemanticValue(e.advance());E&&o.set(l,E);return}}}tryAttachTrailingStyle(e,r,i){if(r.action!=="fetch"&&r.action!=="render")return;let n=r.roles;if(!re(r.action)?.roles.some(y=>y.role==="style"))return;let o=n.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let y=Ye(e,o.raw);y&&n.set("style",{type:"expression",raw:y});}this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(r.action==="fetch"){let y=n.get("patient"),h=n.get("source");if(y&&h&&(y.type==="literal"||y.type==="expression")&&h.type==="expression"&&typeof h.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(h.raw)&&e.peek()?.value===":"){let z=Ye(e,h.raw);z&&(n.set("source",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,r,i));return}}let s=L(i)?.roleMarkers?.style;if(!s)return;if(s.position==="before"){let y=new Set([s.primary,...s.alternatives??[]].map(D=>D.toLowerCase())),h=e.peek();if(!h||!y.has(h.value.toLowerCase()))return;let z=e.mark();e.advance();let A=Ye(e);if(!A){e.reset(z);return}n.set("style",{type:"expression",raw:A}),this.tryAttachResponseTypeAfterStyle(e,r,i);return}if(s.position!=="after")return;let l=new Set([s.primary,...s.alternatives??[]].map(y=>y.toLowerCase())),c=y=>y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)),m=24,d=-1,p=0;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),p===0&&(h.kind==="particle"||h.kind==="keyword")&&l.has(h.value.toLowerCase())){d=y;break}}if(d<=0)return;let f=[];for(let y=0;y<d;y++){let h=e.peek(y);h&&f.push(h);}if(f.length===1&&x.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let v=new ie(f,i),E=Ye(v);n.set("style",{type:"expression",raw:E&&v.isAtEnd()?E:this.joinTokenText(f,i)});for(let y=0;y<=d;y++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,i);}tryAttachResponseTypeAfterStyle(e,r,i){let n=r.roles;if(n.has("responseType")||!re(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&x.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),u=e.peek();if(!u)return;let s=c=>{n.set("responseType",{type:"expression",raw:c});};if(x.AS_MARKERS_BEFORE[i]?.some(c=>u.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(o(u.value)){e.advance(),s(u.value);for(let c of x.AS_MARKERS_AFTER[i]??[])if(c.every((m,d)=>e.peek(d)?.value.toLowerCase()===m)){for(let m=0;m<c.length;m++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,i){let n=r.action,a=n==="js"?{role:"patient",terminator:"boundary"}:n==="go"||n==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,u=o.get(a.role);if(n==="go"&&u&&u.type==="expression"&&String(u.raw).toLowerCase()==="url"){let y=e.peek();if(y&&!wr.has((y.normalized??y.value).toLowerCase())){let z=this.tokenToSemanticValue(y);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let h=o.get("patient");if(h&&(h.type==="literal"||h.type==="selector")){o.set(a.role,h),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(n==="go"&&u&&u.type==="expression"){let y=/^url\s+(\S+)$/i.exec(String(u.raw??""));if(y){let h=y[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:h,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(n==="go"&&!u){let y=o.get("patient");if(y&&y.type==="expression"&&String(y.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!wr.has((h.normalized??h.value).toLowerCase())){let z=this.tokenToSemanticValue(h);if(z.type==="literal"||z.type==="selector"){o.set(a.role,z),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(u&&!(u.type==="reference"&&u.value==="me"))return;let s=L(i);if(!s)return;let l=null;if(a.terminator==="destination-marker"){let y=s.roleMarkers?.destination;if(!y||y.position!=="after")return;l=y.primary.toLowerCase();}let c=y=>y.kind==="conjunction"||y.kind==="keyword"&&(this.isThenKeyword(y.value,i)||this.isEndKeyword(y.value,i)),m=24,d=[],p=0,f=false;for(let y=0;y<m;y++){let h=e.peek(y);if(!h||c(h))break;if(h.value==="("||h.value==="{"?p++:(h.value===")"||h.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(h.kind==="particle"||h.kind==="keyword")&&h.value.toLowerCase()===l){f=true;break}d.push(h);}if(d.length===0||l!==null&&!f)return;let v=d.length+(f?1:0);if(n==="go"&&d.length===2&&d[0].value.toLowerCase()==="url"){let y=this.tokenToSemanticValue(d[1]);if(y.type==="literal"||y.type==="selector"){o.set(a.role,y),o.set("method",{type:"literal",value:"url"});let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!re(n)?.roles.some(z=>z.role==="patient")&&o.delete("patient");for(let z=0;z<v;z++)e.advance();return}}let E=d;if(n==="js"){let y=s.keywords?.js,h=A=>[y?.primary,...y?.alternatives??[]].some(D=>!!D&&D.length>A.value.length&&D.includes(A.value)),z=0;for(;z<E.length&&h(E[z]);)z++;if(E=E.slice(z),E.length===0)return}if(o.set(a.role,{type:"expression",raw:this.joinTokenText(E,i)}),a.role!=="patient"){let y=o.get("patient");y&&y.type==="reference"&&y.value==="me"&&!re(n)?.roles.some(h=>h.role==="patient")&&o.delete("patient");}for(let y=0;y<v;y++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(i)&&(r.set(n.primary.toLowerCase(),i),n.alternatives))for(let a of n.alternatives)r.set(a.toLowerCase(),i);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[i,n]of Object.entries(e.roleMarkers)){if(!n)continue;if((i!=="event"||!r.has(n.primary))&&r.set(n.primary,i),n.alternatives)for(let o of n.alternatives)r.has(o)||r.set(o,i);}return r}parseSOVClauseByVerbAnchoring(e,r){let i=L(r);if(!i||i.wordOrder!=="SOV")return [];let n=x.buildVerbLookup(i),a=x.buildMarkerToRoleLookup(i),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let v=e[f];if(a.has(v.value))continue;let E=n.get(v.value.toLowerCase()),y=v.normalized?n.get(v.normalized.toLowerCase()):void 0,h=E||y;if(h){s=f,l=h;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let f=s+1;f<e.length;f++){let v=e[f];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=f;break}if(f>s+1&&!a.has(v.value)&&(n.get(v.value.toLowerCase())||(v.normalized?n.get(v.normalized.toLowerCase()):void 0))){m=f;break}}let d=e.slice(s+1,m),p=this.extractRolesFromMarkedTokens(c,d,a,l,r);if(o.push(ee(l,p,{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,i,n,a){let o={},u=(l,c)=>{let m=this.isEndKeyword(l.value,a),d=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !m&&!d?false:l.metadata?.closesTrackedBlock===true||m?true:!(c&&c.kind==="selector")},s=l=>{let c=[];for(let m=0;m<l.length;m++){let d=l[m];if(u(d,l[m+1]))continue;let p=i.get(d.value);if(p&&d.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,a);if(f){let v=this.mapRoleForCommand(p,n,o);v&&(o[v]=f);}c=[];}else c.push(d);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&re(n)?.roles.some(d=>d.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let d=this.tokensToSemanticValue(c,a);d&&(o.patient?o.destination||(o.destination=d):o.patient=d);}};return s(e),s(r),o}mapRoleForCommand(e,r,i){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),i[e]?e==="patient"&&!i.destination?"destination":e==="destination"&&!i.patient?"patient":e==="source"&&!i.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let i=e.filter(o=>o.kind!=="whitespace");if(i.length===0)return null;if(i.length>=2&&(i[0].kind==="selector"||/^[#.@*<]/.test(i[0].value))){let o=i.findIndex((u,s)=>s>0&&(u.normalized??u.value).toLowerCase()==="in");o>0&&(i=i.slice(0,o));}if(i.length===1)return this.tokenToSemanticValue(i[0]);let n=i.map(o=>o.value).join(""),a=i[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?Ee(n):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?W(zt(n),"string"):a.kind==="reference"?ue(n):W(this.joinTokenText(i,r))}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return Ee(r);if(r.startsWith('"')||r.startsWith("'"))return W(zt(r),"string");if(/^-?\d+(\.\d+)?$/.test(r))return W(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return W(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return W(false);if(r.length>1&&(r.startsWith(":")||r.startsWith("$")))return ue(r);let i=e.normalized?.toLowerCase();return i==="me"||i==="it"||i==="you"||i==="result"||i==="body"?ue(i):e.kind==="reference"?ue(e.normalized||"me"):W(r)}parseBodyWithGrammarPatterns(e,r,i,n){let a=[],o=[],u=false,s=()=>{if(!u&&o.length>0){let m=this.parseSOVClauseByVerbAnchoring(o,n);a.push(...m),m.length===0&&this.recordDroppedTokens(o,n,"fused body walk");}else o.length>0&&this.recordDroppedTokens(o,n,"fused body walk");o=[],u=false;},l=0,c=()=>{let m=0;for(let d of a){let p=d;(p.action==="for"||p.action==="repeat"||p.action==="while")&&(!Array.isArray(p.body)||p.body.length===0)&&m++;}return m-l};for(;!e.isAtEnd();){let m=e.peek();if(m&&this.isThenKeyword(m.value,n)){s(),e.advance();continue}if(m&&this.isEndKeyword(m.value,n)){let p=e.peek(-1),f=e.peek(1);if(!st(n,m.value,p?.value,f?.value)){if(s(),c()>0){l++,e.advance();continue}e.advance();break}}if(m&&!u&&this.isIfKeyword((m.normalized??m.value).toLowerCase(),n)){s();let p=this.tryParseConditionalBlock(e,r,n);if(p){a.push(p),u=true;continue}}let d=false;if(i.length>0){let p=oe.matchBest(e,i);if(p){let f=p.pattern.command,v={};for(let[h,z]of p.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(v[h]=z);let E=ee(f,v,{sourceLanguage:n,patternId:p.pattern.id});a.push(E),d=true,u=true;let y=p.captured.get("continues");if(y&&y.type==="literal"&&y.value==="then")continue}}if(!d){let p=e.mark(),f=oe.matchBest(e,r);if(f){if(f.pattern.command==="if"){let E=e.mark();for(e.reset(p);!e.isAtEnd();){let h=e.peek();if(!h||this.isIfKeyword((h.normalized??h.value).toLowerCase(),n))break;e.advance();}let y=this.tryParseConditionalBlock(e,r,n);if(y){s(),a.push(y),u=true;continue}e.reset(E);}let v=this.buildCommand(f,n);a.push(v),this.tryAttachTrailingRole(e,v,n),d=true,u=true;}}d||(m&&o.push(m),e.advance());}s(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"fused body walk");for(let m=a.length-1;m>=0;m--){let d=a[m];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&a.splice(m,1);}return a}tryCompoundCommandParsing(e,r,i){let n=e.tokens,a=n.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,i)),o=n.some(c=>this.isElseKeyword(c.value,i));if(!a&&!o)return null;let u=new ie(n,i),s=this.coverageMark(),l=this.parseBodyWithClauses(u,r,i);return l.length===0?(this.coverageRollback(s),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let r=e.toLowerCase(),i=x.enEventKeywordCache.get(r);if(i!==void 0)return i;let n=false;try{let a=Y(r,"en").tokens;n=a.length===1&&a[0]?.kind==="keyword";}catch{n=false;}return x.enEventKeywordCache.set(r,n),n}matchEventMarkerPhrase(e,r,i){let n=x.SOV_EVENT_MARKER_PHRASES[i];if(!n)return 0;for(let a of n)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let i=x.SOV_EVENT_MARKERS[r];if(i===void 0)return false;let{tokens:n}=Y(e,r),a=ve[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length;u++){let s=n[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(x.KNOWN_EVENTS.has(c)||Re.has(c))||x.KNOWN_EVENTS.has(l)||Re.has(l)||o.has(l)))continue;let d=this.matchEventParamPhrase(n,u+1).len,p=n[u+1+d];if(p&&(p.kind==="particle"||p.kind==="keyword")&&i.has(p.value)||this.matchEventMarkerPhrase(n,u+1+d,r)>0)return true}return false}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let i=[];for(let n=r+1;n<e.length;n++){let a=e[n].value;if(a===")")return {len:n-r+1,names:i};if(a!==","){if(e[n].kind!=="identifier")break;i.push(a);}}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let i=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(i==="me"||i==="i"||i==="it"))return true;let n=e.value.toLowerCase();return r.has(n)||!!i&&r.has(i)}tryTrailingEventExtraction(e,r,i){let n=Y(e,r).tokens;if(n.length<3)return null;let a=ve[r],o=new Set;if(a)for(let A of Object.keys(a))o.add(A.toLowerCase());let u=n.length-2,s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=n[n.length-1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&x.KNOWN_EVENTS.has(d)||x.KNOWN_EVENTS.has(m)||o.has(m)))return null;let f=d&&x.KNOWN_EVENTS.has(d)?d:a?.[m]??m,v=n.slice(0,u);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),z=this.parseBodyWithClauses(y,E,r);return z.length===0?(this.coverageRollback(h),null):He({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,i){let n=Y(e,r).tokens;if(n.length<3)return null;let a=ve[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<n.length-1;u++){let s=n[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=n[u+1],m=c.value.toLowerCase(),d=c.normalized?.toLowerCase();if(!(!!d&&x.KNOWN_EVENTS.has(d)||x.KNOWN_EVENTS.has(m)||o.has(m)))continue;let f=d&&x.KNOWN_EVENTS.has(d)?d:a?.[m]??m,v=n.filter((A,D)=>D!==u&&D!==u+1);if(v.length===0)return null;let E=i.filter(A=>A.command!=="on"),y=new ie(v,r),h=this.coverageMark(),z=this.parseBodyWithClauses(y,E,r);return z.length===0?(this.coverageRollback(h),null):He({type:"literal",value:f},z,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,i){let n=x.SOV_EVENT_MARKERS[r];if(!n)return null;let o=Y(e,r).tokens,u=ve[r],s=new Set;if(u)for(let b of Object.keys(u))s.add(b.toLowerCase());let l=x.SOV_SOURCE_MARKERS[r],c=-1,m="",d="",p=1,f=[];for(let b=0;b<o.length;b++){let g=o[b],w=g.value.toLowerCase(),S=w,C="",k=w.indexOf("[");k>0&&(S=w.slice(0,k),C=g.value.slice(k));let B=g.normalized?.toLowerCase(),R=B&&(x.KNOWN_EVENTS.has(B)||Re.has(B)),F=s.has(w)||s.has(S),O=x.KNOWN_EVENTS.has(S)||Re.has(S);if(R||F||O){let N=o[b-1];if(N&&(N.normalized??N.value).toLowerCase()==="event")continue;let I;R?I=B:F?I=u?.[w]??u?.[S]??S:I=S;let j=this.matchEventParamPhrase(o,b+1);if(n.size>0){let P=1+j.len,Z=o[b+P];Z&&Z.kind==="selector"&&Z.value.startsWith("[")&&(P+=1);let J=o[b+P];if(J&&(J.kind==="particle"||J.kind==="keyword")&&n.has(J.value)){c=b,m=I,d=C||(P===j.len+2?o[b+P-1].value:""),p=P+1,f=j.names;break}}else {c=b,m=I,d=C,p=1+j.len+this.matchEventMarkerPhrase(o,b+1+j.len,r),f=j.names;break}}}if(c===-1){let b=new Set(i.filter(g=>g.command!=="on").map(g=>g.command));for(let g=0;g<o.length;g++){let w=o[g];if(w.kind==="identifier")if(n.size>0){let S=1,C=o[g+1];C&&C.kind==="selector"&&C.value.startsWith("[")&&(S=2);let k=o[g+S];if(k&&(k.kind==="particle"||k.kind==="keyword")&&n.has(k.value)){c=g,m=w.value,d=S===2?o[g+1].value:"",p=S+1;break}}else {let S=this.matchEventMarkerPhrase(o,g+1,r);if(S>0){c=g,m=w.value,d="",p=1+S;break}let C=o[g+1];if(C&&C.kind==="keyword"&&C.normalized!=null&&b.has(C.normalized)){c=g,m=w.value,d="",p=1;break}}}}if(c===-1)return null;let v=new Set;for(let b=c;b<c+p;b++)v.add(b);if(l){let b=c+p;if(b<o.length){let g=o[b];if((g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value))v.add(b);else if(this.isStrippableSourceRef(g,l.windowTokens)){let w=o[b+1];w&&(w.kind==="particle"||w.kind==="keyword")&&l.markers.has(w.value)&&(v.add(b),v.add(b+1));}}if(c>=2){let g=o[c-1];(g.kind==="particle"||g.kind==="keyword")&&l.markers.has(g.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(v.add(c-2),v.add(c-1));}for(let g=0;g<c;g++){let w=o[g],S=w.value.toLowerCase(),C=w.normalized?.toLowerCase();if(l.windowTokens.has(S)||C&&l.windowTokens.has(C)){v.add(g);break}}}let E=o.filter((b,g)=>!v.has(g));if(E.length===0)return null;let y=i.filter(b=>b.command!=="on"),h=new ie(E,r),z=this.coverageMark(),A=this.parseBodyWithClauses(h,y,r);if(A.length===0)return this.coverageRollback(z),null;let D={sourceLanguage:r,confidence:.75};return d&&(D.keyFilter=d),He(x.isEnEventKeyword(m)?{type:"literal",value:m}:{type:"expression",raw:m},A,void 0,D,f)}profileKeywordMatches(e,r,i){let n=L(e)?.keywords?.[r];return n?n.primary?.toLowerCase()===i?true:!!n.alternatives?.some(a=>a.toLowerCase()===i):false}consumeForPostposition(e,r){let i=e.peek();if(!i)return;let n=(i.normalized??"").toLowerCase(),a=L(r)?.keywords?.for;(n==="for"||i.value===a?.primary||(a?.alternatives??[]).includes(i.value))&&e.advance();}isThenKeyword(e,r){let i=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(i):i==="then"||this.profileKeywordMatches(r,"then",i)}isElseKeyword(e,r){let i=e.toLowerCase();return i==="else"?true:this.profileKeywordMatches(r,"else",i)}isEndKeyword(e,r){let i=e.toLowerCase(),n=qo(r);return n?i==="end"||n.has(i):i==="end"||this.profileKeywordMatches(r,"end",i)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}isPatientMarker(e,r){let i=L(r)?.roleMarkers?.patient;if(!i?.primary)return false;let n=e.value.toLowerCase();return i.primary.toLowerCase()===n?true:!!i.alternatives?.some(a=>a.toLowerCase()===n)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let i=e.mark(),n=0,a=-1;for(;;){let c=e.peek(n);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let m=e.peek(n+1),d=!!m&&c.position?.end!==void 0&&c.position.end===m.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${m.value}`.toLowerCase()),p=e.peek(n+(d?2:1));if(n>0&&p&&this.isJsBlockTerminator(p.value,r)){a=n;break}}n++;}if(a<=0)return null;let o=[];for(let c=0;c<a;c++){let m=e.peek(c);m&&o.push(m);}let u=o[o.length-1];if(u&&this.isPatientMarker(u,r)&&o.pop(),o.length===0)return e.reset(i),null;let s=this.rawJsBody(o);for(let c=0;c<a;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),ee("js",{patient:{type:"expression",raw:s||"()"}},{sourceLanguage:r,patternId:`js-opaque-final-${r}`,confidence:1})}consumeJsBlock(e,r){let i=e.peek();if(!i||!this.isJsKeyword(i))return null;let n=e.mark(),a=[];e.advance();let o=e.peek();o&&i.position?.end!==void 0&&i.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${i.value}${o.value}`.toLowerCase())&&e.advance();let u=e.peek();u&&this.isPatientMarker(u,r)&&e.advance();let s=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,r)){s=true;break}a.push(c);}if(!s)return e.reset(n),null;let l=this.rawJsBody(a);return ee("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let r=e[0].position?.start,i=e[e.length-1].position?.end,n=this.positionSource;if(n!==void 0&&r!==void 0&&i!==void 0){let o=n.slice(r,i),u=s=>s.replace(/\s+/g,"");if(u(o)===u(e.map(s=>s.value).join("")))return o.trim()}let a="";for(let o=0;o<e.length;o++){let u=e[o-1],s=u?.position?.end!==void 0&&e[o].position?.start===u.position.end;o>0&&!s&&(a+=" "),a+=e[o].value;}return a.trim()}isIfKeyword(e,r){let i=e.toLowerCase();return i==="if"?true:this.profileKeywordMatches(r,"if",i)}isUnlessKeyword(e,r){let i=e.toLowerCase();return i==="unless"?true:this.profileKeywordMatches(r,"unless",i)}tryParseUnlessGuard(e,r,i){let n=e.peek();if(!n||!this.isUnlessKeyword((n.normalized??n.value).toLowerCase(),i))return null;let a=e.mark(),o=this.tryParseConditionalBlock(e,r,i,true);if(!o||o.kind!=="conditional")return e.reset(a),null;let u=o;if(u.elseBranch&&u.elseBranch.length>0)return e.reset(a),null;let s=u.roles.get("condition");return s?[ee("unless",{condition:s},{sourceLanguage:i,patternId:`unless-${i}-guard`,confidence:1}),...u.thenBranch]:(e.reset(a),null)}isBlockEndToken(e,r,i){return this.isEndKeyword(e.value,i)?true:e.kind!=="keyword"||(e.normalized??"").toLowerCase()!=="end"?false:!(r&&r.kind==="selector")}tryParseConditionalBlock(e,r,i,n=false){let a=e.peek();if(!a)return null;let o=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(o,i)&&!(n&&this.isUnlessKeyword(o,i)))return null;let u=e.mark(),s=this.coverageMark();e.advance();let l=[],c=0;for(;!e.isAtEnd();){let w=e.peek();if(!w)break;let S=(w.normalized??w.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)){c++,l.push(w),e.advance();continue}if(this.isBlockEndToken(w,e.peek(1)??void 0,i)){if(c===0){e.advance();break}c--,l.push(w),e.advance();continue}l.push(w),e.advance();}if(l.length===0)return e.reset(u),this.coverageRollback(s),null;let m=L(i),d=m?.wordOrder==="SOV"?x.buildVerbLookup(m):null,p=0,f=0,v=[];for(;p<l.length;p++){let w=l[p],S=(w.normalized??w.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?f++:this.isBlockEndToken(w,l[p+1],i)&&f--,f===0&&this.isThenKeyword(w.value,i)){p++;break}if(f===0&&v.length>0){let C=(l[p-1].normalized??l[p-1].value).toLowerCase(),k=l[p-1].value.toLowerCase(),B=(w.normalized??w.value).toLowerCase(),R=x.CONDITION_COPULAS.has(C)||x.CONDITION_COPULAS_SURFACE.has(k)&&x.CONDITION_PREDICATES.has(B),F=d!==null&&d.has(w.value.toLowerCase())&&!x.CONDITION_PREDICATES.has(B),O=/^\.[a-zA-Z_]\w*$/.test(w.value)&&l[p-1].position?.end!==void 0&&w.position?.start!==void 0&&l[p-1].position.end===w.position.start;if(!x.CONDITION_OPERATORS.has(B)&&!O&&(!R||F)&&(this.tokensBeginCommand(l.slice(p),r,i)||this.sovCommandStartsAt(l.slice(p),d)))break}v.push(w);}if(v.length===0)return e.reset(u),this.coverageRollback(s),null;let y=[],h=[],z=false,A=0;for(;p<l.length;p++){let w=l[p],S=(w.normalized??w.value).toLowerCase();if(this.isIfKeyword(S,i)||this.isUnlessKeyword(S,i)?A++:this.isBlockEndToken(w,l[p+1],i)&&A--,A===0&&!z&&this.isElseKeyword(w.value,i)){z=true;continue}(z?h:y).push(w);}let D={type:"expression",raw:this.joinTokenText(v,i)},b=this.parseBranch(y,r,i),g=h.length>0?this.parseBranch(h,r,i):void 0;return b.length===0&&(!g||g.length===0)?(e.reset(u),this.coverageRollback(s),null):Ao(D,b,g,{sourceLanguage:i,patternId:`conditional-${i}-folded`,confidence:1})}joinTokenText(e,r){return Oe(e,L(r))}tokensBeginCommand(e,r,i){if(e.length===0)return false;let n=new ie(e,i);return oe.matchBest(n,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let i=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),n=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!n(u)||s.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&i(l))return true}return false}parseBranch(e,r,i){if(e.length===0)return [];let n=new ie(e,i),a=this.parseBodyWithClauses(n,r,i);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let n=Y(e,r).tokens;if(n.length===0)return {modifiers:null,remainingInput:null};let o=n[0].value.toLowerCase(),u=x.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let p=1;if(p<n.length){let f=n[p],v=n[p+1],E=f.kind==="identifier"&&v?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(v.value);(f.kind==="keyword"||f.kind==="particle"||E)&&(p++,l++);}if(p<n.length){let f=n[p];if(f.kind==="literal"){let v=f.value.match(/^(\d+)(ms|s|m)?$/);if(v){let E=parseInt(v[1],10),y=v[2]||"ms";y==="s"?E*=1e3:y==="m"&&(E*=6e4),s[u]=E,l=p+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let c=n.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,d=e.slice(m);return {modifiers:s,remainingInput:d}}stripAsyncModifier(e,r){let i=L(r)?.keywords?.async,n=new Set(["async"]);i?.primary&&n.add(i.primary.toLowerCase()),i?.alternatives?.forEach(l=>n.add(l.toLowerCase()));let a=Y(e,r).tokens,o=a.findIndex(l=>n.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let i=Y(e,r).tokens;for(let n=0;n<i.length-1;n++){if(i[n].value.toLowerCase()!=="do")continue;let a=-1;for(let l=n+1;l<=n+5&&l<i.length;l++){let c=i[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let m=c.kind;if(m==="selector"||m==="literal"||m==="reference"||m==="conjunction")break}if(a===-1)continue;let o=i[n].position.start,u=i[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,i)=>r+(parseInt(/left (\d+) token/.exec(i.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(i=>{if(i.code!=="unconsumed-input")return true;let n=/unconsumed: "(.*)"$/.exec(i.message)?.[1];return !n||n.replace(/\s+/g," ").trim()!==r})}}reclaimDanglingFromTail(e,r,i){let n=x.droppedTokenCount,a=x.unconsumedSpans(e);if(a.length===0)return null;let o=n(e),u=L(i)?.roleMarkers?.source,s=new Set;u?.primary&&s.add(u.primary),u?.alternatives?.forEach(c=>s.add(c));let l=Y(r,i).tokens;for(let c=0;c<l.length;c++){let m=l[c];if(m.normalized!=="source"&&!s.has(m.value))continue;let d=u?.position==="after"?c-1:c+1,p=l[d];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(m.position.start,p.position.start),v=Math.max(m.position.end,p.position.end),E=r.slice(f,v).replace(/\s+/g," ").trim();if(!a.some(h=>h===E||h.includes(E)))continue;let y=(r.slice(0,f).trimEnd()+" "+r.slice(v).trimStart()).trim();if(!(!y||y===r))try{let h=this.parse(y,i);if(!h||h.kind!=="event-handler")continue;let z=br(h);if(n(z)<o)return {node:{...z,eventModifiers:{...z.eventModifiers,from:{type:"literal",value:p.value,dataType:"string"}}},input:y}}catch{}}return null}reclaimEventCompoundTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=ve[i];if(!a)return null;let o=e.roles,u=o.get("event"),s=u?.type==="literal"&&typeof u.value=="string"?u.value:null;if(!s)return null;let l=m=>m.replace(/\s+/g," ").trim(),c=Y(r,i).tokens;for(let m of n)for(let d=1;d<c.length;d++)for(let p=d;p<c.length;p++){let f=l(r.slice(c[d].position.start,c[p].position.end));if(f.length>m.length)break;if(f!==m)continue;let v=c[d-1];if((a[v.value]??v.normalized)!==s)break;let y=l(r.slice(v.position.start,c[p].position.end)),h=a[y];if(!h)break;return o.set("event",{type:"literal",value:h,dataType:"string"}),{node:x.withoutSpanDiagnostics(e,m),input:r}}return null}reclaimResponseTypeTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=x.AS_MARKERS_BEFORE[i];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),u=x.droppedTokenCount(e),s=Y(r,i).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1];if(!a.some(f=>c.value.toLowerCase()===f)||!x.RESPONSE_TYPE_WORDS.has(m.value.toLowerCase()))continue;let d=o(r.slice(c.position.start,m.position.end));if(!n.includes(d))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(m.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,i);if(!f||f.kind!=="event-handler")continue;let v=br(f);if(x.droppedTokenCount(v)>=u)continue;let E=x.findResponseTypeTarget(v);if(!E)continue;return E.roles.set("responseType",{type:"expression",raw:m.value}),{node:v,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,i=n=>{if(!n||typeof n!="object"||r)return;if(n.kind==="command"){let o=n;if(re(o.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!o.roles.has("responseType")){r=o;return}}let a=n;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let u=a[o];Array.isArray(u)&&u.forEach(s=>i(s));}};return i(e),r}reclaimCapturedDestinationTail(e,r,i){let n=x.unconsumedSpans(e);if(n.length===0)return null;let a=L(i)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let u=l=>l.replace(/\s+/g," ").trim(),s=Y(r,i).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],m=s[l+1],d=o.has(c.value)&&m.normalized==="me",p=c.normalized==="me"&&o.has(m.value);if(!d&&!p)continue;let f=u(r.slice(c.position.start,m.position.end));if(!n.includes(f))continue;let v=false,E=y=>{if(!y||typeof y!="object"||v)return;if(y.kind==="command"){let z=y.roles.get("destination");if(z?.type==="reference"&&z.value==="me"){v=true;return}}let h=y;for(let z of ["body","statements","thenBranch","elseBranch","commands"]){let A=h[z];Array.isArray(A)&&A.forEach(D=>E(D));}};if(E(e),!!v)return {node:x.withoutSpanDiagnostics(e,f),input:r}}return null}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let i=[];for(;;){let n=e.mark(),a=e.peek();if(!a)break;if(!xr(a,r)){e.reset(n);break}e.advance();let o=e.peek();if(!o){e.reset(n);break}let u=(o.normalized||o.value).toLowerCase();e.advance(),i.push({type:"literal",value:u});}return i}};Q.coverageMarkerSurfaces=new Map;Q.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Q.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};Q.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Q.enEventKeywordCache=new Map;Q.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Q.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Q.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"]),hi:new Set(["\u092A\u0930"])};Q.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Q.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])},hi:{markers:new Set(["\u0938\u0947"]),windowTokens:new Set(["\u0935\u093F\u0902\u0921\u094B","\u0926\u0938\u094D\u0924\u093E\u0935\u0947\u091C\u093C","window","document"])}};Q.CONDITION_COPULAS=new Set(["is","am","are","be","was","were","not","no"]);Q.CONDITION_COPULAS_SURFACE=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948"]);Q.CONDITION_PREDICATES=new Set(["empty","null","undefined"]);Q.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Q.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var Zu=Q,Ju=new Zu;function Xu(t,e){return Ju.parse(t,e)}function Qu(t,e){try{let r=Y(t,e),i=de(e);if(i.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let n=[...i].sort((l,c)=>c.priority-l.priority),a=n.filter(l=>l.command==="on"),o=oe.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=n.filter(l=>l.command!=="on"),s=oe.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: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function ti(t,e){try{let i=Xu(t,e);if(i)return {node:i,confidence:i.metadata?.confidence??.8,error:void 0,tokensConsumed:Y(t,e).tokens.length}}catch{}let r=Qu(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function ii(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((i,n)=>{let a=i[r]??99,o=n[r]??99;return a-o})}function _e(t,e){let r,i;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],i=r?fe(t,e.code,r):void 0;else {let n=e.roleMarkers[t.role];if(n){r=n.primary;let a=fe(t,e.code,r)??[],o=[...new Set([...n.alternatives??[],...a])].filter(u=>u!==r);i=o.length?o:void 0;}}return {marker:r,alternatives:i}}function Qe(t,e,r){r.roles.find(n=>n.role==="scope"&&!n.required)&&(t.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function $r(t,e,r,i){ai(t,e,r,i,"manner",{requireMarker:true});}function ni(t,e,r,i){ai(t,e,r,i,"recipient",{requireMarker:false});}function ai(t,e,r,i,n,a){let o=r.roles.find(s=>s.role===n&&!s.required);if(!o)return;let u=o.markerOverride?.[i];a.requireMarker&&!u||(t.push({type:"group",optional:true,tokens:[...(u?u.split(/\s+/):[]).map(s=>({type:"literal",value:s})),{type:"role",role:n,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[n]={fromRole:n});}function oi(t){if(t.roles.some(i=>i.role==="patient"))return "patient";let e=t.roles.filter(i=>i.required),r=e.find(i=>i.role===t.primaryRole)??e[0];return !r||r.role==="event"?"patient":r.role}function ui(t,e,r){let i=t.roles.find(c=>c.role===r);if(!i||r==="patient")return [{type:"role",role:r,optional:false}];let{marker:n,alternatives:a}=_e(i,e),o={type:"role",role:r,optional:false,...i.valueShape!==void 0?{valueShape:i.valueShape}:{}};if(!n)return [o];let u=n.split(/\s+/).filter(Boolean),s={type:"group",optional:true,tokens:u.map(c=>({type:"literal",value:c,...u.length===1&&a?.length?{alternatives:a}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,s]:[s,o]}function si(t,e,r,i,n){for(let a of r.roles)a.required||n.has(a.role)||e[a.role]||!(a.markerOverride?.[i.code]??i.roleMarkers[a.role]?.primary)&&a.valueShape===void 0||(t.push({type:"group",optional:true,tokens:mi(a,i)}),e[a.role]=a.default?{fromRole:a.role,default:a.default}:{fromRole:a.role});}function es(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let f=i.primary.split(/\s+/);if(f.length>1)for(let v of f)a.push({type:"literal",value:v});else {let v=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(v);}}let o=oi(t),u=e.roleMarkers.destination,s=t.roles.some(f=>f.role==="destination");u&&s&&o!=="destination"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]});let l=e.roleMarkers.source,c=t.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),a.push(...ui(t,e,o));let m=e.roleMarkers.patient;if(m&&o==="patient"){let f=m.alternatives?{type:"literal",value:m.primary,alternatives:m.alternatives}:{type:"literal",value:m.primary};a.push(f);}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(d),o!=="source"&&a.push(...Ae(t,e.roleMarkers.source)),o!=="destination"&&a.push(...Rr(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:we(t),...o==="source"?{}:be(t)};return si(a,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`{event} ${i.primary} {destination?} {${o}} ${m?.primary||""} ${r.primary}`,tokens:a},extraction:p}}function rs(t,e,r,i,n){let a=[],o=t.action==="swap",u=o?"destination":"patient";a.push({type:"role",role:u,optional:false});let s=e.roleMarkers.patient;if(s){let d=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(d);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let d=i.primary.split(/\s+/);if(d.length>1)for(let p of d)a.push({type:"literal",value:p});else {let p=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(l),a.push(...Ae(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let d=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(d&&d!==c.primary){let p=c.alternatives??[];p.includes(d)||(c={...c,alternatives:[...p,d]});}}a.push(...o?An(t,c):Rr(t,c));let m={action:{value:t.action},event:{fromRole:"event"},[u]:{fromRole:u},...o?{}:we(t),...be(t)};return ni(a,m,t,e.code),$r(a,m,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:m}}function ts(t,e,r,i,n){let a=t.roles.find(m=>m.role==="source");if(!a)return null;let{marker:o,alternatives:u}=_e(a,e),s=e.roleMarkers.patient;if(!o||o===i.primary||o===s?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),s&&l.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}),l.push({type:"role",role:"source",optional:false,...a.expectedTypes?{expectedTypes:a.expectedTypes}:{},...a.valueShape!==void 0?{valueShape:a.valueShape}:{}});for(let m of o.split(/\s+/))l.push(u&&o.split(/\s+/).length===1?{type:"literal",value:m,alternatives:u}:{type:"literal",value:m});if(l.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)l.push({type:"literal",value:d});else l.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}l.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary});let c={action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return ni(l,c,t,e.code),$r(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{patient} ${s?.primary||""} {source} ${o} {event} ${i.primary} ${r.primary}`,tokens:l},extraction:c}}function is(t,e,r,i,n){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let l=i.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ns(t,e,r,i,n){let a=[];a.push({type:"role",role:"event",optional:false});let o=i.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...Ae(t,e.roleMarkers.source)),a.push(...Rr(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(n.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...we(t),...be(t)}}}function as(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let u=i.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{event} ${i.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function os(t,e,r,i){let n=e.eventHandler?.temporalMarkers;if(!n||n.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:n[0],alternatives:n.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(i.basePriority??100)+49,template:{format:`{event} ${n[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function us(t,e,r,i,n){let a=[];if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let m=i.primary.split(/\s+/);if(m.length>1)for(let d of m)a.push({type:"literal",value:d});else {let d=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(d);}}let u=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.sovPosition??999,f=d.sovPosition??999;return p-f});for(let m of u){a.push({type:"role",role:m.role,optional:false});let{marker:d,alternatives:p}=_e(m,e);if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(f);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(m=>[m.role,{fromRole:m.role}]))};return Qe(a,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`{event} ${i.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function ss(t,e,r,i,n){let a=[],u=[...t.roles.filter(c=>c.required)].sort((c,m)=>{let d=c.sovPosition??999,p=m.sovPosition??999;return d-p});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:m,alternatives:d}=_e(c,e);m&&a.push(d?{type:"literal",value:m,alternatives:d}:{type:"literal",value:m});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),i.position==="after"){let c=i.primary.split(/\s+/);if(c.length>1)for(let m of c)a.push({type:"literal",value:m});else a.push(i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return Qe(a,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(n.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${i.primary}`,tokens:a},extraction:l}}function ls(t,e,r,i,n){let a=[],u=[...t.roles.filter(E=>E.required)].sort((E,y)=>{let h=E.sovPosition??999,z=y.sovPosition??999;return h-z}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=_e(s,e);if(l){let E=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(E);}if(a.push({type:"role",role:"event",optional:false}),i.position==="after"){let E=i.primary.split(/\s+/);if(E.length>1)for(let y of E)a.push({type:"literal",value:y});else {let y=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(y);}}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m);let d=u[1];a.push({type:"role",role:d.role,optional:false});let{marker:p,alternatives:f}=_e(d,e);if(p){let E=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};a.push(E);}let v={action:{value:t.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[d.role]:{fromRole:d.role}};return Qe(a,v,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`{${s.role}} {event} ${i.primary} ${r.primary} {${d.role}}`,tokens:a},extraction:v}}function li(t,e,r){let i=fe(t,e.code,r.primary)??[],n=[...new Set([...r.alternatives??[],...i])].filter(a=>a!==r.primary);return n.length?n:void 0}function kt(t,e,r,i,n){let a=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=oi(t);a.push(...ui(t,e,u));let s=e.roleMarkers.destination,l=t.roles.some(m=>m.role==="destination");s&&l&&u!=="destination"&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),u!=="source"&&a.push(...Ae(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[u]:{fromRole:u},...u==="destination"?{}:we(t),...u==="source"?{}:be(t)};return si(a,c,t,e,new Set(["event",u,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(n.basePriority??100)+50,template:{format:`${i.primary} {event} ${r.primary} {${u}} ${s?.primary||""} {destination?}`,tokens:a},extraction:c}}function cs(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=t.action==="swap";a.push({type:"role",role:u?"destination":"patient",optional:false});let s=u?void 0:e.roleMarkers.destination;if(s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Ae(t,e.roleMarkers.source)),i.position==="before"){let c=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(c);}if(a.push({type:"role",role:"event",optional:false}),u){let c=t.roles.find(m=>m.role==="patient")?.markerOverride?.[e.code];c&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:t.action},event:{fromRole:"event"},[u?"destination":"patient"]:{fromRole:u?"destination":"patient"},...u?{}:we(t),...be(t)};return $r(a,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`${r.primary} {patient} ${s?.primary||""} {destination?} ${i.primary} {event}`,tokens:a},extraction:l}}function ms(t,e,r,i,n){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of s){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?fe(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=li(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(f);}a.push({type:"role",role:m.role,optional:false});}if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Qe(a,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${r.primary} ${l} ${i.primary} {event}`,tokens:a},extraction:c}}function wt(t,e,r,i,n){let a=[];if(i.position==="before"){let m=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(m);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...t.roles.filter(m=>m.required)].sort((m,d)=>{let p=m.svoPosition??999,f=d.svoPosition??999;return p-f});for(let m of s){let d,p;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)d=m.markerOverride[e.code],p=d?fe(m,e.code,d):void 0;else {let f=e.roleMarkers[m.role];f&&(d=f.primary,p=li(m,e,f));}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};a.push(f);}a.push({type:"role",role:m.role,optional:false});}let l=s.map(m=>`{${m.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(m=>[m.role,{fromRole:m.role}]))};return Qe(a,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(n.basePriority??100)+55,template:{format:`${i.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function ds(t,e,r,i,n){let a=[],o=e.eventHandler?.negationMarker;if(i.position==="before"){let l=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...Ae(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(n.basePriority??100)+48,template:{format:`${i.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...we(t),...be(t)}}}function ps(t,e,r,i){let n=[];n.push({type:"literal",value:"and",alternatives:["then"]}),n.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(a),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&n.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),n.push(...Ae(t,e.roleMarkers.source)),{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} ${o?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...we(t),...be(t)}}}var $e={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Je(t,e,r=$e){let i=`${t.action}-${e.code}-generated`,n=r.basePriority??100,a=e.keywords[t.action];if(!a)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=vs(t,e,a),u=Vr(t,e),s=zs(t,e,a);return {id:i,language:e.code,command:t.action,priority:n,template:{format:s,tokens:o},extraction:u}}function fs(t,e,r=$e){if(t.roles.filter(u=>!u.required).length===0)return null;let n=t.roles.filter(u=>u.required),a={...t,roles:n};return {...Je(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Vr(t,e)}}function bt(t,e,r=$e){if(e.wordOrder!=="SOV")return null;let i=t.roles.filter(u=>u.required);if(i.length!==1)return null;let n=e.keywords[t.action];if(!n)return null;let a=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary},o=i.flatMap(u=>{let s=u.valuePrefixLiteral?.[e.code],l={type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes};return s?[{type:"literal",value:s},l]:[l]});return {id:`${t.action}-${e.code}-generated-verb-first`,language:e.code,command:t.action,priority:(r.basePriority??100)-20,template:{format:`${n.primary} <${i[0].role}>`,tokens:[a,...o]},extraction:Vr(t,e)}}function ys(t,e,r=$e){let i=[];if(i.push(Je(t,e,r)),r.generateSimpleVariants){let n=fs(t,e,r);n&&i.push(n);}for(let n of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(u=>u.role!==n)},o=Je(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-no-${n}`,priority:(r.basePriority??100)-8});}for(let n of t.widenTypeVariants??[]){if(n.excludeLanguages?.includes(e.code))continue;let a={...t,roles:t.roles.map(u=>u.role===n.role?{...u,expectedTypes:[...n.types]}:u)},o=Je(a,e,r);i.push({...o,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)-(n.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let n=bt(t,e,r);n&&i.push(n);}for(let n of t.rolePrefixLiteralVariants??[]){let a=n.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...u}=t,s={...u,roles:t.roles.map(d=>d.role===n.role?{...d,valuePrefixLiteral:{[e.code]:a}}:d)},l=n.priorityDelta??5,c=n.methodCarrier?{[n.methodCarrier]:{value:a}}:{},m=Je(s,e,r);if(i.push({...m,id:`${t.action}-${e.code}-generated-${n.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...m.extraction,...c}}),r.generateVerbFirstVariants!==false){let d=bt(s,e,r);d&&i.push({...d,id:`${t.action}-${e.code}-generated-verb-first-${n.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...d.extraction,...c}});}}return i}function ci(t,e=$e){let r=[],i=Wa();for(let n of i){if(!t.keywords[n.action])continue;let a=ys(n,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=hs(n,t,e);r.push(...o);}}return r}function hs(t,e,r=$e){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let i=[],n=e.eventHandler.eventMarker,a=e.keywords[t.action];if(!a)return [];if(t.roles.length===0)return [];if(t.action==="js")return [];let u=t.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)i.push(us(t,e,a,n,r)),i.push(ls(t,e,a,n,r)),i.push(ss(t,e,a,n,r));else {i.push(es(t,e,a,n,r)),i.push(rs(t,e,a,n,r));let s=ts(t,e,a,n,r);s&&i.push(s);let l=e.roleMarkers.destination;l&&l.primary!==n.primary&&i.push(is(t,e,a,n,r));let c=n.primary.split(/\s+/),m=n.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&m&&i.push(ns(t,e,a,n,r)),i.push(as(t,e,a,n,r));let d=os(t,e,a,r);d&&i.push(d);}else e.wordOrder==="VSO"?u?(i.push(wt(t,e,a,n,r)),i.push(ms(t,e,a,n,r))):(i.push(kt(t,e,a,n,r)),i.push(cs(t,e,a,n,r)),e.eventHandler?.negationMarker&&i.push(ds(t,e,a,n,r)),e.tokenization?.prefixes&&i.push(ps(t,e,a,r))):u?i.push(wt(t,e,a,n,r)):i.push(kt(t,e,a,n,r));return i}function vs(t,e,r){let i=[],n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=gs(t,e);switch(e.wordOrder){case "SVO":i.push(n),i.push(...a);break;case "SOV":i.push(...a),i.push(n);break;case "VSO":i.push(n),i.push(...a);break;default:i.push(n),i.push(...a);}return Es(i)}function Es(t){let e=[];for(let r of t){let i=e[e.length-1];if(i&&i.type==="literal"&&r.type==="literal"&&i.value===r.value){let n=[...i.alternatives??[],...r.alternatives??[]];n.length&&(e[e.length-1]={...i,alternatives:[...new Set(n)]});continue}e.push(r);}return e}function gs(t,e){let r=[],i=ii(t.roles,e.wordOrder);for(let n of i){let a=mi(n,e);n.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function mi(t,e){let r=[],i=t.markerOverride?.[e.code],n=e.roleMarkers[t.role],a=t.renderOverride?.[e.code]==="",o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes,...t.valueShape!==void 0?{valueShape:t.valueShape}:{}},u=t.valuePrefixLiteral?.[e.code],s=()=>{u&&r.push({type:"literal",value:u}),r.push(o);};if(i!==void 0){let l=i?i.split(/\s+/).filter(Boolean):[],c=i!==void 0&&i===t.markerOverride?.en,m=n?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),d=t.markerOptional?.[e.code]===true,p=f=>{let v=l.length===1?fe(t,e.code,f)??[]:[],E={type:"literal",value:f,...v.length?{alternatives:v}:{},...a?{renderSuppress:true}:{}};r.push(d?{type:"group",optional:true,tokens:[E]}:E);};if(m==="before"){for(let f of l)p(f);s();}else {s();for(let f of l)p(f);}}else if(n){let l=()=>{let m=[...new Set([...n.alternatives??[],...fe(t,e.code,n.primary)??[]])].filter(d=>d!==n.primary);return {type:"literal",value:n.primary,...m.length?{alternatives:m}:{},...a?{renderSuppress:true}:{}}},c=m=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(m);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[m]});};n.position==="before"?(n.primary&&c(l()),s()):(s(),c(l()));}else s();return r}function Cs(t,e){let r={};for(let i of t.roles){let n=i.markerOverride?.[e.code],a=e.roleMarkers[i.role];if(i.valuePrefixLiteral?.[e.code])r[i.role]={marker:i.valuePrefixLiteral[e.code]};else if(n!==void 0)if(!n)r[i.role]={};else {let u=!/\s/.test(n.trim())?fe(i,e.code,n)??[]:[];r[i.role]=u.length?{marker:n,markerAlternatives:u}:{marker:n};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...fe(i,e.code,a.primary)??[]])].filter(u=>u!==a.primary);r[i.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[i.role]={};}return r}function Vr(t,e){let r=Cs(t,e),i={};for(let n of t.roles){let a=r[n.role]||{};!n.required&&n.default?i[n.role]={...a,default:n.default}:i[n.role]=a;}return i}function zs(t,e,r){let i=[],a=ii(t.roles,e.wordOrder).map(o=>{let u=Do(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":i.push(r.primary,...a);break;case "SOV":i.push(...a,r.primary);break;default:i.push(r.primary,...a);}return i.join(" ")}var ks=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),n=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(i,{result:r,createdAt:n,lastAccessed:n});}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 ks;var ws=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to",minStemLength:2},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u305F\u3089",confidence:.85,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u308C\u3070",confidence:.82,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3057\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3067\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304A\u304F",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u307F\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u3042\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3067\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3061\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3058\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3061\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u3058\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u307E\u3057\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u307E\u305B\u3093",confidence:.85,conjugationType:"negative",minStemLength:2},{pattern:"\u307E\u3059",confidence:.85,conjugationType:"polite",minStemLength:2},{pattern:"\u3066",confidence:.85,conjugationType:"te-form",minStemLength:2},{pattern:"\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u306A\u3044",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"\u306A\u304B\u3063\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3089\u308C\u308B",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"\u308C\u308B",confidence:.78,conjugationType:"potential",minStemLength:2},{pattern:"\u3089\u308C\u305F",confidence:.8,conjugationType:"passive",minStemLength:2},{pattern:"\u3055\u305B\u308B",confidence:.8,conjugationType:"causative",minStemLength:2},{pattern:"\u305B\u308B",confidence:.78,conjugationType:"causative",minStemLength:2},{pattern:"\u3088\u3046",confidence:.8,conjugationType:"volitional",minStemLength:2},{pattern:"\u308B",confidence:.75,conjugationType:"dictionary",minStemLength:3}],bs=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara"},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to"},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba"},{pattern:"\u3057\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u307E\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3057\u307E\u3059",confidence:.85,conjugationType:"polite"},{pattern:"\u3057\u306A\u3044",confidence:.82,conjugationType:"negative"},{pattern:"\u3057\u3066",confidence:.85,conjugationType:"te-form"},{pattern:"\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3059\u308B",confidence:.88,conjugationType:"dictionary"}];function hi(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function As(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function Ds(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903}function Bs(t){for(let e of t)if(hi(e)||As(e)||Ds(e))return true;return false}var vi=class{constructor(){this.language="ja";}isNormalizable(t){if(!Bs(t)||t.length<2)return false;let e=t[t.length-1];return hi(e)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.trySuruNormalization(t);if(r)return r;for(let i of ws)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),he(n,i.confidence,o)}return or(t)}trySuruNormalization(t){for(let e of bs)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return he(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"suru-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\u3066\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3066","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3067\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3067","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3066\u3044\u306A\u3044",suffixes:["\u3066","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3067\u3044\u306A\u3044",suffixes:["\u3067","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3066\u3044\u305F",suffixes:["\u3066","\u3044","\u305F"],confidence:.85,minStemLength:2},{pattern:"\u3067\u3044\u305F",suffixes:["\u3067","\u3044","\u305F"],confidence:.85,minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,minStemLength:a}of e)if(t.endsWith(r)){let o=t.slice(0,-r.length);if(o.length<a)continue;return he(o,n,{removedSuffixes:i,conjugationType:"compound"})}return null}},Ei={code:"ja",name:"Japanese",nativeName:"\u65E5\u672C\u8A9E",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:false,defaultVerbForm:"base",verb:{position:"end",suffixes:["\u308B","\u3066","\u305F","\u307E\u3059","\u306A\u3044"],subjectDrop:true},references:{me:"\u81EA\u5206",it:"\u305D\u308C",you:"\u3042\u306A\u305F",result:"\u7D50\u679C",event:"\u30A4\u30D9\u30F3\u30C8",target:"\u30BF\u30FC\u30B2\u30C3\u30C8",body:"\u30DC\u30C7\u30A3",document:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",window:"\u30A6\u30A3\u30F3\u30C9\u30A6",detail:"\u8A73\u7D30"},possessive:{marker:"\u306E",markerPosition:"between",keywords:{\u79C1\u306E:"me",\u3042\u306A\u305F\u306E:"you",\u305D\u306E:"it"}},roleMarkers:{patient:{primary:"\u3092",position:"after"},destination:{primary:"\u306B",alternatives:["\u3078","\u3067","\u306E"],position:"after"},source:{primary:"\u304B\u3089",position:"after"},style:{primary:"\u3067",position:"after"},event:{primary:"\u3092",position:"after"}},keywords:{toggle:{primary:"\u5207\u308A\u66FF\u3048",alternatives:["\u5207\u308A\u66FF\u3048\u308B","\u30C8\u30B0\u30EB","\u30C8\u30B0\u30EB\u3059\u308B"],normalized:"toggle"},add:{primary:"\u8FFD\u52A0",alternatives:["\u8FFD\u52A0\u3059\u308B","\u52A0\u3048\u308B"],normalized:"add"},remove:{primary:"\u524A\u9664",alternatives:["\u524A\u9664\u3059\u308B","\u53D6\u308A\u9664\u304F"],normalized:"remove"},put:{primary:"\u7F6E\u304F",alternatives:["\u5165\u308C\u308B"],normalized:"put"},append:{primary:"\u672B\u5C3E\u8FFD\u52A0",alternatives:["\u672B\u5C3E\u306B\u8FFD\u52A0","\u30A2\u30DA\u30F3\u30C9"],normalized:"append"},prepend:{primary:"\u5148\u982D\u8FFD\u52A0",alternatives:["\u5148\u982D\u306B\u8FFD\u52A0","\u30D7\u30EA\u30DA\u30F3\u30C9"],normalized:"prepend"},take:{primary:"\u53D6\u308B",normalized:"take"},make:{primary:"\u4F5C\u308B",alternatives:["\u4F5C\u6210"],normalized:"make"},clone:{primary:"\u8907\u88FD",alternatives:["\u30AF\u30ED\u30FC\u30F3"],normalized:"clone"},swap:{primary:"\u4EA4\u63DB",alternatives:["\u30B9\u30EF\u30C3\u30D7","\u5165\u308C\u66FF\u3048"],normalized:"swap"},morph:{primary:"\u5909\u5F62",alternatives:["\u30E2\u30FC\u30D5","\u5909\u63DB"],normalized:"morph"},set:{primary:"\u8A2D\u5B9A",alternatives:["\u8A2D\u5B9A\u3059\u308B"],normalized:"set"},get:{primary:"\u53D6\u5F97",alternatives:["\u53D6\u5F97\u3059\u308B","\u30B2\u30C3\u30C8"],normalized:"get"},increment:{primary:"\u5897\u52A0",alternatives:["\u5897\u3084\u3059","\u30A4\u30F3\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"increment"},decrement:{primary:"\u6E1B\u5C11",alternatives:["\u6E1B\u3089\u3059","\u30C7\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"decrement"},log:{primary:"\u8A18\u9332",alternatives:["\u30ED\u30B0","\u51FA\u529B"],normalized:"log"},show:{primary:"\u8868\u793A",alternatives:["\u8868\u793A\u3059\u308B","\u898B\u305B\u308B"],normalized:"show"},hide:{primary:"\u96A0\u3059",alternatives:["\u975E\u8868\u793A","\u975E\u8868\u793A\u306B\u3059\u308B"],normalized:"hide"},transition:{primary:"\u9077\u79FB",alternatives:["\u30C8\u30E9\u30F3\u30B8\u30B7\u30E7\u30F3","\u30A2\u30CB\u30E1\u30FC\u30B7\u30E7\u30F3"],normalized:"transition"},on:{primary:"\u3067",alternatives:["\u6642"],normalized:"on"},trigger:{primary:"\u5F15\u304D\u91D1",alternatives:["\u767A\u706B","\u30C8\u30EA\u30AC\u30FC"],normalized:"trigger"},send:{primary:"\u9001\u308B",alternatives:["\u9001\u4FE1"],normalized:"send"},focus:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9",normalized:"focus"},blur:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9\u89E3\u9664",alternatives:["\u30D5\u30A9\u30FC\u30AB\u30B9\u30A2\u30A6\u30C8","\u30D6\u30E9\u30FC","\u307C\u304B\u3057"],normalized:"blur"},empty:{primary:"\u7A7A\u306B",alternatives:["\u7A7A\u306B\u3059\u308B"],normalized:"empty"},open:{primary:"\u958B\u304F",alternatives:["\u30AA\u30FC\u30D7\u30F3"],normalized:"open"},close:{primary:"\u9589\u3058\u308B",alternatives:["\u30AF\u30ED\u30FC\u30BA"],normalized:"close"},select:{primary:"\u9078\u3076",alternatives:["\u30BB\u30EC\u30AF\u30C8"],normalized:"select"},clear:{primary:"\u30AF\u30EA\u30A2",alternatives:["\u6D88\u53BB"],normalized:"clear"},reset:{primary:"\u30EA\u30BB\u30C3\u30C8",alternatives:["\u518D\u8A2D\u5B9A"],normalized:"reset"},breakpoint:{primary:"\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8",normalized:"breakpoint"},go:{primary:"\u79FB\u52D5",alternatives:["\u884C\u304F","\u30CA\u30D3\u30B2\u30FC\u30C8"],normalized:"go"},scroll:{primary:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},push:{primary:"\u30D7\u30C3\u30B7\u30E5",normalized:"push"},replace:{primary:"\u7F6E\u63DB",alternatives:["\u7F6E\u304D\u63DB\u3048"],normalized:"replace"},process:{primary:"\u51E6\u7406",normalized:"process"},wait:{primary:"\u5F85\u3064",alternatives:["\u5F85\u6A5F"],normalized:"wait"},fetch:{primary:"\u30D5\u30A7\u30C3\u30C1",normalized:"fetch"},settle:{primary:"\u5B89\u5B9A",alternatives:["\u843D\u3061\u7740\u304F"],normalized:"settle"},if:{primary:"\u3082\u3057",normalized:"if"},when:{primary:"\u3068\u304D",alternatives:["\u3068\u304D\u306B"],normalized:"when"},changes:{primary:"\u5909\u308F\u3063\u305F\u3089",normalized:"changes"},where:{primary:"\u3069\u3053",normalized:"where"},else:{primary:"\u305D\u3046\u3067\u306A\u3051\u308C\u3070",alternatives:["\u305D\u308C\u4EE5\u5916"],normalized:"else"},unless:{primary:"\u306A\u3044\u9650\u308A",normalized:"unless"},repeat:{primary:"\u7E70\u308A\u8FD4\u3057",alternatives:["\u7E70\u308A\u8FD4\u3059","\u30EA\u30D4\u30FC\u30C8"],normalized:"repeat"},for:{primary:"\u305F\u3081\u306B",alternatives:["\u5404"],normalized:"for"},while:{primary:"\u306E\u9593",alternatives:["\u9593"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\u7D9A\u3051\u308B",alternatives:["\u7D99\u7D9A"],normalized:"continue"},halt:{primary:"\u505C\u6B62",alternatives:["\u6B62\u3081\u308B","\u30CF\u30EB\u30C8"],normalized:"halt"},throw:{primary:"\u6295\u3052\u308B",alternatives:["\u30B9\u30ED\u30FC"],normalized:"throw"},call:{primary:"\u547C\u3073\u51FA\u3057",alternatives:["\u30B3\u30FC\u30EB","\u547C\u3076"],normalized:"call"},return:{primary:"\u623B\u308B",alternatives:["\u8FD4\u3059","\u30EA\u30BF\u30FC\u30F3"],normalized:"return"},then:{primary:"\u305D\u308C\u304B\u3089",alternatives:["\u6B21\u306B","\u306A\u3089\u3070","\u306A\u3089"],normalized:"then"},and:{primary:"\u307E\u305F",alternatives:["\u3068","\u305D\u3057\u3066"],normalized:"and"},matches:{primary:"\u4E00\u81F4\u3059\u308B",normalized:"matches"},exists:{primary:"\u5B58\u5728\u3059\u308B",normalized:"exists"},is:{primary:"\u3067\u3042\u308B",normalized:"is"},no:{primary:"\u306A\u3044",normalized:"no"},end:{primary:"\u7D42\u308F\u308A",alternatives:["\u304A\u308F\u308A"],normalized:"end"},js:{primary:"JS\u5B9F\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u975E\u540C\u671F",alternatives:["\u30A2\u30B7\u30F3\u30AF"],normalized:"async"},tell:{primary:"\u4F1D\u3048\u308B",alternatives:["\u30C6\u30EB"],normalized:"tell"},default:{primary:"\u65E2\u5B9A",alternatives:["\u30C7\u30D5\u30A9\u30EB\u30C8"],normalized:"default"},init:{primary:"\u521D\u671F\u5316",normalized:"init"},behavior:{primary:"\u632F\u308B\u821E\u3044",alternatives:["\u30D3\u30D8\u30A4\u30D3\u30A2"],normalized:"behavior"},install:{primary:"\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB",alternatives:["\u5C0E\u5165"],normalized:"install"},measure:{primary:"\u6E2C\u5B9A",alternatives:["\u8A08\u6E2C","\u30E1\u30B8\u30E3\u30FC"],normalized:"measure"},beep:{primary:"\u30D3\u30FC\u30D7",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u30B3\u30D4\u30FC",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9078\u629E",normalized:"pick"},render:{primary:"\u63CF\u753B",normalized:"render"},into:{primary:"\u3078",alternatives:["\u306B"],normalized:"into"},before:{primary:"\u524D\u306B",alternatives:["\u524D"],normalized:"before"},after:{primary:"\u5F8C\u306B",alternatives:["\u5F8C"],normalized:"after"},until:{primary:"\u307E\u3067",alternatives:["\u8FC4"],normalized:"until"},event:{primary:"\u30A4\u30D9\u30F3\u30C8",alternatives:["\u4E8B\u8C61"],normalized:"event"},from:{primary:"\u304B\u3089",normalized:"from"},connect:{primary:"\u63A5\u7D9A",alternatives:["\u63A5\u7D9A\u3059\u308B"],normalized:"connect"},stream:{primary:"\u30B9\u30C8\u30EA\u30FC\u30E0",alternatives:["\u914D\u4FE1"],normalized:"stream"},live:{primary:"\u30E9\u30A4\u30D6",alternatives:["\u5B9F\u6642\u9593"],normalized:"live"},socket:{primary:"\u30BD\u30B1\u30C3\u30C8",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\u30D0\u30A4\u30F3\u30C9",alternatives:["\u7D50\u3073\u3064\u3051\u308B","bind"],normalized:"bind"},intercept:{primary:"\u30A4\u30F3\u30BF\u30FC\u30BB\u30D7\u30C8",alternatives:["\u508D\u53D7","intercept"],normalized:"intercept"},worker:{primary:"\u30EF\u30FC\u30AB\u30FC",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u30A4\u30D9\u30F3\u30C8\u30BD\u30FC\u30B9"],normalized:"eventsource"}},tokenization:{particles:["\u3092","\u306B","\u3067","\u304B\u3089","\u306E","\u304C","\u306F","\u3082","\u3078","\u3068"],boundaryStrategy:"particle"},eventHandler:{eventMarker:{primary:"\u3067",position:"after"},temporalMarkers:["\u6642","\u3068\u304D"]}},Ss=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],xs=class{constructor(t=Ss){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}},Fs="()[]{},:;",Ts=class{constructor(t=Fs){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 qr(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function di(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=qr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=qr(t,e+n[0].length);return t.slice(e,a)}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,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=qr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Rs=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?di(t,e)!==null:false}extract(t,e){let r=di(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Os=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],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Ls=["http://","https://","//","./","../","/"];function Ps(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Ns(t,e){let r=t.slice(e),i=Ls.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Ps(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Ms=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=Ns(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},_s=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 Is(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function js(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function $s(t){let e=t.charCodeAt(0);return e>=19968&&e<=40879||e>=13312&&e<=19903}function pi(t){return Is(t)||js(t)||$s(t)}var Vs=class{constructor(){this.name="japanese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return pi(t[e])}extract(t,e){if(!this.context)throw new Error("JapaneseKeywordExtractor: context not set");let r=e;this.context.isKeywordStart(t,e);let i="",n=e;for(;n<t.length&&pi(t[n]);)i+=t[n],n++;let a=i,o=i.length;for(let c=i.length;c>0;c--){let m=i.substring(0,c);if(this.context.lookupKeyword(m)){a=m,o=c;break}}if(i=a,n=e+o,!i)return null;let u=this.context.lookupKeyword(i),s=u&&u.normalized!==u.native?u.normalized:void 0,l;if(!u&&this.context.normalizer){let c=this.context.normalizer.normalize(i);if(c.stem!==i&&c.confidence>=.7){let m=this.context.lookupKeyword(c.stem);m&&(l=m.normalized);}}return {value:i,length:n-r,metadata:{normalized:s||l}}}},fi=new Map([["\u3092",{role:"patient",confidence:.95}],["\u306B",{role:"destination",confidence:.85}],["\u304C",{role:"subject",confidence:.9}],["\u306E",{role:"possessive",confidence:.9}],["\u3068",{role:"conjunction",confidence:.8}],["\u3067",{role:"instrument",confidence:.85}],["\u3078",{role:"direction",confidence:.85}],["\u3084",{role:"listing",confidence:.8}],["\u304B",{role:"question",confidence:.85}],["\u3082",{role:"also",confidence:.85}],["\u306F",{role:"topic",confidence:.9}]]),yi=new Map([["\u304B\u3089",{role:"source",confidence:.95}],["\u307E\u3067",{role:"until",confidence:.95}],["\u3088\u308A",{role:"comparison",confidence:.9}],["\u3068\u3057\u3066",{role:"as",confidence:.9}],["\u306B\u3064\u3044\u3066",{role:"about",confidence:.9}],["\u306B\u3088\u3063\u3066",{role:"by-means",confidence:.9}],["\u306B\u3066",{role:"at-location",confidence:.85}]]),qs=class{constructor(){this.name="japanese-particle";}setContext(t){this._context=t;}longerKeywordStartsHere(t,e){if(!this._context)return false;for(let r=4;r>=2;r--){let i=t.slice(e,e+r);if(i.length===r&&this._context.isKeyword(i))return true}return false}canExtract(t,e){let r=t[e];if(fi.has(r)&&!this.longerKeywordStartsHere(t,e))return true;for(let[i]of yi)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of yi)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{role:a.role,confidence:a.confidence,variant:n}};let r=t[e];if(this.longerKeywordStartsHere(t,e))return null;let i=fi.get(r);return i?{value:r,length:1,metadata:{role:i.role,confidence:i.confidence,variant:r}}:null}};function Ws(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Ks(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Hs=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Ws(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&Ks(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Us(){return [new Ms,new Os,new _s,new Rs]}var Gs=new Set(["\u3092","\u306B","\u3067","\u304B\u3089","\u307E\u3067","\u3078","\u3068","\u306E","\u304C","\u306F","\u3082","\u3088\u308A"]),Ys=[{native:"\u771F",normalized:"true"},{native:"\u507D",normalized:"false"},{native:"\u30CC\u30EB",normalized:"null"},{native:"\u672A\u5B9A\u7FA9",normalized:"undefined"},{native:"\u6700\u521D",normalized:"first"},{native:"\u6700\u5F8C",normalized:"last"},{native:"\u6B21",normalized:"next"},{native:"\u524D",normalized:"previous"},{native:"\u6700\u3082\u8FD1\u3044",normalized:"closest"},{native:"\u89AA",normalized:"parent"},{native:"\u306E\u4E2D",normalized:"in"},{native:"\u30AF\u30EA\u30C3\u30AF",normalized:"click"},{native:"\u5909\u66F4",normalized:"change"},{native:"\u9001\u4FE1",normalized:"submit"},{native:"\u5165\u529B",normalized:"input"},{native:"\u30ED\u30FC\u30C9",normalized:"load"},{native:"\u8AAD\u307F\u8FBC\u307F",normalized:"load"},{native:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},{native:"\u30AD\u30FC\u30C0\u30A6\u30F3",normalized:"keydown"},{native:"\u30AD\u30FC\u30A2\u30C3\u30D7",normalized:"keyup"},{native:"\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC",normalized:"mouseover"},{native:"\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8",normalized:"mouseout"},{native:"\u30DE\u30A6\u30B9\u62BC\u4E0B",normalized:"mousedown"},{native:"\u30DE\u30A6\u30B9\u89E3\u653E",normalized:"mouseup"},{native:"\u307E\u305F\u306F",normalized:"or"},{native:"\u79C1",normalized:"me"},{native:"\u5BFE\u8C61",normalized:"target"},{native:"\u3057\u305F\u3089",normalized:"on"},{native:"\u3059\u308B\u3068",normalized:"on"},{native:"\u6642\u306B",normalized:"on"},{native:"\u79D2",normalized:"s"},{native:"\u30DF\u30EA\u79D2",normalized:"ms"},{native:"\u5206",normalized:"m"},{native:"\u6642\u9593",normalized:"h"},{native:"\u542B\u3080",normalized:"inclusive"},{native:"\u9664\u304F",normalized:"exclusive"},{native:"\u6587\u5B57",normalized:"characters"},{native:"\u30E9\u30F3\u30C0\u30E0",normalized:"random"}],Zs=class extends Fe{constructor(){super(),this.language="ja",this.direction="ltr",this.initializeKeywordsFromProfile(Ei,Ys),this.normalizer=new vi,this.registerExtractors(Us()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new Hs),this.registerExtractor(new qs),this.registerExtractor(new Vs),this.registerExtractor(new xs),this.registerExtractor(new Ts);}classifyToken(t){return Gs.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("'")||t.startsWith("\u300C")||/^\d/.test(t)?"literal":"identifier"}},Js=new Zs;Ie("ja",Js,Ei);function Xs(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function Qs(t){for(let e of t)if(Xs(e))return true;return false}var el=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.85,conjugationType:"honorific-causal",minStemLength:1},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional",minStemLength:1},{pattern:"\uC73C\uC2DC\uBA74",confidence:.85,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uC2DC\uBA74",confidence:.82,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uACE0\uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0 \uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uAE30\uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uAE30 \uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate",minStemLength:1},{pattern:"\uC790\uB9C8\uC790",confidence:.85,conjugationType:"immediate",minStemLength:2},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD574",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uC5B4\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC5B4\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uB2C8\uAE4C",confidence:.85,conjugationType:"causal-nikka",minStemLength:1},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uC744\uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uC744 \uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon",minStemLength:1},{pattern:"\uC73C\uBA74",confidence:.85,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uB2C8\uAE4C",confidence:.82,conjugationType:"causal-nikka",minStemLength:2},{pattern:"\uBA74",confidence:.8,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC2B5\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uB429\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:1},{pattern:"\u3142\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uC138\uC694",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uC2ED\uC2DC\uC624",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC5B4\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uC544\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574",confidence:.8,conjugationType:"present",minStemLength:1},{pattern:"\uC5C8\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uC558\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uACE0\uC788\uB2E4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uACE0\uC788\uC5B4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary",minStemLength:1},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC548\uD558\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC9C0\uC54A\uB2E4",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uB2E4",confidence:.75,conjugationType:"dictionary",minStemLength:2}],rl=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.88,conjugationType:"honorific-causal"},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional"},{pattern:"\uD558\uC168\uC5B4\uC694",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC168\uC5B4",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC2ED\uB2C8\uB2E4",confidence:.85,conjugationType:"honorific-polite"},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate"},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD574",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.88,conjugationType:"obligation"},{pattern:"\uD558\uB2C8\uAE4C",confidence:.88,conjugationType:"causal-nikka"},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon"},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite"},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific"},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific"},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past"},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite"},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past"},{pattern:"\uD574",confidence:.8,conjugationType:"present"},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD574\uC11C",confidence:.82,conjugationType:"connective"},{pattern:"\uD558\uACE0",confidence:.8,conjugationType:"connective"},{pattern:"\uD558\uC9C0\uC54A\uC544\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574",confidence:.82,conjugationType:"negative"},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary"}],wi=class{constructor(){this.language="ko";}isNormalizable(t){return !(!Qs(t)||t.length<2)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.tryHadaNormalization(t);if(r)return r;for(let i of el)if(t.endsWith(i.pattern)){let n=t.slice(0,-i.pattern.length),a=i.minStemLength??2;if(n.length<a)continue;let o={removedSuffixes:[i.pattern]};return i.conjugationType&&(o.conjugationType=i.conjugationType),he(n,i.confidence,o)}return or(t)}tryHadaNormalization(t){for(let e of rl)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return he(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"hada-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uC5B4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uC5B4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uB2E4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uB2E4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",suffixes:["\uD558\uACE0","\uB098\uC11C"],confidence:.85,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC5B4",suffixes:["\uD574\uC57C","\uD588\uC5B4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uB2E4",suffixes:["\uD574\uC57C","\uD588\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC2B5\uB2C8\uB2E4",suffixes:["\uD574\uC57C","\uD588\uC2B5\uB2C8\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uC2DC\uBA74\uC11C",suffixes:["\uD558\uC2DC","\uBA74\uC11C"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uC2DC\uBA70",suffixes:["\uD558\uC2DC","\uBA70"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uC5B4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uC5B4"],confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uB2E4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uB2E4"],confidence:.8,conjugationType:"progressive",minStemLength:2}];for(let{pattern:r,suffixes:i,confidence:n,conjugationType:a,minStemLength:o}of e)if(t.endsWith(r)){let u=t.slice(0,-r.length);if(u.length<o)continue;return he(u,n,{removedSuffixes:i,conjugationType:a})}return null}},bi={code:"ko",name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4",regions:["east-asian","priority"],direction:"ltr",script:"hangul",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:true,verb:{position:"end",suffixes:["\uB2E4","\uC694","\uB2C8\uB2E4","\uC138\uC694"],subjectDrop:true},references:{me:"\uB098",it:"\uADF8\uAC83",you:"\uB108",result:"\uACB0\uACFC",event:"\uC774\uBCA4\uD2B8",target:"\uB300\uC0C1",body:"\uBC14\uB514",document:"\uBB38\uC11C",window:"\uCC3D",detail:"\uC138\uBD80"},possessive:{marker:"\uC758",markerPosition:"between",specialForms:{me:"\uB0B4",it:"\uADF8\uAC83\uC758",you:"\uB124"},keywords:{\uB0B4:"me",\uB124:"you",\uADF8\uC758:"it"}},roleMarkers:{patient:{primary:"\uC744",alternatives:["\uB97C"],position:"after"},destination:{primary:"\uC5D0",alternatives:["\uC73C\uB85C","\uB85C","\uC758"],position:"after"},source:{primary:"\uC5D0\uC11C",alternatives:["\uBD80\uD130"],position:"after"},style:{primary:"\uB85C",alternatives:["\uC73C\uB85C"],position:"after"},event:{primary:"\uC744",alternatives:["\uB97C"],position:"after"}},keywords:{toggle:{primary:"\uD1A0\uAE00",normalized:"toggle"},add:{primary:"\uCD94\uAC00",normalized:"add"},remove:{primary:"\uC81C\uAC70",alternatives:["\uC0AD\uC81C"],normalized:"remove"},put:{primary:"\uB123\uB2E4",alternatives:["\uB123\uAE30","\uB193\uAE30","\uB123\uC73C\uC138\uC694"],normalized:"put"},append:{primary:"\uB367\uBD99\uC774\uB2E4",alternatives:["\uB05D\uC5D0\uCD94\uAC00"],normalized:"append"},prepend:{primary:"\uC55E\uC5D0\uCD94\uAC00",alternatives:["\uC120\uB450\uCD94\uAC00"],normalized:"prepend"},take:{primary:"\uAC00\uC838\uC624\uB2E4",alternatives:["\uAC00\uC838\uC624\uC138\uC694"],normalized:"take"},make:{primary:"\uB9CC\uB4E4\uB2E4",normalized:"make"},clone:{primary:"\uBCF5\uC81C",normalized:"clone"},swap:{primary:"\uAD50\uD658",alternatives:["\uBC14\uAFB8\uB2E4"],normalized:"swap"},morph:{primary:"\uBCC0\uD615",alternatives:["\uBCC0\uD658"],normalized:"morph"},set:{primary:"\uC124\uC815",normalized:"set"},get:{primary:"\uC5BB\uB2E4",alternatives:["\uC5BB\uC73C\uC138\uC694"],normalized:"get"},increment:{primary:"\uC99D\uAC00",normalized:"increment"},decrement:{primary:"\uAC10\uC18C",normalized:"decrement"},log:{primary:"\uB85C\uADF8",normalized:"log"},show:{primary:"\uBCF4\uC774\uB2E4",alternatives:["\uD45C\uC2DC","\uBCF4\uC774\uAE30","\uBCF4\uC774\uC138\uC694"],normalized:"show"},hide:{primary:"\uC228\uAE30\uB2E4",alternatives:["\uC228\uAE30\uAE30","\uC228\uAE30\uC138\uC694"],normalized:"hide"},transition:{primary:"\uD2B8\uB79C\uC9C0\uC158",alternatives:["\uC804\uD658"],normalized:"transition"},on:{primary:"\uC5D0",alternatives:["\uC2DC","\uD560 \uB54C"],normalized:"on"},trigger:{primary:"\uD2B8\uB9AC\uAC70",normalized:"trigger"},send:{primary:"\uBCF4\uB0B4\uB2E4",alternatives:["\uBCF4\uB0B4\uC138\uC694"],normalized:"send"},focus:{primary:"\uD3EC\uCEE4\uC2A4",normalized:"focus"},blur:{primary:"\uD3EC\uCEE4\uC2A4\uC544\uC6C3",alternatives:["\uBE14\uB7EC"],normalized:"blur"},empty:{primary:"\uBE44\uC6B0\uAE30",alternatives:["\uBE44\uC5B4\uC788\uB294"],normalized:"empty"},open:{primary:"\uC5F4\uAE30",normalized:"open"},close:{primary:"\uB2EB\uAE30",normalized:"close"},select:{primary:"\uACE0\uB974\uAE30",normalized:"select"},clear:{primary:"\uC9C0\uC6B0\uAE30",normalized:"clear"},reset:{primary:"\uC7AC\uC124\uC815",normalized:"reset"},breakpoint:{primary:"\uC911\uB2E8\uC810",normalized:"breakpoint"},click:{primary:"\uD074\uB9AD",normalized:"click"},hover:{primary:"\uD638\uBC84",normalized:"hover"},submit:{primary:"\uC81C\uCD9C",normalized:"submit"},input:{primary:"\uC785\uB825",normalized:"input"},change:{primary:"\uBCC0\uACBD",normalized:"change"},go:{primary:"\uC774\uB3D9",normalized:"go"},scroll:{primary:"\uC2A4\uD06C\uB864",normalized:"scroll"},push:{primary:"\uD478\uC2DC",normalized:"push"},replace:{primary:"\uAD50\uCCB4",alternatives:["\uBC14\uAFB8\uAE30"],normalized:"replace"},process:{primary:"\uCC98\uB9AC",normalized:"process"},wait:{primary:"\uB300\uAE30",normalized:"wait"},fetch:{primary:"\uD328\uCE58",alternatives:["\uAC00\uC838\uC624\uAE30"],normalized:"fetch"},settle:{primary:"\uC548\uC815",normalized:"settle"},if:{primary:"\uB9CC\uC57D",normalized:"if"},when:{primary:"\uB54C",normalized:"when"},changes:{primary:"\uBCC0\uACBD\uB418\uBA74",normalized:"changes"},where:{primary:"\uC5B4\uB514",normalized:"where"},else:{primary:"\uC544\uB2C8\uBA74",normalized:"else"},unless:{primary:"\uC544\uB2C8\uB77C\uBA74",normalized:"unless"},repeat:{primary:"\uBC18\uBCF5",normalized:"repeat"},for:{primary:"\uAC01\uAC01",normalized:"for"},while:{primary:"\uB3D9\uC548",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\uACC4\uC18D",normalized:"continue"},halt:{primary:"\uC815\uC9C0",normalized:"halt"},throw:{primary:"\uB358\uC9C0\uB2E4",normalized:"throw"},call:{primary:"\uD638\uCD9C",normalized:"call"},return:{primary:"\uBC18\uD658",normalized:"return"},then:{primary:"\uADF8\uB2E4\uC74C",alternatives:["\uADF8\uB7F0\uD6C4"],normalized:"then"},and:{primary:"\uADF8\uB9AC\uACE0",alternatives:["\uB610\uD55C","\uBC0F"],normalized:"and"},matches:{primary:"\uC77C\uCE58",normalized:"matches"},exists:{primary:"\uC874\uC7AC",normalized:"exists"},no:{primary:"\uC5C6\uC74C",normalized:"no"},end:{primary:"\uB05D",alternatives:["\uB9C8\uCE68"],normalized:"end"},js:{primary:"JS\uC2E4\uD589",alternatives:["js"],normalized:"js"},async:{primary:"\uBE44\uB3D9\uAE30",normalized:"async"},tell:{primary:"\uB9D0\uD558\uB2E4",normalized:"tell"},default:{primary:"\uAE30\uBCF8\uAC12",normalized:"default"},init:{primary:"\uCD08\uAE30\uD654",normalized:"init"},behavior:{primary:"\uB3D9\uC791",normalized:"behavior"},install:{primary:"\uC124\uCE58",normalized:"install"},measure:{primary:"\uCE21\uC815",normalized:"measure"},beep:{primary:"\uBE44\uD504",normalized:"beep"},break:{primary:"\uC911\uB2E8",normalized:"break"},copy:{primary:"\uBCF5\uC0AC",normalized:"copy"},exit:{primary:"\uB098\uAC00\uAE30",normalized:"exit"},pick:{primary:"\uC120\uD0DD",normalized:"pick"},render:{primary:"\uB80C\uB354\uB9C1",normalized:"render"},into:{primary:"\uC73C\uB85C",normalized:"into"},before:{primary:"\uC804\uC5D0",normalized:"before"},after:{primary:"\uD6C4\uC5D0",normalized:"after"},until:{primary:"\uAE4C\uC9C0",normalized:"until"},event:{primary:"\uC774\uBCA4\uD2B8",normalized:"event"},from:{primary:"\uC5D0\uC11C",normalized:"from"},connect:{primary:"\uC5F0\uACB0",alternatives:["\uC811\uC18D"],normalized:"connect"},stream:{primary:"\uC2A4\uD2B8\uB9BC",alternatives:["\uC2A4\uD2B8\uB9AC\uBC0D"],normalized:"stream"},live:{primary:"\uC2E4\uC2DC\uAC04",alternatives:["\uB77C\uC774\uBE0C"],normalized:"live"},socket:{primary:"\uC18C\uCF13",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\uBC14\uC778\uB4DC",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\uAC00\uB85C\uCC44\uAE30",alternatives:["\uC778\uD130\uC149\uD2B8","intercept"],normalized:"intercept"},worker:{primary:"\uC6CC\uCEE4",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\uC774\uBCA4\uD2B8\uC18C\uC2A4"],normalized:"eventsource"}},tokenization:{particles:["\uC744","\uB97C","\uC774","\uAC00","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uC73C\uB85C","\uB85C","\uC640","\uACFC","\uB3C4"],boundaryStrategy:"space"},eventHandler:{eventMarker:{primary:"\uD560 \uB54C",alternatives:["\uD560\uB54C","\uB54C","\uC5D0"],position:"after"},temporalMarkers:["\uD560 \uB54C","\uD560\uB54C","\uB54C"]}},tl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],il=class{constructor(t=tl){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}},nl="()[]{},:;",al=class{constructor(t=nl){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 Wr(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function gi(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Wr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Wr(t,e+n[0].length);return t.slice(e,a)}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,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Wr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var ol=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?gi(t,e)!==null:false}extract(t,e){let r=gi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},ul=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],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},sl=["http://","https://","//","./","../","/"];function ll(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function cl(t,e){let r=t.slice(e),i=sl.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=ll(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var ml=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=cl(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},dl=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 pl(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function fl(t){let e=t.charCodeAt(0);return e>=4352&&e<=4607||e>=12592&&e<=12687}function Kr(t){return pl(t)||fl(t)}var yl=["\uD560\uB54C","\uD558\uBA74","\uD558\uB2C8\uAE4C","\uD560 \uB54C"],hl=class{constructor(){this.name="korean-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Kr(t[e])}extract(t,e){if(!this.context)throw new Error("KoreanKeywordExtractor: context not set");let r=e,i=6;for(let m=Math.min(i,t.length-r);m>=2;m--){let d=t.slice(r,r+m),p=true;for(let v=0;v<d.length;v++)if(!Kr(d[v])){p=false;break}if(!p)continue;let f=this.context.lookupKeyword(d);if(f)return {value:d,length:m,metadata:{normalized:f.normalized!==f.native?f.normalized:void 0}};if(this.context.normalizer){let v=this.context.normalizer.normalize(d);if(v.stem!==d&&v.confidence>=.7){let E=this.context.lookupKeyword(v.stem);if(E)return {value:d,length:m,metadata:{normalized:E.normalized,stem:v.stem,stemConfidence:v.confidence}}}}}let n="",a=e;for(;a<t.length&&Kr(t[a])&&!(n.length>0&&this.context.isKeywordStart(t,a));)n+=t[a],a++;if(!n)return null;for(let m of yl)if(n.endsWith(m)&&n.length>m.length){let d=n.slice(0,-m.length),p=this.context.lookupKeyword(d);if(p)return {value:d,length:d.length,metadata:{normalized:p.normalized,hasSuffix:true,suffix:m,stem:d}}}let o=this.context.lookupKeyword(n),u=o&&o.normalized!==o.native?o.normalized:void 0;n.includes("\uD1A0\uAE00")&&(console.log(`[KO DEBUG] word="${n}"`),console.log(`[KO DEBUG] keywordEntry=${o?"FOUND":"NOT FOUND"}`),console.log(`[KO DEBUG] normalizer=${this.context.normalizer?"EXISTS":"MISSING"}`));let s,l,c;if(!o&&this.context.normalizer){let m=this.context.normalizer.normalize(n);if(m.stem!==n&&m.confidence>=.7){let d=this.context.lookupKeyword(m.stem);d&&(s=d.normalized,l=m.stem,c=m.confidence,n.includes("\uD1A0\uAE00")&&console.log(`[KO DEBUG] word="${n}", stem="${m.stem}", normalized="${s}"`));}}return {value:n,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:c}}}},Ci=new Map([["\uC774",{role:"agent",confidence:.85,variant:"consonant",description:"subject marker (after consonant)"}],["\uAC00",{role:"agent",confidence:.85,variant:"vowel",description:"subject marker (after vowel)"}],["\uC744",{role:"patient",confidence:.95,variant:"consonant",description:"object marker (after consonant)"}],["\uB97C",{role:"patient",confidence:.95,variant:"vowel",description:"object marker (after vowel)"}],["\uC740",{role:"agent",confidence:.75,variant:"consonant",description:"topic marker (after consonant)"}],["\uB294",{role:"agent",confidence:.75,variant:"vowel",description:"topic marker (after vowel)"}],["\uC5D0",{role:"destination",confidence:.85,description:"at/to marker"}],["\uB85C",{role:"destination",confidence:.85,variant:"vowel",description:"to/by means (after vowel or \u3139)"}],["\uC640",{role:"style",confidence:.7,variant:"vowel",description:"and/with (after vowel)"}],["\uACFC",{role:"style",confidence:.7,variant:"consonant",description:"and/with (after consonant)"}],["\uC758",{role:"patient",confidence:.6,description:"possessive marker"}],["\uB3C4",{role:"patient",confidence:.65,description:"also/too marker"}],["\uB9CC",{role:"patient",confidence:.65,description:"only marker"}]]),zi=new Map([["\uC5D0\uC11C",{role:"source",confidence:.8,description:"at/from marker (action location)"}],["\uC73C\uB85C",{role:"destination",confidence:.85,variant:"consonant",description:"to/by means (after consonant)"}],["\uBD80\uD130",{role:"source",confidence:.9,description:"from/since marker"}],["\uAE4C\uC9C0",{role:"destination",confidence:.75,description:"until/to marker"}],["\uCC98\uB7FC",{role:"manner",confidence:.8,description:"like/as marker"}],["\uBCF4\uB2E4",{role:"source",confidence:.75,description:"than marker"}]]);function ki(t){if(!t)return false;let e=t.codePointAt(0);return e>=44032&&e<=55203}var vl=class{constructor(){this.name="korean-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){let r=t[e];if(Ci.has(r)&&!ki(t[e+1]))return true;for(let[i]of zi)if(t.startsWith(i,e))return true;return false}extract(t,e){for(let[n,a]of zi)if(t.startsWith(n,e))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleVariant:a.variant}};let r=t[e],i=Ci.get(r);return i&&!ki(t[e+1])?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleVariant:i.variant}}:null}};function El(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function gl(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Cl=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return El(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&gl(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function zl(){return [new ml,new ul,new dl,new ol]}var kl=new Set(["\uC774","\uAC00","\uC744","\uB97C","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uB85C","\uC73C\uB85C","\uC640","\uACFC","\uC758","\uB3C4","\uB9CC","\uBD80\uD130","\uAE4C\uC9C0","\uCC98\uB7FC","\uBCF4\uB2E4"]),wl=[{native:"\uCC38",normalized:"true"},{native:"\uAC70\uC9D3",normalized:"false"},{native:"\uB110",normalized:"null"},{native:"\uBBF8\uC815\uC758",normalized:"undefined"},{native:"\uC815\uC758\uC548\uB428",normalized:"undefined"},{native:"\uCCAB\uBC88\uC9F8",normalized:"first"},{native:"\uB9C8\uC9C0\uB9C9",normalized:"last"},{native:"\uB2E4\uC74C",normalized:"next"},{native:"\uC774\uC804",normalized:"previous"},{native:"\uAC00\uC7A5\uAC00\uAE4C\uC6B4",normalized:"closest"},{native:"\uBD80\uBAA8",normalized:"parent"},{native:"\uC548\uC5D0",normalized:"in"},{native:"\uD074\uB9AD",normalized:"click"},{native:"\uB354\uBE14\uD074\uB9AD",normalized:"dblclick"},{native:"\uBCC0\uACBD",normalized:"change"},{native:"\uC81C\uCD9C",normalized:"submit"},{native:"\uC785\uB825",normalized:"input"},{native:"\uB85C\uB4DC",normalized:"load"},{native:"\uC2A4\uD06C\uB864",normalized:"scroll"},{native:"\uD0A4\uB2E4\uC6B4",normalized:"keydown"},{native:"\uD0A4\uC5C5",normalized:"keyup"},{native:"\uB9C8\uC6B0\uC2A4\uC624\uBC84",normalized:"mouseover"},{native:"\uB9C8\uC6B0\uC2A4\uC544\uC6C3",normalized:"mouseout"},{native:"\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4",normalized:"mousedown"},{native:"\uB9C8\uC6B0\uC2A4\uC5C5",normalized:"mouseup"},{native:"\uB0B4",normalized:"my"},{native:"\uADF8\uAC83\uC758",normalized:"its"},{native:"\uADF8\uB2E4\uC74C",normalized:"then"},{native:"\uADF8\uB7F0\uD6C4",normalized:"then"},{native:"\uADF8\uB7EC\uBA74",normalized:"then"},{native:"\uADF8\uB9AC\uACE0",normalized:"and"},{native:"\uB610\uB294",normalized:"or"},{native:"\uC544\uB2C8",normalized:"not"},{native:"\uC774\uB2E4",normalized:"is"},{native:"\uCD08",normalized:"s"},{native:"\uBC00\uB9AC\uCD08",normalized:"ms"},{native:"\uBD84",normalized:"m"},{native:"\uC2DC\uAC04",normalized:"h"},{native:"\uD3EC\uD568",normalized:"inclusive"},{native:"\uC81C\uC678",normalized:"exclusive"},{native:"\uBB38\uC790",normalized:"characters"},{native:"\uBB34\uC791\uC704",normalized:"random"}],bl=class extends Fe{constructor(){super(),this.language="ko",this.direction="ltr",this.initializeKeywordsFromProfile(bi,wl),this.normalizer=new wi,this.registerExtractors(zl()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new Cl),this.registerExtractor(new vl),this.registerExtractor(new hl),this.registerExtractor(new il),this.registerExtractor(new al);}classifyToken(t){return kl.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":"identifier"}},Al=new bl;Ie("ko",Al,bi);var Si={code:"zh",name:"Chinese",nativeName:"\u4E2D\u6587",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,verb:{position:"second",subjectDrop:true},references:{me:"\u6211",it:"\u5B83",you:"\u4F60",result:"\u7ED3\u679C",event:"\u4E8B\u4EF6",target:"\u76EE\u6807",body:"\u4E3B\u4F53",document:"\u6587\u6863",window:"\u7A97\u53E3",detail:"\u8BE6\u60C5"},possessive:{marker:"\u7684",markerPosition:"between",keywords:{\u6211\u7684:"me",\u4F60\u7684:"you",\u5B83\u7684:"it",\u4ED6\u7684:"it",\u5979\u7684:"it"}},roleMarkers:{destination:{primary:"\u5728",alternatives:["\u5230","\u4E8E"],position:"before"},source:{primary:"\u4ECE",alternatives:["\u7531"],position:"before"},patient:{primary:"\u628A",position:"before"},style:{primary:"\u7528",alternatives:["\u4EE5"],position:"before"}},keywords:{toggle:{primary:"\u5207\u6362",normalized:"toggle"},add:{primary:"\u6DFB\u52A0",alternatives:["\u52A0"],normalized:"add"},remove:{primary:"\u79FB\u9664",alternatives:["\u5220\u9664","\u53BB\u6389"],normalized:"remove"},put:{primary:"\u653E\u7F6E",alternatives:["\u653E","\u653E\u5165"],normalized:"put"},append:{primary:"\u8FFD\u52A0",alternatives:["\u9644\u52A0"],normalized:"append"},prepend:{primary:"\u524D\u7F6E",alternatives:["\u9884\u7F6E"],normalized:"prepend"},take:{primary:"\u62FF\u53D6",normalized:"take"},make:{primary:"\u5236\u4F5C",normalized:"make"},clone:{primary:"\u514B\u9686",normalized:"clone"},swap:{primary:"\u4EA4\u6362",normalized:"swap"},morph:{primary:"\u53D8\u5F62",alternatives:["\u8F6C\u6362"],normalized:"morph"},set:{primary:"\u8BBE\u7F6E",alternatives:["\u8BBE\u5B9A"],normalized:"set"},get:{primary:"\u83B7\u53D6",alternatives:["\u83B7\u5F97","\u53D6\u5F97"],normalized:"get"},increment:{primary:"\u589E\u52A0",normalized:"increment"},decrement:{primary:"\u51CF\u5C11",normalized:"decrement"},log:{primary:"\u65E5\u5FD7",normalized:"log"},show:{primary:"\u663E\u793A",alternatives:["\u5C55\u793A"],normalized:"show"},hide:{primary:"\u9690\u85CF",normalized:"hide"},transition:{primary:"\u8FC7\u6E21",normalized:"transition"},on:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},trigger:{primary:"\u89E6\u53D1",normalized:"trigger"},send:{primary:"\u53D1\u9001",normalized:"send"},focus:{primary:"\u805A\u7126",alternatives:["\u53D6\u5F97\u7126\u9EDE"],normalized:"focus"},blur:{primary:"\u5931\u7126",alternatives:["\u5931\u53BB\u7126\u9EDE"],normalized:"blur"},empty:{primary:"\u6E05\u7A7A",alternatives:["\u7A7A\u7684"],normalized:"empty"},open:{primary:"\u6253\u5F00",normalized:"open"},close:{primary:"\u5173\u95ED",normalized:"close"},select:{primary:"\u9009\u62E9",normalized:"select"},clear:{primary:"\u6E05\u9664",normalized:"clear"},reset:{primary:"\u91CD\u7F6E",normalized:"reset"},breakpoint:{primary:"\u65AD\u70B9",normalized:"breakpoint"},click:{primary:"\u70B9\u51FB",normalized:"click"},hover:{primary:"\u60AC\u505C",alternatives:["\u60AC\u6D6E"],normalized:"hover"},submit:{primary:"\u63D0\u4EA4",alternatives:["\u9001\u51FA"],normalized:"submit"},input:{primary:"\u8F93\u5165",normalized:"input"},change:{primary:"\u53D8\u5316",alternatives:["\u6539\u53D8"],normalized:"change"},go:{primary:"\u524D\u5F80",normalized:"go"},scroll:{primary:"\u6EDA\u52A8",alternatives:["\u6372\u52D5"],normalized:"scroll"},push:{primary:"\u63A8\u9001",normalized:"push"},replace:{primary:"\u66FF\u6362",normalized:"replace"},process:{primary:"\u5904\u7406",normalized:"process"},wait:{primary:"\u7B49\u5F85",normalized:"wait"},fetch:{primary:"\u6293\u53D6",normalized:"fetch"},settle:{primary:"\u7A33\u5B9A",normalized:"settle"},if:{primary:"\u5982\u679C",normalized:"if"},unless:{primary:"\u9664\u975E",normalized:"unless"},when:{primary:"\u4F55\u65F6",normalized:"when"},changes:{primary:"\u6539\u53D8\u65F6",normalized:"changes"},where:{primary:"\u54EA\u91CC",normalized:"where"},else:{primary:"\u5426\u5219",normalized:"else"},matches:{primary:"\u5339\u914D",normalized:"matches"},repeat:{primary:"\u91CD\u590D",normalized:"repeat"},forever:{primary:"forever",normalized:"forever"},for:{primary:"\u4E3A",normalized:"for"},while:{primary:"\u6301\u7EED",normalized:"while"},continue:{primary:"\u7EE7\u7EED",normalized:"continue"},halt:{primary:"\u505C\u6B62",normalized:"halt"},throw:{primary:"\u629B\u51FA",normalized:"throw"},call:{primary:"\u8C03\u7528",normalized:"call"},return:{primary:"\u8FD4\u56DE",normalized:"return"},then:{primary:"\u7136\u540E",alternatives:["\u63A5\u7740","\u90A3\u4E48"],normalized:"then"},and:{primary:"\u5E76\u4E14",alternatives:["\u548C","\u800C\u4E14"],normalized:"and"},exists:{primary:"\u5B58\u5728",normalized:"exists"},end:{primary:"\u7ED3\u675F",alternatives:["\u7EC8\u6B62","\u5B8C"],normalized:"end"},js:{primary:"JS\u6267\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u5F02\u6B65",normalized:"async"},tell:{primary:"\u544A\u8BC9",normalized:"tell"},default:{primary:"\u9ED8\u8BA4",normalized:"default"},init:{primary:"\u521D\u59CB\u5316",normalized:"init"},behavior:{primary:"\u884C\u4E3A",normalized:"behavior"},install:{primary:"\u5B89\u88C5",normalized:"install"},measure:{primary:"\u6D4B\u91CF",normalized:"measure"},beep:{primary:"\u8702\u9E23",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u590D\u5236",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9009\u53D6",normalized:"pick"},render:{primary:"\u6E32\u67D3",normalized:"render"},into:{primary:"\u8FDB\u5165",normalized:"into"},before:{primary:"\u4E4B\u524D",normalized:"before"},after:{primary:"\u4E4B\u540E",normalized:"after"},until:{primary:"\u76F4\u5230",normalized:"until"},event:{primary:"\u4E8B\u4EF6",normalized:"event"},from:{primary:"\u4ECE",normalized:"from"},connect:{primary:"\u8FDE\u63A5",alternatives:["\u8FDE\u63A5\u5668"],normalized:"connect"},stream:{primary:"\u6D41",alternatives:["\u6D41\u5F0F\u4F20\u8F93"],normalized:"stream"},live:{primary:"\u5B9E\u65F6",alternatives:["\u76F4\u64AD"],normalized:"live"},socket:{primary:"\u5957\u63A5\u5B57",alternatives:["websocket","socket"],normalized:"socket"},bind:{primary:"\u7ED1\u5B9A",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\u62E6\u622A",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"\u5DE5\u4F5C\u7EBF\u7A0B",alternatives:["\u5DE5\u4F5C\u8005","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u4E8B\u4EF6\u6E90"],normalized:"eventsource"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},sourceMarker:{primary:"\u4ECE",position:"before"},eventMarker:{primary:"\u5F53",alternatives:["\u5728"],position:"before"},temporalMarkers:["\u5F53","\u5728...\u65F6","\u4E00"]}},Dl=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Bl=class{constructor(t=Dl){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}},Sl="()[]{},:;",xl=class{constructor(t=Sl){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 Hr(t,e){let r=e;for(;r<t.length&&t[r]===":";){let i=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!i)break;let n=r+i[0].length;if(t[n]==="("){let a=0,o=n;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;n=o;}r=n;}return r}function Ai(t,e){let r=t[e];if(r==="#"){let i=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!i)return null;let n=Hr(t,e+i[0].length);return t.slice(e,n)}if(r==="."){let i=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(i)return i[0];let n=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!n)return null;let a=Hr(t,e+n[0].length);return t.slice(e,a)}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,n=e;for(;n<t.length;){if(t[n]==="["&&i++,t[n]==="]"&&(i--,i===0)){let a=Hr(t,n+1);return t.slice(e,a)}n++;}return null}if(r==="<"){let i=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return i?i[0]:null}return null}var Fl=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Ai(t,e)!==null:false}extract(t,e){let r=Ai(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},Tl=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],n=i.slice(1).split("(")[0],a=r[1];return {value:i,length:i.length,metadata:{modifierName:n,value:a?n==="queue"?a:parseInt(a,10):void 0}}}},Rl=["http://","https://","//","./","../","/"];function Ol(t,e){let r=1;for(let i=e;i<t.length;i++){let n=t[i];if(n==="{")r++;else if(n==="}"&&--r===0)return i+1}return -1}function Ll(t,e){let r=t.slice(e),i=Rl.find(a=>r.startsWith(a));if(!i)return null;let n=i.length;for(;n<r.length;){let a=r[n];if(a==="$"&&r[n+1]==="{"){let o=Ol(r,n+2);if(o!==-1){n=o;continue}}if(/\s/.test(a))break;n++;}return r.slice(0,n)}var Pl=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=Ll(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Nl=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 Ur(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=63744&&e<=64255||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=194560&&e<=195103}var Ml=class{constructor(){this.name="chinese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Ur(t[e])}extract(t,e){if(!this.context)throw new Error("ChineseKeywordExtractor: context not set");let r=e,i=null;if(this.context.isKeywordStart(t,e))for(let o=10;o>=1;o--){let u=t.slice(e,e+o);if([...u].every(s=>Ur(s))){let s=this.context.lookupKeyword(u);if(s){i={word:u,entry:s};break}}}if(i)return {value:i.word,length:i.word.length,metadata:{normalized:i.entry.normalized}};let n="",a=e;for(;a<t.length&&Ur(t[a])&&(n+=t[a],a++,!(a<t.length&&this.context.isKeywordStart(t,a))););return n?{value:n,length:a-r,metadata:{}}:null}},Di=new Map([["\u628A",{role:"patient",confidence:.95,description:"ba-construction object marker"}],["\u5728",{role:"location",confidence:.85,description:"at/in/on location marker"}],["\u4ECE",{role:"source",confidence:.9,description:"from marker"}],["\u5230",{role:"destination",confidence:.9,description:"to/until marker"}],["\u5411",{role:"destination",confidence:.85,description:"towards marker"}],["\u7ED9",{role:"destination",confidence:.85,description:"to/for recipient marker"}],["\u5BF9",{role:"destination",confidence:.8,description:"to/towards marker"}],["\u7528",{role:"instrument",confidence:.85,description:"with/using marker"}],["\u88AB",{role:"agent",confidence:.8,description:"by (passive) marker"}],["\u8BA9",{role:"agent",confidence:.75,description:"let/make causative marker"}],["\u7684",{role:"possessive",confidence:.9,description:"possessive/attributive marker"}],["\u5730",{role:"manner",confidence:.85,description:"adverbial marker"}],["\u5F97",{role:"manner",confidence:.8,description:"complement marker"}],["\u4E86",{role:"aspect",confidence:.7,description:"completion aspect marker"}],["\u7740",{role:"aspect",confidence:.7,description:"progressive aspect marker"}],["\u8FC7",{role:"aspect",confidence:.7,description:"experiential aspect marker"}],["\u5417",{role:"mood",confidence:.75,description:"question particle"}],["\u5462",{role:"mood",confidence:.7,description:"question/emphasis particle"}],["\u5427",{role:"mood",confidence:.7,description:"suggestion particle"}]]),Bi=new Map([["\u7136\u540E",{role:"sequence",confidence:.9,description:"then/afterwards"}],["\u63A5\u7740",{role:"sequence",confidence:.85,description:"next/following"}],["\u5E76\u4E14",{role:"conjunction",confidence:.85,description:"and/moreover"}],["\u6216\u8005",{role:"conjunction",confidence:.85,description:"or"}],["\u5982\u679C",{role:"condition",confidence:.9,description:"if"}],["\u90A3\u4E48",{role:"consequence",confidence:.85,description:"then"}],["\u5426\u5219",{role:"alternative",confidence:.85,description:"otherwise"}]]),_l=class{constructor(){this.name="chinese-particle";}setContext(t){this._context=t;}longerKeywordAt(t,e,r){let i=this._context;if(!i)return false;let n=Math.min(10,t.length-e);for(let a=n;a>r;a--)if(i.lookupKeyword(t.slice(e,e+a)))return true;return false}canExtract(t,e){let r=t[e];if(Di.has(r)&&!this.longerKeywordAt(t,e,1))return true;for(let[i]of Bi)if(t.startsWith(i,e)&&!this.longerKeywordAt(t,e,i.length))return true;return false}extract(t,e){for(let[n,a]of Bi)if(t.startsWith(n,e)&&!this.longerKeywordAt(t,e,n.length))return {value:n,length:n.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleDescription:a.description}};let r=t[e],i=Di.get(r);return i&&!this.longerKeywordAt(t,e,1)?{value:r,length:1,metadata:{particleRole:i.role,particleConfidence:i.confidence,particleDescription:i.description}}:null}};function Il(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function jl(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var $l=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Il(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,i="",n=e;for(;n<t.length&&jl(t[n]);)i+=t[n],n++;if(!i)return null;let a=this.context.lookupKeyword(i),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:i,length:n-r,metadata:{normalized:o}}}};function Vl(){return [new Pl,new Tl,new Nl,new Fl]}var ql=new Set(["\u628A","\u5728","\u4ECE","\u5230","\u5411","\u7ED9","\u5BF9","\u7528","\u88AB","\u8BA9","\u7684","\u5730","\u5F97","\u4E86","\u7740","\u8FC7","\u5417","\u5462","\u5427"]),Wl=[{native:"\u771F",normalized:"true"},{native:"\u5047",normalized:"false"},{native:"\u7A7A",normalized:"null"},{native:"\u672A\u5B9A\u4E49",normalized:"undefined"},{native:"\u7B2C\u4E00\u4E2A",normalized:"first"},{native:"\u9996\u4E2A",normalized:"first"},{native:"\u6700\u540E\u4E00\u4E2A",normalized:"last"},{native:"\u672B\u4E2A",normalized:"last"},{native:"\u4E0B\u4E00\u4E2A",normalized:"next"},{native:"\u4E0A\u4E00\u4E2A",normalized:"previous"},{native:"\u6700\u8FD1\u7684",normalized:"closest"},{native:"\u7236\u7EA7",normalized:"parent"},{native:"\u70B9\u51FB",normalized:"click"},{native:"\u53CC\u51FB",normalized:"dblclick"},{native:"\u8F93\u5165",normalized:"input"},{native:"\u53D8\u66F4",normalized:"change"},{native:"\u6539\u53D8",normalized:"change"},{native:"\u63D0\u4EA4",normalized:"submit"},{native:"\u6309\u952E",normalized:"keydown"},{native:"\u91CA\u653E\u952E",normalized:"keyup"},{native:"\u9F20\u6807\u79FB\u5165",normalized:"mouseover"},{native:"\u9F20\u6807\u79FB\u51FA",normalized:"mouseout"},{native:"\u83B7\u5F97\u7126\u70B9",normalized:"focus"},{native:"\u5931\u53BB\u7126\u70B9",normalized:"blur"},{native:"\u52A0\u8F7D",normalized:"load"},{native:"\u6EDA\u52A8",normalized:"scroll"},{native:"\u6211\u7684",normalized:"my"},{native:"\u5B83\u7684",normalized:"its"},{native:"\u79D2",normalized:"s"},{native:"\u6BEB\u79D2",normalized:"ms"},{native:"\u5206\u949F",normalized:"m"},{native:"\u5C0F\u65F6",normalized:"h"},{native:"\u548C",normalized:"and"},{native:"\u6216\u8005",normalized:"or"},{native:"\u6216",normalized:"or"},{native:"\u4E0D",normalized:"not"},{native:"\u975E",normalized:"not"},{native:"\u662F",normalized:"is"},{native:"\u82E5",normalized:"if"},{native:"\u4E0D\u7136",normalized:"else"},{native:"\u5FAA\u73AF",normalized:"repeat"},{native:"\u904D\u5386",normalized:"for"},{native:"\u6BCF\u4E2A",normalized:"for"},{native:"\u4E3A\u6BCF",normalized:"for"},{native:"\u4E2D\u6B62",normalized:"halt"},{native:"\u629B",normalized:"throw"},{native:"\u547C\u53EB",normalized:"call"},{native:"\u56DE",normalized:"return"},{native:"\u811A\u672C",normalized:"js"},{native:"\u901A\u77E5",normalized:"tell"},{native:"\u7F3A\u7701",normalized:"default"},{native:"\u521D\u59CB",normalized:"init"},{native:"\u52A8\u4F5C",normalized:"behavior"},{native:"\u6FC0\u53D1",normalized:"trigger"},{native:"\u5BF9\u7126",normalized:"focus"},{native:"\u6A21\u7CCA",normalized:"blur"},{native:"\u8DF3\u8F6C",normalized:"go"},{native:"\u5BFC\u822A",normalized:"go"},{native:"\u6293\u53D6",normalized:"fetch"},{native:"\u83B7\u53D6\u6570\u636E",normalized:"fetch"},{native:"\u5B89\u5B9A",normalized:"settle"},{native:"\u62FF\u53D6",normalized:"take"},{native:"\u53D6",normalized:"take"},{native:"\u521B\u5EFA",normalized:"make"},{native:"\u514B\u9686",normalized:"clone"},{native:"\u8BB0\u5F55",normalized:"log"},{native:"\u6253\u5370",normalized:"log"},{native:"\u52A8\u753B",normalized:"transition"},{native:"\u5230\u91CC\u9762",normalized:"into"},{native:"\u91CC",normalized:"into"},{native:"\u524D",normalized:"before"},{native:"\u540E",normalized:"after"},{native:"\u90A3\u4E48",normalized:"then"},{native:"\u5B8C",normalized:"end"},{native:"\u4F5C\u4E3A",normalized:"as"},{native:"\u5305\u542B",normalized:"inclusive"},{native:"\u6392\u9664",normalized:"exclusive"},{native:"\u5B57\u7B26",normalized:"characters"},{native:"\u968F\u673A",normalized:"random"}],Kl=class extends Fe{constructor(){super(),this.language="zh",this.direction="ltr",this.initializeKeywordsFromProfile(Si,Wl),this.registerExtractors(Vl()),this.registerExtractor(new Se),this.registerExtractor(new xe),this.registerExtractor(new $l),this.registerExtractor(new _l),this.registerExtractor(new Ml),this.registerExtractor(new Bl),this.registerExtractor(new xl);}classifyToken(t){return ql.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("'")||t.startsWith("\u201C")||t.startsWith("\u2018")||/^\d/.test(t)?"literal":"identifier"}},Hl=new Kl;Ie("zh",Hl,Si);function fr(t){let e=t.getAttribute("data-lang");if(e)return pr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return pr(r);let i=t.closest?.("[lang]")?.getAttribute("lang");if(i)return pr(i);let n=typeof document<"u"?document.documentElement?.lang:null;return n&&n!=="en"?pr(n):null}function pr(t){return t.split("-")[0].toLowerCase()}var xi={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],intercept:[],js:[["patient",""]],live:[],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["patient",""],["destination","to"],["manner","using view"]],on:[["event",""],["source","from"]],open:[["patient",""],["style","as"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"],["manner","using view"]],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"],["manner","using view"]],take:[["patient",""],["source","from"],["recipient","for"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"],["duration","for"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],when:[["condition",""]],while:[["condition",""]],worker:[]};var Ul=new Set(["repeat","for","while","tell"]),Gl=new Set(["js"]);function yr(t){switch(t.kind){case "event-handler":return Yl(t);case "compound":return Zl(t);default:return Jl(t)}}function Yl(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):er(r));let i=t.roles.get("source");if(i&&e.push("from",er(i)),t.body&&t.body.length>0){let n=t.body.map(yr);e.push(n.join(" "));}return e.join(" ")}function Zl(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(yr),i=r[0]??"";for(let n=1;n<r.length;n++){let a=t.statements[n-1],o=t.statements[n],u=a.kind==="command"&&Ul.has(a.action),s=a.kind==="command"&&a.action==="bind"&&o.kind==="command"&&o.action==="bind";a.kind==="command"&&Gl.has(a.action)&&(i+=" end"),i+=(u||s?" ":` ${e} `)+r[n];}return i}function Jl(t){let e=xi[t.action];if(e){let i=[t.action];for(let[n,a]of e){let o=t.roles.get(n);o&&((n==="destination"||n==="source")&&o.type==="reference"&&o.value==="me"||(a&&i.push(a),i.push(er(o))));}return i.join(" ")}let r=[t.action];for(let[,i]of t.roles)r.push(er(i));return r.join(" ")}function er(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 Xl(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function Xl(t){let e=er(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 Ql={confidenceThreshold:.5,strategy:"semantic"};function ec(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var rc=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function tc(t){let e=t.match(rc);if(!e)return null;let r=e[1],i=t.slice(r.length);return i?{prefix:r,commands:i}:null}function Fi(t){function e(n,a,o){try{return t.isLanguageRegistered(a)?t.translateSingle(n,a,o):null}catch{return null}}function r(n,a,o){try{let u=o(n,a);return u!==n?u:null}catch{return null}}function i(n,a,o){if(o.strategy==="semantic"||o.strategy==="auto"){let u=ec(o.confidenceThreshold,a),s=e(n,a,u);if(s!==null)return s}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let u=r(n,a,o.i18nToEnglish);if(u!==null)return u}return null}return function(a,o,u={}){if(o==="en")return a;let s={...Ql,...u},l=i(a,o,s);if(l!==null)return l;let c=tc(a);if(c){let m=i(c.commands,o,s);if(m!==null)return c.prefix+m}return a}}var Gr=Fi({isLanguageRegistered:Pt,translateSingle(t,e,r){let i=ti(t,e);return i.confidence<r||!i.node?null:yr(i.node)}});var Yr=new WeakSet;function ic(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function nc(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function Ti(t,e){if(typeof t.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let r=ic(t),i=[...r.map(a=>`[${a}]`),'script[type="text/hyperscript"]'].join(", "),n=a=>{if(Yr.has(a))return;if(a instanceof HTMLScriptElement&&a.type==="text/hyperscript"){let l=a.textContent??"";if(!l)return;let c=e(l,a);Yr.add(a),c!=null&&c!==l&&(a.textContent=c);return}let o=nc(a,r);if(!o)return;let u=a.getAttribute(o);if(!u)return;let s=e(u,a);Yr.add(a),s!=null&&s!==u&&a.setAttribute(o,s);};t.addBeforeProcessHook(a=>{!a||typeof a.querySelectorAll!="function"||(typeof a.matches=="function"&&a.matches(i)&&n(a),a.querySelectorAll(i).forEach(n));});}function Oi(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return !r?.errors||r.errors.length===0}catch{return false}}var Ri=new Set;function Li(t,e,r){Ri.has(t)||(Ri.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects \u2014 falling back to the original text. Source: "${e.length>60?e.slice(0,60)+"\u2026":e}" \u2192 "${r.length>60?r.slice(0,60)+"\u2026":r}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function Zr(t={}){return function(r){let i=r;Ti(i,(n,a)=>{let o=ac(a,t);if(!o||o==="en")return n;let u=Gr(n,o,t);if(u!==n){if(t.validateWithHost!==false&&!Oi(i,u))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${u}" \u2014 keeping "${n}"`):Li(o,n,u),n;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${n}" \u2192 "${u}"`);}return u});}}function ac(t,e){if(e.languageAttribute){let i=t.getAttribute(e.languageAttribute);if(i)return i.split("-")[0].toLowerCase()}let r=fr(t);return r||(e.defaultLanguage??null)}function Pi(t,e,r={}){return e==="en"?t:Gr(t,e,r)}Lt(t=>ci(t));function Ni(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Zr());}var gm=["ja","ko","zh"];Ni();
5
- exports.plugin=Zr;exports.preprocess=Pi;exports.resolveLanguage=fr;exports.supportedLanguages=gm;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function be(t,e){return e?{type:"literal",value:t,dataType:e}:{type:"literal",value:t}}function Fr(t,e){return e?{type:"selector",value:t,selectorKind:e}:{type:"selector",value:t}}function pr(t){return {type:"reference",value:t}}function Lr(t,e){return {type:"property-path",object:t,property:e}}var Ut=new Set(["me","you","it","result","event","target","body","document","window","detail"]);function it(t,e=Ut){return e.has(t)}var Da=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 n=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(t){case "debug":console.debug(`${i} ${n} DEBUG:`,e,...r);break;case "info":console.info(`${i} ${n} INFO:`,e,...r);break;case "warn":console.warn(`${i} ${n} WARN:`,e,...r);break;case "error":console.error(`${i} ${n} 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 Ba(t){return new Da(t)}function Ye(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 Sa(t,e){return t?.possessive?.keywords?.[e]}var yr=class Ze{constructor(){this.logger=Ba("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,n){let i=e.mark(),a=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",n?.code);}this.currentProfile=n,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,a);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(a.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let u=this.calculateConfidence(r,a);return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-i.position,confidence:u}}matchBest(e,r,n){let i=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,n);s&&i.push(s),e.reset(u);}if(i.length===0)return null;i.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let a=i[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,n,i){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let d=e.peek();if(this.logger.debug(" >> Current input token:",d?JSON.stringify({type:d.type,value:d.value,kind:d.kind}):"EOF"),c.type==="role"&&c.greedy){let v=this.collectStopMarkers(r,l+1);if(i)for(let E of i)v.add(E);let h=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,v))break;h.push(E.value),e.advance();}if(h.length>0){n.set(c.role,{type:"expression",raw:h.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let v=this.collectStopMarkers(r,l+1);if(i)for(let E of i)v.add(E);if(this.matchGroupToken(e,c,n,v)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let m=c.type==="role"&&c.optional===true,p=m?e.mark():null;if(c.type==="role"&&!m){let v=l+1<r.length?r[l+1]:null;if(v?.type==="literal"){let h=e.peek();if(h&&this.getMatchType(h,v.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),n.delete(s),u=null,s=null;let E=this.matchPatternToken(e,c,n);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let y=this.matchPatternToken(e,c,n);if(this.logger.debug(" >> Match result:",y),y){m?(u=p,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),n.delete(s),u=null,s=null;let v=this.matchPatternToken(e,c,n);if(this.logger.debug(" >> Backtrack retry result:",v),v)continue}return false}}return true}matchPatternToken(e,r,n){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,n);case "group":return this.matchGroupToken(e,r,n);default:return false}}matchLiteralToken(e,r){let n=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",n?JSON.stringify({type:n.type,value:n.value,kind:n.kind}):"null"),!n)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(n,r.value);if(this.logger.debug(" >>> matchType for",n.value,"vs",r.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(n,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,n){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 i=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null"),!i)return r.optional||false;let a=this.tryMatchPossessiveExpression(e);if(a)return r.expectedTypes&&r.expectedTypes.length>0&&!Ye(a.type,r.expectedTypes)?r.optional||false:(n.set(r.role,a),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!Ye(o.type,r.expectedTypes)?r.optional||false:(n.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Ye(u.type,r.expectedTypes)?r.optional||false:(n.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Ye(s.type,r.expectedTypes)?r.optional||false:(n.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!Ye(l.type,r.expectedTypes)?r.optional||false:(n.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let c=this.tokenToSemanticValue(i);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&&!Ye(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),n.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let n=r.normalized||r.value,i=this.safeToLowerCase(n),a=Sa(this.currentProfile,i);if(!a)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),Lr(pr(a),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(n),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<Ze.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(n),null;e.advance();let o=`${r.value}.${a.value}`,u=1;for(;!e.isAtEnd()&&u<Ze.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<Ze.MAX_METHOD_ARGS;){let m=e.peek();if(!m)break;if(m.kind==="punctuation"&&m.value===")"){if(c===0){e.advance();break}c--;}if(m.kind==="punctuation"&&m.value==="("&&c++,m.kind==="punctuation"&&m.value===","){e.advance();continue}l.push(m.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 n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(n),null;e.advance();let a=e.peek();return !a||a.kind!=="selector"&&a.kind!=="identifier"?(e.reset(n),null):(e.advance(),Lr(Fr(r.value),a.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;let a=e.peek(1);a&&a.kind,e.advance();let o=i.value.slice(1);return Lr(Fr(r.value),o)}matchGroupToken(e,r,n,i){let a=e.mark(),o=new Set(n.keys());if(this.matchTokenSequence(e,r.tokens,n,i))return true;e.reset(a);for(let l of n.keys())o.has(l)||n.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=Ze.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 p=0;p<l;p++)e.advance();if(this.matchTokenSequence(e,r.tokens,n,i))return true;e.reset(a);for(let p of n.keys())o.has(p)||n.delete(p);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 n=new Set;for(let i=r;i<e.length;i++){let a=e[i];if(a.type==="literal"){if(n.add(a.value.toLowerCase()),a.alternatives)for(let o of a.alternatives)n.add(o.toLowerCase());break}if(a.type==="group"){for(let o of a.tokens)if(o.type==="literal"){if(n.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)n.add(u.toLowerCase());break}if(!a.optional)break}}return n}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 Fr(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return be(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return pr(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return be(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return be(i,"string")}if(e==="true")return be(true,"boolean");if(e==="false")return be(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let i=parseFloat(r[1]);return r[2]?be(e,"duration"):be(i,"number")}let n=parseFloat(e);return isNaN(n)?be(e,"string"):be(n,"number")}applyExtractionRules(e,r){for(let[n,i]of Object.entries(e.extraction))r.has(n)||(i.value!==void 0?r.set(n,{type:"literal",value:i.value}):i.default&&r.set(n,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let n=0,i=0,a=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")i+=1,r.has(l.role)&&(n+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let d=a(c.role),m=.8;i+=m,r.has(c.role)?n+=m:d&&(n+=m*.6);}}let o=i>0?n/i: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 n=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(n.has(r.value))return .15;if(r.alternatives){for(let i of r.alternatives)if(n.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let n=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[a,o]of r.entries()){let u=i[a];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?n+=.1:n-=.1;}}return Math.max(-0.1,Math.min(.1,n))}skipNoiseWords(e){let r=e.peek();if(!r)return;let n=this.safeToLowerCase(r.value);if(Ze.ENGLISH_NOISE_WORDS.has(n)){let i=e.mark();e.advance();let a=e.peek();if(a&&a.kind==="selector")return;e.reset(i);}n==="class"&&e.advance();}extractEventModifiers(e){let r={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let a=i.metadata;if(!a)break;switch(n=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return n?r:void 0}};yr.MAX_MARKER_SCAN=3;yr.MAX_PROPERTY_DEPTH=10;yr.MAX_METHOD_ARGS=20;yr.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var xa=yr;new xa;var Je=class{constructor(){this.name="string-literal";}canExtract(t,e){let r=t[e];return r==="'"&&e>0&&/[\p{L}\p{M}\p{N}_)\]]/u.test(t[e-1])?false:r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(t,e){let r=t[e];if(r==="\u201C"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u201D")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}if(r==="\u2018"){let a=1;for(;e+a<t.length;){if(t[e+a]==="\u2019")return a++,{value:t.substring(e,e+a),length:a};a++;}return null}let n=1,i=false;for(;e+n<t.length;){let a=t[e+n];if(i){i=false,n++;continue}if(a==="\\"){i=true,n++;continue}if(a===r)return n++,{value:t.substring(e,e+n),length:n};n++;}return null}},Xe=class{constructor(){this.name="number";}canExtract(t,e){return /\d/.test(t[e])}extract(t,e){let r=0,n=false;for(;e+r<t.length;){let o=t[e+r];if(/\d/.test(o))r++;else if(o==="."&&!n)n=true,r++;else break}if(r===0)return null;let i=t.substring(e,e+r),a=e+r;if(a<t.length){let o=t.slice(a),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:i+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:i+"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:i+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:i+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:i,length:r}}};function Ta(t){return "setContext"in t&&typeof t.setContext=="function"}function Fa(t){let e={language:t.language,direction:t.direction,lookupKeyword:t.lookupKeyword.bind(t),isKeyword:t.isKeyword.bind(t),isKeywordStart:t.isKeywordStart.bind(t),...t.isKeywordStartAtBoundary?{isKeywordStartAtBoundary:t.isKeywordStartAtBoundary.bind(t)}:{}};return t.normalizer?{...e,normalizer:t.normalizer}:e}var ce=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 ee(t,e){return {start:t,end:e}}function re(t,e,r,n){if(typeof t=="object"){let{value:a,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:d}=t;return {value:a,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...d!==void 0&&{metadata:d}}}let i=t;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof n=="string")return {value:i,kind:e,position:r,normalized:n};if(n){let{normalized:a,stem:o,stemConfidence:u,metadata:s}=n;return {value:i,kind:e,position:r,...a!==void 0&&{normalized:a},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:i,kind:e,position:r}}function fr(t){return /\s/.test(t)}function La(t){return t==="#"||t==="."||t==="["||t==="@"||t==="*"||t==="<"}function Oa(t){return t==='"'||t==="'"||t==="`"||t==="\u300C"||t==="\u300D"}function je(t){return /\d/.test(t)}function Rr(t){return t.replace(/[\u064b-\u0652\u0670]/g,"")}function Ra(t){return /[a-zA-Z]/.test(t)}function pe(t){return /[a-zA-Z0-9_-]/.test(t)}function Pa(t,e){if(e>=t.length)return null;let r=t[e];if(!La(r))return null;let n=e,i="";if(r==="#"||r==="."){for(i+=t[n++];n<t.length&&pe(t[n]);)i+=t[n++];if(i.length<=1)return null;if(n<t.length&&t[n]==="."&&r==="#"){let o=n+1;for(;o<t.length&&pe(t[o]);)o++;if(o<t.length&&t[o]==="(")return i}}else if(r==="["){let a=1,o=false,u=null,s=false;for(i+=t[n++];n<t.length&&a>0;){let l=t[n];i+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?a++:l==="]"&&a--,n++;}if(a!==0)return null}else if(r==="@"){for(i+=t[n++];n<t.length&&pe(t[n]);)i+=t[n++];if(i.length<=1)return null}else if(r==="*"){for(i+=t[n++];n<t.length&&pe(t[n]);)i+=t[n++];if(i.length<=1)return null}else if(r==="<"){if(i+=t[n++],n>=t.length||!Ra(t[n]))return null;for(;n<t.length&&pe(t[n]);)i+=t[n++];for(;n<t.length;){let a=t[n];if(a==="."){if(i+=t[n++],n>=t.length||!pe(t[n]))return null;for(;n<t.length&&pe(t[n]);)i+=t[n++];}else if(a==="#"){if(i+=t[n++],n>=t.length||!pe(t[n]))return null;for(;n<t.length&&pe(t[n]);)i+=t[n++];}else if(a==="["){let o=1,u=false,s=null,l=false;for(i+=t[n++];n<t.length&&o>0;){let c=t[n];i+=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--,n++;}if(o!==0)return null}else break}for(;n<t.length&&fr(t[n]);)i+=t[n++];if(n<t.length&&t[n]==="/")for(i+=t[n++];n<t.length&&fr(t[n]);)i+=t[n++];if(n>=t.length||t[n]!==">")return null;i+=t[n++];}return i||null}function Na(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 n=t[e+2];return fr(n)||n==="*"||!pe(n)}function Ma(t,e){if(e>=t.length)return null;let r=t[e];if(!Oa(r)||r==="'"&&Na(t,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!i)return null;let a=e+1,o=r,u=false;for(;a<t.length;){let s=t[a];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===i)return o;a++;}return o}function _a(t,e){if(e>=t.length)return false;let r=t[e],n=t[e+1]||"",i=t[e+2]||"";if(r==="/"&&n!=="/"&&/[a-zA-Z0-9._-]/.test(n)||r==="/"&&n==="/"&&/[a-zA-Z]/.test(i)||r==="."&&(n==="/"||n==="."&&i==="/"))return true;let a=t.slice(e,e+8).toLowerCase();return !!(a.startsWith("http://")||a.startsWith("https://"))}function Ia(t,e){if(!_a(t,e))return null;let r=e,n="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<t.length;){let a=t[r];if(a==="#"){if(n.length>0&&/[a-zA-Z0-9/.]$/.test(n))for(n+=a,r++;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)n+=t[r++];break}if(i.test(a))n+=a,r++;else break}return n.length<2?null:n}function ja(t,e){if(e>=t.length)return null;let r=t[e];if(!je(r)&&r!=="-"&&r!=="+")return null;let n=e,i="";if((t[n]==="-"||t[n]==="+")&&(i+=t[n++]),n>=t.length||!je(t[n]))return null;for(;n<t.length&&je(t[n]);)i+=t[n++];if(n<t.length&&t[n]===".")for(i+=t[n++];n<t.length&&je(t[n]);)i+=t[n++];return n<t.length&&(t.slice(n,n+2)==="ms"?i+="ms":(t[n]==="s"||t[n]==="m"||t[n]==="h")&&(i+=t[n])),i}var $a=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set($a);var Va=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"]);function qa(t){return t.includes("-")&&/^[\p{L}\p{N}_]+(-[\p{L}\p{N}_]+)+$/u.test(t)}var Wa=["click","dblclick","input","change","submit","keydown","keyup","keypress","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","mousemove","pointerdown","pointerup","pointermove","focus","blur","load","resize","scroll"],Pr=class Or{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){Ta(e)&&e.setContext(Fa(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=[],n=0;for(;n<e.length;){for(;n<e.length&&fr(e[n]);)n++;if(n>=e.length)break;let i=this.tryMultiWordKeyword(e,n);if(i){r.push(i),n=i.position.end;continue}let a=false;for(let o of this.extractors)if(o.canExtract(e,n)){let u=o.extract(e,n);if(u){let s=u.metadata?.normalized,l=u.metadata?.stem,c=u.metadata?.stemConfidence,d={};if(u.metadata)for(let[p,f]of Object.entries(u.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(d[p]=f);let m={};s&&(m.normalized=s),l&&(m.stem=l),c!==void 0&&(m.stemConfidence=c),Object.keys(d).length>0&&(m.metadata=d),r.push(re(u.value,this.classifyToken(u.value),ee(n,n+u.length),Object.keys(m).length>0?m:void 0)),n+=u.length,a=true;break}}if(!a){let o=e[n],u=this.classifyUnknownChar(o);r.push(re(o,u,ee(n,n+1))),n++;}}return new ce(this.mergeColonQualifiedNames(r),this.language)}mergeColonQualifiedNames(e){let r=[];for(let n of e){let i=r[r.length-1];if(i&&Or.ASCII_WORD.test(i.value)&&Or.COLON_QUALIFIER.test(n.value)&&i.position.end===n.position.start){let a=i.value+n.value;r[r.length-1]=re(a,this.classifyToken(a),ee(i.position.start,n.position.end));continue}r.push(n);}return r}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,n){if(e[r]!==".")return false;let i=n[n.length-1],a=i&&i.position.end<r;if(i&&!a&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return n.push(re(".","operator",ee(r,r+1))),true;let s=r+1;for(;s<e.length&&pe(e[s]);)s++;return s<e.length&&e[s]==="("?(n.push(re(".","operator",ee(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let n=new Map;if(this.rawExtraEntries=r,e.keywords){for(let[i,a]of Object.entries(e.keywords))if(n.set(a.primary,{native:a.primary,normalized:a.normalized||i}),a.alternatives)for(let o of a.alternatives)n.set(o,{native:o,normalized:a.normalized||i});}if(e.references){for(let[i,a]of Object.entries(e.references))n.set(a,{native:a,normalized:i});for(let i of Object.keys(e.references))n.has(i)||n.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,a]of Object.entries(e.roleMarkers))if(a.primary&&n.set(a.primary,{native:a.primary,normalized:i}),a.alternatives)for(let o of a.alternatives)n.set(o,{native:o,normalized:i});}if(e.possessive?.keywords)for(let[i,a]of Object.entries(e.possessive.keywords))n.set(i,{native:i,normalized:a});for(let i of Wa)n.has(i)||n.set(i,{native:i,normalized:i});for(let i of r)n.set(i.native,i);this.profileKeywords=Array.from(n.values()).sort((i,a)=>a.native.length-i.native.length),this.multiWordKeywords=this.profileKeywords.filter(i=>(i.native.includes(" ")||qa(i.native))&&!Va.has(i.normalized)),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let a=this.removeDiacritics(i.native);a!==i.native&&!this.profileKeywordMap.has(a.toLowerCase())&&this.profileKeywordMap.set(a.toLowerCase(),i);}}removeDiacritics(e){return Rr(e)}tryProfileKeyword(e,r){for(let n of this.profileKeywords)if(e.slice(r).startsWith(n.native))return re(n.native,"keyword",ee(r,r+n.native.length),n.normalized);return null}tryMultiWordKeyword(e,r,n=i=>/[\p{L}\p{N}_]/u.test(i)){if(this.multiWordKeywords.length===0)return null;let i=e.slice(r);for(let a of this.multiWordKeywords){if(!i.startsWith(a.native))continue;let o=e[r+a.native.length];if(!(o!==void 0&&n(o)))return re(a.native,"keyword",ee(r,r+a.native.length),a.normalized)}return null}isKeywordStart(e,r){let n=e.slice(r);return this.profileKeywords.some(i=>n.startsWith(i.native))}isKeywordStartAtBoundary(e,r,n=i=>/[\p{L}\p{N}_]/u.test(i)){let i=e.slice(r);return this.profileKeywords.some(a=>{if(!i.startsWith(a.native))return false;let o=e[r+a.native.length];return o===void 0||!n(o)})}lookupKeyword(e){let r=this.profileKeywordMap.get(e.toLowerCase());if(r)return r;let n=this.removeDiacritics(e);if(n!==e)return this.profileKeywordMap.get(n.toLowerCase())}isKeyword(e){return this.lookupKeyword(e)!==void 0}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,n){let i=this.tryNormalize(e);if(!i)return null;let a=this.lookupKeyword(i.stem);if(!a)return null;let o={normalized:a.normalized,stem:i.stem,stemConfidence:i.confidence};return re(e,"keyword",ee(r,n),o)}trySelector(e,r){let n=Pa(e,r);return n?re(n,"selector",ee(r,r+n.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let n=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!n)return null;let i=n[0].replace(/(\s|\.)$/,""),a=i.slice(1).split("(")[0],o=n[1];return {...re(i,"event-modifier",ee(r,r+i.length)),metadata:{modifierName:a,value:o?a==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let n=Ma(e,r);return n?re(n,"literal",ee(r,r+n.length)):null}tryNumber(e,r){let n=ja(e,r);return n?re(n,"literal",ee(r,r+n.length)):null}tryMatchTimeUnit(e,r,n,i=false){let a=r;if(i)for(;a<e.length&&fr(e[a]);)a++;let o=e.slice(a);for(let u of n){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(pe(c))continue}return {suffix:u.suffix,endPos:a+u.length}}}return null}parseBaseNumber(e,r,n=true){let i=r,a="";if(n&&(e[i]==="-"||e[i]==="+")&&(a+=e[i++]),i>=e.length||!je(e[i]))return null;for(;i<e.length&&je(e[i]);)a+=e[i++];if(i<e.length&&e[i]===".")for(a+=e[i++];i<e.length&&je(e[i]);)a+=e[i++];return !a||a==="-"||a==="+"?null:{number:a,endPos:i}}tryNumberWithTimeUnits(e,r,n,i={}){let{allowSign:a=true,skipWhitespace:o=false}=i,u=this.parseBaseNumber(e,r,a);if(!u)return null;let{number:s,endPos:l}=u,c=[...n,...Or.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,l,c,o);return d&&(s+=d.suffix,l=d.endPos),re(s,"literal",ee(r,l))}tryUrl(e,r){let n=Ia(e,r);return n?re(n,"url",ee(r,r+n.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!pe(e[r+1]))return null;let n=r+1;for(;n<e.length&&pe(e[n]);)n++;let i=e.slice(r,n);return re(i,"identifier",ee(r,n))}tryOperator(e,r){let n=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(n))return re(n,"operator",ee(r,r+2));let i=e[r];return ["<",">","!","+","-","*","/","="].includes(i)?re(i,"operator",ee(r,r+1)):["(",")","{","}",",",";",":"].includes(i)?re(i,"punctuation",ee(r,r+1)):null}tryMultiCharParticle(e,r,n){for(let i of n)if(e.slice(r,r+i.length)===i)return re(i,"particle",ee(r,r+i.length));return null}};Pr.ASCII_WORD=/^[A-Za-z_][A-Za-z0-9_]*$/;Pr.COLON_QUALIFIER=/^:[A-Za-z_][A-Za-z0-9_]*$/;Pr.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 Qe=Pr;function Nr(t){return {stem:t,confidence:1}}function Ne(t,e,r){return r?{stem:t,confidence:e,metadata:r}:{stem:t,confidence:e}}var Ka=Object.defineProperty,Ha=Object.getOwnPropertyNames,Nn=(t,e)=>function(){return t&&(e=(0, t[Ha(t)[0]])(t=0)),e},Ua=(t,e)=>{for(var r in e)Ka(t,r,{get:e[r],enumerable:true});};function Zt(t,e){return t.replace(/\{(\w+)\}/g,(r,n)=>String(e[n]??`{${n}}`))}function ve(t,e,r={},n){let i=Mn[t],a=Zt(i,r),o=_n[t],u=o?Zt(o,r):void 0;return {code:t,message:a,severity:e,...n&&{role:n},...u&&{suggestion:u}}}var R,Mn,_n,Ga=Nn({"src/generators/schema-error-codes.ts"(){R={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"},Mn={[R.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[R.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[R.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[R.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[R.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[R.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.",[R.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.",[R.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[R.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[R.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[R.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[R.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[R.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[R.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[R.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[R.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},_n={[R.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[R.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[R.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[R.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[R.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[R.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[R.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[R.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[R.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[R.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[R.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[R.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[R.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),In={};Ua(In,{SchemaErrorCodes:()=>R,formatValidationResults:()=>ro,getValidationStats:()=>to,validateAllKeywordCollisions:()=>ao,validateAllSchemas:()=>eo,validateCommandSchema:()=>jn,validateKeywordCollisions:()=>$n,validateRoleValues:()=>no});function Ya(t,e){return {action:t,items:e}}function jn(t){let e=[];for(let n of t.roles)n.expectedTypes.includes("literal")&&n.expectedTypes.includes("selector")&&(n.role==="patient"&&mt.has(t.action)?e.push(ve(R.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:n.role,command:t.action},n.role)):e.push(ve(R.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:n.role},n.role))),n.expectedTypes.length>3&&!mt.has(t.action)&&e.push(ve(R.TOO_MANY_EXPECTED_TYPES,"warning",{role:n.role,count:n.expectedTypes.length},n.role));for(let n of t.roles)n.selectorKinds&&n.selectorKinds.length>0&&(n.expectedTypes.includes("selector")||e.push(ve(R.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:n.role},n.role)));switch(t.action){case "transition":Za(t,e);break;case "on":Ja(t,e);break;case "if":case "unless":Xa(t,e);break;case "repeat":case "for":case "while":Qa(t,e);break}return t.roles.filter(n=>n.required).length===0&&(Vn.has(t.action)?e.push(ve(R.NO_REQUIRED_ROLES_EXPECTED,"note",{command:t.action})):e.push(ve(R.NO_REQUIRED_ROLES,"warning",{}))),Ya(t.action,e)}function Za(t,e){let r=t.roles.find(i=>i.role==="patient"),n=t.roles.find(i=>i.role==="goal");r&&!n&&e.push(ve(R.TRANSITION_MISSING_GOAL,"error",{}));}function Ja(t,e){let r=t.roles.find(n=>n.role==="event");r||e.push(ve(R.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(ve(R.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Xa(t,e){let r=t.roles.find(n=>n.role==="condition");r||e.push(ve(R.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(ve(R.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Qa(t,e){t.action==="for"?t.roles.find(n=>n.role==="source")||e.push(ve(R.FOR_LOOP_MISSING_SOURCE,"warning",{})):t.action==="while"&&(t.roles.find(n=>n.role==="condition")||e.push(ve(R.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function eo(t,e={}){let r=new Map,{includeNotes:n=false}=e;for(let[i,a]of Object.entries(t)){let o=jn(a),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=n&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(i,o);}return r}function ro(t,e={}){let r=[],{showNotes:n=false,showCodes:i=true}=e;for(let[a,o]of t){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${a}:`);for(let c of u){let d=i?` [${c.code}]`:"";r.push(` ERROR${d}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${a}:`);for(let c of s){let d=i?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(n&&l.length>0){r.push(` \u2139\uFE0F ${a}:`);for(let c of l){let d=i?` [${c.code}]`:"";r.push(` ${d?`${c.code}: `:""}${c.message}`);}}}return r.join(`
2
+ `)}function to(t){let e=0,r=0,n=0,i={};for(let a of t.values())for(let o of a.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&n++,i[o.code]=(i[o.code]||0)+1;return {totalCommands:t.size,errors:e,warnings:r,notes:n,byCode:i}}function no(t,e){let r=[];for(let n of e){let i=t.roles.find(a=>a.role===n.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(n.type)&&(i.expectedTypes.includes("expression")||r.push({level:"error",role:n.role,message:`${t.action}.${n.role} expects type [${i.expectedTypes.join(", ")}], got '${n.type}'`,code:R.VALUE_TYPE_MISMATCH})),n.type==="selector"&&n.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(n.selectorKind)||r.push({level:"error",role:n.role,message:`${t.action}.${n.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${n.selectorKind}'`,code:R.SELECTOR_KIND_MISMATCH})));}return r}function io(t){if(t.length!==2)return false;let[e,r]=[...t].sort();return qn.some(([n,i])=>n===e&&i===r)}function $n(t){let e=[];if(!t.keywords)return {language:t.code,collisions:e};let r=new Map;for(let[i,a]of Object.entries(t.keywords)){if(!a||!a.primary)continue;let o=r.get(a.primary)||[];if(o.push({command:i,isPrimary:true}),r.set(a.primary,o),a.alternatives)for(let u of a.alternatives){let s=r.get(u)||[];s.push({command:i,isPrimary:false}),r.set(u,s);}}for(let[i,a]of r){let o=[...new Set(a.map(l=>l.command))];if(o.length<=1||io(o))continue;let u=a.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:i,commands:o.sort(),type:s});}let n={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,a)=>n[i.type]-n[a.type]),{language:t.code,collisions:e}}function ao(t){let e=[];for(let[,r]of Object.entries(t)){let n=$n(r);n.collisions.length>0&&e.push(n);}return e.sort((r,n)=>r.language.localeCompare(n.language))}var mt,Vn,qn,oo=Nn({"src/generators/schema-validator.ts"(){Ga(),mt=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Vn=new Set(["compound","else","halt","continue","init","settle","focus","blur","show","hide","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint","live","eventsource","socket","worker","intercept"]),qn=[["change","changes"]];}});var wt=["is not really equal to","is really equal to","is greater than or equal to","is less than or equal to","is not equal to","is equal to","is greater than","is less than","is not really","is really","is not equal","is equal","is not in","is in","is not","is","am not in","am in","am","does not match","do not match","does not contain","does not contains","do not contain","does not include","does not precede","does not follow","precedes","follows","really equals","equals","matches","match","contains","contain","includes","include","has","have","in"],zt=["is not empty","is empty","does not exist"],kt=["is not an","is not a","is an","is a"],uo=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document"]),so=new Set(["and","or","not","no"]),lo=new Set(["true","false","null","undefined"]),co=new Set(wt.map(t=>t.slice(t.lastIndexOf(" ")+1))),mo=new Set(["next","previous","closest","first","last"]),po=new Set(["ms","s","seconds","second","milliseconds","millisecond","minutes","minute","hours","hour"]);function Wn(t){let e=[],r=0,n=1,i=1;function a(){if(e.length===0)return true;let f=e[e.length-1];return f.type==="IDENTIFIER"&&co.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&mo.has(f.value.toLowerCase())||f.type==="IDENTIFIER"&&f.value.toLowerCase()==="of"?true:["OPERATOR","COMPARISON","LOGICAL","LPAREN","LBRACKET","LBRACE","COMMA","COLON"].includes(f.type)}function o(f=0){return t[r+f]??""}function u(){let f=t[r];return r++,f===`
3
+ `?(n++,i=1):i++,f}function s(){for(;r<t.length&&/\s/.test(t[r]);)u();}function l(f){let y="";for(;r<t.length&&f(t[r]);)y+=u();return y}function c(f){let y=f;for(u();r<t.length&&t[r]!==f;)t[r]==="\\"&&r+1<t.length&&(y+=u()),y+=u();return r<t.length&&(y+=u()),y}function d(){let f="`";for(u();r<t.length&&t[r]!=="`";)t[r]==="\\"&&r+1<t.length&&(f+=u()),f+=u();return r<t.length&&(f+=u()),f}function m(){let f="<";for(u();r<t.length&&(f+=u(),!f.endsWith("/>")););return f}function p(f,y,v){return {type:f,value:y,start:v,end:r,line:n,column:i-y.length}}for(;r<t.length&&(s(),!(r>=t.length));){let f=r,y=o();if(y==="'"&&o(1)==="s"&&!/\w/.test(o(2))){u(),u(),e.push(p("POSSESSIVE","'s",f));continue}if(y==='"'||y==="'"){let v=c(y);e.push(p("STRING",v,f));continue}if(y==="`"){let v=d();e.push(p("TEMPLATE_LITERAL",v,f));continue}if(y==="<"&&/[a-zA-Z.#\[]/.test(o(1))){let v=m();e.push(p("QUERY_SELECTOR",v,f));continue}if(y==="#"&&a()){u();let v=l(h=>/[\w-]/.test(h));e.push(p("ID_SELECTOR","#"+v,f));continue}if(y==="."&&/[a-zA-Z_-]/.test(o(1))&&a()){u();let v=l(h=>/[\w-]/.test(h));e.push(p("CLASS_SELECTOR","."+v,f));continue}if(y==="@"&&/[a-zA-Z_]/.test(o(1))){u();let v=l(h=>/[\w-]/.test(h));e.push(p("ATTRIBUTE_REF","@"+v,f));continue}if(y==="["&&a()&&o(1)==="@"){let h="";for(h+=u();r<t.length&&t[r]!=="]";)t[r]==='"'||t[r]==="'"?h+=c(t[r]):h+=u();r<t.length&&(h+=u()),e.push(p("ATTRIBUTE_SELECTOR",h,f));continue}if(y==="["){u(),e.push(p("LBRACKET","[",f));continue}if(y==="]"){u(),e.push(p("RBRACKET","]",f));continue}if(/\d/.test(y)){let v=l(C=>/[\d.]/.test(C)),h=r,E=l(C=>/[a-zA-Z]/.test(C));po.has(E)?e.push(p("TIME_EXPRESSION",v+E,f)):(r=h,e.push(p("NUMBER",v,f)));continue}if(y==="("){u(),e.push(p("LPAREN","(",f));continue}if(y===")"){u(),e.push(p("RPAREN",")",f));continue}if(y==="{"){u(),e.push(p("LBRACE","{",f));continue}if(y==="}"){u(),e.push(p("RBRACE","}",f));continue}if(y===","){u(),e.push(p("COMMA",",",f));continue}if(y===":"){u(),e.push(p("COLON",":",f));continue}if(y==="."){u(),e.push(p("DOT",".",f));continue}if(y==="|"){u(),e.push(p("PIPE","|",f));continue}if(y==="+"||y==="-"||y==="*"||y==="/"||y==="%"){u(),e.push(p("OPERATOR",y,f));continue}if(y==="="||y==="!"||y==="<"||y===">"){let v=u();o()==="="&&(v+=u()),(v==="=="||v==="!=")&&o()==="="&&(v+=u()),e.push(p("COMPARISON",v,f));continue}if(/[a-zA-Z_$]/.test(y)){let v=l(E=>/[\w$]/.test(E)),h=v.toLowerCase();uo.has(h)?e.push(p("CONTEXT_VAR",v,f)):so.has(h)?e.push(p("LOGICAL",v,f)):lo.has(h)?e.push(p("BOOLEAN",v,f)):e.push(p("IDENTIFIER",v,f));continue}u();}return e.push(p("EOF","",r)),e}var fo=new Set(["my","its","your"]),yo={my:"me",its:"it",your:"you"},ho=new Set(["is","matches","match","contains","in","exists","does"]),vo=new Set(["next","previous","closest","first","last"]),Eo=[...zt,...kt,...wt].map(t=>[t,t.split(" ")]),go=class{constructor(){this.tokens=[],this.current=0;}parse(t){try{return this.tokens=Wn(t),this.current=0,this.isAtEnd()?{success:!1,error:"Empty expression"}:{success:!0,node:this.parseExpression(),consumed:this.current}}catch(e){return {success:false,error:e instanceof Error?e.message:"Parse error"}}}peek(){return this.tokens[this.current]??{type:"EOF",value:"",start:0,end:0}}peekAt(t){return this.tokens[this.current+t]??{type:"EOF",value:"",start:0,end:0}}previous(){return this.tokens[this.current-1]??{type:"EOF",value:"",start:0,end:0}}isAtEnd(){return this.peek().type==="EOF"}advance(){return this.isAtEnd()||this.current++,this.previous()}check(t){return this.peek().type===t}checkValue(t){return this.peek().value.toLowerCase()===t.toLowerCase()}match(...t){for(let e of t)if(this.check(e))return this.advance(),true;return false}parseExpression(){return this.parseOr()}parseOr(){let t=this.parseAnd();for(;this.checkValue("or");){let e=this.advance().value,r=this.parseAnd();t=this.createBinaryExpression(e,t,r);}return t}parseAnd(){let t=this.parseEquality();for(;this.checkValue("and");){let e=this.advance().value,r=this.parseEquality();t=this.createBinaryExpression(e,t,r);}return t}parseEquality(){let t=this.parseComparison();for(;;){if(this.match("COMPARISON")){let r=this.previous().value;t=this.createBinaryExpression(r,t,this.parseComparison());continue}let e=this.matchComparisonPhrase();if(e===void 0)break;if(zt.includes(e))t=this.createPostfixUnary(e,t);else if(kt.includes(e))t=this.parseTypeCheck(t,e.startsWith("is not"));else {let r=e==="match"?"matches":e;t=this.createBinaryExpression(r,t,this.parseComparison());}}return t}matchComparisonPhrase(){for(let[t,e]of Eo)if(e.every((r,n)=>this.peekAt(n).value.toLowerCase()===r)){for(let r=0;r<e.length;r++)this.advance();return t}}parseTypeCheck(t,e){let r=this.advance();if(r.type==="EOF")throw new Error(`Expected a type name after 'is ${e?"not ":""}a'`);let n=true;return this.peek().value==="!"&&(this.advance(),n=false),{type:"typeCheckExpression",value:t,typeName:r.value,nullOk:n,negated:e,start:t.start,end:this.previous().end}}parseComparison(){let t=this.parseAddition();for(;this.check("COMPARISON");){let e=this.advance().value,r=this.parseAddition();t=this.createBinaryExpression(e,t,r);}return t}parseAddition(){let t=this.parseMultiplication();for(;this.peek().value==="+"||this.peek().value==="-";){let e=this.advance().value,r=this.parseMultiplication();t=this.createBinaryExpression(e,t,r);}return t}parseMultiplication(){let t=this.parseConversion();for(;this.peek().value==="*"||this.peek().value==="/"||this.peek().value==="%"||this.checkValue("mod");){let e=this.advance().value.toLowerCase(),r=this.parseConversion();t=this.createBinaryExpression(e,t,r);}return t}parseConversion(){let t=this.parseUnary();for(;this.checkValue("as")&&this.conversionTypeAt(1)!==void 0;)for(this.advance(),t=this.createAsExpression(t,this.parseConversionType());this.check("PIPE")&&this.conversionTypeAt(1)!==void 0;)this.advance(),t=this.createAsExpression(t,this.parseConversionType());return t}conversionTypeAt(t){let e=this.peekAt(t).value.toLowerCase(),r=e==="a"||e==="an"?t+1:t;return this.peekAt(r).type==="IDENTIFIER"?r:void 0}parseConversionType(){let t=this.conversionTypeAt(0)??0;for(let i=0;i<t;i++)this.advance();let e=this.advance(),r=this.peekAt(1).type;if(!this.check("COLON")||r!=="NUMBER"&&r!=="IDENTIFIER")return e;this.advance();let n=this.advance();return {...e,value:`${e.value}:${n.value}`,end:n.end}}parseUnary(){if(this.checkValue("not")||this.checkValue("no")||this.peek().value==="-"){let t=this.advance().value,e=this.parseUnary();return this.createUnaryExpression(t,e)}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("DOT"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createMemberExpression(t,this.createIdentifier(e.value,e),false);}else break;else if(this.match("POSSESSIVE"))if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR")){let e=this.advance();t=this.createPossessiveExpression(t,this.createIdentifier(e.value,e));}else break;else if(this.match("LPAREN")){let e=this.parseArguments();t=this.createCallExpression(t,e);}else if(this.match("LBRACKET")){let e=this.parseExpression();if(!this.match("RBRACKET"))throw new Error("Expected ] after index");t=this.createMemberExpression(t,e,true);}else if(t.type==="identifier"&&fo.has(t.name)&&this.check("IDENTIFIER")&&!ho.has(this.peek().value.toLowerCase())){let e=this.advance(),r=t,n={...r,name:yo[r.name]??r.name};t=this.createMemberExpression(n,this.createIdentifier(e.value,e),false);}else if(this.checkValue("exists")&&this.peekAt(1).type!=="LPAREN")this.advance(),t=this.createPostfixUnary("exists",t);else break;return t}parsePrimary(){let t=this.peek();if(this.checkValue("the")&&(this.peekAt(1).type==="IDENTIFIER"||this.peekAt(1).type==="CONTEXT_VAR")&&this.peekAt(2).value.toLowerCase()==="of")return this.advance(),this.parsePropertyOf(this.advance(),t,false);if(this.match("NUMBER"))return this.createLiteral(parseFloat(t.value),"number",t);if(this.match("STRING")){let e=t.value.slice(1,-1);return this.createLiteral(e,"string",t)}if(this.match("BOOLEAN")){let e=t.value==="true"?true:t.value==="false"?false:t.value==="null"?null:void 0,r={true:"boolean",false:"boolean",null:"null",undefined:"undefined"};return this.createLiteral(e,r[t.value]??"string",t)}if(this.match("TEMPLATE_LITERAL")){let e=t.value;return {type:"templateLiteral",value:e.length>=2&&e.startsWith("`")&&e.endsWith("`")?e.slice(1,-1):e,start:t.start,end:t.end,line:t.line,column:t.column}}if(this.match("TIME_EXPRESSION"))return this.parseTimeExpression(t);if(this.match("ID_SELECTOR"))return this.createSelector(t.value,"id",t);if(this.match("CLASS_SELECTOR"))return this.createSelector(t.value,"class",t);if(this.match("ATTRIBUTE_SELECTOR"))return this.createSelector(t.value,"attribute",t);if(this.match("ATTRIBUTE_REF")){let e={type:"attributeAccess",attributeName:t.value.slice(1),start:t.start,end:t.end};return this.checkValue("of")?(this.advance(),this.createBinaryExpression("of",e,this.parseConversion())):e}if(this.match("QUERY_SELECTOR")){let e=t.value.slice(1,-2);return this.createSelector(e,"query",t)}if(this.match("CONTEXT_VAR"))return this.createIdentifier(t.value,t);if(this.match("IDENTIFIER")){if(vo.has(t.value.toLowerCase())&&(this.check("CLASS_SELECTOR")||this.check("ID_SELECTOR")||this.check("QUERY_SELECTOR"))){let e=this.advance(),r=e.type==="QUERY_SELECTOR"?e.value.slice(1,-2):e.value,n=e.type==="CLASS_SELECTOR"?"class":e.type==="ID_SELECTOR"?"id":"query";return {type:"callExpression",callee:this.createIdentifier(t.value,t),arguments:[this.createSelector(r,n,e)],start:t.start,end:e.end}}return this.checkValue("of")?this.parsePropertyOf(t,t):this.createIdentifier(t.value,t)}if(this.match("LPAREN")){let e=this.parseExpression();if(!this.match("RPAREN"))throw new Error("Expected ) after expression");return e}if(this.match("LBRACKET"))return this.parseArrayLiteral();if(this.match("LBRACE"))return this.parseObjectLiteral();throw new Error(`Unexpected token: ${t.value}`)}parsePropertyOf(t,e,r=true){this.advance();let n=r?this.parseConversion():this.parseUnary();return {type:"propertyOfExpression",property:this.createIdentifier(t.value,t),target:n,start:e.start,end:this.previous().end}}parseArguments(){let t=[];if(!this.check("RPAREN"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RPAREN"))throw new Error("Expected ) after arguments");return t}parseArrayLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACKET"))do t.push(this.parseExpression());while(this.match("COMMA"));if(!this.match("RBRACKET"))throw new Error("Expected ] after array elements");return {type:"arrayLiteral",elements:t,start:e,end:this.previous().end}}parseObjectLiteral(){let t=[],e=this.previous().start;if(!this.check("RBRACE"))do{let r;if(this.check("STRING"))r=this.advance().value.slice(1,-1);else if(this.check("IDENTIFIER")||this.check("CONTEXT_VAR"))r=this.advance().value;else throw new Error("Expected property name");if(!this.match("COLON"))throw new Error("Expected : after property name");let n=this.parseExpression();t.push({key:r,value:n});}while(this.match("COMMA"));if(!this.match("RBRACE"))throw new Error("Expected } after object properties");return {type:"objectLiteral",properties:t.map(r=>({type:"objectProperty",key:{type:"identifier",name:r.key},value:r.value})),start:e,end:this.previous().end}}parseTimeExpression(t){let e=t.value.match(/^(\d+(?:\.\d+)?)(ms|s|seconds?|milliseconds?|minutes?|hours?)$/i);if(!e)throw new Error(`Invalid time expression: ${t.value}`);let r=parseFloat(e[1]),n=e[2].toLowerCase();return {type:"timeExpression",value:r,unit:n,raw:t.value,start:t.start,end:t.end,line:t.line,column:t.column}}createLiteral(t,e,r){return {type:"literal",value:t,dataType:e,raw:r.value,start:r.start,end:r.end,line:r.line,column:r.column}}createSelector(t,e,r){return {type:"selector",value:t,selector:t,selectorType:e,start:r.start,end:r.end,line:r.line,column:r.column}}createIdentifier(t,e){return {type:"identifier",name:t,start:e.start,end:e.end,line:e.line,column:e.column}}createMemberExpression(t,e,r){return {type:"memberExpression",object:t,property:e,computed:r,start:t.start,end:this.previous().end}}createPossessiveExpression(t,e){return {type:"possessiveExpression",object:t,property:e,start:t.start,end:this.previous().end}}createBinaryExpression(t,e,r){return {type:"binaryExpression",operator:t,left:e,right:r,start:e.start,end:r.end}}createAsExpression(t,e){return {type:"asExpression",expression:t,targetType:this.createIdentifier(e.value,e),start:t.start,end:e.end}}createUnaryExpression(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:true,start:this.previous().start,end:e.end}}createPostfixUnary(t,e){return {type:"unaryExpression",operator:t,operand:e,prefix:false,start:e.start,end:this.previous().end}}createCallExpression(t,e){return {type:"callExpression",callee:t,arguments:e,start:t.start,end:this.previous().end}}};function Co(t){return new go().parse(t)}function We(t){let e=t.roles.find(r=>r.role==="destination");return e?{destination:e.default?{fromRole:"destination",default:e.default}:{fromRole:"destination"}}:{}}function Ke(t){let e=t.roles.find(r=>r.role==="source");return e?{source:e.default?{fromRole:"source",default:e.default}:{fromRole:"source"}}:{}}function He(t,e){return At(t,e,"source")}function bt(t,e){return At(t,e,"destination")}function wo(t,e){return At(t,e,"patient")}function At(t,e,r){if(!e||!t.roles.some(a=>a.role===r))return [];let n=e.alternatives?{type:"literal",value:e.primary,alternatives:[...e.alternatives]}:{type:"literal",value:e.primary},i={type:"role",role:r,optional:true};return [{type:"group",optional:true,tokens:e.position==="after"?[i,n]:[n,i]}]}var te=["selector","reference","expression"],zo={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination",for:"duration"}},argSkipTokens:["on"],roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2,markerOptional:{zh:true}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerVariants:{ko:["\uC5D0\uC11C"]}},{role:"duration",description:"How long the class stays on before reverting (`toggle .a for 2s`)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3,valueShape:"time",markerOverride:{en:"for",ja:"\u9593",ko:"\uB3D9\uC548"}}],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)"}},ko={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},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",es:"a",ar:"\u0625\u0644\u0649",zh:"\u5230",fr:"\xE0",de:"zu",pt:"a",he:"\u05D0\u05DC",id:"ke",it:"a",sw:"kwa"},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","dans"],de:["auf","in"],pt:["em","para"],he:["\u05E2\u05DC","\u05D1","\u05DC"],id:["pada","di"],it:["in","su"],sw:["kwenye"]}}],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"}},bo={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source"}},targetRole:"source",argSkipTokens:["from"],roles:[{role:"patient",description:"The class/attribute to remove, or the element to remove",required:true,expectedTypes:te,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"}},Dt={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","property-path"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"into",ar:"\u0641\u064A",zh:"\u5230",fr:"dans",de:"in",he:"\u05D1",id:"ke",sw:"kwa"},markerVariants:{en:["before","after"]},markerLegacy:{ar:["\u0639\u0644\u0649","\u0625\u0644\u0649","\u0628"],zh:["\u5728","\u4E8E"],fr:["sur","\xE0"],de:["auf","zu"],he:["\u05E2\u05DC","\u05D0\u05DC","\u05DC"],id:["pada","di"],sw:["kwenye"]},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"}},Ao={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient",on:"scope"}},argSkipTokens:["to"],roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",th:"",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B",zh:"\u628A"},markerOptional:{zh:true}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","selector","expression","reference","property-path"],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",th:"\u0E43\u0E19",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902",zh:"\u5230"},markerVariants:{tr:["e","a","ye","ya"],zh:["\u4E3A","\u70BA","\u6210"]}},{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>"}},Do={action:"bind",description:"Reactively bind a variable to an element or property value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to bind",required:true,expectedTypes:["reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",it:"",id:"",ms:"",vi:"",ru:"",uk:"",pl:"",th:"",zh:"",he:"",ar:"",sw:"",tl:"",ja:"\u3092",ko:"\uB97C",tr:"i",bn:"\u0995\u09C7",qu:"ta",hi:"\u0915\u094B"}},{role:"source",description:"The element or property to bind to",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"zu",it:"in",id:"ke",ms:"ke",vi:"v\xE0o",ru:"\u0432",uk:"\u0432",pl:"do",ja:"\u306B",ko:"\uC5D0",tr:"e",ar:"\u0625\u0644\u0649",zh:"\u5230",he:"\u05DC",sw:"kwa",th:"\u0E43\u0E19",tl:"sa",bn:"\u09A4\u09C7",qu:"man",hi:"\u092E\u0947\u0902"}}],errorCodes:["MISSING_TARGET","MISSING_VALUE","INVALID_SYNTAX"],recoveryHints:{MISSING_TARGET:"Add a variable to bind: bind $name to #input",MISSING_VALUE:'Add "to <element>" to specify the binding source',INVALID_SYNTAX:"Use syntax: bind <variable> to <element>"}},Bo={action:"live",description:"Reactive block: re-run the body when its dependencies change",category:"control-flow",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},So={action:"when",description:"Reactive observer: re-run the body when a watched expression changes",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,structuralOnly:true,roles:[{role:"condition",description:"The watched expression (`or`-separated expressions watch each)",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1}]},xo={action:"eventsource",description:"Open a Server-Sent Events stream and handle its events",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},To={action:"socket",description:"Open a WebSocket and handle its messages",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Fo={action:"worker",description:"Define a Web Worker with inline methods",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Lo={action:"intercept",description:"Service-worker fetch interception / caching strategies",category:"async",primaryRole:"patient",hasBody:true,bareKeyword:true,roles:[]},Oo={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to show",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Ro={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{with:["style","duration"]}},roles:[{role:"patient",description:"The element to hide",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"The hide/show strategy (`with opacity`, `with *opacity`)",required:false,expectedTypes:["expression","selector"],svoPosition:2,sovPosition:2}]},Po={action:"on",description:"Handle an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{from:"source"}},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","expression"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],widenTypeVariants:[{role:"event",types:["literal","expression"],idSuffix:"expr-event",excludeLanguages:["ko"]}]},No={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{on:"destination"}},argSkipTokens:["on"],roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2,markerVariants:{hi:["\u0915\u094B"],qu:["ta"],bn:["\u0995\u09C7"]},markerOverride:{bn:"\u0995\u09C7",hi:"\u0915\u094B"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Mo={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},_o={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",ast:{args:["source"],modifiers:{with:["style","method"],as:"responseType",body:"patient"},isBlocking:true},roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"style",description:"Request options object (method, headers, body, credentials\u2026)",required:false,expectedTypes:["expression"],valueShape:"object",svoPosition:2,sovPosition:2},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:3,sovPosition:3,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:5,sovPosition:5}]},Io={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},jo={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",ast:{args:[["destination","patient"]],modifiers:{by:"quantity"}},roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression","property-path"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal","selector","expression","reference","property-path"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by",es:"por",pt:"por",fr:"par",de:"um"}}]},$o={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Vo={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"destination"}},omitRoleVariants:["destination"],roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},qo={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],svoPosition:1,sovPosition:1}]},Wo={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",ast:{args:[["source","patient"]]},roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["literal","selector","reference","expression","property-path"],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}]},Ko={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{from:"source",for:"recipient"}},argSkipTokens:["from"],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 all current holders)",required:false,expectedTypes:te,svoPosition:2,sovPosition:1},{role:"recipient",description:"The element the class moves ONTO (`take .active from .tab for me`)",required:false,expectedTypes:["reference"],svoPosition:3,sovPosition:3,valueShape:"reference",markerOverride:{en:"for"}}]},Ho={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},Uo={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",ast:{args:[],modifiers:{the:"patient"}},argSkipTokens:["the"],roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Go={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",ast:{args:[["destination","patient"]],isBlocking:true},roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Yo={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression","property-path"],svoPosition:1,sovPosition:1}]},Zo={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",ast:{args:["event"],modifiers:{to:"destination",detail:"patient"}},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"}}]},Jo={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression","reference","selector"],svoPosition:1,sovPosition:1}]},Xo={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",ast:{args:["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}]},Qo={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},eu={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",ast:{args:[["quantity","patient"]]},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"'},ru={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{in:"source"}},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"}}]},tu={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",ast:{args:["condition"]},hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},nu={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",ast:{},roles:[]},Ur={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"},iu=Object.fromEntries(Object.keys(Ur).map(t=>[t,"in new"])),au={action:"go",description:"Navigate to a URL, or scroll to an element",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to, or the element to scroll to",required:true,expectedTypes:["literal",...te],svoPosition:1,sovPosition:1,markerOverride:{en:"to",es:"a",ar:"\u0625\u0644\u0649",fr:"\xE0",de:"zu",pt:"para",he:"\u05D0\u05DC",hi:"\u092A\u0930",id:"ke",it:"a",ru:"\u043D\u0430",sw:"kwa",uk:"\u043D\u0430"},renderOverride:{en:"",zh:"",vi:"",th:""},markerOptional:{en:true,zh:true,vi:true,th:true},markerVariants:{zh:["\u628A"]},markerLegacy:{es:["en","sobre","hacia"],ar:["\u0639\u0644\u0649","\u0641\u064A","\u0628"],fr:["sur","dans"],de:["auf","in"],pt:["em","a"],he:["\u05E2\u05DC","\u05D1","\u05DC","\u05D0\u05EA"],hi:["\u092E\u0947\u0902"],id:["pada","di"],it:["in","su"],ru:["\u0432","\u043A"],sw:["kwenye"],uk:["\u0432","\u0434\u043E"]}},{role:"manner",description:"Open the URL in a new window (`in new window`)",required:false,expectedTypes:["reference","literal","expression"],valueShape:"keyword",svoPosition:2,sovPosition:2,markerOverride:iu}],rolePrefixLiteralVariants:[{role:"destination",literal:Ur,idSuffix:"url",priorityDelta:5,methodCarrier:"method"}]},ou={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",ast:{args:["patient"],modifiers:{to:"goal",over:"duration",on:"destination"}},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}]},uu={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",ast:{args:[["source","patient"]],modifiers:{into:"destination"}},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"}}]},su={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},lu={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",ast:{args:[["destination","patient"]]},roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},cu={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:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},du={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{as:"style"}},roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"as",ja:"\u3068\u3057\u3066"}}]},mu={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:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},pu={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:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},fu={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}]},yu={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:te,default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},hu={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},vu={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],markerOptional:{he:true,zh:true},svoPosition:1,sovPosition:1}]},Eu={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference","property-path"],svoPosition:1,sovPosition:1}]},gu={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Cu={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",ast:{args:[["destination","patient"]]},hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:te,svoPosition:1,sovPosition:1,markerOverride:{en:"",he:"\u05D0\u05EA",zh:"\u628A"}}]},wu={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",ast:{args:["destination"],modifiers:{to:"patient"}},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","property-path"],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"}}]},zu={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",ast:{},hasBody:true,roles:[]},ku={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",ast:{args:["patient"]},hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},bu={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",ast:{args:["patient"],modifiers:{on:"destination"}},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}]},Au={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{of:["destination","source"]}},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:te,default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Du={en:"using view",es:"using view",pt:"using view",fr:"using view",de:"using view",it:"using view",ja:"using view",ko:"using view",zh:"using view",ar:"using view",he:"using view",hi:"using view",bn:"using view",tr:"using view",ru:"using view",uk:"using view",pl:"using view",id:"using view",vi:"using view",th:"using view",ms:"using view",tl:"using view",sw:"using view",qu:"using view"},Bt={role:"manner",description:"Run the swap inside a `document.startViewTransition()` (`using view transition`)",required:false,expectedTypes:["literal","expression"],valueShape:"keyword",markerOverride:Du},Bu={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",ast:{args:["method","destination","patient"],modifiers:{viewTransition:"manner"}},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:te,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",tl:""}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with",es:"con",fr:"avec",pt:"com",it:"con",de:"mit",pl:"z",ru:"\u0441",uk:"\u0437",id:"dengan",ms:"dengan",sw:"na",th:"\u0E14\u0E49\u0E27\u0E22",vi:"v\u1EDBi",he:"\u05E2\u05DD",zh:"\u7528",hi:"\u0938\u0947",bn:"\u09A6\u09BF\u09AF\u09BC\u09C7",tr:"ile",qu:"wan",ar:"\u0628\u0640",tl:"nang"}},{...Bt,svoPosition:4,sovPosition:4}]},Su={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"patient",ast:{args:[["source","destination"]],modifiers:{on:"patient",viewTransition:"manner"}},roles:[{role:"patient",description:"The element to morph",required:true,expectedTypes:te,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"}},{...Bt,svoPosition:3,sovPosition:3}]},xu={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}]},Tu={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Fu={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","property-path"],svoPosition:1,sovPosition:1}]},Lu={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[],bareKeyword:true},Ou={action:"pick",description:"Select item(s), character(s), a range, first/last/random N, or regex matches from a root",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The range/count/index/regex argument to pick",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The root to pick from (with "of"/"from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Ru={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",ast:{args:["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"}}]},Pu={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"},Nu={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:Ur}]},Mu={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:Ur}]},_u={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",ast:{args:["patient"],modifiers:{viewTransition:"manner"}},roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Pu},{...Bt,svoPosition:2,sovPosition:2}]},Iu={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"],valueShape:"object",svoPosition:2,sovPosition:1}]},ue={toggle:zo,add:ko,remove:bo,put:Dt,set:Ao,show:Oo,hide:Ro,on:Po,trigger:No,wait:Mo,fetch:_o,increment:Io,decrement:jo,append:$o,prepend:Vo,log:qo,get:Wo,take:Ko,make:Ho,halt:Uo,settle:Go,throw:Yo,send:Zo,if:Jo,unless:Xo,else:Qo,repeat:eu,for:ru,while:tu,continue:nu,go:au,scroll:Ru,push:Nu,replace:Mu,process:_u,transition:ou,clone:uu,focus:su,blur:lu,empty:cu,open:du,close:mu,select:pu,clear:fu,reset:yu,breakpoint:hu,call:vu,return:Eu,js:gu,tell:Cu,default:wu,init:zu,behavior:ku,install:bu,measure:Au,swap:Bu,morph:Su,beep:xu,break:Tu,copy:Fu,exit:Lu,pick:Ou,render:Iu,bind:Do,live:Bo,when:So,eventsource:xo,socket:To,worker:Fo,intercept:Lo,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function oe(t){return ue[t]}function ju(){return Object.values(ue).filter(t=>t.structuralOnly!==true&&(t.roles.length>0||t.bareKeyword===true))}typeof process<"u"&&process.env.LOKASCRIPT_SCHEMA_VALIDATION==="1"&&Promise.resolve().then(()=>(oo(),In)).then(({validateAllSchemas:t,formatValidationResults:e})=>{let r=t(ue);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
4
+ 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 Kn=new Set(["me","my","myself","you","your","yourself","it","its","result","event","target","body","detail","window","document","true","false","null","undefined","empty"]),Ve=new Map,Oe=new Map,Er=new Map,pt=null;function Hn(t,e){let r={...t};for(let n of Object.keys(e)){let i=e[n],a=t[n];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof a=="object"&&a!==null&&!Array.isArray(a)?r[n]=Hn(a,i):r[n]=i);}return r}function $u(t,e){return Hn(t,e)}function St(t){if(!t.extends)return t;let e=Oe.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=St(e);return $u(r,t)}function lr(t,e,r){Ve.set(t,e),Oe.set(t,r),Er.delete(t);}function Un(t){pt=t;}var Jt=new Map;function ir(t){return t.split("-")[0]}function ar(t){return t.includes("-")}function Vu(t){let e=Ve.get(t);if(!e&&ar(t)){let r=ir(t);e=Ve.get(r);}if(!e){let r=Array.from(Ve.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 qu(t){let e=Oe.get(t);if(!e&&ar(t)){let r=ir(t);e=Oe.get(r);}if(!e){let r=Array.from(Oe.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 St(e)}function L(t){let e=Oe.get(t);return !e&&ar(t)&&(e=Oe.get(ir(t))),e?St(e):void 0}function Wu(){return Array.from(Ve.keys())}function Gn(t){if(Ve.has(t)&&Oe.has(t))return true;if(ar(t)){let e=ir(t);return Ve.has(e)&&Oe.has(e)}return false}function Ku(t,e){let n=Vu(e).tokenize(t);return e==="en"?n:Uu(n,e)}var Yn=()=>false;function Hu(t){Yn=t;}function Uu(t,e){let r=t.tokens,n=[],i=false;for(let a=0;a<r.length;a++){let o=r[a],u=r[a-1],s=a+2;for(;s<r.length&&r[s]?.value!==")"&&r[s-1].position.end===r[s].position.start;)s++;let l=r.slice(a+1,s),c=l.map(p=>p.value).join(""),d=l[0],m=l[l.length-1];if(o.value==="("&&d&&m&&r[s]?.value===")"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(c)&&!(d.kind!=="particle"&&Kn.has((d.normalized??d.value).toLowerCase()))&&Yn(c,e)&&o.position.end===d.position.start&&m.position.end===r[s].position.start&&!(u&&u.position.end===o.position.start&&/[\p{L}\p{N}_)\]]$/u.test(u.value))){n.push({value:`(${c})`,kind:"identifier",position:{...o.position,end:r[s].position.end}}),a=s,i=true;continue}n.push(o);}return i?new ce(n,e):t}function me(t){let e=Er.get(t);if(!e&&ar(t)&&(e=Er.get(ir(t))),e)return e;let r=Jt.get(t);if(!r&&ar(t)&&(r=Jt.get(ir(t))),r)return Er.set(t,r),r;if(!pt)throw new Error(`No patterns registered for language '${t}'. Either import the language module or set a pattern generator.`);let n=qu(t),i=pt(n);return Er.set(t,i),i}var Zn={possessive:{specialForms:{me:"my",it:"its",you:"your"}}};function Te(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 Z(t,e){let r={type:"literal",value:t};return e!==void 0?{type:"literal",value:t,dataType:e}:r}function Jn(t){if(t==="true")return Z(true,"boolean");if(t==="false")return Z(false,"boolean");if(t==="null")return {type:"expression",raw:"null"}}function xe(t){return it(t)}function ke(t){return {type:"reference",value:t}}function Xn(t,e){return e?{...t,position:e}:t}function Fe(t,e,r){return r?{type:"property-path",object:t,property:e,access:r}:{type:"property-path",object:t,property:e}}function de(t,e,r){let n={kind:"command",action:t,roles:new Map(Object.entries(e))};return r!==void 0?{...n,metadata:r}:n}function hr(t,e,r,n,i,a){let o=new Map;o.set("event",t);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),n!==void 0&&(u.metadata=n),i!==void 0&&i.length>0&&(u.parameterNames=i),u}function gs(t,e,r,n,i){let a={kind:"behavior",action:"behavior",roles:new Map,name:t,parameters:e,eventHandlers:r};return n!==void 0&&n.length>0&&(a.initBlock=n),i!==void 0&&(a.metadata=i),a}function Cs(t,e,r,n){let i={kind:"def",action:"def",roles:new Map,name:t,parameters:e,body:r};return n!==void 0&&(i.metadata=n),i}function ft(t,e,r,n,i){let a={kind:"feature",action:t,roles:i??new Map,body:e};return r!==void 0&&(a.name=r),n!==void 0&&(a.metadata=n),a}function er(t,e="then",r){let n={kind:"compound",action:"compound",roles:new Map,statements:t,chainType:e};return r!==void 0&&(n.metadata=r),n}function ws(t,e,r,n){let i=new Map;i.set("condition",t);let a={kind:"conditional",action:"if",roles:i,thenBranch:e};return r!==void 0&&(a.elseBranch=r),n!==void 0&&(a.metadata=n),a}function zs(t,e,r,n,i){let a={kind:"loop",action:t,loopVariant:e,roles:new Map(Object.entries(r)),body:n};return i?.loopVariable&&(a.loopVariable=i.loopVariable),i?.indexVariable&&(a.indexVariable=i.indexVariable),i?.metadata&&(a.metadata=i.metadata),a}function Mr(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)):t==="expression"?e.some(r=>["selector","reference","expression"].includes(r)):false}function ks(t,e){let r=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];if(r!==void 0){let i=bs(t,e.code,r);return {primary:r,...i&&{alternatives:i},position:n?.position??"before",isOverride:true}}if(n&&n.primary){let i={primary:n.primary,position:n.position,isOverride:false};return n.alternatives&&(i.alternatives=n.alternatives),i}return null}function bs(t,e,r){let n=t.markerLegacy?.[e];if(!n?.length)return;let i=[...new Set(n)].filter(a=>a&&a!==r);return i.length?i:void 0}function Re(t,e,r){let n=t.markerLegacy?.[e]??[],i=t.methodCarrier?[]:t.markerVariants?.[e]??[],a=[...new Set([...n,...i])].filter(o=>o&&o!==r);return a.length?a:void 0}var Ar=new Set(["destination","source","patient","object","event","eventmarker","manner","instrument","style"]);function Ae(t,e){let r=t.possessive?.keywords?.[e];if(r)return r;let n=t.possessive?.specialForms;if(n){for(let[i,a]of Object.entries(n))if(a===e)return i}}function at(t){return Zn.possessive?.specialForms?.[t]??`${t}'s`}var Gr=new Set(["+","-","*","/","%","<",">","<=",">=","==","!=","===","!=="]),Qn=new Set(["<",">","<=",">=","==","!=","===","!=="]),Me=new Set([...Gr,"mod"]),As=/^[<>=!+\-*/%]+$/,ei={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0627\u0644\u0646\u0647\u0627\u064A\u0629"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};function Ds(t){return ei[t]}function Yr(t,e){return ei[e]?.has(t.toLowerCase())??false}var ri={ar:["\u0645\u0631\u0627\u062A","\u0645\u0631\u0629"],bn:["\u09AC\u09BE\u09B0"],de:["mal","Mal"],es:["veces","vez"],fr:["fois"],he:["\u05E4\u05E2\u05DE\u05D9\u05DD","\u05E4\u05E2\u05DD"],hi:["\u092C\u093E\u0930"],id:["kali"],it:["volte","volta"],ja:["\u56DE","\u5EA6"],ko:["\uBC88","\uD68C"],ms:["kali"],pl:["razy","raz"],pt:["vezes","vez"],qu:["kuti"],ru:["\u0440\u0430\u0437","\u0440\u0430\u0437\u0430"],sw:["mara"],th:["\u0E04\u0E23\u0E31\u0E49\u0E07"],tl:["beses"],tr:["kez","kere","defa"],uk:["\u0440\u0430\u0437\u0456\u0432","\u0440\u0430\u0437\u0438","\u0440\u0430\u0437"],vi:["l\u1EA7n"],zh:["\u6B21","\u904D"]},xt={ar:{\u0642\u064A\u0645\u0629:"value"},bn:{\u0985\u0995\u09CD\u09B7\u09AE:"disabled",\u0986\u0987\u09A1\u09BF:"id","\u099A\u09C7\u0995 \u0995\u09B0\u09BE":"checked",\u09A6\u09C8\u09B0\u09CD\u0998\u09CD\u09AF:"length",\u09AE\u09BE\u09A8:"value"},de:{wert:"value"},es:{valor:"value"},fr:{valeur:"value"},hi:{\u0905\u0915\u094D\u0937\u092E:"disabled",\u091A\u0947\u0915:"checked",\u091B\u093F\u092A\u093E:"hidden",\u092E\u093E\u0928:"value"},id:{nilai:"value"},it:{valore:"value"},ja:{\u5024:"value"},ko:{\uAC12:"value"},ms:{dilumpuhkan:"disabled",ditanda:"checked",nilai:"value",panjang:"length"},pl:{warto\u015B\u0107:"value"},pt:{valor:"value"},qu:{chanin:"value"},ru:{\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435:"value",\u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043E:"disabled",\u043E\u0442\u043C\u0435\u0447\u0435\u043D\u043E:"checked",\u0441\u043A\u0440\u044B\u0442\u043E:"hidden"},sw:{thamani:"value"},th:{\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27:"length",\u0E04\u0E48\u0E32:"value",\u0E1B\u0E34\u0E14\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19:"disabled",\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E41\u0E25\u0E49\u0E27:"checked",\u0E44\u0E2D\u0E14\u0E35:"id"},tl:{haba:"length",halaga:"value",hindi_pinagana:"disabled",naka_tsek:"checked"},tr:{de\u011Fer:"value"},uk:{\u0432\u0438\u043C\u043A\u043D\u0435\u043D\u043E:"disabled",\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F:"value",\u043F\u043E\u0437\u043D\u0430\u0447\u0435\u043D\u043E:"checked",\u043F\u0440\u0438\u0445\u043E\u0432\u0430\u043D\u043E:"hidden"},vi:{\u1EA9n:"hidden","\u0111\u01B0\u1EE3c ch\u1ECDn":"checked","gi\xE1 tr\u1ECB":"value","v\xF4 hi\u1EC7u":"disabled"},zh:{\u503C:"value"}},Bs={ar:{\u0623\u0648:"or",\u0643\u0640:"as",\u0644\u064A\u0633:"not",\u0648:"and",\u064A\u062D\u062A\u0648\u064A:"contains",\u064A\u0633\u0627\u0648\u064A:"equals",\u064A\u0634\u0645\u0644:"includes"},bn:{\u0985\u09A5\u09AC\u09BE:"or",\u098F\u09AC\u0982:"and",\u09A8\u09BE:"not",\u09B9\u09BF\u09B8\u09BE\u09AC\u09C7:"as"},de:{als:"as",beinhaltet:"includes",enth\u00E4lt:"contains",gleicht:"equals",nicht:"not",oder:"or",und:"and"},es:{como:"as",contiene:"contains",iguala:"equals",incluye:"includes",no:"not",o:"or",y:"and"},fr:{comme:"as",contient:"contains",\u00E9gale:"equals",et:"and",inclut:"includes",non:"not",ou:"or"},he:{\u05D5\u05D2\u05DD:"and"},hi:{\u0914\u0930:"and",\u0915\u0947_\u0930\u0942\u092A_\u092E\u0947\u0902:"as",\u0928\u0939\u0940\u0902:"not",\u092C\u0930\u093E\u092C\u0930:"equals",\u092E\u0947\u0902_\u0939\u0948:"includes",\u092F\u093E:"or",\u0936\u093E\u092E\u093F\u0932:"contains"},id:{atau:"or",berisi:"contains",bukan:"not",dan:"and",sama:"equals",sebagai:"as",termasuk:"includes"},it:{come:"as",contiene:"contains",e:"and",include:"includes",non:"not",o:"or",uguale:"equals"},ja:{\u305D\u3057\u3066:"and",\u3067\u306F\u306A\u3044:"not",\u3068\u3057\u3066:"as",\u307E\u305F\u306F:"or",\u542B\u3080:"contains",\u542B\u3081\u308B:"includes",\u7B49\u3057\u3044:"equals"},ko:{\uAC19\uB2E4:"equals",\uADF8\uB9AC\uACE0:"and",\uB610\uB294:"or",\uB85C:"as",\uC544\uB2C8:"not",\uD3EC\uD568:"contains",\uD3EC\uD568\uD558\uB2E4:"includes"},ms:{atau:"or",bukan:"not",dan:"and",mengandungi:"contains",sama:"equals",sebagai:"as",termasuk:"includes"},pl:{i:"and",jako:"as",lub:"or",nie:"not",obejmuje:"includes","r\xF3wna si\u0119":"equals",zawiera:"contains"},pt:{como:"as",cont\u00E9m:"contains",e:"and",igual:"equals",inclui:"includes",n\u00E3o:"not",ou:"or"},qu:{churasqa:"includes",hina:"as",hinallataq:"and",kikin:"equals",ukupi_kan:"contains",utaq:"or"},ru:{\u0432\u043A\u043B\u044E\u0447\u0430\u0435\u0442:"includes",\u0438:"and",\u0438\u043B\u0438:"or",\u043A\u0430\u043A:"as",\u043D\u0435:"not",\u0440\u0430\u0432\u043D\u043E:"equals",\u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442:"contains"},sw:{au:"or",ina:"contains",kuwa:"as",pamoja:"includes",sawa:"equals",si:"not"},th:{\u0E44\u0E21\u0E48:"not",\u0E41\u0E25\u0E30:"and",\u0E2B\u0E23\u0E37\u0E2D:"or"},tl:{at:"and",bilang:"as",hindi:"not",katumbas:"equals",naglalaman:"contains",o:"or"},tr:{de\u011Fil:"not",e\u015Fittir:"equals",i\u00E7erir:"contains",olarak:"as",ve:"and",veya:"or"},uk:{\u0430\u0431\u043E:"or",\u0432\u043A\u043B\u044E\u0447\u0430\u0454:"includes",\u0434\u043E\u0440\u0456\u0432\u043D\u044E\u0454:"equals",\u0456:"and",\u043C\u0456\u0441\u0442\u0438\u0442\u044C:"contains",\u043D\u0435:"not",\u044F\u043A:"as"},vi:{b\u1EB1ng:"equals",ch\u1EE9a:"contains",ho\u1EB7c:"or",kh\u00F4ng:"not",nh\u01B0:"as",v\u00E0:"and"},zh:{\u4F5C\u4E3A:"as",\u5305\u542B:"contains",\u5305\u62EC:"includes",\u548C:"and",\u6216:"or",\u7B49\u4E8E:"equals",\u975E:"not"}},ti={ms:new Set(["daripada"]),sw:new Set(["ya"]),vi:new Set(["c\u1EE7a"]),zh:new Set(["\u7684"]),it:new Set(["di"]),pl:new Set(["z"]),uk:new Set(["\u0437"]),th:new Set(["\u0E02\u0E2D\u0E07"]),ar:new Set(["\u0644\u0640"]),ja:new Set(["\u306E"]),ko:new Set(["\uC758"]),bn:new Set(["\u09B0"]),hi:new Set(["\u0915\u093E"]),qu:new Set(["pa"]),tr:new Set(["nin","n\u0131n","nun","n\xFCn","in","\u0131n","un","\xFCn"])};function Ie(t,e){let r=e.value.toLowerCase(),n=(e.normalized??"").toLowerCase();if(r==="of"||r==="ng"||n==="of"||n==="source")return true;let i=t?.code?ti[t.code]:void 0;return !!i&&i.has(r)}var Ss={destination:"in",source:"from"},ni={ar:new Set(["\u0639\u0646\u062F","\u0641\u064A"]),bn:new Set(["\u098F","\u09A4\u09C7"]),de:new Set(["bei"]),es:new Set(["en"]),fr:new Set(["dans","en","\xE0"]),he:new Set(["\u05DC\u05EA\u05D5\u05DA"]),hi:new Set(["\u092A\u0930","\u092E\u0947\u0902"]),id:new Set(["dalam","di","ke_dalam"]),it:new Set(["a"]),ja:new Set(["\u3067","\u306E\u4E2D","\u3078"]),ko:new Set(["\uC548\uC5D0","\uC5D0","\uC73C\uB85C"]),ms:new Set(["dalam","di","ke_dalam"]),pl:new Set(["do","przy","w"]),pt:new Set(["dentro","em"]),qu:new Set(["pi","ukupi"]),ru:new Set(["\u0432","\u0443"]),sw:new Set(["katika","ndani"]),th:new Set(["\u0E17\u0E35\u0E48","\u0E43\u0E19"]),tl:new Set(["papasok_sa","sa","sa_loob"]),tr:new Set(["de","i\xE7inde","i\xE7ine"]),uk:new Set(["\u0432","\u0443"]),vi:new Set(["trong","t\u1EA1i","v\xE0o"]),zh:new Set(["\u5728","\u8FDB\u5165"])},ii=new Set(["in","into","at","within","inside"]);function xs(t,e){let r=e.value.toLowerCase();if((t?.code?ni[t.code]:void 0)?.has(r))return "in";let i=e.normalized??e.value,a=i.toLowerCase();return ii.has(a)?"in":Ss[a]??i}function Ts(t,e){return e.value.toLowerCase()==="in"||(t?.code?ni[t.code]:void 0)?.has(e.value.toLowerCase())?true:ii.has((e.normalized??e.value).toLowerCase())}var Fs=new Set(["me","it","you","body","document","target","result"]);function Ls(t,e){let r=t[e];if(!r)return null;if(r.kind==="selector")return /^[*@]/.test(r.value)?null:{kind:"selector",parts:[{text:r.value,token:r}],consumed:1};let n=(r.normalized??r.value).toLowerCase();if(Fs.has(n))return {kind:"reference",parts:[{text:n,token:r}],consumed:1};let i=t[e+1];return n==="closest"&&i?.kind==="selector"&&!/^[*@]/.test(i.value)?{kind:"closest",parts:[{text:"closest",token:r},{text:i.value,token:i}],consumed:2}:null}function ai(t,e,r,n){let i=t[e];if(!i||!Ts(r,i))return null;let a=Ls(t,e+1);if(!a)return null;let o=t[e+1+a.consumed];return n?.(i)===true&&n(o)!==true?null:{marker:i,scope:a}}var ot=new Set(["first","last","next","previous","random","closest"]),Os={bn:{\u09B6\u09C7\u09B7:"last"}},cr=new Set(Object.keys(ue).map(t=>t.toLowerCase()));function zr(t,e,r,n){let i=t[e];if(!i)return null;let a=(i.normalized??i.value).toLowerCase(),o=t[e+1],u=r?.code&&o?.kind==="selector"&&o.value.startsWith("<")?Os[r.code]?.[i.value.toLowerCase()]:void 0;if(!ot.has(a)&&!ot.has(i.value.toLowerCase())&&u===void 0)return null;let s=[{text:u??i.normalized??i.value,token:i}],l=e+1,c=t[l];if(!c||c.kind!=="selector"||Qn.has(c.value))return null;s.push({text:c.value,token:c}),l++;let d=0;for(;d++<8;){let f=t[l];if(f&&f.kind==="selector"&&f.value.startsWith("."))s.push({text:f.value,token:f}),l++;else break}let m=t[l],p=t[l+1];if(m&&p&&p.kind==="selector"&&!/^[*@]/.test(p.value)&&(m.kind==="keyword"||m.kind==="particle"||m.kind==="identifier")&&!ot.has((m.normalized??m.value).toLowerCase())&&!cr.has((m.normalized??m.value).toLowerCase())&&!(n?.(m)===true&&n(t[l+2])!==true))s.push({text:xs(r,m),token:m}),s.push({text:p.value,token:p}),l+=2;else {let f=ai(t,l,r,n);f&&f.scope.kind!=="selector"&&(s.push({text:"in",token:f.marker},...f.scope.parts),l+=1+f.scope.consumed);}return {parts:s,consumed:l-e}}function qe(t,e){let r=Bs[t];return r?r[e.toLowerCase()]??e:e}function ye(t,e){let r=xt[t];return r?r[e.toLowerCase()]??e:e}function en(t,e){return xt[t]?.[e.toLowerCase()]!==void 0}function Rs(t,e){let r=[e.value,e.normalized].filter(Boolean);for(let n of r){let i=Ae(t,n)??Ae(t,n.toLowerCase());if(i)return i}}function oi(t){return t.kind==="literal"||t.kind==="operator"||t.kind==="punctuation"?false:!/^[$:@#.*^(){}[\]]/.test(t.value)}function Ps(t,e){let r=t?.references;if(!r)return false;let n=Object.values(r).filter(a=>typeof a=="string").map(a=>a.toLowerCase());return [e.value,e.normalized].filter(Boolean).some(a=>n.includes(a.toLowerCase()))}function tr(t,e){return oi(t)?ye(e,t.value)!==t.value?true:t.kind==="identifier":false}var Ns=new Set(["true","false","null","undefined","me","my","it","its","you","your","result","event","target","body","detail","document","window"]);function ui(t){return t.kind==="literal"||t.kind==="selector"||t.kind==="reference"?true:t.kind==="identifier"?_s.test(t.value):t.kind==="keyword"&&Ns.has((t.normalized??t.value).toLowerCase())}function rn(t){return !!t&&(t.value===")"||t.value==="]"||ui(t))}function yt(t){if(!t)return false;if(/^[([-]$/.test(t.value)||ui(t))return true;let e=(t.normalized??"").toLowerCase();return t.kind==="keyword"&&(e==="not"||e==="no")}var Ms=/^\.[\p{L}_-][\p{L}\p{N}_-]*$/u,_s=/^(?:[:$]?[\p{L}_][\p{L}\p{M}\p{N}_]*|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u,U={beforeClassRef:"has"},Is={ar:{\u0647\u0648:{beforePredicate:"is",afterOperand:"is"},\u0641\u0627\u0631\u063A:{afterCopula:"empty"}},hi:{\u0939\u0948:{beforePredicate:"is",beforeClassRef:"has",afterOperand:"is"},\u0916\u093E\u0932\u0940:{afterCopula:"empty"}},id:{kosong:{afterCopula:"empty"},punya:U},th:{\u0E40\u0E1B\u0E47\u0E19:{beforeTypeName:"as",beforePredicate:"is",afterOperand:"is"},\u0E27\u0E48\u0E32\u0E07:{afterCopula:"empty"},\u0E21\u0E35:U},ja:{\u7A7A:{afterCopula:"empty"},\u3042\u308B:U},sw:{tupu:{afterCopula:"empty",otherwise:"null"},na:{betweenOperands:"and"},ana:U,nina:U},zh:{\u6CA1\u6709:{beforeBareIdentifier:"no",beforeSelector:"no"},\u6709:U},tl:{walang:{beforeBareIdentifier:"no",beforeSelector:"no"},may:{afterSubject:"exists",beforeClassRef:"has"}},bn:{\u0986\u099B\u09C7:{afterSubject:"exists",beforeClassRef:"has"},\u0986\u099B\u09BF:U},qu:{mana:{beforeOperand:"not"},chusaq:{afterCopula:"empty"},kachkan:U,kachkani:U},tr:{var:{afterSubject:"exists",beforeClassRef:"has"},bo\u015F:{afterCopula:"empty"}},de:{hat:U,habe:U},es:{tiene:U,tengo:U},fr:{a:U,ai:U},it:{ha:U,ho:U},ko:{\uC788\uB2E4:U},ms:{ada:U},pl:{ma:U,mam:U},pt:{tem:U,tenho:U},ru:{\u0438\u043C\u0435\u0435\u0442:U,\u0438\u043C\u0435\u044E:U},uk:{\u043C\u0430\u0454:U,\u043C\u0430\u044E:U},vi:{c\u00F3:U}},js=new Set(["text","json","html","response","blob","arraybuffer"]),$s=new Set(["empty","null","undefined","true","false"]),si=new Set(["Number","Int","Float","String","Boolean","Date","Array","Object","JSON","json","JSONString","FormData","FormEncoded","HTML","Fragment","Values","Values:Form","Values:JSON","Set","Map","Keys","Entries","Reversed","Unique","Flat"]);function kr(t){return si.has(t)||/^Fixed(?::\d+)?$/.test(t)||/^[A-Z][A-Za-z0-9_]*(?::[A-Za-z0-9_]+)?$/.test(t)}function li(t,e,r,n,i,a){let o=ht(t,e);if(!o)return;if(o.beforeTypeName&&n?.kind==="identifier"&&a?.value!=="("&&(si.has(n.value)||js.has(n.value.toLowerCase())))return o.beforeTypeName;if(o.beforePredicate&&n&&(n.kind==="literal"||n.kind==="keyword"&&$s.has((n.normalized??"").toLowerCase())))return o.beforePredicate;if(o.afterCopula&&i!==void 0&&["is","not","does","do"].includes(i.toLowerCase()))return o.afterCopula;if(o.beforeBareIdentifier&&n?.kind==="identifier"&&/^[A-Za-z_]\w*$/.test(n.value))return o.beforeBareIdentifier;let u=!!n&&br(n,t)&&Le({prev:e,beforePrev:r,next:a},t);if(o.beforeOperand&&(yt(n)||u))return o.beforeOperand;if(o.beforeSelector&&n?.kind==="selector")return o.beforeSelector;if(o.beforeClassRef&&n&&Ms.test(n.value))return o.beforeClassRef;if(o.afterSubject&&(r?.kind==="selector"||r?.kind==="reference"))return o.afterSubject;let s=!!r&&br(r,t)&&i===r.value;return o.betweenOperands&&(rn(r)||s)&&yt(n)?o.betweenOperands:o.afterOperand&&(rn(r)||r?.value==="}")?o.afterOperand:o.otherwise}function ht(t,e){let r=Is[t];return r?.[e.value]??r?.[e.value.toLowerCase()]}function Vs(t,e,r,n){return li(t,e,r,n,void 0,void 0)}function qs(t){return As.test(t)||t==="("||t==="["||t===","}function Ws(t){return Gr.has(t)&&t!=="-"||t===")"||t==="]"||t===","}var Ks=new Set(["is","am","contains","contain","matches","match","has","have","includes","include","exists","exist","mod"]);function ci(t,e,r,n){let i=e.kind==="keyword"?(e.normalized??"").toLowerCase():qe(t,e.value).toLowerCase();if(i!=="and"&&i!=="or")return false;if(r===void 0||r!==void 0&&qs(r.value))return true;if(n===void 0)return false;if(Ws(n.value))return true;let a=n.kind==="keyword"?(n.normalized??n.value).toLowerCase():qe(t,n.value).toLowerCase();return Ks.has(a)}var Hs=new Set(["include","contain","match","exist"]);function di(t){let e=t?.toLowerCase();return e==="is"||e==="not"}function mi(t,e,r){let n=e[r],i=e[r-1];return !n||!i||n.value.toLowerCase()!=="in"?false:di(or(t,i,e[r-2],n,void 0))}function or(t,e,r,n,i,a){if(i?.toLowerCase()==="equal"&&e.value.toLowerCase()==="to")return "to";if(di(i)&&e.value.toLowerCase()==="in")return "in";if(i?.toLowerCase()==="not"&&Hs.has(e.value.toLowerCase()))return e.value.toLowerCase();let o=li(t,e,r,n,i,a);if(o!==void 0)return o;if(ci(t,e,r,n))return e.value;let u=qe(t,e.value);if(u!==e.value)return u;if(e.kind!=="keyword")return e.value;let s=(e.normalized??e.value).toLowerCase();return s!=="event"&&Ar.has(s)||br(e,t)&&Le({prev:r,next:n,afterNext:a},t)?e.value:e.normalized??e.value}function pi(t,e,r,n){let i=t[e],a=t[e+1];if(!i||!a||!oi(i)||!Ie(r,a)||!tr(i,n))return;if(t[e+2]?.kind==="selector")return e+2;let o=e;for(;t[o]!==void 0&&t[o+1]!==void 0&&Ie(r,t[o+1])&&tr(t[o],n);)o+=2;return o>e+2&&t[o]?.kind==="selector"?o:void 0}var Us=new Set(["if","unless","while","until","for","when","where","is","not","no","and","or","as"]);function Gs(t){let e=(t.normalized??t.value).toLowerCase();return e==="event"||xe(e)?false:Us.has(e)||Ar.has(e)}function br(t,e){return t.kind!=="keyword"?false:(t.normalized??t.value).toLowerCase()==="end"||Yr(t.value,e)}function he(t,e){return {prev:t[e-1],beforePrev:t[e-2],third:t[e-3],next:t[e+1],afterNext:t[e+2]}}var Ys=new Set(["and","or","is","times"]),Zs=new Set(["if","unless","while","until","is","and","or","in"]),Js=t=>Object.prototype.hasOwnProperty.call(ue,t);function ut(t){if(t.kind!=="keyword"&&!(t.normalized&&t.normalized!==t.value))return;let e=(t.normalized??t.value).toLowerCase();return Js(e)?e:void 0}var tn=new WeakMap;function nn(t,e,r=false){let n;try{n=me(t);}catch{return new Set}let i=tn.get(n);i||(i=new Map,tn.set(n,i));let a=r?`${e} before a role pair`:e,o=i.get(a);if(!o){o=new Set;for(let u of n){if(u.command!==e)continue;let[s,l,c,d]=u.template.tokens;if(!(s?.type!=="literal"||l?.type!=="literal")&&!(r&&(c?.type!=="role"||d?.type!=="role")))for(let m of [l.value,...l.alternatives??[]])o.add(m.toLowerCase());}i.set(a,o);}return o}var an=new WeakMap;function Xs(t){let e;try{e=me(t);}catch{return new Set}let r=an.get(e);if(!r){let n=new Set(Object.values(L(t)?.roleMarkers??{}).flatMap(a=>a?[a.primary,...a.alternatives??[]]:[]).map(a=>a.toLowerCase())),i=new Set;for(let a of e){if(a.command!=="repeat")continue;let o=a.template.tokens;o.forEach((u,s)=>{if(!(u.type!=="literal"||o[s+1]?.type!=="role"))for(let l of [u.value,...u.alternatives??[]])n.has(l.toLowerCase())||i.add(l.toLowerCase());});}r=i,an.set(e,r);}return r}function on(t){return t.kind==="particle"?true:t.kind==="keyword"&&Ar.has((t.normalized??"").toLowerCase())}function un(t,e){return t.kind==="keyword"&&t.normalized?t.normalized.toLowerCase():qe(e,t.value).toLowerCase()}function Le(t,e){let{prev:r,beforePrev:n,next:i,afterNext:a}=t;if(i){if(Me.has(i.value)||Ys.has((i.normalized??i.value).toLowerCase())||i.value==="'"&&a?.value.toLowerCase()==="s")return true;let f=ht(e,i)?.betweenOperands;if((f==="and"||f==="or")&&yt(a))return true}let o=L(e),u=!!o&&o.markingStrategy!=="preposition";if(u&&i?.kind==="particle"&&a?.kind!=="particle")return true;if(!r)return false;if(Gr.has(r.value))return true;let s=un(r,e);if(s==="not"||s==="no"||ht(e,r)?.beforeOperand==="not")return true;let l=o?.wordOrder!=="SOV",c=t.third?ut(t.third):void 0;if(c&&n&&nn(e,c,true).has(n.value.toLowerCase()))return true;let d=n&&l?ut(n):void 0;if(d&&!nn(e,d).has(r.value.toLowerCase())||n&&!u&&on(n))return false;if(Zs.has(s))return true;let m=!!n&&un(n,e)!=="repeat"&&!!ri[e]?.includes(r.value);if(Xs(e).has(r.value.toLowerCase())&&(l||s!=="repeat")&&!m)return true;let p=l?ut(r):void 0;return p&&ue[p].roles.some(f=>f.required)?true:!u&&on(r)}function fi(t){if(t.kind==="keyword")return Gs(t)?"structure":cr.has((t.normalized??t.value).toLowerCase())?"verb":void 0}function Be(t,e){let r=e?.code??"en",[n]=t;if(t.length===1&&n&&(fi(n)||br(n,r)))return n.value;let i="",a,o,u=(s,l)=>{if(o=s,a===void 0){i=s,a=l;return}let d=a.position?.end!==void 0&&l.position?.start!==void 0&&a.position.end===l.position.start&&(s.startsWith(".")||s.startsWith("!"));i+=(d?"":" ")+s,a=l;};for(let s=0;s<t.length;s++){let l=t[s],c=e?Rs(e,l):void 0,d=t[s+1];if(l.value===":"&&a!==void 0&&o!==void 0&&d!==void 0&&a.position?.end===l.position?.start&&l.position?.end===d.position?.start&&kr(`${o}:${d.value}`)){i+=`:${d.value}`,o=`${o}:${d.value}`,a=d,s+=1;continue}if(l.value==="'"&&a!==void 0&&d?.value==="s"&&l.position?.end!==void 0&&d.position?.start===l.position.end){i+="'s",a=d;let h=t[s+2];h&&ye(r,h.value)!==h.value?(u(ye(r,h.value),h),s+=2):s+=1;continue}let m=e?.possessive,p=t[s+2];if(m?.markerPosition==="between"&&m.marker&&l.kind==="selector"&&d?.value===m.marker&&p!==void 0&&tr(p,r)){u(`${l.value}'s`,l),u(ye(r,p.value),p),s+=2;continue}if(d?.value.toLowerCase()==="of"&&ye(r,l.value)!==l.value&&tr(l,r)){u(ye(r,l.value),l);continue}if(c!==void 0&&d){let h=e?.possessive?.connectors,E=!!h?.length&&h.some(g=>{let A=g.toLowerCase();return A===d.value.toLowerCase()||A===(d.normalized??"").toLowerCase()}),C=E?s+2:s+1,z=t[C];if(z&&tr(z,r)){u(at(c),l),u(ye(r,z.value),z),s=C;continue}if(E&&z&&/^\.[a-zA-Z_]\w*$/.test(z.value)&&d.position?.end!==void 0&&z.position?.start!==void 0&&d.position.end===z.position.start){u(at(c),l),u(ye(r,z.value.slice(1)),z),s=C;continue}if(!E&&/^\.[a-zA-Z_]\w*$/.test(d.value)&&l.position?.end!==void 0&&d.position?.start!==void 0&&l.position.end===d.position.start&&!Ps(e,l)){u(at(c),l),u(ye(r,d.value.slice(1)),d),s+=1;continue}}let f=t[s+2],y=pi(t,s,e,r);if(y!==void 0){for(let h=s;h<y;h+=2)u(ye(r,t[h].value),t[h]),u("of",t[h+1]);u(t[y].value,t[y]),s=y;continue}if(l.kind==="selector"&&d&&f&&Ie(e,d)&&tr(f,r)&&ye(r,f.value)!==f.value){u(ye(r,f.value),f),u("of",d),u(l.value,l),s+=2;continue}let v=zr(t,s,e);if(v){for(let h of v.parts)u(h.text,h.token);s+=v.consumed-1;continue}u(or(r,l,t[s-1],d,o,t[s+2]),l);}return i.trim()}function Qs(t){if(!t)return true;if(t.kind!=="keyword")return false;let e=(t.normalized??t.value).toLowerCase();return e==="then"||e==="end"||e==="else"}function yi(t){return !!t&&Me.has(t.value)}var el=class{constructor(t,e,r,n,i){this.patternToken=e,this.afterLiteral=r,this.nextPatternToken=n,this.wouldMatch=i;let a=t.position();this.token=t.tokens[a],this.prev=t.tokens[a-1],this.next=t.tokens[a+1],this.place=he(t.tokens,a);}get lastSlot(){return this.nextPatternToken===void 0}get tokenIsMarker(){return this.tokenIsMarkerMemo??(this.tokenIsMarkerMemo=this.wouldMatch(this.nextPatternToken,this.token)),this.tokenIsMarkerMemo}get beforeRole(){return this.nextPatternToken?.type==="role"}get nextIsMarker(){return this.nextIsMarkerMemo??(this.nextIsMarkerMemo=this.next!==void 0&&this.wouldMatch(this.nextPatternToken,this.next)),this.nextIsMarkerMemo}get clauseEndsAfter(){return Qs(this.next)}};function rl(t){let e=t.token.value.toLowerCase();if(e!=="a"&&e!=="an")return false;let r=t.next;return r!==void 0&&(Gr.has(r.value)||t.nextIsMarker)}function Tt(t){return t.kind==="keyword"&&cr.has((t.normalized??t.value).toLowerCase())}function tl(t,e){let r=t.token;if(r.kind!=="keyword")return false;let n=(r.normalized??r.value).toLowerCase();return n==="then"?true:(n==="end"&&t.next?.kind!=="selector"||Yr(r.value,e))&&!Le(t.place,e)}function nl(t,e){return br(t.token,e)&&Le(t.place,e)}function hi(t){return t.afterLiteral&&(t.clauseEndsAfter||t.nextIsMarker)}function il(t,e){let r=t.patternToken.role;return r!=="quantity"&&!(r==="event"&&e==="repeat")?false:Tt(t.token)&&!hi(t)&&!t.nextIsMarker}function al(t){let e=t.patternToken;return !e.optional||e.role==="event"||e.role==="action"||e.valueShape==="keyword"||!Tt(t.token)?false:(t.lastSlot||t.tokenIsMarker)&&!hi(t)}function ol(t,e,r,n){let i=t.type==="group"&&t.optional?t.tokens.every(o=>o.type==="role")?t.tokens[0]:void 0:t;if(!i||i.type!=="role"||!i.optional||i.role==="event"||i.role==="action"||i.valueShape==="keyword"||!e||e.kind!=="keyword"||r===void 0)return false;let a=n(r,e);return Tt(e)?!a:a}function ul(t){return cr.has((t.normalized??t.value).toLowerCase())}function sl(t,e){return t?.kind==="particle"&&!!e&&["selector","literal","identifier"].includes(e.kind)&&!yi(e)}function ll(t){if(t.token.kind!=="particle")return false;let e=t.next;return e!==void 0&&t.nextIsMarker&&(e.kind==="particle"||t.prev?.kind==="particle")||t.afterLiteral&&t.beforeRole||t.clauseEndsAfter}function cl(t,e){let r=t.patternToken;if(r.role==="event"||r.role==="action"||r.valueShape==="keyword")return false;let n=r.expectedTypes;if(n?.length&&!n.some(a=>a==="expression"||a==="reference"))return false;let i=fi(t.token);return i==="structure"?true:i!=="verb"||(t.token.normalized??t.token.value).toLowerCase()==="empty"?false:!e?.hasBody&&!e?.roles.some(a=>a.role==="event")}function dl(t){let e=(t.normalized||t.value).toLowerCase();if(e==="empty")return Jn("null");if(e==="a"||e==="an")return {type:"expression",raw:t.value}}function ml(t,e,r){return t.kind==="particle"&&(e||yi(r))}function vi(t,e){let r=t[e];return r?.kind==="particle"&&t[e-1]?.value.toLowerCase()==="of"&&/^[\p{L}_$][\p{L}\p{M}\p{N}_$]*$/u.test(r.value)}var sn=new Set(["is","am","are","be","was","were","not","no"]),pl=new Set(["\u0647\u0648","\u0E40\u0E1B\u0E47\u0E19","\u0939\u0948","\u0928\u0939\u0940\u0902","mana"]),Ei=new Set(["empty","null","undefined"]);function fl(t,e,r,n){let i=(t.normalized??t.value).toLowerCase(),a=t.value.toLowerCase(),o=(e.normalized??e.value).toLowerCase();return (sn.has(i)||sn.has(qe(n,a))||pl.has(a)&&Ei.has(o))&&!r}var yl=new Set(["'s","a","am","an","and","as","closest","contain","contains","do","does","empty","equal","equals","exist","exists","false","first","greater","has","have","in","include","includes","is","it","its","last","less","match","matches","me","mod","my","next","no","not","null","of","or","previous","really","some","than","the","true","undefined","you","your","result","target","body","detail"]),hl=new Set(["am","and","as","contain","contains","do","does","empty","equal","equals","exist","exists","greater","has","have","in","include","includes","is","less","match","matches","mod","no","not","of","or","really","some","than"]),ln=/\s+as\s+([A-Za-z]\w*)!?\s*$/;function gi(t){let e=t;for(let i=ln.exec(e);i;i=ln.exec(e)){if(!kr(i[1]??""))return false;e=e.slice(0,i.index);}let r=e.replace(/"[^"]*"|'[^']*'/g,"");if(/["']/.test(r.replace(/'s\b/g,""))||/[^\x00-\x7F]/.test(r))return false;let n=Co(e);return !n.success||n.consumed===void 0||n.consumed!==Wn(e).length-1?false:vl(n.node).every(kr)}function vl(t){let e=[],r=n=>{if(Array.isArray(n)){n.forEach(r);return}if(!n||typeof n!="object")return;let i=n;i.type==="asExpression"&&e.push(String(i.targetType?.name??"")),Object.values(n).forEach(r);};return r(t),e}function gr(t,e){return t?.position?.end!==void 0&&e?.position?.start!==void 0&&t.position.end===e.position.start}var El=new Set(["is","not","really","am","or"]);function Ci(t,e,r){let n=i=>{let a=t[i];return a?or(r,a,t[i-1],t[i+1],void 0).toLowerCase():""};return n(e)==="to"&&n(e-1)==="equal"&&El.has(n(e-2))}function gl(t){return t.value==="a"}var Cl=new Set(["event","window","document"]);function wl(t,e,r){let n=t[e],i=t[e-1];return !n||!i||!Ie(r,i)?false:Cl.has((n.normalized??n.value).toLowerCase())}function zl(t,e){if(t.kind==="conjunction")return true;if(t.kind==="keyword"){let r=(t.normalized??t.value).toLowerCase();if(r==="then"||r==="end"||r==="else"||Yr(t.value,e.profile?.code??""))return true}return e.owes(t)}function cn(t,e,r){let n=r.profile?.code??"en";if(mi(n,t,e)||vi(t,e)||Ci(t,e,n)||gl(t[e]))return false;let i=t[e];return zl(i,r)||r.commandMarkers.has(i.value.toLowerCase())}function kl(t,e,r){let n=t[e],i=t[e-1],a=r.profile?.code??"en";if(n.kind==="literal"||n.value==="'"&&t[e+1]?.value==="s"||n.value==="s"&&i?.value==="'")return true;if(n.kind==="selector"){if(!n.value.startsWith(".")||!i||gr(i,n)||Me.has(i.value)||/^[([,]$/.test(i.value)||Ie(r.profile,i))return true;let u=or(a,i,t[e-2],n,void 0).toLowerCase();return hl.has(u)}if(Me.has(n.value)||/^[()[\],.!<>=+\-*/%]+$/.test(n.value)||Ie(r.profile,n)||ci(a,n,i,t[e+1])||mi(a,t,e)||vi(t,e)||wl(t,e,r.profile)||Ci(t,e,a))return true;let o=or(a,n,i,t[e+1],void 0).toLowerCase();return o==="as"&&r.hasResponseType?false:yl.has(o)?true:n.kind==="identifier"&&/^(?:[\p{L}_$][\p{L}\p{M}\p{N}_$]*('s)?|\([\p{L}_$][\p{L}\p{M}\p{N}_$]*\))$/u.test(n.value)}function bl(t,e,r){if(!t[e]||cn(t,e,r))return [];let n=e;for(;n<t.length&&!cn(t,n,r)&&kl(t,n,r);)n++;let i=[];for(let a=n;a>e;a--)i.push(a);return i}function Al(t,e,r){let n=[],i=e;for(;;){let a=t[i];if(!a)break;if(a.value==="'"&&t[i+1]?.value==="s"&&t[i+2])i+=3;else if(/.'s$/.test(t[i-1]?.value??""))i+=1;else if(Ie(r,a)&&t[i+1])i+=2;else break;n.push(i);}return n.reverse()}function Dl(t,e,r,n){for(let i of r){let a=Be(t.slice(e,i),n);if(gi(a))return {end:i,raw:a}}}[...Dt.roles.find(t=>t.role==="destination")?.expectedTypes??[]];[...Dt.roles.find(t=>t.role==="patient")?.expectedTypes??[]];var wi=[{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 st(t,e,r,n){let i=wi.find(o=>o.lang===t);if(!i)return false;let a=(o,u)=>(o??"").toLowerCase()===u.toLowerCase();return a(e,i.end)&&a(r,i.at)&&a(n,i.of)}function Bl(t,e){let r=wi.find(i=>i.lang===t);if(!r)return false;let n=e.toLowerCase();return n===r.at.toLowerCase()||n===r.of.toLowerCase()||n===r.end.toLowerCase()}var zi=96,Sl=/^[A-Za-z_][\w-]*$/,xl=/^[A-Za-z_][\w-]*:[^\s'"`/:][^\s]*$/;function ki(t,e){let r=t.peek(e);return !!r&&r.kind==="identifier"&&xl.test(r.value)}function bi(t,e){let r=t.peek(e);if(!r||r.kind!=="identifier"&&r.kind!=="keyword"||!Sl.test(r.value))return false;let n=t.peek(e+1),i=t.peek(e+2);return !!n&&n.value===":"&&!!i}function dn(t,e=0){return ki(t,e)||bi(t,e)}function Tl(t){let e=t.peek();if(!e||e.value!=="{"&&e.value!=="(")return null;let r="",n=-1,i=0,a=0;for(;!t.isAtEnd()&&a++<zi;){let o=t.advance();if(!o)break;if(n>=0&&o.position.start>n&&(r+=" ".repeat(o.position.start-n)),r+=o.value,n=o.position.end,o.value==="{"||o.value==="(")i++;else if((o.value==="}"||o.value===")")&&(i--,i===0))return r}return null}function mn(t){let e=t.peek();return e?e.value==="{"||e.value==="("?Tl(t):e.value===","||e.value===":"?null:(t.advance(),e.value):null}function Cr(t,e){let r=t.mark(),n=[];if(e!==void 0){let a=t.peek();if(!a||a.value!==":"||!t.peek(1))return null;t.advance();let o=mn(t);if(o===null)return t.reset(r),null;n.push(`${e}:${o}`);}else if(!dn(t))return null;let i=0;for(;i++<zi;){let a=t.peek();if(!a)break;if(a.value===","){if(n.length===0||!dn(t,1))break;t.advance();continue}if(ki(t,0)){n.push(t.advance().value);continue}if(!bi(t,0))break;let o=t.advance().value;t.advance();let u=mn(t);if(u===null)return t.reset(r),null;n.push(`${o}:${u}`);}return n.length===0?(t.reset(r),null):`{${n.join(", ")}}`}function Vr(t){switch(t.kind){case "selector":return Te(t.value);case "literal":return Fl(t.value);case "keyword":{let r=dl(t);if(r)return r;let n=(t.normalized||t.value).toLowerCase();return xe(n)?ke(n):Jn(n)??Z(t.normalized||t.value)}case "identifier":if(t.value.startsWith("@"))return Te(t.value);if(t.value.startsWith(":")||t.value.startsWith("$"))return ke(t.value);let e=t.value.toLowerCase();return xe(e)?ke(e):{type:"expression",raw:t.value};case "url":{let r=Z(t.value,"string");return t.value.includes("${")?{...r,interpolates:true}:r}default:return null}}function Fl(t){if(t.startsWith('"')||t.startsWith("'")||t.startsWith("`")||t.startsWith("\u300C")){let n=t.slice(1,-1);return Z(n,"string")}if(t==="true")return Z(true,"boolean");if(t==="false")return Z(false,"boolean");let e=t.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(e){let n=parseFloat(e[1]);return e[2]?Z(t,"duration"):Z(n,"number")}let r=parseFloat(t);return isNaN(r)?Z(t,"string"):Z(r,"number")}var _r=.8,Ll=.6,Ol=.15,Rl=.5,pn=.15,fn=.1,yn=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"]),Pl={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"]},Nl=class{calculate(t){return this.calculateWithBreakdown(t).final}calculateWithBreakdown(t){let e=this.scoreRoleCoverage(t),r=this.scoreStemPenalty(t),n=this.scoreLanguageBoost(t),i=this.scoreLanguageAdjustment(t),a=e;return a=Math.max(Rl,a+r),a=Math.min(1,a+n),a=Math.max(0,Math.min(1,a+i)),{roleCoverage:e,stemPenalty:r,languageBoost:n,languageAdjustment:i,final:a}}scoreRoleCoverage(t){let{pattern:e,captured:r}=t,n=0,i=0,a=l=>e.extraction?.[l]?.default!==void 0,o=e.command==="on"?e.extraction?.action?.value:void 0,u=ue[o??e.command]?.roles,s=l=>u?.find(c=>c.role===l)?.valueShape!==void 0;for(let l of e.template.tokens)if(l.type==="role")r.has(l.role)?(i+=1,n+=1):s(l.role)||(i+=1);else if(l.type==="group")for(let c of l.tokens)c.type==="role"&&(r.has(c.role)?(i+=_r,n+=_r):s(c.role)||(i+=_r,a(c.role)&&(n+=_r*Ll)));return i>0?n/i:1}scoreStemPenalty(t){let{stemMatchCount:e,totalKeywordMatches:r}=t;return e<=0||r<=0?0:-(e/r)*Ol}scoreLanguageBoost(t){let{pattern:e}=t;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:yn.has(r.value)||r.alternatives?.some(n=>yn.has(n))?pn:0}scoreLanguageAdjustment(t){let{pattern:e,captured:r}=t;if(e.language!=="ar")return 0;let n=0;for(let[i,a]of r.entries()){let o=Pl[i];if(!o||o.length===0)continue;let u="metadata"in a?a.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?n+=.1:n-=.1);}return Math.max(-fn,Math.min(fn,n))}},Ml=new Nl,_l=new Set(Object.values(ue).filter(t=>t.bareKeyword===true).map(t=>t.action));function Il(t){return t.startsWith("*")||t.startsWith("@")}var ne=class j{constructor(e){this.patternRest=[],this.slotAfterLiteral=false,this.wouldMatch=(r,n)=>this.patternTokenWouldMatch(r,n),this.matchCache=new Map,this.roleStarts=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Ml;}matchPattern(e,r){let n=e.mark(),i=new Map;if(this.currentProfile=L(r.language),this.currentPatternCommand=r.command,this.currentRoleCommand=r.extraction?.action?.value??r.command,this.stemMatchCount=0,this.totalKeywordMatches=0,this.roleStarts=new Map,this.eventSource=void 0,this.patternRest=[],!this.matchTokenSequence(e,r.template.tokens,i))return e.reset(n),null;let o=this.confidenceModel.calculate({pattern:r,captured:i,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,i),{pattern:r,captured:i,consumedTokens:e.position()-n.position,confidence:o,roleStarts:this.roleStarts,...this.eventSource?{eventSource:this.eventSource}:{}}}matchBest(e,r){this.matchCache.clear();let n=[],i=e.position();for(let o of r){let u=e.mark(),s=`${i}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&n.push(l),e.reset(u);}if(n.length===0)return null;n.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let a=n[0];return this.matchPattern(e,a.pattern),a}matchTokenSequence(e,r,n,i){let a=r[0],o=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=0;for(let s=0;s<r.length;s++){let l=r[s];if(u>0&&l.type==="literal"&&this.tryConsumeEventSourceClause(e,n,l),ol(l,e.peek(),r[s+1]??i,this.wouldMatch)){let m=e.mark(),p=new Map(n);if(this.matchTokenSequence(e,r.slice(s+1),p,i)&&this.atClauseEnd(e)){n.clear();for(let[f,y]of p)n.set(f,y);return true}e.reset(m);}let c=this.patternRest;this.patternRest=[...r.slice(s+1),...c],this.slotAfterLiteral=l.type==="role"&&r[s-1]?.type==="literal";let d=this.matchPatternToken(e,l,n,r[s+1]??i);if(this.patternRest=c,u=l.type==="role"&&l.role==="event"?2:Math.max(0,u-1),!d){if(this.isOptional(l))continue;return false}}return true}tryConsumeEventSourceClause(e,r,n){if(r.has("source")||this.eventSource)return;let i=e.peek(),a=e.peek(1);if(!i||!a||this.patternTokenWouldMatch(n,i))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(d=>d.toLowerCase()===c)},s=o?.position;if(s!=="after"&&u(i)){let l=this.sourceNounValue(a);if(!l)return;e.advance(),e.advance(),this.eventSource=l;return}if(s==="after"&&u(a)){let l=this.sourceNounValue(i);if(!l)return;e.advance(),e.advance(),this.eventSource=l;}}sourceNounValue(e){if(e.kind==="selector")return this.tokenToSemanticValue(e)??void 0;if(e.kind!=="keyword"&&e.kind!=="identifier")return;let r=(e.normalized??e.value).toLowerCase();if(r!=="me"){if(xe(r))return {type:"reference",value:r};if(e.kind==="identifier"&&/^[A-Za-z_$][\w$]*$/.test(e.value))return {type:"expression",raw:e.value}}}matchPatternToken(e,r,n,i){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":{let a=e.position(),o=this.matchRoleToken(e,r,n,i);return o&&n.has(r.role)&&this.roleStarts.set(r.role,a),o}case "group":return this.matchGroupToken(e,r,n,i);default:return false}}matchLiteralToken(e,r){let n=e.peek();if(!n)return false;let i=this.getMatchType(n,r.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let a of r.alternatives){let o=this.getMatchType(n,a);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}for(let a of [r.value,...r.alternatives??[]])for(let o of ["-","_"])if(a.includes(o)&&this.tryMatchShatteredCompound(e,a,o))return this.totalKeywordMatches++,true;return false}tryFoldHyphenActionKeyword(e){let r=this.currentProfile;if(!r)return null;let n=e.mark(),i=[];for(;;){let o=e.peek();if(!o||o.kind!=="identifier"&&o.kind!=="keyword")break;i.push(o.value),e.advance();let u=e.peek();if(!u||u.value!=="-")break;e.advance(),i.push("-");}if(i.length<3||i[i.length-1]==="-")return e.reset(n),null;let a=i.join("").toLowerCase();for(let[o,u]of Object.entries(r.keywords))if(u.primary.toLowerCase()===a||u.alternatives?.some(s=>s.toLowerCase()===a))return Z(o);return e.reset(n),null}tryMatchShatteredCompound(e,r,n){let i=r.split(n);if(i.length<2||i.some(o=>o.length===0))return false;let a=e.mark();for(let o=0;o<i.length;o++){if(o>0){let s=e.peek();if(!s||s.value!==n)return e.reset(a),false;e.advance();}let u=e.peek();if(!u||u.kind!=="identifier"&&u.kind!=="keyword"&&u.kind!=="particle"||u.value.toLowerCase()!==i[o].toLowerCase())return e.reset(a),false;e.advance();}return true}matchRoleToken(e,r,n,i){let a=e.position(),o=n.get(r.role);return this.matchRoleTokenCore(e,r,n,i)?(this.absorbTrailingConversion(e,r,n,i,a),this.absorbTrailingConditionOperand(e,r,n,i,a),this.absorbExpressionTail(e,r,n,i,a),this.stampCaptureSpan(e,r.role,n,a,o),true):false}absorbExpressionTail(e,r,n,i,a){if(r.role==="event"||r.role==="action"||this.isClassNameSlot(r)||!n.has(r.role)||e.position()<=a)return;let o=r.expectedTypes;if(o&&o.length>0&&!o.includes("expression"))return;let u=j.boundedByMarker(i)?bl(e.tokens,e.position(),this.extentContext()):Al(e.tokens,e.position(),this.currentProfile),s=Dl(e.tokens,a,u,this.currentProfile);if(s){for(;e.position()<s.end;)e.advance();n.set(r.role,{type:"expression",raw:s.raw,value:s.raw});}}extentContext(){let e=this.restLiterals();return {profile:this.currentProfile,owes:r=>e.some(n=>this.patternTokenWouldMatch(n,r)),commandMarkers:this.commandMarkers(),hasResponseType:!!this.currentSchema()?.roles.some(r=>r.role==="responseType")}}isClassNameSlot(e){return e.role==="patient"&&["add","remove","toggle","take"].includes(this.currentRoleCommand??"")}isObjectValueSlot(e){let r=this.currentRoleCommand;return e.role==="source"?r==="get":e.role==="patient"&&(r==="put"||r==="set")}static boundedByMarker(e){return !e||e.type==="literal"?true:e.type==="group"?e.tokens[0]?.type==="literal":false}restLiterals(){let e=[],r=n=>{for(let i of n)i.type==="literal"?e.push(i):i.type==="group"&&r(i.tokens);};return r(this.patternRest),e}currentSchema(){let e=this.currentRoleCommand;if(!(!e||!(e in ue)))return ue[e]}commandMarkers(){let e=this.currentSchema(),r=this.currentProfile,n=new Set;if(!e||!r)return n;for(let i of e.roles){let a=i.markerOverride?.[r.code];if(a){n.add(a.toLowerCase());continue}let o=r.roleMarkers[i.role];if(o){n.add(o.primary.toLowerCase());for(let u of o.alternatives??[])n.add(u.toLowerCase());}}return n.delete(""),n}stampCaptureSpan(e,r,n,i,a){let o=n.get(r);if(!o||o===a||o.position||e.position()<=i)return;let u=e.tokens[i],s=e.tokens[e.position()-1];!u||!s||n.set(r,Xn(o,{start:u.position.start,end:s.position.end}));}absorbTrailingConditionOperand(e,r,n,i,a){if(r.role!=="condition"||!n.has("condition")||e.position()<=a)return;let o=this.currentPatternCommand==="repeat";if(!o&&(i!==void 0||this.currentPatternCommand!=="on"))return;let u=j.CONDITION_OPERATOR_WORDS,s=m=>{let p=(m.normalized??"").toLowerCase(),f=m.value.toLowerCase();if(u.has(p)||u.has(f))return true;let y=j.LOOP_CONDITION_OPERATORS;return o&&(y.has(f)||y.has(p))},l=m=>!!m&&(m.kind==="selector"||m.kind==="identifier"||m.kind==="literal")&&!s(m)&&!cr.has((m.normalized??m.value).toLowerCase())&&!this.patternTokenWouldMatch(i,m),c=false;for(;;){let m=e.peek();if(!m||!s(m)||this.patternTokenWouldMatch(i,m))break;e.advance(),c=true;let p=e.peek();if(l(p)){e.advance();for(let f=e.peek();!(!f||!/^\.[a-zA-Z_]\w*$/.test(f.value)||f.position.start!==p.position.end);f=e.peek())e.advance(),p=f;}if(!o)break}if(!c)return;let d=Be(e.tokens.slice(a,e.position()),this.currentProfile);n.set("condition",{type:"expression",raw:d,value:d});}conversionRunLength(e){let r=e.peek();if(!r||(r.normalized??r.value).toLowerCase()!=="as"&&r.value.toLowerCase()!=="as")return 0;let i=this.conversionTypeLength(e,1);if(i===0)return 0;for(i+=1;;){if(e.peek(i)?.value!=="|")return i;let a=this.conversionTypeLength(e,i+1);if(a===0)return i;i+=1+a;}}conversionTypeLength(e,r){let n=e.peek(r)?.value.toLowerCase(),i=n==="a"||n==="an"?r+1:r,a=e.peek(i);if(!a)return 0;let o=e.peek(i+1),u=e.peek(i+2);return o?.value===":"&&u&&gr(a,o)&&gr(o,u)&&kr(`${a.value}:${u.value}`)?i-r+3:kr(a.value)?i-r+1:0}absorbTrailingConversion(e,r,n,i,a){if(r.role==="event"||r.role==="action"||!n.has(r.role)||e.position()<=a)return;let o=this.conversionRunLength(e);if(o===0||this.patternTokenWouldMatch(i,e.peek()))return;for(let s=0;s<o;s++)e.advance();let u=Be(e.tokens.slice(a,e.position()),this.currentProfile);n.set(r.role,{type:"expression",raw:u,value:u});}matchRoleTokenCore(e,r,n,i){this.skipNoiseWords(e,r,i);let a=e.peek();if(!a)return r.optional||false;let o=this.slotAt(e,r,i);if(r.role==="action"&&this.currentProfile&&e.peek(1)?.value==="-"){let g=this.tryFoldHyphenActionKeyword(e);if(g)return n.set(r.role,g),true}if(r.role==="event"&&this.currentPatternCommand==="on"){if(!j.tokenLooksLikeEvent(a))return r.optional||false;let g=(a.normalized??a.value).toLowerCase();if(j.POSITIONAL_OR_SCOPE_KEYWORDS.has(g)||j.VISIBILITY_STRATEGIES.has(g)||this.currentProfile&&(Ae(this.currentProfile,a.value)??Ae(this.currentProfile,g))!==void 0||a.value.includes("?."))return r.optional||false}if(r.role==="event"){let g=(a.normalized??a.value).toLowerCase();if(j.STRUCTURAL_NEVER_EVENT.has(g))return r.optional||false}if(tl(o,this.currentProfile?.code??"")||il(o,this.currentPatternCommand))return r.optional||false;if(r.role==="duration"){let g=(a.normalized??a.value).toLowerCase();if(j.POSITIONAL_OR_SCOPE_KEYWORDS.has(g))return r.optional||false}if(al(o))return true;if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchPositionalPossessiveExpression(e,i);if(g)return n.set(r.role,g),true}let u=this.tryMatchPositionalExpression(e,i);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(u.type,r.expectedTypes)?r.optional||false:(n.set(r.role,u),true);let s=this.tryMatchCaretScopeExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(s.type,r.expectedTypes)?r.optional||false:(n.set(r.role,s),true);let l=this.tryMatchParenReceiverCall(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,l),true);if(r.role!=="event"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchBeepPrefixExpression(e);if(g)return n.set(r.role,g),true;let A=this.tryMatchHyphenatedWord(e);if(A)return n.set(r.role,A),true;let k=this.isWrittenTarget(r)?null:this.tryMatchOperatorRunExpression(e);if(k)return n.set(r.role,k),true}if(this.currentPatternCommand==="pick"&&r.role==="patient"&&(!r.expectedTypes||r.expectedTypes.includes("expression"))){let g=this.tryMatchPickRangeExpression(e);if(g)return n.set(r.role,g),true}if(this.roleAcceptsPropertyPath(r)){let g=this.tryMatchOfPossessiveExpression(e,i);if(g)return n.set(r.role,g),true;let A=this.tryMatchPostNominalPossessiveExpression(e);if(A)return n.set(r.role,A),true}let c=this.tryMatchPossessiveExpression(e);if(c)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,c),true);let d=this.tryMatchMethodCallExpression(e);if(d)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(d.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,d),true);let p=r.role==="event"&&this.currentPatternCommand==="on"||j.DECLARATION_COMMANDS.has(this.currentPatternCommand??"")||this.isWrittenTarget(r)?null:this.tryMatchBareCallExpression(e);if(p)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(p.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,p),true);let f=this.tryMatchPossessiveSelectorExpression(e);if(f)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(f.type,r.expectedTypes)?r.optional||false:(n.set(r.role,f),true);let y=r.role!=="condition",v=this.tryMatchPropertyAccessExpression(e,y);if(v)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(v.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(n.set(r.role,v),true);let h=this.tryMatchSelectorPropertyExpression(e);if(h)return r.expectedTypes&&r.expectedTypes.length>0&&!Mr(h.type,r.expectedTypes)?r.optional||false:(n.set(r.role,h),true);if(a.value==="("&&r.role!=="event"&&r.role!=="action"&&(!r.expectedTypes?.length||r.expectedTypes.some(g=>g==="expression"||g==="selector"||g==="reference"))){let g=this.tryMatchParenGroupExpression(e);if(g)return n.set(r.role,g),true}if(a.kind==="identifier"&&a.value==="{"){let g=r.expectedTypes,k=g?.length===1&&g[0]==="expression"||this.isObjectValueSlot(r)?this.tryMatchBraceRunExpression(e):!g?.length||g.includes("literal")?this.tryMatchBraceRunLiteral(e):null;if(k)return n.set(r.role,k),true}if(r.role==="style"&&r.expectedTypes?.length===1&&r.expectedTypes[0]==="expression"){let g=Cr(e);if(g)return n.set(r.role,{type:"expression",raw:g}),true}if(ll(o)||cl(o,this.currentSchema())||nl(o,this.currentProfile?.code??""))return n.set(r.role,{type:"expression",raw:a.value}),e.advance(),true;let E=this.tokenToSemanticValue(a);if(!E)return r.optional||false;if(r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(E.type)){let g=E.type==="selector"&&String(E.value).startsWith("@"),A=r.expectedTypes.some(k=>k==="expression"||k==="reference");if(!(g&&A))return r.optional||false}r.valueShape==="keyword"&&E.type==="expression"?n.set(r.role,Z(String(E.raw??""))):n.set(r.role,E),e.advance();let C=this.isClassNameSlot(r);if(E.type==="selector"&&(E.value.startsWith("<")||E.value.startsWith(".")&&!C)&&r.role!=="event"){let g=ai(e.tokens,e.position(),this.currentProfile,A=>A===void 0?false:this.patternTokenWouldMatch(i,A));if(g){let[A,k]=g.scope.parts,D=g.scope.kind==="reference"?ke(A.text):g.scope.kind==="closest"?{type:"expression",raw:`closest ${k.text}`}:this.tokenToSemanticValue(A.token);for(let S=0;S<1+g.scope.consumed;S++)e.advance();n.set(r.role,{...E,scope:D});}}if(r.role==="event"){let g=e.peek();g&&g.kind==="selector"&&g.value.startsWith("[")&&g.position.start===a.position.end&&"value"in E&&(n.set(r.role,Z(`${String(E.value)}${g.value}`)),e.advance());let A=e.peek();if(A&&(A.kind==="particle"||A.kind==="keyword")&&(A.normalized??"").toLowerCase()==="source"&&!this.patternTokenWouldMatch(i,A)){let k=e.peek(1),D=k?this.sourceNounValue(k):void 0;D&&!this.eventSource&&(e.advance(),e.advance(),this.eventSource=D);}}return true}atClauseEnd(e){let r=e.peek();if(!r||r.kind==="conjunction")return true;if(r.kind!=="keyword")return false;let n=(r.normalized??r.value).toLowerCase();return n==="then"||n==="end"?true:Yr(r.value,this.currentProfile?.code??"")}patternTokenWouldMatch(e,r){return e?e.type==="literal"?this.getMatchType(r,e.value)!=="none"?true:!!e.alternatives?.some(n=>this.getMatchType(r,n)!=="none"):e.type==="group"?this.patternTokenWouldMatch(e.tokens?.[0],r):false:false}tryMatchPositionalExpression(e,r){let n=zr(e.tokens,e.position(),this.currentProfile,i=>i===void 0?false:this.patternTokenWouldMatch(r,i));if(!n)return null;for(let i=0;i<n.consumed;i++)e.advance();return {type:"expression",raw:n.parts.map(i=>i.text).join(" ")}}tryMatchCaretScopeExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!r.value.startsWith("^"))return null;let n=e.peek(1),i=e.peek(2),a=(n?.normalized??"").toLowerCase(),o=!!n&&(n.value.toLowerCase()==="on"||a==="destination"||a==="on");return !n||!i||i.kind!=="selector"||!o?null:(e.advance(),e.advance(),e.advance(),{type:"expression",raw:`${r.value} on ${i.value}`})}isOfPossessiveMarker(e){return Ie(this.currentProfile,e)}logicalConnectiveOf(e){let r=e.peek();if(!r)return;let n=this.currentProfile?.code??"en",i=s=>s==="and"||s==="or"||s==="not",a=qe(n,r.value).toLowerCase();if(i(a))return a;if(this.commandMarkers().has(r.value.toLowerCase()))return;let o=e.position(),u=Vs(n,r,e.tokens[o-1],e.tokens[o+1]);return u&&i(u)?u:void 0}tryConsumeRunPhrase(e){let r=this.currentProfile?.code??"en",n=e.tokens,i=e.position(),a=[],o;for(let u=0;u<6&&i+u<n.length;u++){let s=n[i+u],l=or(r,s,n[i+u-1],n[i+u+1],o).toLowerCase();a.push(l),o=l;}for(let[u,s]of j.RUN_PHRASES)if(u.every((l,c)=>a[c]===l)){for(let l=0;l<u.length;l++)e.advance();return s}}slotAt(e,r,n){return new el(e,r,this.slotAfterLiteral,n,this.wouldMatch)}static isBareWordToken(e){return !!e&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(e.value)}tryMatchBeepPrefixExpression(e){let r=e.peek(),n=e.peek(1);if(!r||!n||n.value!=="!"||(r.normalized??r.value).toLowerCase()!=="beep"||!(r.position?.end!==void 0&&n.position?.start!==void 0&&r.position.end===n.position.start))return null;let a=e.mark(),o=e.position();if(e.advance(),e.advance(),!this.tryConsumeRunOperand(e))return e.reset(a),null;for(;;){let s=e.peek();if(!s||!Me.has(s.value))break;let l=e.mark();if(e.advance(),!this.tryConsumeRunOperand(e,true)){e.reset(l);break}}let u=Be(e.tokens.slice(o,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}tryMatchHyphenatedWord(e){let r=e.peek();if(!j.isBareWordToken(r))return null;let n=1,i=[r.value];for(;;){let a=e.peek(n),o=e.peek(n+1);if(!a||a.value!=="-"||!j.isBareWordToken(o)||!gr(e.peek(n-1),a)||!gr(a,o))break;i.push(o.value),n+=2;}if(i.length<2)return null;for(let a=0;a<n;a++)e.advance();return Z(i.join("-"),"string")}tryMatchOperatorRunExpression(e){let r=e.mark(),n=e.position(),i=e.peek(),a=!!i&&(this.logicalConnectiveOf(e)==="not"||i.value==="-");if(!this.tryConsumeRunOperand(e))return e.reset(r),null;let o=1;for(;;){let s=e.peek();if(!s)break;let l=this.logicalConnectiveOf(e),c=(l==="and"||l==="or")&&this.currentRoleCommand!=="wait",d=e.mark();if(c||Me.has(s.value))e.advance();else {let m=this.tryConsumeRunPhrase(e);if(m===void 0)break;if(m==="none"){o++;continue}}if(!this.tryConsumeRunOperand(e,true,c)){e.reset(d);break}o++;}if(o<2&&!a)return e.reset(r),null;let u=Be(e.tokens.slice(n,e.position()),this.currentProfile);return {type:"expression",raw:u,value:u}}static rangeSeparatorFor(e){let[r]=j.PICK_RANGE_SEPARATORS_BY_LANG[e]??[];return r}isPickRangeSeparator(e){let r=(e.normalized??e.value).toLowerCase();if(j.PICK_RANGE_SEPARATORS.has(r))return true;let n=this.currentProfile?.code;return n?j.PICK_RANGE_SEPARATORS_BY_LANG[n]?.has(e.value.toLowerCase())??false:false}tryMatchPickRangeExpression(e){let r=e.mark(),n=e.position();if(!this.tryConsumePickRangeOperand(e))return e.reset(r),null;let i=e.peek();if(!i||!this.isPickRangeSeparator(i)||(e.advance(),!this.tryConsumePickRangeOperand(e)))return e.reset(r),null;let a=e.peek();a&&j.PICK_RANGE_MODES.has((a.normalized??a.value).toLowerCase())&&e.advance();let o=e.tokens.slice(n,e.position()),[u,,s,l]=o,c=m=>m.kind==="keyword"?m.normalized??m.value:m.value,d=`${c(u)} to ${c(s)}`;return l&&(d+=` ${(l.normalized??l.value).toLowerCase()}`),{type:"expression",raw:d,value:d}}tryConsumePickRangeOperand(e){let r=e.peek();if(!r)return false;let n=(r.normalized??r.value).toLowerCase();if(this.isPickRangeSeparator(r))return false;let i=n==="start"||n==="end";return r.kind==="literal"||r.kind==="identifier"||r.kind==="keyword"&&i?(e.advance(),true):false}tryConsumeRunOperand(e,r=false,n=false){let i=e.peek();if(!i)return false;if(this.logicalConnectiveOf(e)==="not"){let o=e.mark();return e.advance(),sl(e.peek()??void 0,e.peek(1)??void 0)?(e.reset(o),false):this.tryConsumeRunOperand(e,true,n)?true:(e.reset(o),false)}if(i.value==="-"){let o=e.mark();return e.advance(),this.tryConsumeRunOperand(e,true,n)?true:(e.reset(o),false)}if(n&&ul(i))return false;if(ml(i,r,e.peek(1)??void 0))return e.advance(),true;if(i.value==="("){let o=e.mark(),u=0;for(;!e.isAtEnd();){let s=e.advance();if(s.value==="(")u++;else if(s.value===")"&&(u--,u===0))return true}return e.reset(o),false}if(this.tryMatchPossessiveExpression(e))return true;if(i.value.toLowerCase()==="the"){let o=e.mark();if(e.advance(),this.tryConsumeRunOperand(e,r,n))return true;e.reset(o);}if(this.tryMatchOfPossessiveExpression(e)||this.tryMatchPossessiveSelectorExpression(e)||this.tryMatchPropertyAccessExpression(e,true)||this.tryMatchSelectorPropertyExpression(e))return true;let a=(i.normalized??"").toLowerCase();return (i.kind==="literal"||i.kind==="identifier"||i.kind==="selector"||i.kind==="keyword")&&!Me.has(i.value)&&!["then","else"].includes(a)&&(a!=="end"||this.endWordIsValueAt(e))&&i.value!==")"?(e.advance(),true):false}endWordIsValueAt(e){return Le(he(e.tokens,e.position()),this.currentProfile?.code??"")}isPossessorToken(e){if(!this.currentProfile)return false;for(let r of [e.value,e.normalized].filter(Boolean))if(Ae(this.currentProfile,r)??Ae(this.currentProfile,r.toLowerCase()))return true;return false}isBareWordPropertyHead(e){return e.kind!=="identifier"||/^[$:@#.*]/.test(e.value)||this.isStructuralKeyword(e.value)||e.normalized&&this.isStructuralKeyword(e.normalized)||e.normalized&&this.isRoleMarkerConcept(e.normalized)?false:!this.isPossessorToken(e)}toEnglishProperty(e){return this.currentProfile?ye(this.currentProfile.code,e):e}roleAcceptsPropertyPath(e){if(e.type!=="role")return false;if(e.expectedTypes)return e.expectedTypes.includes("property-path");let r=this.currentRoleCommand;return r?ue[r]?.roles.find(a=>a.role===e.role)?.expectedTypes?.includes("property-path")??false:false}tryMatchOfPossessiveExpression(e,r){let n=e.peek();if(!n||!(n.kind==="selector"?/^[*@]/.test(n.value):this.isBareWordPropertyHead(n)))return null;let a=e.position(),o=e.mark();e.advance();let u=e.peek();if(!u||!this.isOfPossessiveMarker(u))return e.reset(o),null;e.advance(),e.peek()?.value.toLowerCase()==="the"&&e.advance();let s=zr(e.tokens,e.position(),this.currentProfile,c=>c===void 0?false:this.patternTokenWouldMatch(r,c));if(s){for(let c=0;c<s.consumed;c++)e.advance();return Fe({type:"expression",raw:s.parts.map(c=>c.text).join(" ")},this.toEnglishProperty(n.value),"possessive")}let l=e.peek();if(!l||l.kind!=="selector"||Il(l.value)){if(e.reset(o),this.patternTokenWouldMatch(r,u))return null;let c=this.currentProfile?.code??"en",d=pi(e.tokens,a,this.currentProfile,c);if(d===void 0)return null;for(;e.position()<=d;)e.advance();let m=Be(e.tokens.slice(a,d+1),this.currentProfile);return {type:"expression",raw:m,value:m}}return e.advance(),Fe(Te(l.value),this.toEnglishProperty(n.value),"possessive")}tryMatchPositionalPossessiveExpression(e,r){let n=this.currentProfile,i=n?.possessive?.marker;if(!n||!i||n.possessive?.markerPosition!=="between"||n.code==="th")return null;let a=zr(e.tokens,e.position(),n,l=>l===void 0?false:this.patternTokenWouldMatch(r,l));if(!a)return null;let o=e.peek(a.consumed),u=e.peek(a.consumed+1);if(!o||o.value!==i)return null;let s=!!u&&(this.isBareWordPropertyHead(u)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="keyword"&&en(n.code,u.value));if(!u||!s)return null;for(let l=0;l<a.consumed+2;l++)e.advance();return Fe({type:"expression",raw:a.parts.map(l=>l.text).join(" ")},this.toEnglishProperty(u.value),"possessive")}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let n=[r.value,r.normalized].filter(Boolean),i;for(let s of n)if(i=Ae(this.currentProfile,s)??Ae(this.currentProfile,s.toLowerCase()),i)break;if(!i)return null;let a=e.mark();e.advance();let o=this.currentProfile.possessive?.connectors;if(o&&o.length>0){let s=e.peek();if(s){let l=s.value.toLowerCase(),c=(s.normalized??"").toLowerCase();o.some(d=>d.toLowerCase()===l||d.toLowerCase()===c)&&e.advance();}}let u=e.peek();if(!u||Bl(this.currentProfile.code,u.value))return e.reset(a),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)&&!(u.normalized&&this.isStructuralKeyword(u.normalized))&&!(u.normalized&&this.isRoleMarkerConcept(u.normalized))&&!(u.normalized&&j.COMMAND_ACTION_KEYWORDS.has(u.normalized.toLowerCase()))||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1)),s=this.toEnglishProperty(s);let l=s;for(;;){let d=e.peek();if(d?.kind==="selector"&&d.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(d.value)){l+=d.value,e.advance();continue}if(d?.value==="?"){let m=e.peek(1);if(m?.kind==="selector"&&m.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(m.value)){l+=`?${m.value}`,e.advance(),e.advance();continue}}break}let c=e.peek();if(c&&c.value.startsWith("(")){let d="",m=0,p=0;for(;!e.isAtEnd()&&p++<j.MAX_METHOD_ARGS+2;){let f=e.peek();if(!f)break;d+=f.value,e.advance();for(let y of f.value)y==="("?m++:y===")"&&m--;if(m<=0)break}l+=d;}return Fe(ke(i),l,"possessive")}return e.reset(a),null}tryMatchPostNominalPossessiveExpression(e){if(!this.currentProfile||this.currentProfile.possessive?.markerPosition!=="after-object")return null;let r=e.peek();if(!r)return null;let n=r.kind==="selector"&&r.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(r.value);if(!(r.kind==="identifier"&&!this.isStructuralKeyword(r.value)&&!(r.normalized&&this.isStructuralKeyword(r.normalized))&&!(r.normalized&&this.isRoleMarkerConcept(r.normalized))||r.kind==="selector"&&(r.value.startsWith("*")||r.value.startsWith("@"))||n)||this.isPossessorToken(r))return null;let a=e.mark(),o=r.value;n&&(o=o.substring(1)),e.advance(),o=this.toEnglishProperty(o);let u=o;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let s=e.peek();if(!s)return e.reset(a),null;let l;for(let d of [s.value,s.normalized].filter(Boolean))if(l=Ae(this.currentProfile,d)??Ae(this.currentProfile,d.toLowerCase()),l)break;if(!l)return e.reset(a),null;let c=e.mark();return this.tryMatchPossessiveExpression(e)?(e.reset(a),null):(e.reset(c),e.advance(),Fe(ke(l),u,"possessive"))}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 Ar.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 n=e.normalized?.toLowerCase();return !(n&&_l.has(n)||n==="me"||n==="it"||n==="you")}tryMatchBraceRunLiteral(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let n=e.mark();e.advance();let i=["{"],a=1,o=0;for(;!e.isAtEnd()&&o++<j.MAX_BRACE_RUN_TOKENS;){let u=e.advance();if(!u)break;if(u.value==="{")a++;else if(u.value==="}"&&(a--,a===0))return i.push("}"),Z(i.join(" "));i.push(u.value);}return e.reset(n),null}tryMatchBraceRunExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||r.value!=="{")return null;let n=e.mark(),i="",a=-1,o=0,u=0;for(;!e.isAtEnd()&&u++<j.MAX_BRACE_RUN_TOKENS;){let s=e.advance();if(!s)break;if(a>=0&&s.position.start>a&&(i+=" ".repeat(s.position.start-a)),i+=s.value,a=s.position.end,s.value==="{")o++;else if(s.value==="}"&&(o--,o===0))return {type:"expression",raw:i}}return e.reset(n),null}tryMatchBareCallExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"||!/^[A-Za-z_][\w$]*$/.test(r.value))return null;let n=e.peek(1);if(!n||n.value!=="(")return null;let i=e.mark();e.advance();let a=e.advance(),o="",u=a.position?.end,s=false,l=0;for(;!e.isAtEnd()&&l++<j.MAX_METHOD_ARGS+2;){let c=e.peek();if(!c)break;if(c.value===")"){e.advance(),s=true;break}let d=u!==void 0&&c.position?.start===u;o+=(o===""||d?"":" ")+c.value,u=c.position?.end,e.advance();}return s?{type:"expression",raw:`${r.value}(${o})`}:(e.reset(i),null)}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(n),null;e.advance();let a=e.peek();if(!a||a.kind!=="identifier")return e.reset(n),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(n),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<j.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${a.value}(${u.join(", ")})`}}tryMatchParenReceiverCall(e){if(e.peek()?.value!=="(")return null;let r=e.mark(),n=[];e.advance();let i=1;for(;!e.isAtEnd()&&n.length<=j.MAX_METHOD_ARGS*4;){let c=e.peek();if(e.advance(),c.value==="(")i++;else if(c.value===")"&&--i===0)break;n.push(c);}let a=e.tokens[e.position()-1],o=e.peek();if(i!==0||n.length===0||!o||o.kind!=="selector"||!/^\.[A-Za-z_$][\w$]*$/.test(o.value)||!j.abuts(a,o))return e.reset(r),null;e.advance();let u=e.peek();if(u?.value!=="("||!j.abuts(o,u))return e.reset(r),null;let s=this.consumeCallParens(e);return s===null?(e.reset(r),null):{type:"expression",raw:`(${Be(n,this.currentProfile)})${o.value}${s}`}}tryMatchParenGroupExpression(e){if(e.peek()?.value!=="(")return null;let r=e.mark();e.advance();let n=[],i=1;for(;!e.isAtEnd();){let l=e.peek();if(e.advance(),l.value==="(")i++;else if(l.value===")"&&--i===0)break;n.push(l);}let a=e.tokens[e.position()-1],o=e.peek(),u=!!o&&(o.value==="'"||Me.has(o.value)||j.abuts(a,o)&&(o.value.startsWith(".")||o.value==="("));if(i!==0||n.length===0||u)return e.reset(r),null;let s=`(${Be(n,this.currentProfile)})`;return {type:"expression",raw:s,value:s}}static abuts(e,r){return !!e&&!!r&&e.position.end===r.position.start}consumeCallParens(e){let r=e.mark(),n=[],i=0;for(;!e.isAtEnd();){let a=e.peek();if(!a)break;if(n.push(a.value),e.advance(),a.value==="(")i++;else if(a.value===")"&&--i===0)return n.join("")}return e.reset(r),null}tryMatchPropertyAccessExpression(e,r=true){let n=e.peek();if(!n||n.kind!=="identifier"&&n.kind!=="keyword")return null;let i=e.mark();e.advance();let a=n.value.toLowerCase(),o=e.peek();if((n.kind==="identifier"||j.PROPERTY_ACCESS_BASES.has(a))&&o&&o.kind==="selector"&&/^\.[a-zA-Z_]/.test(o.value)&&o.position.start===n.position.end){let p=n.value,f=[],y=0;for(;y<j.MAX_PROPERTY_DEPTH;){let E=e.peek();if(E&&E.kind==="selector"&&/^\.[a-zA-Z_]/.test(E.value))p+=`.${E.value.slice(1)}`,f.push(E.value.slice(1)),e.advance(),y++;else break}let v=e.peek(),h=!!v&&v.value.startsWith("(");return r&&!h&&f.length>0&&xe(a)?Fe(ke(a),f.join("."),"dot"):(h&&(p+=this.consumeCallParens(e)??""),{type:"expression",raw:p})}let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")return e.reset(i),null;e.advance();let s=e.peek();if(!s||s.kind!=="identifier")return e.reset(i),null;e.advance();let l=`${n.value}.${s.value}`,c=1;for(;!e.isAtEnd()&&c<j.MAX_PROPERTY_DEPTH;){let p=e.peek();if(!p||p.kind!=="operator"||p.value!==".")break;e.advance();let f=e.peek();if(!f||f.kind!=="identifier")break;e.advance(),l+=`.${f.value}`,c++;}let d=e.peek();if(d&&d.kind==="punctuation"&&d.value==="("){e.advance();let p=[],f=0;for(;!e.isAtEnd()&&p.length<j.MAX_METHOD_ARGS;){let v=e.peek();if(!v)break;if(v.kind==="punctuation"&&v.value===")"){if(f===0){e.advance();break}f--;}if(v.kind==="punctuation"&&v.value==="("&&f++,v.kind==="punctuation"&&v.value===","){e.advance();continue}p.push(v.value),e.advance();}return {type:"expression",raw:`${l}(${p.join(", ")})`}}let m=n.value.toLowerCase();if(r&&xe(m)){let p=l.split(".").slice(1).join(".");return Fe(ke(m),p,"dot")}return {type:"expression",raw:l}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let n=e.mark();e.advance();let i=e.peek(),a=this.currentProfile?.possessive?.marker?.replace(/^-/,""),o=!!i&&i.kind==="punctuation"&&i.value==="'s",u=!!i&&i.value==="'"&&(e.peek(1)?.value??"").toLowerCase()==="s",s=(()=>{if(!this.currentPatternCommand||(i?.normalized??"").toLowerCase()!=="source")return false;let f=ue[this.currentPatternCommand];return !!f&&f.roles.some(y=>y.role==="source")})(),l=!!i&&!!a&&a!=="'s"&&i.value===a&&(i.kind==="particle"||i.kind==="punctuation"||i.kind==="identifier")&&!s;if(!o&&!l&&!u)return e.reset(n),null;e.advance(),u&&e.advance();let c=e.peek();if(!c)return e.reset(n),null;let d=c.kind==="selector"&&c.value.startsWith("*"),m=c.kind==="keyword"&&!!this.currentProfile&&en(this.currentProfile.code,c.value);return c.kind==="identifier"||d||m||(o||u)&&(c.kind==="selector"||c.kind==="keyword")?(e.advance(),Fe(Te(r.value),this.toEnglishProperty(c.value),"possessive")):(e.reset(n),null)}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let n=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(n),null;e.advance();let a=[i.value.slice(1)],o=i;for(let s=e.peek();s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value)&&a.length<j.MAX_PROPERTY_DEPTH;s=e.peek())a.push(s.value.slice(1)),o=s,e.advance();let u=e.peek();if(u?.value==="("&&j.abuts(o,u)){let s=this.consumeCallParens(e);if(s!==null)return {type:"expression",raw:`${r.value}.${a.join(".")}${s}`}}return Fe(Te(r.value),a.join("."),"dot")}matchGroupToken(e,r,n,i){let a=e.mark(),o=new Map(n),u=this.matchTokenSequence(e,r.tokens,n,i);if(u){let s=[];for(let l of r.tokens)if(l.type==="group"&&l.renderRequired)for(let c of l.tokens)c.type==="literal"&&s.push(c.value,...c.alternatives??[]);s.length>0&&[...n.keys()].some(c=>!o.has(c))&&(e.tokens.slice(a.position,e.position()).some(m=>s.some(p=>this.getMatchType(m,p)!=="none"))||(u=false));}if(!u){e.reset(a);for(let s of n.keys())o.has(s)||n.delete(s);for(let[s,l]of o)n.get(s)!==l&&n.set(s,l);return r.optional||false}return true}getMatchType(e,r){if(e.value===r)return "exact";if(e.normalized===r)return "normalized";if(e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7)return "stem";if(e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase())return "case-insensitive";if(e.kind==="keyword"){let n=Rr(e.value).toLowerCase();if(n&&n===Rr(r).toLowerCase())return "case-insensitive"}return "none"}isWrittenTarget(e){return j.WRITTEN_ROLE[this.currentRoleCommand??""]===e.role}tokenToSemanticValue(e){return Vr(e)}applyExtractionRules(e,r){for(let[n,i]of Object.entries(e.extraction)){let a=r.get(n);if(a){if(i.transform){let o=a.type==="literal"?String(a.value):String(a.raw??"");r.set(n,i.transform(o));}}else i.value!==void 0?r.set(n,{type:"literal",value:i.value}):i.default&&r.set(n,{...i.default,implicit:true});}}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e,r,n){let i=e.peek();if(!i)return;let a=i.value.toLowerCase();if(j.ENGLISH_NOISE_WORDS.has(a)){if(rl(this.slotAt(e,r,n)))return;let o=e.mark();e.advance();let u=e.peek();if(u&&(u.kind==="selector"||u.kind==="identifier"))return;let s=e.peek(1);if(u&&u.kind==="keyword"&&s&&s.kind==="selector"&&/^\.[a-zA-Z_]/.test(s.value))return;let l=u?(u.normalized??u.value).toLowerCase():"";if(u&&j.POSITIONAL_OR_SCOPE_KEYWORDS.has(l))return;let c=e.peek(1),d=c?(c.normalized??c.value).toLowerCase():"",m=this.currentProfile?.wordOrder!=="SOV"&&j.COMMAND_ACTION_KEYWORDS.has(d),p=!c||c.kind==="particle"||j.CLAUSE_BOUNDARY_KEYWORDS.has(d)||m;if(u&&u.kind==="keyword"&&this.currentProfile?.code!=="en"&&xe(l)&&p||u&&u.kind==="keyword"&&this.currentProfile?.code==="en"&&xe(l))return;e.reset(o);}a==="class"&&e.advance();}extractEventModifiers(e){let r={},n=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let a=i.metadata;if(!a)break;switch(n=true,a.modifierName){case "once":r.once=true;break;case "debounce":typeof a.value=="number"&&(r.debounce=a.value);break;case "throttle":typeof a.value=="number"&&(r.throttle=a.value);break;case "queue":(a.value==="first"||a.value==="last"||a.value==="all"||a.value==="none")&&(r.queue=a.value);break}e.advance();}return n?r:void 0}};ne.CONDITION_OPERATOR_WORDS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);ne.LOOP_CONDITION_OPERATORS=new Set([...Qn,"and","or"]);ne.POSITIONAL_OR_SCOPE_KEYWORDS=new Set(["first","last","next","previous","random","closest","parent"]);ne.STRUCTURAL_NEVER_EVENT=new Set(["if","unless","else","end","then","while"]);ne.PROPERTY_ACCESS_BASES=new Set(["it","me","you","my","its","your","event","result","target","detail","body","window","document","self","this"]);ne.COMMAND_ACTION_KEYWORDS=cr;ne.CLAUSE_BOUNDARY_KEYWORDS=new Set(["then","and","or","end","else"]);ne.RUN_PHRASES=[...zt.map(t=>[t.split(" "),"none"]),...kt.map(t=>[t.split(" "),"type"]),...wt.filter(t=>!/^(in|am|has|have)$|^am /.test(t)).map(t=>[t.split(" "),"operand"]),[["exists"],"none"]];ne.PICK_RANGE_SEPARATORS=new Set(["to"]);ne.PICK_RANGE_SEPARATORS_BY_LANG={ar:new Set(["\u0625\u0644\u0649"]),bn:new Set(["\u09A5\u09C7\u0995\u09C7"]),de:new Set(["zu","bis"]),es:new Set(["a"]),fr:new Set(["\xE0"]),he:new Set(["\u05E2\u05DC","\u05E2\u05D3"]),hi:new Set(["\u0938\u0947"]),id:new Set(["ke"]),it:new Set(["in","a"]),ja:new Set(["\u304B\u3089"]),ko:new Set(["\uBD80\uD130"]),ms:new Set(["ke"]),pl:new Set(["do"]),pt:new Set(["para","a"]),qu:new Set(["kama"]),ru:new Set(["\u0432","\u0434\u043E"]),sw:new Set(["kwa","hadi"]),th:new Set(["\u0E43\u0E19","\u0E16\u0E36\u0E07"]),tl:new Set(["sa"]),tr:new Set(["ile"]),uk:new Set(["\u0432","\u0434\u043E"]),vi:new Set(["v\xE0o","\u0111\u1EBFn"]),zh:new Set(["\u5230"])};ne.PICK_RANGE_MODES=new Set(["inclusive","exclusive"]);ne.VISIBILITY_STRATEGIES=new Set(["display","visibility","opacity","twdisplay","twvisibility","twopacity"]);ne.MAX_BRACE_RUN_TOKENS=64;ne.MAX_PROPERTY_DEPTH=10;ne.MAX_METHOD_ARGS=20;ne.DECLARATION_COMMANDS=new Set(["behavior","def","install"]);ne.WRITTEN_ROLE={increment:"patient",decrement:"patient",set:"destination"};ne.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ai=ne,ze=new Ai;function Y(t,e){return Ku(t,e)}function Di(){return Wu()}var Wr={ar:new Set(["\u0623\u0648"]),bn:new Set(["\u0985\u09A5\u09AC\u09BE"]),de:new Set(["oder"]),en:new Set(["or"]),es:new Set(["o"]),fr:new Set(["ou"]),he:new Set(["\u05D0\u05D5"]),hi:new Set(["\u092F\u093E"]),id:new Set(["atau"]),it:new Set(["o"]),ja:new Set(["\u307E\u305F\u306F"]),ko:new Set(["\uB610\uB294"]),ms:new Set(["atau"]),pl:new Set(["lub"]),pt:new Set(["ou"]),qu:new Set(["utaq"]),ru:new Set(["\u0438\u043B\u0438"]),sw:new Set(["au"]),th:new Set(["\u0E2B\u0E23\u0E37\u0E2D"]),tl:new Set(["o"]),tr:new Set(["veya"]),uk:new Set(["\u0430\u0431\u043E"]),vi:new Set(["ho\u1EB7c"]),zh:new Set(["\u6216"])},jl=new Set(Object.values(Wr).flatMap(t=>[...t]));function qr(t,e){let r=(t.normalized??t.value).toLowerCase();if(r==="or")return true;let n=e===void 0?jl:Wr[e];return n?n.has(t.value)||n.has(r):false}var Bi=["if","unless","repeat","for","while"],Zr=/^[A-Z][A-Za-z0-9_]*$/;function Q(t,e){let r=new Set([e]),i=L(t)?.keywords?.[e];if(i){i.primary&&r.add(i.primary.toLowerCase());for(let a of i.alternatives??[])r.add(a.toLowerCase());}return r}function V(t,e){return e.has(t.value.toLowerCase())?true:t.normalized?e.has(t.normalized.toLowerCase()):false}var $l=new Set(Bi);function Dr(t){return {byAction:Bi.map(e=>[e,Q(t,e)]),elseForms:Q(t,"else"),inForms:Q(t,"in")}}function hn(t,e){if(!t)return;let r=t.normalized?.toLowerCase();return r?$l.has(r)?r:void 0:e.byAction.find(([,n])=>V(t,n))?.[0]}function Br(t,e,r){let n=t[e],i=hn(n,r);if(!i||i==="while")return false;let a=t[e-1];if(i==="for"){if(hn(a,r)==="repeat")return false;if(n.value.toLowerCase()==="for"){let o=t[e+2];return !!o&&(V(o,r.inForms)||o.normalized==="in")}}return !(i==="if"&&a&&V(a,r.elseForms))}var vn=new Set(["me","it","you","the","body","window","document","its","event","result","target","self","this","them","parent","next","previous","closest","first","last"]),Vl=new Set(["destination","source","style","patient","on","from","to"]);function nr(t){if(!t||t.kind==="selector")return false;let e=(t.normalized??t.value).toLowerCase(),r=t.value.toLowerCase();return !(vn.has(e)||vn.has(r)||Vl.has(e))}var ql=t=>Object.prototype.hasOwnProperty.call(ue,t);function Si(t){return t.flatMap(e=>e.type==="literal"?[e.value,...e.alternatives??[]].map(r=>r.toLowerCase()):e.type==="group"?Si(e.tokens):[])}var Wl=new Set(["toggle","trigger"]);function xi(t){return t.flatMap((e,r)=>{if(e.type==="group")return xi(e.tokens);if(e.type!=="literal")return [];let n=t[r+1];return [{words:[e.value,...e.alternatives??[]].map(i=>i.toLowerCase()),role:n?.type==="role"?n.role:void 0}]})}function Kl(t,e,r,n){return t.some((i,a)=>{if(!i.words.includes(e)||!i.role||!n.has(i.role))return false;let o=0;for(let u of r){let s=t.findIndex((l,c)=>c>=o&&c<a&&l.words.includes(u));if(s<0)return false;o=s+1;}return true})}function Hl(t,e,r,n,i){let a=t[r].value.toLowerCase();for(let o=r-1;o>e;o--){let u=t[o];if(i(u)||u.value.toLowerCase()===a)return false;let s=(u.normalized??u.value).toLowerCase();if(!ql(s))continue;let l=me(n).filter(d=>d.command===s);if(Wl.has(s))return l.some(d=>Si(d.template.tokens).includes(a));let c=new Set((ue[s]?.roles??[]).filter(d=>d.required).map(d=>d.role));return l.some(d=>{let m=xi(d.template.tokens),p=new Set(m.flatMap(y=>y.words)),f=t.slice(o+1,r).map(y=>y.value.toLowerCase()).filter(y=>p.has(y));return Kl(m,a,f,c)})}return false}var En=new Set(["ja","ko"]);function _e(t){let e=new Set;t?.primary&&e.add(t.primary.toLowerCase());for(let r of t?.alternatives??[])e.add(r.toLowerCase());return e}function Ti(t,e){let r=[],n=e.position.end,i=t.slice(e.position.end).match(/^\s*\(([^)]*)\)/);if(i){n=e.position.end+i[0].length;for(let a of i[1].split(/[,\u060c\u3001]/)){let o=a.trim();o&&r.push(o);}}return {parameters:r,headerEnd:n}}function Sr(t,e,r){let n=e+1;if(n>=t.length)return -1;let i=_e(L(r)?.roleMarkers?.patient);return i.size>0&&V(t[n],i)&&n++,n<t.length?n:-1}var Fi=/^[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*$/;function Ul(t){let e=1;if(t[1]?.value==="("){let r=0,n=1;for(;n<t.length;n++)if(t[n].value==="(")r++;else if(t[n].value===")"&&--r===0)break;if(n>=t.length)return -1;e=n+1;}return e+1}function Gl(t,e,r){let n=L(r);if(n?.wordOrder!=="SOV"||!Fi.test(t[0].value)||e!==Ul(t))return false;let i=_e(n.roleMarkers?.patient);return i.size===0?false:V(t[e-1],i)}function Yl(t,e,r){if(!L(e))return null;let n=Q(e,"behavior"),i=Q(e,"def"),a=t.toLowerCase(),o=[...n].some(d=>a.includes(d)),u=/\bdef\b/.test(a)||[...i].some(d=>d!=="def"&&a.includes(d));if(!o&&!u)return null;let s=Y(t,e).tokens;if(s.length<2)return null;if(V(s[0],n))return gn(t,e,s,r,0);let l=s.findIndex((d,m)=>m>0&&V(d,n));if(l>0&&Zr.test(s[0].value))return gn(t,e,s,r,l);if(V(s[0],i))return Cn(t,e,s,r,0);let c=s.findIndex((d,m)=>m>0&&V(d,i));return c>0&&Gl(s,c,e)?Cn(t,e,s,r,c):null}function Zl(t,e,r){let n=L(e);if(!n)return null;let i=n.wordOrder!=="SOV",a=En.has(e)?_e(n.roleMarkers?.event):new Set,o=En.has(e)?_e(n.keywords?.on):new Set,u=a.size>0&&o.size>0,s=u?_e(n.roleMarkers?.source):new Set,l=Q(e,"end"),c=Q(e,"on"),d=Q(e,"then"),m=t.toLowerCase(),p=[...l].some(D=>m.includes(D)),f=(i||u)&&(()=>{let D=0;for(let S of c)if(S){for(let w=m.indexOf(S);w>=0;w=m.indexOf(S,w+S.length))if(++D>=2)return true}return false})();if(!p&&!f)return null;let y=Y(t,e).tokens;if(y.length<2)return null;let v=Dr(e),h=D=>Br(y,D,v),E=D=>V(D,l),C=[],z=0,g=0;for(let D=0;D<y.length;D++){let S=y[D];if(E(S)){if(z>0){z--;continue}let w=t.slice(y[g].position.start,S.position.start).trim();w&&C.push(w),g=D+1;}else if(h(D))z++;else if(i&&z===0&&D>g&&V(S,c)&&nr(y[D+1])&&!(y[D+2]&&V(y[D+2],d))&&!Hl(y,g,D,e,w=>E(w)||V(w,d))){let w=t.slice(y[g].position.start,S.position.start).trim();w&&C.push(w),g=D;}else if(u&&z===0&&D-1>g&&V(S,a)&&y[D+1]!==void 0&&V(y[D+1],o)){let w=y[D-1],b=y.slice(g,D-1);if(!(b.length===2&&V(b[1],s))){let O=t.slice(y[g].position.start,w.position.start).trim();O&&C.push(O),g=D-1;}}}if(g<y.length){let D=t.slice(y[g].position.start).trim();D&&C.push(D);}if(C.length<2)return null;let A=[],k=[];for(let D of C){let S;try{S=r.statement(D,e);}catch{return null}if(!S||S.kind!=="event-handler")return null;let w=S;if(A.push(w),!w.body||w.body.length===0)return null;k.push(w.metadata?.confidence??.75);}return er(A,"then",{sourceLanguage:e,confidence:ur(k),sourceText:t})}function ur(t){return t.length>0?t.reduce((e,r)=>e+r,0)/t.length:0}function Jr(t){let e=[];for(let r of t){let n=r.statements;r.kind==="compound"&&Array.isArray(n)?e.push(...n):e.push(r);}return e}function gn(t,e,r,n,i){let a=i>0,o=a?0:Sr(r,i,e);if(o<0)return null;let u=r[o],s=u.value;if(!Zr.test(s))return null;let{parameters:l,headerEnd:c}=Ti(t,u),d=a?i+1:r.findIndex(b=>b.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"init"),p=Q(e,"end"),f=Dr(e),y=b=>Br(r,b,f),v=b=>V(b,p),h=L(e)?.wordOrder!=="SOV",E=h?Jl(e):new Set,C=b=>{let B=t.slice(r[S].position.end,r[b].position.start).trim();if(B)try{let O=Jr(n.body(B,e));g.push(...O),A.push(ur(O.map(_=>_.metadata?.confidence??.75)));}catch{A.push(0);}},z=[],g=[],A=[],k=false,D=0,S=d;for(let b=d;b<r.length;b++){let B=r[b];if(v(B)){if(D>0){D--;continue}if(b===S){k=true;break}if(V(r[S],m))C(b);else {let O=t.slice(r[S].position.start,B.position.start).trim();try{let _=n.statement(O,e);if(_&&_.kind==="event-handler"){let F=_;z.push(F);let T=!F.body||F.body.length===0;A.push(T?.2:F.metadata?.confidence??.75);}else A.push(0);}catch{A.push(0);}}S=b+1;}else y(b)?D++:h&&D===0&&b>S&&V(r[S],m)&&E.has(B.value.toLowerCase())&&(r[b+1]?.kind==="identifier"||r[b+1]?.kind==="keyword")&&nr(r[b+1])&&(C(b),S=b);}if(z.length===0&&g.length===0)return null;let w=(k?1:.8)*ur(A);return gs(s,l,z,g.length>0?g:void 0,{sourceLanguage:e,confidence:w,sourceText:t})}function Jl(t){let e=new Set;for(let r of me(t))if(!(r.command!=="on"||/-event-/i.test(r.id)))for(let n of r.template.tokens){if(n.type==="role"&&n.role==="event")break;if(n.type==="literal")for(let i of [n.value,...n.alternatives??[]])e.add(i.toLowerCase());}return e}function Cn(t,e,r,n,i){let a=i>0,o=a?0:Sr(r,i,e);if(o<0)return null;let u=r[o],s=u.value;if(!Fi.test(s))return null;let{parameters:l,headerEnd:c}=Ti(t,u),d=a?i+1:r.findIndex(k=>k.position.start>=c);d<=o&&(d=o+1);let m=Q(e,"end"),p=Dr(e),f=k=>Br(r,k,p),y=k=>V(k,m),v=0,h=-1;for(let k=d;k<r.length;k++)if(y(r[k])){if(v===0){h=k;break}v--;}else f(k)&&v++;let E=r[d]?.position.start??c,C=h>=0?r[h].position.start:t.length,z=t.slice(E,C).trim();if(!z)return null;let g;try{g=Jr(n.body(z,e));}catch{return null}if(g.length===0)return null;let A=ur(g.map(k=>k.metadata?.confidence??.75));return h<0&&(A*=.8),Cs(s,l,g,{sourceLanguage:e,confidence:A,sourceText:t})}var vt=["live","eventsource","socket","worker","intercept"],Xl=new Set(["intercept"]),Ft=new Set(["eventsource","socket","worker"]),Ql=new Set(["eventsource","socket"]),ec=new Set(["worker"]),rc=6,tc=2;function nc(t,e){for(let n of vt)if(V(t[0],Q(e,n)))return {action:n,keywordIdx:0};if(L(e)?.wordOrder!=="SOV")return null;let r=Math.min(t.length,rc);for(let n=1;n<r;n++)for(let i of vt)if(i!=="live"&&V(t[n],Q(e,i))&&!(Ft.has(i)&&!Zr.test(t[0].value))&&!(i==="intercept"&&n>tc))return {action:i,keywordIdx:n};return null}function ic(t,e,r){let n=_e(L(r)?.roleMarkers?.source);return n.size===0||e+1>=t.length?0:V(t[e],n)||V(t[e+1],n)?2:0}function Li(t){let e=Q(t,"on");e.add("when");let r=L(t)?.eventHandler;if(r?.keyword){e.add(r.keyword.primary.toLowerCase());for(let n of r.keyword.alternatives??[])e.add(n.toLowerCase());}for(let n of r?.temporalMarkers??[])e.add(n.toLowerCase());return e}function ac(t,e,r){let n=L(r)?.eventHandler,i=[n?.eventMarker?.primary,...n?.eventMarker?.alternatives??[],...n?.temporalMarkers??[]].filter(o=>!!o&&/\s/.test(o)),a=1;for(let o of i){let u=o.toLowerCase().split(/\s+/),s=e-u.length+1;s<0||u.every((l,c)=>t[s+c]?.value.toLowerCase()===l)&&(a=Math.max(a,u.length));}return a}function oc(t,e,r,n,i){if(t==="live")return r+1;if(r>0){let l=r+1;return t==="eventsource"&&(l+=ic(e,l,n)),l}let a=Sr(e,r,n);if(a<0)return -1;if(t==="worker")return a+1;let o=Li(n),u=_e(L(n)?.roleMarkers?.event),s=i>=0?i:e.length;for(let l=a+1;l<s;l++){if(!V(e[l],o))continue;if(nr(e[l+1]))return l;if(l>a+2&&u.size>0&&V(e[l-1],u)&&nr(e[l-2]))return l-2;let c=ac(e,l,n);if(c>1&&l-c>a&&nr(e[l-c]))return l-c;if(l>a+1&&nr(e[l-1]))return l-1}return s}function uc(t,e,r,n){if(!Ft.has(t))return;let i=r>0?0:Sr(e,r,n);if(!(i<0))return e[i].value}function sc(t,e,r){if(!L(e))return null;let n=t.toLowerCase(),i=false;for(let s of [...vt,"changes"]){for(let l of Q(e,s))if(l&&n.includes(l)){i=true;break}if(i)break}if(!i)return null;let a=Y(t,e).tokens;if(a.length<2)return null;let o=pc(a,e);if(o>=0)return yc(t,e,a,r,o);let u=nc(a,e);return u?lc(t,e,a,r,u.action,u.keywordIdx):null}function lc(t,e,r,n,i,a){let o=Q(e,"end"),u=Dr(e),s=g=>Br(r,g,u),l=g=>V(g,o),c=uc(i,r,a,e);if(Ft.has(i)&&(!c||!Zr.test(c)))return null;let d=g=>({sourceLanguage:e,confidence:g,sourceText:t}),m=Et(r,a+1,l,s);if(Xl.has(i))return m>=0&&m!==r.length-1?null:ft(i,[],c,d(m>=0?1:.8));let p=oc(i,r,a,e,m);if(p<0||p>r.length)return null;let f=[],y=[],v=false,h=ec.has(i);if(h||Ql.has(i)){let g=h?"def":"event-handler",A=0,k=p;for(let D=p;D<r.length;D++){let S=r[D];if(l(S)){if(A>0){A--;continue}if(v=true,D===k)break;let w=h?S.position.end:S.position.start,b=t.slice(r[k].position.start,w).trim();try{let B=n.statement(b,e);if(B&&B.kind===g){let O=B;f.push(O);let _=!O.body||O.body.length===0;y.push(_?.2:O.metadata?.confidence??.75);}else y.push(0);}catch{y.push(0);}k=D+1;}else s(D)&&A++;}}else {let g=Et(r,p,l,s);v=g>=0;let A=g>=0?r[g].position.start:t.length,k=t.slice(r[p].position.start,A).trim();if(!k)return null;try{f.push(...Jr(n.body(k,e)));}catch{return null}if(f.length===0)return null;y.push(...f.map(D=>D.metadata?.confidence??.75));}if(f.length===0&&!v)return null;let E=v?1:.8,C=y.length>0?E*ur(y):E,z=cc(i,t,r,a,p,e);return ft(i,f,c,d(C),z?new Map([["source",z]]):void 0)}function cc(t,e,r,n,i,a){if(t!=="eventsource"&&t!=="socket"||n!==0)return;let o=Sr(r,n,a);if(o<0)return;let u=o+1,s=Math.min(i,r.length)-1;if(t==="eventsource"){let c=_e(L(a)?.roleMarkers?.source),d=m=>!!m&&(V(m,c)||(m.normalized??"").toLowerCase()==="source");d(r[u])?u++:d(r[s])&&s--;}if(u>s)return;let l=e.slice(r[u].position.start,r[s].position.end).trim();return l?{type:"expression",raw:l}:void 0}var dc=new Set([...Object.keys(ue),"then","else"]);function mc(t){let e=Q(t,"when");for(let r of Li(t))e.add(r);return e}function pc(t,e){if(t.length<3||!V(t[0],mc(e)))return -1;let r=Q(e,"changes"),n=Q(e,"end");for(let i=2;i<t.length;i++){let a=t[i];if(a.kind==="literal")continue;if(V(a,r))return i;if(V(a,n))return -1;let o=(a.normalized??a.value).toLowerCase();if(a.kind==="keyword"&&dc.has(o))return -1}return -1}function fc(t,e,r){if(r==="en"){let i=e[0],a=e[e.length-1];return {type:"expression",raw:t.slice(i.position.start,a.position.end).trim()}}let n=e.map(i=>qr(i,r)?{...i,kind:"keyword",normalized:"or"}:i);return {type:"expression",raw:Be(n,L(r))}}function yc(t,e,r,n,i){let a=Q(e,"end"),o=Dr(e),u=E=>Br(r,E,o),s=E=>V(E,a),l=i+1;if(l>=r.length)return null;let c=Et(r,l,s,u),d=c>=0;if(d&&c!==r.length-1)return null;let m=d?r[c].position.start:t.length,p=t.slice(r[l].position.start,m).trim();if(!p)return null;let f;try{f=Jr(n.body(p,e));}catch{return null}if(f.length===0)return null;let y=fc(t,r.slice(1,i),e),h=(d?1:.8)*ur(f.map(E=>E.metadata?.confidence??.75));return ft("when",f,void 0,{sourceLanguage:e,confidence:h,sourceText:t},new Map([["condition",y]]))}function Et(t,e,r,n){let i=0;for(let a=e;a<t.length;a++)if(r(t[a])){if(i===0)return a;i--;}else n(a)&&i++;return -1}var Se={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll",\uB9C8\uC6B0\uC2A4\uC5D4\uD130:"mouseenter",\uB9C8\uC6B0\uC2A4\uB9AC\uBE0C:"mouseleave",\uB9C8\uC6B0\uC2A4\uBB34\uBE0C:"mousemove",\uD0A4\uD504\uB808\uC2A4:"keypress",\uD130\uCE58\uC885\uB8CC:"touchend",\uD130\uCE58\uCDE8\uC18C:"touchcancel"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll",\u307C\u304B\u3057:"blur"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll",\u062A\u0631\u0643\u064A\u0632:"focus","\u0645\u0641\u062A\u0627\u062D \u0623\u0633\u0641\u0644":"keydown","\u0645\u0641\u062A\u0627\u062D \u0623\u0639\u0644\u0649":"keyup","\u0641\u0623\u0631\u0629 \u0641\u0648\u0642":"mouseover","\u062A\u063A\u064A\u064A\u0631 \u062D\u062C\u0645":"resize"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll",cambiar:"change",enfocar:"focus",desenfocar:"blur",cargar:"load",desplazar:"scroll",dobleclic:"dblclick",rat\u00F3nentrar:"mouseenter",rat\u00F3nsalir:"mouseleave",rat\u00F3nmover:"mousemove",teclapresar:"keypress",descargar:"unload",toqueempezar:"touchstart",toqueterminar:"touchend",toquemover:"touchmove",toquecancelar:"touchcancel"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyutland\u0131rma:"resize",boyutland\u0131r:"resize",kayd\u0131rma:"scroll",bulan\u0131k:"blur",farebas:"mousedown",fareb\u0131rak:"mouseup",kayd\u0131r:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll",duploClique:"dblclick",mouseEntrar:"mouseenter",mouseSair:"mouseleave",mouseMover:"mousemove",teclaPressionar:"keypress",descarregar:"unload",toqueIn\u00EDcio:"touchstart",toqueFim:"touchend",toqueMover:"touchmove",toqueCancelar:"touchcancel"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll",\u6309\u952E\u6309\u4E0B:"keydown",\u9F20\u6807\u79FB\u52A8:"mousemove",\u5378\u8F7D:"unload",\u8C03\u6574\u5927\u5C0F:"resize",\u89E6\u6478\u5F00\u59CB:"touchstart",\u89E6\u6478\u79FB\u52A8:"touchmove"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll",flou:"blur",doubleclic:"dblclick",sourisentrer:"mouseenter",sourissortir:"mouseleave",sourisbouger:"mousemove",touchepress\u00E9e:"keypress",d\u00E9charger:"unload",touchercommencer:"touchstart",toucherfin:"touchend",toucherbouger:"touchmove",toucherannuler:"touchcancel"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll","taste unten":"keydown","taste oben":"keyup","maus dr\xFCber":"mouseover","maus weg":"mouseout",doppelklick:"dblclick",mauseintreten:"mouseenter",mausverlassen:"mouseleave",mausbewegen:"mousemove",tastedr\u00FCcken:"keypress",entladen:"unload",ber\u00FChrungstart:"touchstart",ber\u00FChrungend:"touchend",ber\u00FChrungbewegen:"touchmove",ber\u00FChrungabbrechen:"touchcancel"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll",tekan_tombol:"keydown",keyup:"keyup",arahkan:"mouseover",tinggalkan:"mouseout",bongkar:"unload"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",kambiay:"change",apachiy:"submit",kachay:"submit",apaykachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll",bonyeza:"click",ingizo:"input",kitufe_shuka:"keydown",kitufe_juu:"keyup",panya_nje:"mouseout",wasilisha:"submit","sogeza juu":"mouseover",shuka:"unload"},vi:{"\u0111\u1ED5i k\xEDch th\u01B0\u1EDBc":"resize"}};function Oi(t,e){let r=Se[e];return r&&r[t]?r[t]:t.toLowerCase()}function hc(t,e){let r=Se[e];return r?Object.keys(r).filter(n=>r[n]===t):[]}var vc=Object.fromEntries(Object.entries(Se).map(([t,e])=>{let r={};for(let[n,i]of Object.entries(e))i in r||(r[i]=n);return [t,r]})),Ec={ar:new Set(["mouseover"]),bn:new Set(["resize"]),de:new Set(["keydown","keyup","load","mouseout","mouseover"]),fr:new Set(["blur"]),id:new Set(["input","keyup","mouseout","mouseover"]),ja:new Set(["keypress","mousedown","mouseup","resize"]),qu:new Set(["change","focus","load","resize","submit"]),sw:new Set(["change","click","input","keydown","keyup","mouseout","mouseover","submit"]),tr:new Set(["keydown","keyup","load","mousedown","mouseout","mouseover","mouseup","resize","scroll"]),zh:new Set(["focus","keyup","mouseout","mouseover"])};function Ri(t,e){return Ec[e]?.has(t)?t:vc[e]?.[t]??t}var gc=new Set(["the","to","on","with","into","from","at"]),wn=/^[A-Za-z_$][\w$]*$/,Cc=64;function zn(t){let e="";for(let r=0;r<t.length;r++){let n=t[r],i=t[r-1];i&&n.position.start>i.position.end&&(e+=" "),e+=n.value;}return e}function wc(t,e){let r=0;for(let n=e;n<t.length&&n-e<=Cc;n++){let i=t[n].value;if(i==="(")r++;else if(i===")"&&(r--,r===0))return n+1}return -1}function kn(t,e){return e.position.start===t.position.end}function zc(t,e,r,n){let i=t[e];if(!i||i.kind!=="identifier"&&i.kind!=="keyword"||!wn.test(i.value)||n(i))return null;let a=e+1,o=i.value;for(;t[a]?.kind==="selector"&&/^\.[A-Za-z_$][\w$]*$/.test(t[a].value)&&kn(t[a-1],t[a]);)o+=t[a].value,a++;let u=a>e+1,s=t[a];if(!s||s.value!=="("||!kn(t[a-1],s))return null;let l=wc(t,a);if(l<0)return null;let c=o+zn(t.slice(a,l));if(u)return {text:`call ${c}`,consumed:l-e};let d=l,p=t[d]?.value.toLowerCase(),f=null;if(p==="me")f="me",d++;else if(p!==void 0&&gc.has(p)){d++,t[d]?.value.toLowerCase()==="the"&&d++;let y=t[d];if(!y)return null;let v=zr(t,d,r);if(v)f=`(${zn(t.slice(d,d+v.consumed))})`,d+=v.consumed;else if(y.kind==="selector"&&y.value.startsWith("#")&&!/[.[:\s]/.test(y.value.slice(1)))f=y.value,d++;else if(y.kind==="selector"&&/^[.<]/.test(y.value))f=`(${y.value})`,d++;else if((y.kind==="keyword"||y.kind==="identifier")&&wn.test(y.value)&&(xe(y.value.toLowerCase())||y.kind==="identifier"))f=y.value,d++;else return null}return {text:f?`call ${f}.${c}`:`call ${c}`,consumed:d-e}}var kc={debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"},bc=[["\u043E\u0434\u0438\u043D","_","\u0440\u0430\u0437"],["\u043E\u0434\u0438\u043D_\u0440\u0430\u0437"],["\u043E\u0434\u043D\u0430\u0436\u0434\u044B"],["m\u1ED9t","l\u1EA7n"],["once"]],Ac=/^(\d+)(ms|s|m)?$/,Dc=new Set(["selector","literal","url","event-modifier"]);function Bc(t){let e=t.match(Ac);if(!e)return null;let r=parseInt(e[1],10),n=e[2]||"ms";return n==="s"?r*=1e3:n==="m"&&(r*=6e4),r}function Sc(t){for(let e=1;e<t.length;e++){let r=t[e];if(Dc.has(r.kind))continue;let n=r.value.toLowerCase(),i=kc[n];if(i){let a=0;for(let o=e+1;o<t.length;o++){let u=t[o],s=Bc(u.value);if(s!==null)return {modifiers:{[i]:s},start:r.position.start,end:u.position.end};if(u.kind==="selector"||u.kind==="literal"||u.kind==="url"||++a>2)break}continue}for(let a of bc){if(a[0]!==n||e+a.length>t.length)continue;let o=true;for(let u=1;u<a.length;u++)if(t[e+u].value.toLowerCase()!==a[u]){o=false;break}if(o)return {modifiers:{once:true},start:r.position.start,end:t[e+a.length-1].position.end}}}return null}function xc(t,e){try{let r=Y(t,e),n=me(e);if(n.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let i=[...n].sort((l,c)=>c.priority-l.priority),a=i.filter(l=>l.command==="on"),o=ze.matchBest(r,a);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=i.filter(l=>l.command!=="on"),s=ze.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: ${t}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function Pi(t,e){try{let n=s0(t,e);if(n)return {node:n,confidence:n.metadata?.confidence??.8,error:void 0,tokensConsumed:Y(t,e).tokens.length}}catch{}let r=xc(t,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}new Set(Object.values(xt).flatMap(t=>Object.values(t)));var Hc=new Set(["a","an","the"]),Dn=new Map;function Uc(t){let e=Dn.get(t);return e||(e=new Set(Object.values(ue).flatMap(r=>r.roles.flatMap(n=>[n.markerOverride?.[t],...n.markerVariants?.[t]??[]].filter(i=>typeof i=="string"&&i.length>0)))),Dn.set(t,e)),e}function Gc(t,e){let r=Y(t,e).tokens,n=r[0];if(r.length!==1||!n)return {collision:"structure",word:"words"};let i=n.normalized!==t?n.normalized:void 0;if(n.kind==="keyword"&&Kn.has(i??""))return {collision:"pronoun",word:"pronoun",sense:i};if(n.kind==="identifier"&&!i){if(Uc(e).has(t))return {collision:"structure",word:"marker"};let a=qe(e,t);return a!==t?{collision:"structure",word:"connective",sense:a}:Hc.has(t.toLowerCase())?{collision:"structure",word:"article"}:null}return n.kind==="particle"?{collision:"structure",word:"marker"}:{collision:"structure",word:"keyword",sense:i}}function Yc(t,e){let r=`${e}\0${t}`,n=Bn.get(r);return n===void 0&&(n=Gc(t,e)?.collision??null,Bn.set(r,n)),n}var Bn=new Map;Hu((t,e)=>Yc(t,e)==="structure");var $e=new Set(["if","unless","while","repeat","for"]),Ni=new Set(["repeat","for"]),rr={kind:"loop-close"};function Lt(t){return t===rr}function Ct(t){if(Lt(t)||t.kind!=="command"||!Ni.has(t.action))return false;let e=t.body;return !(Array.isArray(e)&&e.length>0)}function Zc(t){switch(t.type){case "expression":return t.raw;case "literal":return String(t.value);case "reference":return t.value;default:return}}function Ir(t,e){for(let r=e-1;r>=0;r--)if(t[r].kind!=="particle")return t[r]}function ct(t){return t.kind!=="keyword"&&t.kind!=="identifier"?false:(t.normalized??t.value).toLowerCase()==="repeat"}function jr(t){let e=0;for(let r of t)Ct(r)?e++:Lt(r)&&e>0&&e--;return e}var dt=new Set(["then","end","else","if","unless","while","for","repeat","and"]),Jc=new Set(["first","last","next","previous","random","closest"]),Xc=new Set(["me","my","i","it","its","you","your","result"]),Sn=new Set(["top","middle","bottom","left","center","right","nearest"]),Qc=new Set(["smoothly","instantly"]);function e0(t,e){if(!e)return false;let r=e.value.toLowerCase();switch(t.type){case "selector":return t.value.toLowerCase()===r;case "reference":return t.value===(e.normalized??e.value).toLowerCase()||t.value===r;case "expression":return t.raw.toLowerCase().split(/\s+/)[0]===r;default:return String("value"in t?t.value:"").toLowerCase()===r}}var vr=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function r0(t){let e=(t.normalized??t.value).toLowerCase();return e==="document"||e==="window"||e==="me"||e==="body"?ke(e):t.kind==="selector"?Te(t.value):{type:"expression",raw:t.value}}var xn=new Map;function Tn(t){let e=xn.get(t);return e||(e=new Set(me(t).map(r=>r.command).filter(r=>r!=="on")),xn.set(t,e)),e}var 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"]),Fn=class extends Error{constructor(t,e,r,n){super(t),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=n;}};function G(t,e,r){return {message:t,severity:e,source:"semantic-parser",...r&&{code:r}}}function W(t,e){return e.length===0?t:{...t,diagnostics:e}}var Hr=120;function t0(t,e,r){let n=e.tokens.length;if(t.consumedTokens>=n)return null;let i=e.tokens[t.consumedTokens],a=e.tokens[n-1];if(!i||!a)return null;let o=r.slice(i.position.start,a.position.end);if(!o.trim())return null;let u=o.length>Hr?`${o.slice(0,Hr)}\u2026`:o,s=n-t.consumedTokens;return `pattern ${t.pattern.id} left ${s} token(s) unconsumed: "${u}"`}var Ln=/^repeat-.*-(times|for-in|while-head|until-head|until-condition-head)$/,n0=new Set(["forever","times","for","while","until","until-event"]),i0=new Set(["to","from","into","onto","with","as","at","of","in","on","by","and","or","then","end","else","the","a","an","async"]);function $r(t){let e=[],r=new Set((t.diagnostics??[]).map(i=>`${i.code}|${i.message}`)),n=i=>{if(!i||typeof i!="object")return;if(i!==t)for(let o of i.diagnostics??[]){if(o.code!=="unconsumed-input")continue;let u=`${o.code}|${o.message}`;r.has(u)||(r.add(u),e.push(o));}let a=i;for(let o of Mi){let u=a[o];if(Array.isArray(u))for(let s of u)n(s);}};return n(t),e.length===0?t:W(t,[...t.diagnostics??[],...e])}function a0(t){if(t.length>=2){let e=t[0];if((e==='"'||e==="'")&&t.endsWith(e))return t.slice(1,-1)}return t}var Mi=["body","statements","thenBranch","elseBranch","eventHandlers","initBlock"];function _i(t,e,r){if(!t||typeof t!="object")return t;if(t.action&&t.roles instanceof Map){let i=oe(t.action),a=i?.primaryRole;if(i&&a&&a!=="patient"&&!i.roles.some(o=>o.role==="patient")&&t.roles.has("patient")&&!t.roles.has(a)){let o=t.roles,u=o.get("patient");u!==void 0&&(o.delete("patient"),o.set(a,u));}if(t.action==="tell"){let o=t.roles,u=o.get("patient"),s=o.get("destination");u&&(u.type==="selector"||u.type==="reference")&&(!s||s.type==="literal")&&(o.delete("patient"),o.set("destination",u));}if(t.action==="transition"){let o=t.roles,u=o.get("goal");u&&u.type==="literal"&&u.dataType==="duration"&&!o.has("duration")&&(o.delete("goal"),o.set("duration",u));}if(t.action==="fetch"){let o=t.roles,u=o.get("patient"),s=o.get("source");u&&s&&(u.type==="literal"||u.type==="expression")&&s.type==="expression"&&!o.has("style")&&(o.delete("patient"),o.set("style",s),o.set("source",u));}if(t.action==="transition"){let o=t.roles,u=o.get("destination");u&&u.type==="literal"&&!o.has("goal")&&(o.delete("destination"),o.set("goal",u));let s=o.get("patient");s&&s.type==="literal"&&typeof s.value=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*$/.test(s.value)&&o.set("patient",{type:"expression",raw:s.value});}if(t.action==="morph"){let o=t.roles,u=o.get("patient");u&&u.type==="literal"&&typeof u.value=="string"&&/<[a-zA-Z][^>]*\/?>/.test(u.value)&&o.set("patient",{type:"expression",raw:u.value});}if(t.action==="wait"){let o=t.roles;if(!o.has("event")){let u=o.get("duration"),s=u?.type==="expression"?u.raw:u?.type==="literal"?u.value:void 0,l=typeof s=="string"&&r?Oi(s,r):"";typeof s=="string"&&De.has(s.toLowerCase())?(o.delete("duration"),o.set("event",{type:"literal",value:s,dataType:"string"})):De.has(l)&&(o.delete("duration"),o.set("event",{type:"literal",value:l,dataType:"string"}));}}if(t.kind==="command"&&t.action!=="on"){let o=t.roles,u=o.get("event");if(u&&u.type==="expression"){let s=u.raw;typeof s=="string"&&/^[A-Za-z_][A-Za-z0-9_-]*(:[A-Za-z0-9_-]+)?$/.test(s)&&o.set("event",{type:"literal",value:s,dataType:"string"});}}if(e?.size){let o=t.roles;for(let u of ["destination","source"]){let s=o.get(u);s&&s.type==="literal"&&typeof s.value=="string"&&e.has(s.value)&&o.set(u,{type:"expression",raw:s.value});}}}let n=t;for(let i of Mi){let a=n[i];if(Array.isArray(a))for(let o of a)_i(o,e,r);}return t}var Ee=class x{constructor(){this.parseDepth=0,this.coverageFrames=[],this.boundIdentifiers=new Set;}parse(e,r){this.parseDepth===0&&this.boundIdentifiers.clear(),this.parseDepth++,this.coverageFrames.push([]);try{let n=_i(this.parseInternal(e,r),this.boundIdentifiers,r),i=this.coverageFrames[this.coverageFrames.length-1];if(i.length>0&&(n=W(n,[...n.diagnostics??[],...i])),this.parseDepth===1&&(n=$r(n),n.kind==="event-handler")){let a={node:n,input:e},o=a.node.eventModifiers;if(o&&(o.once||o.debounce!==void 0||o.throttle!==void 0))for(let s=0;s<4;s++){let l=this.reclaimDanglingFromTail(a.node,a.input,r)??this.reclaimEventCompoundTail(a.node,a.input,r)??this.reclaimResponseTypeTail(a.node,a.input,r)??this.reclaimCapturedDestinationTail(a.node,a.input,r);if(!l)break;a=l;}let u=this.reclaimEventCompoundTail(a.node,a.input,r);u&&(a=u),n=a.node;}return n}finally{this.coverageFrames.pop(),this.parseDepth--;}}coverageMark(){let e=this.coverageFrames[this.coverageFrames.length-1];return e?e.length:0}coverageRollback(e){let r=this.coverageFrames[this.coverageFrames.length-1];r&&r.length>e&&(r.length=e);}static getCoverageMarkerSurfaces(e){let r=x.coverageMarkerSurfaces.get(e);if(!r){r=new Set;let n=L(e)?.roleMarkers;if(n){for(let i of Object.values(n))if(i){if(i.primary)for(let a of i.primary.toLowerCase().split(/\s+/))r.add(a);for(let a of i.alternatives??[])for(let o of a.toLowerCase().split(/\s+/))r.add(o);}}for(let i of x.LEAKED_RENDER_MARKERS[e]??[])r.add(i.toLowerCase());x.coverageMarkerSurfaces.set(e,r);}return r}isCoverageResidueToken(e,r){if(e.kind==="particle"||e.kind==="conjunction"||e.metadata?.closesTrackedBlock||this.isThenKeyword(e.value,r)||this.isEndKeyword(e.value,r)||this.isElseKeyword(e.value,r))return true;let n=(e.normalized??e.value).toLowerCase();return i0.has(n)?true:x.getCoverageMarkerSurfaces(r).has(e.value.toLowerCase())}recordDroppedTokens(e,r,n){if(e.length===0)return;let i=this.coverageFrames[this.coverageFrames.length-1];if(!i||!e.some(u=>!this.isCoverageResidueToken(u,r)))return;let a=e.map(u=>u.value).join(" ").trim();if(!a)return;let o=a.length>Hr?`${a.slice(0,Hr)}\u2026`:a;i.push(G(`${n} left ${e.length} token(s) unconsumed: "${o}"`,"warning","unconsumed-input"));}registerBoundIdentifiers(e){let r=e.action==="repeat"||e.action==="for"?"patient":e.action==="set"?"destination":null;if(!r)return;let n=e.roles.get(r);n?.type==="expression"&&typeof n.raw=="string"&&/^[A-Za-z_]\w*$/.test(n.raw)&&this.boundIdentifiers.add(n.raw);}parseInternal(e,r){let n=Yl(e,r,{statement:(w,b)=>this.parse(w,b),body:(w,b)=>this.parseStatements(w,b)});if(n)return n;let i=sc(e,r,{statement:(w,b)=>this.parse(w,b),body:(w,b)=>this.parseStatements(w,b)});if(i)return i;let a=Zl(e,r,{statement:(w,b)=>this.parse(w,b),body:(w,b)=>this.parseStatements(w,b)});if(a)return a;let{modifiers:o,remainingInput:u}=this.extractStandaloneModifiers(e,r),s=u||e,c=this.stripAsyncModifier(s,r).remainingInput??s,m=this.stripDoNotThrowModifier(c,r).remainingInput??c,p=[],f=Y(m,r);this.positionSource=m;{let w=f.mark(),b=this.consumeJsBlock(f,r);if(b&&f.isAtEnd())return W(b,p);f.reset(w);}let y=me(r);if(y.length===0)throw new Fn(`No patterns available for language: ${r}`,r,m,[G(`No patterns registered for language '${r}'`,"error","no-patterns")]);let v=[...y].sort((w,b)=>b.priority-w.priority);{let w=f.tokens;if(L(r)?.wordOrder==="VSO"&&w.length>=4&&w[0]?.normalized==="source"){let b=w.findIndex(B=>B.normalized==="on");if(b>=2&&b+1<w.length){let B=m.slice(w[0].position.start,w[b].position.start).trim(),O=w[b+1].position.end,_=m.slice(w[b].position.start,O)+" "+B+m.slice(O);if(_!==m)try{let F=this.parse(_,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return W(T,p)}}catch{}}}}{let w=f.tokens,b=w[0]?.normalized==="if";for(let B=0;b&&B+3<w.length;B++){let O=(w[B+3]?.normalized??w[B+3]?.value??"").toLowerCase();if(w[B]?.normalized==="source"&&w[B+2]?.normalized==="on"&&x.KNOWN_EVENTS.has(O)){let _=(m.slice(0,w[B].position.start).trimEnd()+" "+m.slice(w[B+1].position.end).trimStart()).trim();if(_&&_!==m)try{let F=this.parse(_,r);if(F&&F.kind==="event-handler"){let T=o?this.applyModifiers(F,o):F;return W(T,p)}}catch{}break}}}{let w=this.tryDoNotThrow(f.tokens,m,r);if(w){let b=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return W(b,p)}}{let w=this.tryTellTo(f.tokens,m,r);if(w){let b=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return W(b,p)}}{let w=this.tryScrollModifiers(f.tokens,m,r);if(w){let b=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return W(b,p)}}{let w=this.tryLoopIndex(f.tokens,m,r);if(w){let b=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return W(b,p)}}{let w=this.tryWaitAlternatives(f.tokens,m,r);if(w){let b=o&&w.kind==="event-handler"?this.applyModifiers(w,o):w;return W(b,p)}}{let w=f.tokens,b=Tn(r);for(let B=0;B+1<w.length;B++){let O=w[B];if(this.isBodyCommandWord(O,b))break;if(w[B+1].value!=="(")continue;let _=(O.normalized??O.value).toLowerCase();if(!(x.KNOWN_EVENTS.has(_)||De.has(_))&&O.kind!=="identifier")continue;let T=this.matchEventParamPhrase(w,B+1);if(T.len===0)continue;let N=w[B+T.len],K=(m.slice(0,w[B+1].position.start).trimEnd()+" "+m.slice(N.position.end).trimStart()).trim();try{let M=this.parse(K,r);if(M?.kind==="event-handler"){let I=this.reclaimEventCompoundTail($r(M),K,r);I&&(M=I.node);}let $=M?.roles.get("event"),fe=($?.type==="expression"?$.raw:$&&"value"in $?String($.value):void 0)?.toLowerCase(),H=m.slice(0,w[B+1].position.start).trimEnd().toLowerCase(),P=fe===O.value.toLowerCase()||fe===_||fe!==void 0&&hc(fe,r).some(I=>H.endsWith(I.toLowerCase()));if(M?.kind==="event-handler"&&P){M.parameterNames=T.names;let I=o?this.applyModifiers(M,o):M;return W(I,p)}}catch{}}}{let w=f.tokens,b=Tn(r);for(let B=1;B<w.length-1;B++){let O=w[B];if(this.isBodyCommandWord(O,b))break;if(!qr(O,r))continue;let _=w[B+1],F=(_.normalized??_.value).toLowerCase();if(!x.KNOWN_EVENTS.has(F))break;let T=B+1,N=w[B+2];N&&N.kind==="selector"&&N.value.startsWith("[")&&(T=B+2);let K=w[B].position.start,M=w[T].position.end,$=(m.slice(0,K).trimEnd()+" "+m.slice(M).trimStart()).trim();if($&&$!==m)try{let ie=this.parse($,r);if(ie&&ie.kind==="event-handler"){ie.additionalEvents=[{type:"literal",value:T>B+1?F+N.value:F}];let fe=o?this.applyModifiers(ie,o):ie;return W(fe,p)}}catch{}break}}{let w=Sc(f.tokens);if(w){let b=(m.slice(0,w.start).trimEnd()+" "+m.slice(w.end).trimStart()).trim();if(b&&b!==m)try{let B=this.parse(b,r);if(B&&B.kind==="event-handler"){let O=this.applyModifiers(B,{...o??{},...w.modifiers});return W(O,p)}}catch{}}}let h=v.filter(w=>w.command==="on"),E=f.mark(),C=ze.matchBest(f,h);if(C){p.push(G(`event pattern matched: ${C.pattern.id} (confidence: ${C.confidence.toFixed(2)})`,"info","pattern-match"));let w=false;if(/^event-[a-z]+-bare$/.test(C.pattern.id)){let b=C.captured.get("event"),B=(b?.raw??b?.value??"").toString().toLowerCase(),O=Se[r],_=x.KNOWN_EVENTS.has(B)||!!O&&Object.keys(O).some(F=>F.toLowerCase()===B);if(B&&!_){let F=this.trySOVEventExtraction(m,r,v);if(F){p.push(G(`bare-event mis-anchor on "${B}" rejected; SOV extraction preferred`,"info","stage-bare-event-guard"));let T=o?this.applyModifiers(F,o):F;return W(T,p)}if(b?.type==="reference"||b?.type==="expression"){f.reset(E);let T=v.filter(K=>K.command!=="on"),N=ze.matchBest(f,T);f.reset(E),N&&N.pattern.command!=="on"?(w=true,p.push(G(`bare-event mis-anchor on reference "${B}" rejected; command ${N.pattern.command} preferred`,"info","stage-bare-event-guard"))):ze.matchBest(f,h);}}}if(!w){let b=this.buildEventHandler(C,f,r),B=o?this.applyModifiers(b,o):b;return W(B,p)}}p.push(G(`event patterns: ${h.length} tried, no match`,"info","stage-event"));let z=this.tryTrailingEventExtraction(m,r,v);if(z){p.push(G("trailing event extraction succeeded","info","stage-trailing-event"));let w=o?this.applyModifiers(z,o):z;return W(w,p)}let g=v.filter(w=>w.command!=="on"),A=this.tryParseUnlessGuard(f,g,r);if(A&&A.length>0){let w=A.length===1?A[0]:er(A,"then",{sourceLanguage:r,confidence:1});return W(w,p)}let k=ze.matchBest(f,g);if(k){if($e.has(k.pattern.command)){let b=this.trySOVEventExtraction(m,r,v);if(b){p.push(G(`SOV event extraction preferred over bare ${k.pattern.command} command`,"info","stage-sov-loop"));let O=o?this.applyModifiers(b,o):b;return W(O,p)}let B=this.tryMidStreamEventExtraction(m,r,v);if(B){p.push(G(`mid-stream event extraction preferred over bare ${k.pattern.command} command`,"info","stage-midstream-loop"));let O=o?this.applyModifiers(B,o):B;return W(O,p)}}else if(x.KNOWN_EVENTS.has(k.pattern.command)&&this.hasSOVEventMarkerHead(m,r)){let b=this.trySOVEventExtraction(m,r,v);if(b){p.push(G(`SOV event extraction preferred over command-homonym event ${k.pattern.command}`,"info","stage-sov-homonym"));let B=o?this.applyModifiers(b,o):b;return W(B,p)}}else if(L(r)?.wordOrder==="VSO"){let b=this.tryMidStreamEventExtraction(m,r,v);if(b){p.push(G(`mid-stream event extraction preferred over bare ${k.pattern.command} command`,"info","stage-midstream-cmd"));let B=o?this.applyModifiers(b,o):b;return W(B,p)}}if(k.consumedTokens<f.tokens.length&&L(r)?.wordOrder==="SOV"){let b=this.trySOVEventExtraction(m,r,v);if(b){p.push(G(`SOV event extraction preferred over partial ${k.pattern.command} command (trailing remainder)`,"info","stage-sov-trailing"));let B=o?this.applyModifiers(b,o):b;return W(B,p)}}if(k.consumedTokens<f.tokens.length&&Ni.has(k.pattern.command)){let b=this.tryTopLevelLoop(f,g,r);if(b)return p.push(G(`top-level loop: ${b.kind}`,"info","stage-top-level-loop")),W(b,p)}if(k.consumedTokens<f.tokens.length&&!$e.has(k.pattern.command)){let b=this.tryTopLevelCommandSequence(f,g,r);if(b)return p.push(G(`top-level command sequence: ${b.statements.length} commands`,"info","stage-top-level-sequence")),W(b,p)}if(k.consumedTokens<f.tokens.length&&(k.pattern.command==="if"||k.pattern.command==="unless")){let b=this.tryCompoundCommandParsing(f,g,r);if(b)return p.push(G("conditional with a trailing body","info","stage-compound")),W(b,p)}p.push(G(`command pattern matched: ${k.pattern.id} (confidence: ${k.confidence.toFixed(2)})`,"info","pattern-match"));let w=t0(k,f,m);return w&&p.push(G(w,"warning","unconsumed-input")),W(this.buildCommand(k,r),p)}if(p.push(G(`command patterns: ${g.length} tried, no match`,"info","stage-command")),!m.includes(`
5
+ `)&&L(r)?.wordOrder==="VSO"){let w=this.tryMidStreamEventExtraction(m,r,v);if(w){p.push(G("mid-stream event extraction succeeded with no leading command match","info","stage-midstream-nocmd"));let b=o?this.applyModifiers(w,o):w;return W(b,p)}}let D=this.trySOVEventExtraction(m,r,v);if(D){p.push(G("SOV event extraction succeeded","info","stage-sov"));let w=o?this.applyModifiers(D,o):D;return W(w,p)}p.push(G("SOV event extraction: no event keyword found","info","stage-sov"));let S=this.tryCompoundCommandParsing(f,g,r);if(S)return p.push(G("compound command parsing succeeded","info","stage-compound")),W(S,p);if(p.push(G("compound parsing: no then-keywords or no command matches","info","stage-compound")),r==="en"){let w=Y(m,r),b=this.tryParsePseudoCommand(w,g,r);if(b&&w.isAtEnd())return p.push(G("pseudo-command parsed as call","info","stage-pseudo")),W(b,p)}throw p.push(G(`all parse stages exhausted for "${m}"`,"error","parse-failed")),new Fn(`Could not parse input in ${r}: ${m}`,r,m,p)}tryParsePseudoCommand(e,r,n){if(n!=="en")return null;let i=zc(e.tokens,e.position(),L(n),u=>!!oe((u.normalized??u.value).toLowerCase()));if(!i)return null;let a=Y(i.text,n),o=ze.matchBest(a,r.filter(u=>u.command==="call"));if(!o||!a.isAtEnd())return null;for(let u=0;u<i.consumed;u++)e.advance();return this.buildCommand(o,n)}parseStatements(e,r){let n=Y(e,r),i=me(r).filter(a=>a.command!=="on").sort((a,o)=>o.priority-a.priority);this.coverageFrames.push([]);try{let a=this.parseBodyWithClauses(n,i,r),o=this.coverageFrames[this.coverageFrames.length-1];if(o.length>0&&a.length>0){let u=a[a.length-1];a[a.length-1]=W(u,[...u.diagnostics??[],...o]);}return a}finally{this.coverageFrames.pop();}}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return Di()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let n={};for(let[a,o]of e.captured)n[a]=o;let i=de(e.pattern.command,n,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence});return this.registerBoundIdentifiers(i),i}buildEventHandler(e,r,n){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");{let C=i.type==="expression"?i.raw:i.type==="literal"?i.value:void 0;if(typeof C=="string"&&/^[^\s()[\]{}:]+$/.test(C)){let z=Se[n]?.[C];z?i={type:"literal",value:z,dataType:"string"}:i.type==="expression"&&x.KNOWN_EVENTS.has(C.toLowerCase())&&(i={type:"literal",value:C.toLowerCase(),dataType:"string"});}}let a=ze.extractEventModifiers(r),o=C=>!(C.type==="reference"&&C.value==="me")&&C.implicit!==true,u=e.captured.get("source"),s=e.pattern.command==="on"&&/^(on|event)-/.test(e.pattern.id),l=false;u&&(e.pattern.id.endsWith("source")||s)&&o(u)&&(a={...a??{},from:u},l=true);let c;if(e.eventSource&&!l){let C=e.captured.get("action"),z=C?.type==="literal"?oe(String(C.value)):void 0;L(n)?.roleMarkers?.source?.position==="after"&&z?.roles.some(A=>A.role==="source")&&!e.captured.has("source")?c=e.eventSource:o(e.eventSource)&&(a={...a??{},from:e.eventSource});}let d=e.captured.get("event")?.position,m=r.tokens[r.position()-1],f=d!==void 0&&m!==void 0&&m.position.end>d.end?[]:this.extractOrConjunctionEvents(r,n),y=i;f.length>0&&i.type==="literal"&&(y={type:"literal",value:[String(i.value),...f.map(z=>String("value"in z?z.value:""))].join(" or ")});let v,h=e.captured.get("action");if(h&&h.type==="literal"&&h.value==="if"){let C=r.tokens,z=-1;for(let g=r.position()-1;g>=0;g--){let A=C[g],k=(A.normalized??A.value).toLowerCase();if(this.isIfKeyword(k,n)){z=g;break}}for(;z>0;){let g=C[z-1];if(!this.isIfKeyword((g.normalized??g.value).toLowerCase(),n))break;z--;}if(z>=0){let g=me(n).filter(b=>b.command!=="on").sort((b,B)=>B.priority-b.priority),A=C.slice(z);if(e.pattern.id.endsWith("vso-verb-first")&&y.type==="literal"){let b=String(y.value??"").split("[")[0].trim().toLowerCase(),B=A.findIndex((O,_)=>{if(_===0||b==="")return false;let F=(O.normalized??O.value).toLowerCase(),T=A[_-1];return F===b&&T.kind==="keyword"&&(T.normalized??"").toLowerCase()==="on"});if(B>0){let O=A[B+1],_=O&&O.kind==="selector"&&O.value.startsWith("[")?1:0;A=[...A.slice(0,B-1),...A.slice(B+1+_)];}}let k=new ce(A,n),D=this.coverageMark(),S=this.parseBodyWithClauses(k,g,n);if(S.some(b=>b.kind==="conditional")||S.length===1&&S[0]?.kind==="compound"&&S[0].statements.some(b=>b.kind==="conditional")){for(;!r.isAtEnd();)r.advance();return hr(y,S,a,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}this.coverageRollback(D);}}if(h&&h.type==="literal"&&String(h.value)!=="js"&&oe(String(h.value))!==void 0){let C=h.value,z={};for(let[T,N]of e.captured)if(T!=="event"&&T!=="action"&&T!=="continues"){if(T==="source"&&l)continue;z[T]=N;}if(c&&(z.source=c),C==="repeat"){let T=r.peek(),N=M=>(M.normalized??M.value).toLowerCase();if(T&&T.kind==="keyword"&&N(T)==="forever")z.loopType={type:"literal",value:"forever"},delete z.patient,r.advance();else if(T&&T.kind==="keyword"&&N(T)==="event"){r.advance();let M=r.peek();if(M)for(z.event={type:"literal",value:N(M)},z.loopType={type:"literal",value:"until-event"},delete z.patient;!r.isAtEnd();){let $=r.peek();if(!$||$.kind==="conjunction"||$.kind==="keyword"&&(this.isThenKeyword($.value,n)||this.isEndKeyword($.value,n)))break;r.advance();}}let K=z.patient;K&&K.type==="reference"&&K.value==="me"&&delete z.patient;}let g=de(C,z,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence});this.registerBoundIdentifiers(g);let A=[];if(!$e.has(C)||C==="repeat"||C==="while"){let T=e.pattern.id.includes("verb-first"),N=r.tokens,K=r.position(),M=P=>{let I=N[P];if(I.kind==="conjunction")return true;if(I.kind!=="keyword")return false;let J=he(N,P);return this.isThenAt(I,J,n)||this.isEndKeyword(I.value,n)&&!Le(J,n)},$=C==="repeat"||C==="while",ie=P=>M(P)||$&&this.isBlockEndToken(N[P],he(N,P),n),fe=new Set;{let P=L(n)?.keywords?.[C];P?.primary&&fe.add(P.primary.toLowerCase());for(let I of P?.alternatives??[])fe.add(I.toLowerCase());}let H=-1;for(let P=K-1;P>=0;P--){let I=N[P];if(M(P))break;if((I.normalized??I.value).toLowerCase()===C||fe.has(I.value.toLowerCase())){H=P;break}}if(H>=0){let P=K,I=0;for(;P<N.length;){let ae=N[P],Ce=Ir(N,P);if($&&this.isIfKeyword((ae.normalized??ae.value).toLowerCase(),n)&&!(Ce&&this.isElseKeyword(Ce.value,n)))I++;else if(I>0)this.isBlockEndToken(ae,he(N,P),n)&&I--;else if(ie(P))break;P++;}let J=N.slice(H,P),ge=J;if(T){let ae=String(i.value??"").toLowerCase(),Ce=J.findIndex(se=>(se.normalized??se.value).toLowerCase()===ae);if(Ce<0)ge=null;else {let se=J[Ce-1],le=se&&se.kind==="keyword"&&se.normalized?.toLowerCase()==="on"?Ce-1:Ce;ge=[...J.slice(0,le),...J.slice(Ce+1)];}}if(ge&&ge.length>1){let ae=me(n).filter(q=>q.command!=="on").sort((q,X)=>X.priority-q.priority),Ce=this.coverageMark(),se=this.parseClause(ge,ae,n),le=se[0],Ue=q=>q!==null&&typeof q=="object"&&typeof q.type=="string"?q.type:typeof q,Ge=oe(C),rt=Ge?.primaryRole,qt=q=>q==="patient"&&rt&&rt!=="patient"&&!Ge?.roles.some(X=>X.role==="patient")?rt:q,Ca=(q,X)=>{if(!$e.has(C)||!Ge)return false;let Pe=Ge.roles.find(mr=>mr.role===qt(q));return Pe?Pe.expectedTypes.length>0&&!Pe.expectedTypes.includes(Ue(X)):true},tt=(q,X)=>q==="patient"&&!!Ge&&!Ge.roles.some(Pe=>Pe.role==="patient")&&Ue(X)==="literal"&&Ar.has(String(X.value??"").toLowerCase()),nt=q=>q!==null&&typeof q=="object"&&q.implicit===true,wa=!!le&&le.kind==="command"&&Object.entries(z).every(([q,X])=>{if(nt(X)||Ca(q,X)||tt(q,X))return true;let Pe=le.roles.get(qt(q));if(Pe!==void 0&&Ue(Pe)===Ue(X))return true;if(q==="patient"&&C==="pick"&&Ue(X)==="literal"){let mr=le.roles.get("method"),Kt=Ue(mr),Ht=Kt==="literal"?String(mr.value):Kt==="expression"?String(mr.raw):void 0;return Ht!==void 0&&Ht===String(X.value)}return false}),Wt=le?.metadata?.patternId??"",za=!$e.has(C)||Ln.test(Wt),ka=Ln.test(Wt);if((se.length===1||ka&&se.length>1)&&le&&le.kind==="command"&&(le.action===C||C==="while"&&le.action==="repeat"&&/-while-head$/.test(le.metadata?.patternId??""))&&wa&&za&&(le.roles.size>Object.entries(z).filter(([q,X])=>!tt(q,X)).length||[...le.roles.values()].filter(q=>!nt(q)).length>Object.entries(z).filter(([q,X])=>!tt(q,X)&&!nt(X)).length))for(g=le,A=se.slice(1);r.position()<P;)r.advance();else this.coverageRollback(Ce);}}}if(!$e.has(C)){let T=g;if(oe(C)?.roles.some(H=>H.role==="quantity"&&!H.required)&&!T.roles.has("quantity")){let H=r.peek();H&&/^-?\d+(\.\d+)?$/.test(H.value)&&(g=de(C,{...Object.fromEntries(T.roles),quantity:{type:"literal",value:parseFloat(H.value),dataType:"number"}},T.metadata),r.advance());}let K=g;if(oe(C)?.roles.some(H=>H.role==="duration"&&!H.required)&&!K.roles.has("duration")){let H=/^\d+(\.\d+)?(ms|s)$/i,P=r.peek(),I=false;if(P&&P.kind==="particle"){let J=r.peek(1);J&&H.test(J.value)&&(I=true,P=J);}P&&H.test(P.value)&&(g=de(C,{...Object.fromEntries(K.roles),duration:{type:"literal",value:P.value,dataType:"string"}},K.metadata),I&&r.advance(),r.advance(),this.consumeForPostposition(r,n));}let $=g,ie=oe(C);if(ie?.roles.find(H=>H.role==="responseType"&&!H.required)&&!$.roles.has("responseType")){let H=ae=>typeof ae=="string"&&x.RESPONSE_TYPE_WORDS.has(ae.toLowerCase()),P=(ae,Ce)=>{let se=Object.fromEntries($.roles);Ce&&delete se.destination,se.responseType={type:"expression",raw:ae},g=de(C,se,$.metadata);},I=$.roles.get("destination"),J=ie?.roles.find(ae=>ae.role==="destination"),ge=I?.raw??I?.value;if(I&&J&&!J.expectedTypes.includes(I.type)&&H(ge))P(ge,true);else {let ae=r.peek();ae&&H(ae.value)&&(P(ae.value,false),r.advance());}}if(C==="wait"){let H=g;if(!H.roles.has("event")){let P=r.peek();if(P&&De.has(P.value.toLowerCase())){let I=Object.fromEntries(H.roles),J=I.duration;J&&J.type!=="literal"&&J.type!=="expression"&&delete I.duration;let ge=I.patient;ge&&ge.type==="reference"&&ge.value==="me"&&delete I.patient,I.event={type:"literal",value:P.value,dataType:"string"},g=de(C,I,H.metadata),r.advance(),this.consumeForPostposition(r,n);}}}this.tryAttachTrailingRole(r,g,n),this.tryAttachTrailingStyle(r,g,n),this.tryAttachTrailingExpressionRole(r,g,n),this.tryAttachNewWindow(r,g);}let k=e.captured.get("continues"),D=k?.type==="literal"&&k.value==="then",S=r.peek(),w=!!S&&this.isThenKeyword(S.value,n),B=$e.has(C)&&!!S&&!this.isEndKeyword(S.value,n),O=!!S&&!this.isEndKeyword(S.value,n),_=[g,...A],F=!!S&&this.isEndKeyword(S.value,n)&&jr(_)>0&&r.peek(1)!==null;if(F&&(r.advance(),_.push(rr)),D||w||B||O||F){let T=me(n).filter(M=>M.command!=="on").sort((M,$)=>$.priority-M.priority),N=me(n).filter(M=>M.id.startsWith("grammar-")&&M.id.includes("-continuation")).sort((M,$)=>$.priority-M.priority),K=this.parseBodyWithGrammarPatterns(r,T,N,n,_);v=this.foldLoopBlocks([..._,...K]);}else v=this.foldLoopBlocks(_),r.isAtEnd()||this.recordDroppedTokens(r.tokens.slice(r.position()),n,"handler body tail");}else {let C=me(n).filter(g=>g.command!=="on").sort((g,A)=>A.priority-g.priority),z=h?e.roleStarts?.get("action"):void 0;if(z!==void 0&&z<r.position()){let g=new ce(r.tokens.slice(z),n);for(v=this.parseBodyWithClauses(g,C,n);!r.isAtEnd();)r.advance();}else v=this.parseBodyWithClauses(r,C,n);}let E=v.length>1?[er(v,"then",{sourceLanguage:n})]:v;return hr(y,E,a,{sourceLanguage:n,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,n){let i=[],a=[],o=0,u=[],s=(c=0)=>{let d=jr(i);o=d+c,u.length=0;for(let m=0;m<d;m++)u.push("loop");for(let m=0;m<c;m++)u.push("while");};for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(a.length===0){let C=this.consumeJsBlock(e,n)??this.consumeVerbFinalJsBlock(e,n);if(C){i.push(C);continue}let z=this.tryParseConditionalBlock(e,r,n);if(z){i.push(z);continue}let g=this.tryParseUnlessGuard(e,r,n);if(g){i.push(...g);continue}}let d=c.kind==="conjunction"||c.kind==="keyword"&&this.isThenAt(c,he(e.tokens,e.position()),n),m=a[a.length-1],p=e.peek(1),f=m?.value.toLowerCase()==="at"&&p?.value.toLowerCase()==="of"||st(n,c.value,m?.value,p?.value),y=c.kind==="keyword"&&this.isEndKeyword(c.value,n)&&!f&&!Le(he(e.tokens,e.position()),n);if((y||!f&&this.isBlockEndToken(c,he(e.tokens,e.position()),n))&&u.every(C=>C==="loop")&&this.closeLoopAtEnd(e,a,i,r,n)){a.length=0,s();continue}if(y&&o>0){o--,u.pop(),a.push({...c,metadata:{...c.metadata,closesTrackedBlock:true}}),e.advance();continue}if(d&&u.includes("if")){a.push(c),e.advance();continue}if(d){if(a.length>0){let C=this.parseClause(a,r,n);i.push(...C),a.length=0,s(C.filter(z=>{let g=z;return g.action==="while"&&(!Array.isArray(g.body)||g.body.length===0)}).length);}e.advance();continue}if(y){e.advance();let C=[];for(;!e.isAtEnd();){let z=e.peek();if(!z||z.kind==="conjunction"||z.kind==="keyword"&&(this.isThenKeyword(z.value,n)||this.isEndKeyword(z.value,n)))break;C.push(z),e.advance();}if(C.length>0){let z=this.coverageMark(),g=a.length>0?this.parseClause(a,r,n):[];g.length===0&&a.length>0?(this.coverageRollback(z),i.push(...this.parseClause([...a,...C],r,n))):(i.push(...g),i.push(...this.parseClause(C,r,n)));}else if(a.length>0){let z=this.parseClause(a,r,n);i.push(...z);}a.length=0;break}let h=(c.normalized??c.value).toLowerCase(),E=ct(c);if(c.kind==="keyword"||E){let C=this.isIfKeyword(h,n),z=Ir(a,a.length);(h==="for"||h==="while")&&z&&ct(z)||C&&z&&this.isElseKeyword(z.value,n)||(E&&u[u.length-1]==="while"?u[u.length-1]="loop":(C||this.isUnlessKeyword(h,n)||h==="while"||h==="for"||E)&&(o++,u.push(C?"if":E||h==="for"?"loop":h==="while"?"while":"other")));}a.push(c),e.advance();}if(a.length>0){let c=this.parseClause(a,r,n);i.push(...c);}e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),n,"body stream tail"),this.foldFrontedWhileIntoRepeat(i,n);for(let c=i.length-1;c>=0;c--){let d=i[c];d.kind==="command"&&d.action==="for"&&(!(d.roles instanceof Map)||d.roles.size===0)&&(!Array.isArray(d.body)||d.body.length===0)&&i.splice(c,1);}let l=this.foldLoopBlocks(i);return l.length>1?[er(l,"then",{sourceLanguage:n})]:l}closeLoopAtEnd(e,r,n,i,a){let o=jr(n);if(r.length===0)return o===0?false:(n.push(rr),e.advance(),true);let u=this.coverageMark(),s=this.parseClause([...r],i,a);return s.length===0||o+s.filter(Ct).length===0?(this.coverageRollback(u),false):(n.push(...s,rr),e.advance(),true)}foldLoopBlocks(e){let r=[],n=[],i=o=>{(n.length>0?n[n.length-1].body:r).push(o);},a=o=>{let u=n.pop();u&&i(this.buildLoopNode(u.head,u.body,o));};for(let o of e)Lt(o)?a(true):Ct(o)?n.push({head:o,body:[]}):i(o);for(;n.length>0;)a(false);return r}buildLoopNode(e,r,n=false){if(r.length===0&&!n)return e;let i=e.roles.get("loopType");if(i?.type==="literal"&&typeof i.value=="number"){let d=new Map(e.roles);return d.set("quantity",i),d.set("loopType",{type:"literal",value:"times"}),this.buildLoopNode({...e,roles:d},r,n)}let a=i?.type==="literal"?String(i.value):void 0,o=e.action==="for"||a==="for"?"for":a==="times"||a==="while"||a==="forever"?a:a==="until"||a==="until-event"?"until":e.roles.has("quantity")?"times":"forever",u=o==="for"?e.roles.get("patient"):void 0,s=u?Zc(u):void 0,l=new Map(e.roles),c=l.get("quantity");return (o==="while"||o==="until")&&c&&!l.has("condition")&&(l.set("condition",c),l.delete("quantity")),zs(e.action==="for"?"for":"repeat",o,Object.fromEntries(l),r,{...s?{loopVariable:s}:{},...e.metadata?{metadata:e.metadata}:{}})}tryTopLevelLoop(e,r,n){let i=this.coverageMark(),a;try{let u=new ce(e.tokens,n);a=this.parseBodyWithClauses(u,r,n);}catch{return this.coverageRollback(i),null}let[o]=a;if(a.length===1&&o.kind==="loop")return o;if(a.length===1&&o.kind==="compound"){let u=o;if(u.statements[0]?.kind==="loop"){let s=u.statements.map(l=>l.metadata?.confidence??.75);return er(u.statements,u.chainType,{sourceLanguage:n,confidence:s.reduce((l,c)=>l+c,0)/s.length})}}return this.coverageRollback(i),null}tryTopLevelCommandSequence(e,r,n){let i=this.coverageMark(),a;try{let l=new ce(e.tokens,n);a=this.parseBodyWithClauses(l,r,n);}catch{return this.coverageRollback(i),null}if(a.length!==1||a[0].kind!=="compound")return this.coverageRollback(i),null;let o=a[0];if(o.statements.length<2)return this.coverageRollback(i),null;let u=o.statements.map(l=>l.metadata?.confidence??.75),s=u.reduce((l,c)=>l+c,0)/u.length;return er(o.statements,o.chainType,{sourceLanguage:n,confidence:s})}foldFrontedWhileIntoRepeat(e,r){for(let n=0;n+1<e.length;n++){let i=e[n],a=e[n+1];if(i.kind!=="command"||i.action!=="while"||a.kind!=="command"||a.action!=="repeat")continue;let o=i.roles.get("condition");if(!o||a.roles.has("condition")||Array.isArray(i.body)||Array.isArray(a.body))continue;let u=new Map(a.roles);u.set("condition",o),u.set("loopType",{type:"literal",value:"while",dataType:"string"}),e.splice(n,2,{...a,roles:u,metadata:{...a.metadata,sourceLanguage:r,patternId:`repeat-${r}-fronted-while-fold`,confidence:Math.max(a.metadata?.confidence??0,i.metadata?.confidence??0)}});}}takeRepeatCount(e,r,n){if(L(n)?.wordOrder==="SOV"){let o=x.countBeforeVerb(r,n);if(o<0)return;let u=r[o];return r.length=o,u}let i=e.mark();e.peek()?.kind==="particle"&&e.advance();let a=e.peek();if(a&&x.countsBefore(a,e.peek(1),n))return e.advance(),e.advance(),a;if(!x.isCountToken(a)){e.reset(i);return}return e.advance(),e.peek()?.kind==="identifier"&&e.advance(),a}static isCountToken(e){let r=e?.kind==="literal"?Vr(e):null;return r?.type==="literal"&&typeof r.value=="number"}static countsBefore(e,r,n){return !e||!r||!ri[n]?.includes(r.value)?false:e.kind==="identifier"||x.isCountToken(e)}static countBeforeVerb(e,r){let n=x.isCountToken,i=e.length;return e[i-1]?.kind==="particle"&&i--,x.countsBefore(e[i-2],e[i-1],r)?i-2:(e[i-1]?.kind==="identifier"&&n(e[i-2])&&i--,n(e[i-1])?i-1:-1)}loopHeadReadsBody(e,r,n){if(L(n)?.wordOrder!=="SOV")return false;if(x.countBeforeVerb(r,n)>=0)return true;let i=e.captured.get("loopType");return i?.type==="literal"&&typeof i.value!="number"&&!n0.has(String(i.value))}bareRepeatHead(e,r){let n=e?Vr(e):null;return de("repeat",e&&n?{loopType:Z("times"),quantity:Xn(n,{start:e.position.start,end:e.position.end})}:{},{sourceLanguage:r,confidence:.6})}parseClause(e,r,n){if(e.length===0)return [];let i=null,a=e,o=e[e.length-1];if(o&&e.length>=2){let h=(o.normalized??o.value).toLowerCase();this.isUnlessKeyword(h,n)&&(i="unless",a=e.slice(0,-1));}let u=null;if(i&&a.length>=3){let h=L(n),E=h?x.buildVerbLookup(h):null;if(E)for(let C=1;C<a.length-1;C++){let z=a[C],g=E.get(z.value.toLowerCase())??(z.normalized?E.get(z.normalized.toLowerCase()):void 0);if(g&&!x.CONDITION_OPERATORS.has(g)){u=a.slice(0,C),a=a.slice(C);break}}}let s=new ce(a,n),l=[],c=this.coverageMark(),d=0,m=[],p=u,f=()=>{if(m.length===0)return;let h=m.slice();if(m.length=0,i&&l.length===0&&p===null){p=h;return}let E=h[0];if(!(E&&(E.kind==="identifier"||E.kind==="selector"||E.kind==="literal"||E.kind==="reference"))){this.recordDroppedTokens(h,n,"body clause");return}let z=false;for(let g of this.parseSOVClauseByVerbAnchoring(h,n)){let A=g.action,k=g.roles;A&&oe(A)&&k instanceof Map&&k.size>0&&(l.push(g),z=true);}z||this.recordDroppedTokens(h,n,"body clause");};for(;!s.isAtEnd();){let h=s.peek(),E=!!h&&h.normalized?.toLowerCase()==="repeat",C=s.mark(),z=ze.matchBest(s,r);if(E&&z&&(z.pattern.command!=="repeat"||this.loopHeadReadsBody(z,m,n))){s.reset(C),s.advance();let g=this.takeRepeatCount(s,m,n);f(),l.push(this.bareRepeatHead(g,n)),d++;continue}if(!z&&h&&this.isIfKeyword((h.normalized??h.value).toLowerCase(),n)){let g=this.tryParseConditionalBlock(s,r,n);if(g){f(),l.push(g),d++;continue}}if(z&&z.pattern.command==="if"){let g=s.mark(),A=m.length;for(s.reset(C);!s.isAtEnd();){let D=s.peek();if(!D||this.isIfKeyword((D.normalized??D.value).toLowerCase(),n))break;m.push(D),s.advance();}let k=this.tryParseConditionalBlock(s,r,n);if(k){f(),l.push(k),d++;continue}m.length=A,s.reset(g);}if(z){f();let g=this.buildCommand(z,n);l.push(g),d++,this.tryAttachTrailingRole(s,g,n),this.tryAttachTrailingStyle(s,g,n),this.tryAttachTrailingExpressionRole(s,g,n),this.tryAttachTrailingDuration(s,g);}else {let g=m.length===0?this.tryParsePseudoCommand(s,r,n):null;if(g){f(),l.push(g),d++;continue}let A=s.peek(),k=A?.kind==="identifier"&&A.value.toLowerCase()==="repeat";if(A&&(A.normalized?.toLowerCase()==="repeat"||k)){let D=s.mark();s.advance();let S=this.takeRepeatCount(s,m,n);if(S||!k){f(),l.push(this.bareRepeatHead(S,n)),d++;continue}s.reset(D);}A&&m.push(A),s.advance();}}f();let y=l;if(d===0){let h=this.parseSOVClauseByVerbAnchoring(a,n);h.length>0&&(this.coverageRollback(c),y=h);}let v=p;return i&&y.length>0&&v&&v.length>0?[de(i,{condition:{type:"expression",raw:this.joinTokenText(v,n)}},{sourceLanguage:n,patternId:`${i}-${n}-trailing-guard`,confidence:.85}),...y]:i&&v&&v.length>0&&y.length===0?[de(i,{condition:{type:"expression",raw:this.joinTokenText(v,n)}},{sourceLanguage:n,patternId:`${i}-${n}-trailing-guard`,confidence:.85})]:y}tryAttachTrailingDuration(e,r){let n=r.roles;if(n.has("duration")||!oe(r.action)?.roles.some(o=>o.role==="duration"&&!o.required))return;let a=e.peek();!a||!/^\d+(?:\.\d+)?(?:ms|s|m|h)$/.test(a.value)||(n.set("duration",Z(a.value,"duration")),e.advance());}tryAttachNewWindow(e,r){let n=r.roles;if(r.action!=="go"||n.has("manner"))return;let[i,a,o]=[e.peek(),e.peek(1),e.peek(2)];if(!(i?.value.toLowerCase()!=="in"||a?.value.toLowerCase()!=="new")&&!(!o||(o.normalized??o.value).toLowerCase()!=="window")){n.set("manner",ke("window"));for(let u=0;u<3;u++)e.advance();}}tryAttachTrailingRole(e,r,n){let i=oe(r.action);if(!i)return;let a=L(n);if(!a)return;let o=r.roles,u=(l,c)=>{if(!l)return false;if(l.kind==="selector")return true;let d=(l.normalized??l.value).toLowerCase();return dt.has(d)?false:d==="body"||d==="it"||d==="you"||d==="result"||d==="document"||d==="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(!i.roles.some(v=>v.role===l))continue;let d=a.roleMarkers?.[l];if(!d)continue;let m=o.get(l);if(m&&!(m.type==="reference"&&m.value==="me"))continue;let p=v=>{if(!v||v.kind!=="particle"&&v.kind!=="keyword")return false;let h=v.value.toLowerCase();return d.primary?.toLowerCase()===h?true:c?false:(v.normalized??"").toLowerCase()===l?true:!!d.alternatives?.some(E=>E.toLowerCase()===h)},f=e.peek(),y=e.peek(1);if(!f||!y)return;if(c&&d.position==="after"){let v=e.peek(2),h=(f.normalized??f.value).toLowerCase();if(Jc.has(h)&&y.kind==="selector"&&p(v)){o.set(l,{type:"expression",raw:`${h} ${y.value}`}),e.advance(),e.advance(),e.advance();return}}if(d.position==="after"){if(u(f,c)&&p(y)){let v=this.tokenToSemanticValue(f);e.advance(),e.advance(),v&&o.set(l,v);return}if(c&&u(f,c)){let v=e.peek(2),h=e.peek(3);if((y.normalized??y.value).toLowerCase()==="in"&&v&&!p(v)&&p(h)){let E=this.tokenToSemanticValue(f);e.advance(),e.advance(),e.advance(),e.advance(),E&&o.set(l,E);return}}}else if(p(f)&&u(y,c)){e.advance();let v=this.tokenToSemanticValue(e.advance());v&&o.set(l,v);return}}}tryAttachTrailingStyle(e,r,n){if(r.action!=="fetch"&&r.action!=="render")return;let i=r.roles;if(!oe(r.action)?.roles.some(h=>h.role==="style"))return;let o=i.get("style");if(o){if(o.type==="expression"&&typeof o.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(o.raw)&&e.peek()?.value===":"){let h=Cr(e,o.raw);h&&i.set("style",{type:"expression",raw:h});}this.tryAttachResponseTypeAfterStyle(e,r,n);return}if(r.action==="fetch"){let h=i.get("patient"),E=i.get("source");if(h&&E&&(h.type==="literal"||h.type==="expression")&&E.type==="expression"&&typeof E.raw=="string"&&/^[A-Za-z_][\w-]*$/.test(E.raw)&&e.peek()?.value===":"){let C=Cr(e,E.raw);C&&(i.set("source",{type:"expression",raw:C}),this.tryAttachResponseTypeAfterStyle(e,r,n));return}}let s=L(n)?.roleMarkers?.style;if(!s)return;if(s.position==="before"){let h=new Set([s.primary,...s.alternatives??[]].map(g=>g.toLowerCase())),E=e.peek();if(!E||!h.has(E.value.toLowerCase()))return;let C=e.mark();e.advance();let z=Cr(e);if(!z){e.reset(C);return}i.set("style",{type:"expression",raw:z}),this.tryAttachResponseTypeAfterStyle(e,r,n);return}if(s.position!=="after")return;let l=new Set([s.primary,...s.alternatives??[]].map(h=>h.toLowerCase())),c=h=>h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,n)||this.isEndKeyword(h.value,n)),d=24,m=-1,p=0;for(let h=0;h<d;h++){let E=e.peek(h);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),p===0&&(E.kind==="particle"||E.kind==="keyword")&&l.has(E.value.toLowerCase())){m=h;break}}if(m<=0)return;let f=[];for(let h=0;h<m;h++){let E=e.peek(h);E&&f.push(E);}if(f.length===1&&x.RESPONSE_TYPE_WORDS.has(f[0].value.toLowerCase()))return;let y=new ce(f,n),v=Cr(y);i.set("style",{type:"expression",raw:v&&y.isAtEnd()?v:this.joinTokenText(f,n)});for(let h=0;h<=m;h++)e.advance();this.tryAttachResponseTypeAfterStyle(e,r,n);}tryAttachResponseTypeAfterStyle(e,r,n){let i=r.roles;if(i.has("responseType")||!oe(r.action)?.roles.some(c=>c.role==="responseType"&&!c.required))return;let o=c=>!!c&&x.RESPONSE_TYPE_WORDS.has(c.toLowerCase()),u=e.peek();if(!u)return;let s=c=>{i.set("responseType",{type:"expression",raw:c});};if(x.AS_MARKERS_BEFORE[n]?.some(c=>u.value.toLowerCase()===c)){let c=e.peek(1);c&&o(c.value)&&(e.advance(),e.advance(),s(c.value));return}if(o(u.value)){e.advance(),s(u.value);for(let c of x.AS_MARKERS_AFTER[n]??[])if(c.every((d,m)=>e.peek(m)?.value.toLowerCase()===d)){for(let d=0;d<c.length;d++)e.advance();break}}}tryAttachTrailingExpressionRole(e,r,n){let i=r.action,a=i==="js"?{role:"patient",terminator:"boundary"}:i==="go"||i==="scroll"?{role:"destination",terminator:"destination-marker"}:null;if(!a)return;let o=r.roles,u=o.get(a.role);if(i==="go"&&u&&u.type==="expression"&&String(u.raw).toLowerCase()==="url"){let h=e.peek();if(h&&!dt.has((h.normalized??h.value).toLowerCase())){let C=this.tokenToSemanticValue(h);if(C.type==="literal"||C.type==="selector"){o.set(a.role,C),o.set("method",{type:"literal",value:"url"}),e.advance();return}}let E=o.get("patient");if(E&&(E.type==="literal"||E.type==="selector")){o.set(a.role,E),o.set("method",{type:"literal",value:"url"}),o.delete("patient");return}}if(i==="go"&&u&&u.type==="expression"){let h=/^url\s+(\S+)$/i.exec(String(u.raw??""));if(h){let E=h[1].replace(/^["']|["']$/g,"");o.set(a.role,{type:"literal",value:E,dataType:"string"}),o.set("method",{type:"literal",value:"url"});return}}if(i==="go"&&!u){let h=o.get("patient");if(h&&h.type==="expression"&&String(h.raw).toLowerCase()==="url"){let E=e.peek();if(E&&!dt.has((E.normalized??E.value).toLowerCase())){let C=this.tokenToSemanticValue(E);if(C.type==="literal"||C.type==="selector"){o.set(a.role,C),o.set("method",{type:"literal",value:"url"}),o.delete("patient"),e.advance();return}}}}if(u&&!(u.type==="reference"&&u.value==="me"))return;let s=L(n);if(!s)return;let l=null;if(a.terminator==="destination-marker"){let h=s.roleMarkers?.destination;if(!h||h.position!=="after")return;l=h.primary.toLowerCase();}let c=h=>h.kind==="conjunction"||h.kind==="keyword"&&(this.isThenKeyword(h.value,n)||this.isEndKeyword(h.value,n)),d=24,m=[],p=0,f=false;for(let h=0;h<d;h++){let E=e.peek(h);if(!E||c(E))break;if(E.value==="("||E.value==="{"?p++:(E.value===")"||E.value==="}")&&(p=Math.max(0,p-1)),l!==null&&p===0&&(E.kind==="particle"||E.kind==="keyword")&&E.value.toLowerCase()===l){f=true;break}m.push(E);}if(m.length===0||l!==null&&!f)return;let y=m.length+(f?1:0);if(i==="go"&&m.length===2&&m[0].value.toLowerCase()==="url"){let h=this.tokenToSemanticValue(m[1]);if(h.type==="literal"||h.type==="selector"){o.set(a.role,h),o.set("method",{type:"literal",value:"url"});let E=o.get("patient");E&&E.type==="reference"&&E.value==="me"&&!oe(i)?.roles.some(C=>C.role==="patient")&&o.delete("patient");for(let C=0;C<y;C++)e.advance();return}}let v=m;if(i==="js"){let h=s.keywords?.js,E=z=>[h?.primary,...h?.alternatives??[]].some(g=>!!g&&g.length>z.value.length&&g.includes(z.value)),C=0;for(;C<v.length&&E(v[C]);)C++;if(v=v.slice(C),v.length===0)return}if(o.set(a.role,{type:"expression",raw:this.joinTokenText(v,n)}),a.role!=="patient"){let h=o.get("patient");h&&h.type==="reference"&&h.value==="me"&&!oe(i)?.roles.some(E=>E.role==="patient")&&o.delete("patient");}for(let h=0;h<y;h++)e.advance();}static buildVerbLookup(e){let r=new Map;for(let[n,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","end","then","and"].includes(n)&&(r.set(i.primary.toLowerCase(),n),i.alternatives))for(let a of i.alternatives)r.set(a.toLowerCase(),n);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[n,i]of Object.entries(e.roleMarkers)){if(!i)continue;if((n!=="event"||!r.has(i.primary))&&r.set(i.primary,n),i.alternatives)for(let o of i.alternatives)r.has(o)||r.set(o,n);}return r}parseSOVClauseByVerbAnchoring(e,r){let n=L(r);if(!n||n.wordOrder!=="SOV")return [];let i=x.buildVerbLookup(n),a=x.buildMarkerToRoleLookup(n),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let f=u;f<e.length;f++){let y=e[f];if(a.has(y.value))continue;let v=i.get(y.value.toLowerCase()),h=y.normalized?i.get(y.normalized.toLowerCase()):void 0,E=v||h;if(E){s=f,l=E;break}}if(s===-1)break;let c=e.slice(u,s),d=e.length;for(let f=s+1;f<e.length;f++){let y=e[f];if(y.kind==="conjunction"||this.isThenKeyword(y.value,r)){d=f;break}if(f>s+1&&!a.has(y.value)&&(i.get(y.value.toLowerCase())||(y.normalized?i.get(y.normalized.toLowerCase()):void 0))){d=f;break}}let m=e.slice(s+1,d),p=this.extractRolesFromMarkedTokens(c,m,a,l,r);if(o.push(de(l,p,{sourceLanguage:r,confidence:.7})),u=d,u<e.length){let f=e[u];(f.kind==="conjunction"||this.isThenKeyword(f.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,n,i,a){let o={},u=(l,c)=>{let d=this.isEndKeyword(l.value,a),m=l.kind==="keyword"&&(l.normalized??"").toLowerCase()==="end";return !d&&!m?false:l.metadata?.closesTrackedBlock===true||d?true:!(c&&c.kind==="selector")},s=l=>{let c=[];for(let d=0;d<l.length;d++){let m=l[d];if(u(m,l[d+1]))continue;let p=n.get(m.value);if(p&&m.kind==="particle"&&c.length>0){let f=this.tokensToSemanticValue(c,a);if(f){let y=this.mapRoleForCommand(p,i,o);y&&(o[y]=f);}c=[];}else c.push(m);}if(c.length>0)if(c.length===1&&/^\d+(\.\d+)?(ms|s)$/i.test(c[0].value)&&!o.duration&&oe(i)?.roles.some(m=>m.role==="duration"))o.duration={type:"literal",value:c[0].value,dataType:"string"};else {let m=this.tokensToSemanticValue(c,a);m&&(o.patient?o.destination||(o.destination=m):o.patient=m);}};return s(e),s(r),o}mapRoleForCommand(e,r,n){return r==="set"&&(e==="patient"?e="destination":e==="destination"&&(e="patient")),n[e]?e==="patient"&&!n.destination?"destination":e==="destination"&&!n.patient?"patient":e==="source"&&!n.source?"source":null:e}tokensToSemanticValue(e,r){if(e.length===0)return null;let n=e.filter(u=>u.kind!=="whitespace");if(n.length===0)return null;if(n.length>=2&&(n[0].kind==="selector"||/^[#.@*<]/.test(n[0].value))){let u=n.findIndex((s,l)=>l>0&&(s.normalized??s.value).toLowerCase()==="in");u>0&&(n=n.slice(0,u));}if(n.length===1)return this.tokenToSemanticValue(n[0]);let i=this.joinTokenText(n,r);if(gi(i))return {type:"expression",raw:i};let a=n.map(u=>u.value).join(""),o=n[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Te(a):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?Z(a0(a),"string"):o.kind==="reference"?ke(a):Z(i)}tokenToSemanticValue(e){return Vr(e)??Z(e.value)}parseBodyWithGrammarPatterns(e,r,n,i,a=[]){let o=[],u=()=>jr([...a,...o]),s=[],l=false,c=()=>{if(!l&&s.length>0){let p=this.parseSOVClauseByVerbAnchoring(s,i);o.push(...p),p.length===0&&this.recordDroppedTokens(s,i,"fused body walk");}else s.length>0&&this.recordDroppedTokens(s,i,"fused body walk");s=[],l=false;},d=0,m=()=>o.filter(p=>{let f=p;return f.action==="while"&&(!Array.isArray(f.body)||f.body.length===0)}).length-d;for(;!e.isAtEnd();){let p=e.peek();if(p&&this.isThenKeyword(p.value,i)){c(),e.advance();continue}if(p&&u()>0&&!this.isEndKeyword(p.value,i)&&this.isBlockEndToken(p,he(e.tokens,e.position()),i)&&!st(i,p.value,e.peek(-1)?.value,e.peek(1)?.value)){c(),o.push(rr),e.advance();continue}if(p&&this.isEndKeyword(p.value,i)){let y=e.peek(-1),v=e.peek(1);if(!st(i,p.value,y?.value,v?.value)){if(c(),u()>0){o.push(rr),e.advance();continue}if(m()>0){d++,e.advance();continue}e.advance();break}}if(p&&!l&&this.isIfKeyword((p.normalized??p.value).toLowerCase(),i)){c();let y=this.tryParseConditionalBlock(e,r,i);if(y){o.push(y),l=true;continue}}let f=false;if(n.length>0){let y=ze.matchBest(e,n);if(y){let v=y.pattern.command,h={};for(let[z,g]of y.captured)z!=="event"&&z!=="action"&&z!=="continues"&&(h[z]=g);let E=de(v,h,{sourceLanguage:i,patternId:y.pattern.id});o.push(E),f=true,l=true;let C=y.captured.get("continues");if(C&&C.type==="literal"&&C.value==="then")continue}}if(!f){let y=e.mark(),v=ze.matchBest(e,r);if(v){if(v.pattern.command==="if"){let E=e.mark();for(e.reset(y);!e.isAtEnd();){let z=e.peek();if(!z||this.isIfKeyword((z.normalized??z.value).toLowerCase(),i))break;e.advance();}let C=this.tryParseConditionalBlock(e,r,i);if(C){c(),o.push(C),l=true;continue}e.reset(E);}let h=this.buildCommand(v,i);o.push(h),this.tryAttachTrailingRole(e,h,i),f=true,l=true;}}f||(p&&s.push(p),e.advance());}c(),e.isAtEnd()||this.recordDroppedTokens(e.tokens.slice(e.position()),i,"fused body walk");for(let p=o.length-1;p>=0;p--){let f=o[p];f.kind==="command"&&f.action==="for"&&(!(f.roles instanceof Map)||f.roles.size===0)&&(!Array.isArray(f.body)||f.body.length===0)&&o.splice(p,1);}return o}tryCompoundCommandParsing(e,r,n){let i=e.tokens,a=i.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,n)),o=i.some(c=>this.isElseKeyword(c.value,n));if(!a&&!o)return null;let u=new ce(i,n),s=this.coverageMark(),l=this.parseBodyWithClauses(u,r,n);return l.length===0?(this.coverageRollback(s),null):l[0]}static isEnEventKeyword(e){if(typeof e!="string")return false;let r=e.toLowerCase(),n=x.enEventKeywordCache.get(r);if(n!==void 0)return n;let i=false;try{let a=Y(r,"en").tokens;i=a.length===1&&a[0]?.kind==="keyword";}catch{i=false;}return x.enEventKeywordCache.set(r,i),i}matchEventMarkerPhrase(e,r,n){let i=x.SOV_EVENT_MARKER_PHRASES[n];if(!i)return 0;for(let a of i)if(a.every((o,u)=>e[r+u]?.value===o))return a.length;return 0}hasSOVEventMarkerHead(e,r){let n=x.SOV_EVENT_MARKERS[r];if(n===void 0)return false;let{tokens:i}=Y(e,r),a=Se[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<i.length;u++){let s=i[u],l=s.value.toLowerCase(),c=s.normalized?.toLowerCase();if(!(!!c&&(x.KNOWN_EVENTS.has(c)||De.has(c))||x.KNOWN_EVENTS.has(l)||De.has(l)||o.has(l)))continue;let m=this.matchEventParamPhrase(i,u+1).len,p=i[u+1+m];if(p&&(p.kind==="particle"||p.kind==="keyword")&&n.has(p.value)||this.matchEventMarkerPhrase(i,u+1+m,r)>0)return true}return false}tryScrollModifiers(e,r,n){let i=p=>p?.value.toLowerCase()??"",a=-1,o=-1;for(let p=0;p<e.length&&a<0;p++){let f=i(e[p])==="the"?p+1:p;Sn.has(i(e[f]))&&(Sn.has(i(e[f+1]))&&f++,!(i(e[f+1])!=="of"||!e[f+2])&&(a=p,o=f+1));}let u=a<0?e.findIndex(p=>Qc.has(i(p))):-1;if(a<0&&u<0)return null;let s=a>=0?a:u,l=a>=0?o:u,c=r.slice(0,e[s].position.start).trimEnd(),d=r.slice(e[l].position.end).trimStart(),m=c?c.length+1:0;try{let p=this.parse(c?`${c} ${d}`:d,n),f=[],y=E=>{if(!E)return;E.kind==="command"&&(E.action==="go"||E.action==="scroll")&&f.push(E);let C=E;for(let z of vr){let g=C[z];Array.isArray(g)&&g.forEach(A=>y(A));}};y(p??void 0);let v=E=>E.roles.get("destination")?.position?.start??-1,h=E=>f.filter(C=>v(C)>=0&&v(C)<=E).reduce((C,z)=>!C||v(z)>v(C)?z:C,void 0);if(!p)return null;if(a>=0){let E=h(m),C=E?.roles.get("destination"),z=e[o+1];if(!E||!C||!e0(C,z))return null;let g=e.slice(a,o).map(A=>A.value.toLowerCase());E.scrollPosition=g.join(" ");}else {let E=h(e[u].position.start-1);if(!E)return null;E.scrollBehavior=i(e[u]);}return p}catch{return null}}tryDoNotThrow(e,r,n){let i=s=>s?.value.toLowerCase(),a=e.findIndex((s,l)=>i(s)==="do"&&i(e[l+1])==="not"&&i(e[l+2])==="throw");if(a<0)return null;let o=e[a].position.start,u=(r.slice(0,e[a].position.start).trimEnd()+" "+r.slice(e[a+2].position.end).trimStart()).trim();try{let s=this.parse(u,n),l=[],c=p=>{if(!p)return;p.kind==="command"&&p.action==="fetch"&&l.push(p);let f=p;for(let y of vr){let v=f[y];Array.isArray(v)&&v.forEach(h=>c(h));}};c(s??void 0);let d=p=>p.roles.get("source")?.position?.start??-1,m=l.filter(p=>d(p)>=0&&d(p)<o).reduce((p,f)=>!p||d(f)>d(p)?f:p,void 0);return !s||!m?null:(m.doNotThrow=!0,s)}catch{return null}}tryTellTo(e,r,n){let i=s=>(s.normalized??s.value).toLowerCase()==="tell",a=e.findIndex(i);if(a<0)return null;let o=L(n)?.roleMarkers?.destination,u=new Set([o?.primary,...o?.alternatives??[]].filter(s=>!!s));for(let s=a+1;s<e.length;s++){if(e[s].value.toLowerCase()!=="to")continue;let l=e[s].position.start,c=(r.slice(0,l).trimEnd()+" "+r.slice(e[s].position.end).trimStart()).trim();try{let d=this.parse(c,n);if(!d)continue;let m=[],p=E=>{if(!E)return;E.kind==="command"&&m.push(E);let C=E;for(let z of vr){let g=C[z];Array.isArray(g)&&g.forEach(A=>p(A));}};p(d);let f=E=>E.roles.get("destination")?.position?.start??-1,y=m.filter(E=>E.action==="tell"&&f(E)>=0&&f(E)<l).reduce((E,C)=>!E||f(C)>f(E)?C:E,void 0);if(!y)continue;let v=y.roles.get("destination")?.position?.end??-1;if(v<0||!e.filter(E=>E.position.start>=v&&E.position.start<l).every(E=>i(E)||u.has(E.value)))continue;return y.tellTo=!0,d}catch{continue}}return null}tryLoopIndex(e,r,n){let i=l=>l?.value.toLowerCase(),a=new Set;for(let l of me(n))if(!(l.command!=="repeat"&&l.command!=="for")){for(let c of l.template.tokens)if(c.type==="literal")for(let d of [c.value,...c.alternatives??[]])a.add(d.toLowerCase());}let o=l=>a.has(l.value.toLowerCase()),u=L(n)?.roleMarkers?.style?.primary?.toLowerCase(),s=l=>i(l)==="with"||!!u&&i(l)===u;for(let l=0;l+1<e.length;l++){let c=s(e[l])&&i(e[l+1])==="index",d=i(e[l])==="index";if(!c&&!d)continue;let m=e[l].position.start,p=(r.slice(0,m).trimEnd()+" "+r.slice(e[l+1].position.end).trimStart()).trim();try{let f=this.parse(p,n);if(!f)continue;let y=[],v=k=>{if(!k)return;k.kind==="loop"&&y.push(k);let D=k;for(let S of vr){let w=D[S];Array.isArray(w)&&w.forEach(b=>v(b));}};v(f);let h=k=>Math.max(-1,...[...k.roles.values()].map(D=>D.position?.end??-1).filter(D=>D<=m)),E=y.filter(k=>h(k)>=0).reduce((k,D)=>!k||h(D)>h(k)?D:k,void 0);if(!E)continue;let C=e.filter(k=>k.position.start>=h(E)&&k.position.start<m),z=E.roles.get("quantity"),g=z?.type==="literal"&&typeof z.value=="number"?z.position?.end:void 0,A=g===void 0?void 0:e.find(k=>k.position.start>=g);if(!C.every(k=>k===A||o(k)))continue;return E.indexVariable=c?"index":e[l+1].value,c&&(E.indexWith=!0),f}catch{continue}}return null}tryWaitAlternatives(e,r,n){let i=v=>!!v&&(v.normalized??v.value).toLowerCase()==="wait";if(!e.some(v=>i(v)))return null;let a=v=>(v.normalized??v.value).toLowerCase(),o=v=>{if(!v)return;let h=C=>x.KNOWN_EVENTS.has(C)||De.has(C);if(h(a(v)))return a(v);let E=Oi(v.value,n);return h(E)?E:void 0},u=v=>o(v)!==void 0,s=v=>!!v&&/^\d+(?:\.\d+)?(?:ms|s)$/.test(v.value),l=L(n)?.roleMarkers?.source,c=new Set([l?.primary,...l?.alternatives??[]].filter(Boolean).map(v=>v.toLowerCase())),d=v=>!!v&&((v.normalized??"")==="source"||c.has(v.value.toLowerCase())),m=l?.position!=="after",p=L(n)?.wordOrder==="SOV",f=(v,h)=>p?i(e[h])||e[h]?.kind==="particle"&&i(e[h+1]):i(e[v-1])||i(e[v-2]),y=v=>{let h=Ri(o(e[v]),n).split(/\s+/);return h.length<2||e[v].value!==h[0]?1:h.every((E,C)=>C===0||e[v+C]?.value===E)?h.length:1};for(let v=0;v<e.length;v++){if(!u(e[v]))continue;let h=[],E=v+y(v),C=this.matchEventParamPhrase(e,E);h.push(C.names.length>0?{event:o(e[v]),params:C.names}:{event:o(e[v])});let z=E+C.len;for(;qr(e[z]??{value:""},n);){let F=e[z+1];if(u(F)){let T=z+1+y(z+1),N=this.matchEventParamPhrase(e,T);h.push(N.names.length>0?{event:o(F),params:N.names}:{event:o(F)}),z=T+N.len;}else if(s(F))h.push({duration:F.value}),z+=2;else break}let g=z,A,k;if(m&&d(e[z])&&e[z+1]?(A=[z,z+1],k=e[z+1]):!m&&e[z]&&d(e[z+1])&&(A=[z,z+1],k=e[z]),!(h.length>1||C.names.length>0||!!A))continue;let S=A?A[1]+1:g;if(!f(v,S))continue;let w=[];g>E&&w.push([e[E-1].position.end,e[g-1].position.end]),A&&w.push([e[A[0]].position.start,e[A[1]].position.end]),w.sort((F,T)=>F[0]-T[0]);let b="",B=0;for(let[F,T]of w)b+=r.slice(B,F)+" ",B=T;b=(b+r.slice(B)).replace(/\s+/g," ").trim();let O=h[0],_=0;for(let F=0;F<v;F++)o(e[F])===O.event&&f(F,F+1)&&_++;try{let F=this.parse(b,n),T=[],N=M=>{if(!M)return;let $=M.roles?.get("event"),ie=$?.type==="expression"?$.raw:$&&"value"in $?String($.value):void 0;M.kind==="command"&&M.action==="wait"&&ie?.toLowerCase()===O.event&&T.push(M);let fe=M;for(let H of vr){let P=fe[H];Array.isArray(P)&&P.forEach(I=>N(I));}};N(F??void 0);let K=T[_];if(!F||!K)continue;return K.waitAlternatives=h,k&&(K.waitSource=r0(k)),F}catch{}}return null}isBodyCommandWord(e,r){let n=(e.normalized??e.value).toLowerCase();return e.kind==="keyword"&&r.has(n)&&!x.KNOWN_EVENTS.has(n)&&!De.has(n)}matchEventParamPhrase(e,r){if(e[r]?.value!=="(")return {len:0,names:[]};let n=[];for(let i=r+1;i<e.length;i++){let a=e[i].value;if(a===")")return e[r-1]?.position?.end!==e[r]?.position?.start&&e[i+1]?.kind==="particle"?{len:0,names:[]}:{len:i-r+1,names:n};if(a===",")continue;let o=e[i].kind;if(o!=="identifier"&&o!=="keyword"||!/^[A-Za-z_$][\w$]*$/.test(a))break;let u=(e[i].normalized??a).toLowerCase();if(o==="keyword"&&Xc.has(u))break;n.push(a);}return {len:0,names:[]}}isStrippableSourceRef(e,r){if(!e)return false;let n=e.normalized?.toLowerCase();if(e.kind==="keyword"&&(n==="me"||n==="i"||n==="it"))return true;let i=e.value.toLowerCase();return r.has(i)||!!n&&r.has(n)}tryTrailingEventExtraction(e,r,n){let i=Y(e,r).tokens;if(i.length<3)return null;let a=Se[r],o=new Set;if(a)for(let z of Object.keys(a))o.add(z.toLowerCase());let u=i.length-2,s=i[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))return null;let c=i[i.length-1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&x.KNOWN_EVENTS.has(m)||x.KNOWN_EVENTS.has(d)||o.has(d)))return null;let f=m&&x.KNOWN_EVENTS.has(m)?m:a?.[d]??d,y=i.slice(0,u);if(y.length===0)return null;let v=n.filter(z=>z.command!=="on"),h=new ce(y,r),E=this.coverageMark(),C=this.parseBodyWithClauses(h,v,r);return C.length===0?(this.coverageRollback(E),null):hr({type:"literal",value:f},C,void 0,{sourceLanguage:r,confidence:.75})}tryMidStreamEventExtraction(e,r,n){let i=Y(e,r).tokens;if(i.length<3)return null;let a=Se[r],o=new Set;if(a)for(let u of Object.keys(a))o.add(u.toLowerCase());for(let u=0;u<i.length-1;u++){let s=i[u];if(!(s.kind==="keyword"&&s.normalized?.toLowerCase()==="on"))continue;let c=i[u+1],d=c.value.toLowerCase(),m=c.normalized?.toLowerCase();if(!(!!m&&x.KNOWN_EVENTS.has(m)||x.KNOWN_EVENTS.has(d)||o.has(d)))continue;let f=m&&x.KNOWN_EVENTS.has(m)?m:a?.[d]??d,y=i.filter((z,g)=>g!==u&&g!==u+1);if(y.length===0)return null;let v=n.filter(z=>z.command!=="on"),h=new ce(y,r),E=this.coverageMark(),C=this.parseBodyWithClauses(h,v,r);return C.length===0?(this.coverageRollback(E),null):hr({type:"literal",value:f},C,void 0,{sourceLanguage:r,confidence:.75})}return null}trySOVEventExtraction(e,r,n){let i=x.SOV_EVENT_MARKERS[r];if(!i)return null;let o=Y(e,r).tokens,u=Se[r],s=new Set;if(u)for(let A of Object.keys(u))s.add(A.toLowerCase());let l=x.SOV_SOURCE_MARKERS[r],c=-1,d="",m="",p=1,f=[];for(let A=0;A<o.length;A++){let k=o[A],D=k.value.toLowerCase(),S=D,w="",b=D.indexOf("[");b>0&&(S=D.slice(0,b),w=k.value.slice(b));let B=k.normalized?.toLowerCase(),O=B&&(x.KNOWN_EVENTS.has(B)||De.has(B)),_=s.has(D)||s.has(S),F=x.KNOWN_EVENTS.has(S)||De.has(S);if(O||_||F){let T=o[A-1];if(T&&(T.normalized??T.value).toLowerCase()==="event")continue;let N;O?N=B:_?N=u?.[D]??u?.[S]??S:N=S;let K=this.matchEventParamPhrase(o,A+1);if(i.size>0){let M=1+K.len,$=o[A+M];$&&$.kind==="selector"&&$.value.startsWith("[")&&(M+=1);let ie=o[A+M];if(ie&&(ie.kind==="particle"||ie.kind==="keyword")&&i.has(ie.value)){c=A,d=N,m=w||(M===K.len+2?o[A+M-1].value:""),p=M+1,f=K.names;break}}else {c=A,d=N,m=w,p=1+K.len+this.matchEventMarkerPhrase(o,A+1+K.len,r),f=K.names;break}}}if(c===-1){let A=new Set(n.filter(k=>k.command!=="on").map(k=>k.command));for(let k=0;k<o.length;k++){let D=o[k];if(D.kind==="identifier")if(i.size>0){let S=1,w=o[k+1];w&&w.kind==="selector"&&w.value.startsWith("[")&&(S=2);let b=o[k+S];if(b&&(b.kind==="particle"||b.kind==="keyword")&&i.has(b.value)){c=k,d=D.value,m=S===2?o[k+1].value:"",p=S+1;break}}else {let S=this.matchEventMarkerPhrase(o,k+1,r);if(S>0){c=k,d=D.value,m="",p=1+S;break}let w=o[k+1];if(w&&w.kind==="keyword"&&w.normalized!=null&&A.has(w.normalized)){c=k,d=D.value,m="",p=1;break}}}}if(c===-1)return null;let y=new Set;for(let A=c;A<c+p;A++)y.add(A);if(l){let A=c+p;if(A<o.length){let k=o[A];if((k.kind==="particle"||k.kind==="keyword")&&l.markers.has(k.value))y.add(A);else if(this.isStrippableSourceRef(k,l.windowTokens)){let D=o[A+1];D&&(D.kind==="particle"||D.kind==="keyword")&&l.markers.has(D.value)&&(y.add(A),y.add(A+1));}}if(c>=2){let k=o[c-1];(k.kind==="particle"||k.kind==="keyword")&&l.markers.has(k.value)&&this.isStrippableSourceRef(o[c-2],l.windowTokens)&&(y.add(c-2),y.add(c-1));}for(let k=0;k<c;k++){let D=o[k],S=D.value.toLowerCase(),w=D.normalized?.toLowerCase();if(l.windowTokens.has(S)||w&&l.windowTokens.has(w)){y.add(k);break}}}let v=o.filter((A,k)=>!y.has(k));if(v.length===0)return null;let h=n.filter(A=>A.command!=="on"),E=new ce(v,r),C=this.coverageMark(),z=this.parseBodyWithClauses(E,h,r);if(z.length===0)return this.coverageRollback(C),null;let g={sourceLanguage:r,confidence:.75};return m&&(g.keyFilter=m),hr(x.isEnEventKeyword(d)?{type:"literal",value:d}:{type:"expression",raw:d},z,void 0,g,f)}profileKeywordMatches(e,r,n){let i=L(e)?.keywords?.[r];return i?i.primary?.toLowerCase()===n?true:!!i.alternatives?.some(a=>a.toLowerCase()===n):false}consumeForPostposition(e,r){let n=e.peek();if(!n)return;let i=(n.normalized??"").toLowerCase(),a=L(r)?.keywords?.for;(i==="for"||n.value===a?.primary||(a?.alternatives??[]).includes(n.value))&&e.advance();}isThenAt(e,r,n){return this.isThenKeyword(e.value,n)?!(this.isEndKeyword(e.value,n)&&Le(r,n)):false}isThenKeyword(e,r){let n=e.toLowerCase(),a={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B"]),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\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u90A3\u4E48"]),tr:new Set(["ard\u0131ndan","daha sonra","ardindan"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])}[r];return a?a.has(n):n==="then"||this.profileKeywordMatches(r,"then",n)}isElseKeyword(e,r){let n=e.toLowerCase();return n==="else"?true:this.profileKeywordMatches(r,"else",n)}isEndKeyword(e,r){let n=e.toLowerCase(),i=Ds(r);return i?n==="end"||i.has(n):n==="end"||this.profileKeywordMatches(r,"end",n)}isJsKeyword(e){let r=(e.normalized??e.value).toLowerCase();return r==="js"||this.profileKeywordMatches("en","js",r)}isPatientMarker(e,r){let n=L(r)?.roleMarkers?.patient;if(!n?.primary)return false;let i=e.value.toLowerCase();return n.primary.toLowerCase()===i?true:!!n.alternatives?.some(a=>a.toLowerCase()===i)}isJsBlockTerminator(e,r){return this.isEndKeyword(e,r)||this.profileKeywordMatches(r,"end",e.toLowerCase())}consumeVerbFinalJsBlock(e,r){let n=e.mark(),i=0,a=-1;for(;;){let c=e.peek(i);if(!c||this.isThenKeyword(c.value,r)||this.isJsBlockTerminator(c.value,r))break;if(this.isJsKeyword(c)){let d=e.peek(i+1),m=!!d&&c.position?.end!==void 0&&c.position.end===d.position?.start&&this.profileKeywordMatches(r,"js",`${c.value}${d.value}`.toLowerCase()),p=e.peek(i+(m?2:1));if(i>0&&p&&this.isJsBlockTerminator(p.value,r)){a=i;break}}i++;}if(a<=0)return null;let o=[];for(let c=0;c<a;c++){let d=e.peek(c);d&&o.push(d);}let u=o[o.length-1];if(u&&this.isPatientMarker(u,r)&&o.pop(),o.length===0)return e.reset(n),null;let s=this.rawJsBody(o);for(let c=0;c<a;c++)e.advance();e.advance();let l=e.peek();return l&&!this.isJsBlockTerminator(l.value,r)&&e.advance(),e.advance(),de("js",{patient:{type:"expression",raw:s||"()"}},{sourceLanguage:r,patternId:`js-opaque-final-${r}`,confidence:1})}consumeJsBlock(e,r){let n=e.peek();if(!n||!this.isJsKeyword(n))return null;let i=e.mark(),a=[];e.advance();let o=e.peek();o&&n.position?.end!==void 0&&n.position.end===o.position?.start&&this.profileKeywordMatches(r,"js",`${n.value}${o.value}`.toLowerCase())&&e.advance();let u=e.peek();u&&this.isPatientMarker(u,r)&&e.advance();let s=false;for(;!e.isAtEnd();){let c=e.peek();if(!c)break;if(e.advance(),this.isJsBlockTerminator(c.value,r)){s=true;break}a.push(c);}if(!s)return e.reset(i),null;let l=this.rawJsBody(a);return de("js",{patient:{type:"expression",raw:l||"()"}},{sourceLanguage:r,patternId:`js-opaque-${r}`,confidence:1})}rawJsBody(e){if(e.length===0)return "";let r=e[0].position?.start,n=e[e.length-1].position?.end,i=this.positionSource;if(i!==void 0&&r!==void 0&&n!==void 0){let o=i.slice(r,n),u=s=>s.replace(/\s+/g,"");if(u(o)===u(e.map(s=>s.value).join("")))return o.trim()}let a="";for(let o=0;o<e.length;o++){let u=e[o-1],s=u?.position?.end!==void 0&&e[o].position?.start===u.position.end;o>0&&!s&&(a+=" "),a+=e[o].value;}return a.trim()}isIfKeyword(e,r){let n=e.toLowerCase();return n==="if"?true:this.profileKeywordMatches(r,"if",n)}isUnlessKeyword(e,r){let n=e.toLowerCase();return n==="unless"?true:this.profileKeywordMatches(r,"unless",n)}tryParseUnlessGuard(e,r,n){let i=e.peek();if(!i||!this.isUnlessKeyword((i.normalized??i.value).toLowerCase(),n))return null;let a=e.mark(),o=this.tryParseConditionalBlock(e,r,n,true);if(!o||o.kind!=="conditional")return e.reset(a),null;let u=o;if(u.elseBranch&&u.elseBranch.length>0)return e.reset(a),null;let s=u.roles.get("condition");return s?[de("unless",{condition:s},{sourceLanguage:n,patternId:`unless-${n}-guard`,confidence:1}),...u.thenBranch]:(e.reset(a),null)}isBlockEndToken(e,r,n){let i=r.next;return (this.isEndKeyword(e.value,n)||e.kind==="keyword"&&(e.normalized??"").toLowerCase()==="end"&&!(i&&i.kind==="selector"))&&!Le(r,n)}opensNestedBlock(e,r,n){let i=(e.normalized??e.value).toLowerCase();return this.isIfKeyword(i,n)?!(r&&this.isElseKeyword(r.value,n)):this.isUnlessKeyword(i,n)?true:i==="repeat"?e.kind==="keyword"||e.kind==="identifier":i!=="for"||e.kind!=="keyword"?false:!(r&&ct(r))}tryParseConditionalBlock(e,r,n,i=false){let a=e.peek();if(!a)return null;let o=(a.normalized??a.value).toLowerCase();if(!this.isIfKeyword(o,n)&&!(i&&this.isUnlessKeyword(o,n)))return null;let u=e.mark(),s=this.coverageMark();e.advance();let l=e.tokens,c=e.position(),d=[],m=0;for(;!e.isAtEnd();){let w=e.peek();if(!w)break;if(d.length>0&&this.opensNestedBlock(w,Ir(d,d.length),n)){m++,d.push(w),e.advance();continue}if(this.isBlockEndToken(w,he(e.tokens,e.position()),n)){if(m===0){e.advance();break}m--,d.push(w),e.advance();continue}d.push(w),e.advance();}if(d.length===0)return e.reset(u),this.coverageRollback(s),null;let p=L(n),f=p?.wordOrder==="SOV"?x.buildVerbLookup(p):null,y=0,v=0,h=[];for(;y<d.length;y++){let w=d[y],b=(w.normalized??w.value).toLowerCase();if(y>0&&(this.isIfKeyword(b,n)||this.isUnlessKeyword(b,n))?v++:this.isBlockEndToken(w,he(l,c+y),n)&&v--,v===0&&this.isThenAt(w,he(l,c+y),n)){y++;break}if(v===0&&h.length>0){let B=(w.normalized??w.value).toLowerCase(),O=fl(d[y-1],w,h.length===1,n),_=f!==null&&f.has(w.value.toLowerCase())&&!Ei.has(B),F=/^\.[a-zA-Z_]\w*$/.test(w.value)&&d[y-1].position?.end!==void 0&&w.position?.start!==void 0&&d[y-1].position.end===w.position.start;if(!x.CONDITION_OPERATORS.has(B)&&!F&&(!O||_)&&(this.tokensBeginCommand(d.slice(y),r,n)||this.sovCommandStartsAt(d.slice(y),f)))break}h.push(w);}if(h.length===0)return e.reset(u),this.coverageRollback(s),null;let C=[],z=[],g=false,A=0;for(;y<d.length;y++){let w=d[y];if(this.opensNestedBlock(w,Ir(d,y),n)?A++:this.isBlockEndToken(w,he(l,c+y),n)&&A--,A===0&&!g&&this.isElseKeyword(w.value,n)){g=true;continue}(g?z:C).push(w);}let k={type:"expression",raw:this.joinTokenText(h,n)},D=this.parseBranch(C,r,n),S=z.length>0?this.parseBranch(z,r,n):void 0;return D.length===0&&(!S||S.length===0)?(e.reset(u),this.coverageRollback(s),null):ws(k,D,S,{sourceLanguage:n,patternId:`conditional-${n}-folded`,confidence:1})}joinTokenText(e,r){return Be(e,L(r))}tokensBeginCommand(e,r,n){if(e.length===0)return false;let i=new ce(e,n);return ze.matchBest(i,r)!==null}sovCommandStartsAt(e,r){if(!r)return false;let n=u=>r.has(u.value.toLowerCase())||!!u.normalized&&r.has(u.normalized.toLowerCase()),i=u=>u.kind==="identifier"||u.kind==="selector"||u.kind==="literal"||u.kind==="reference",a=0,o=0;for(;a+1<e.length;){let u=e[a],s=e[a+1];if(!i(u)||s.kind!=="particle")break;o+=1,a+=2;let l=e[a];if(o>=1&&l&&n(l))return true}return false}parseBranch(e,r,n){if(e.length===0)return [];let i=new ce(e,n),a=this.parseBodyWithClauses(i,r,n);return a.length===1&&a[0]?.kind==="compound"?a[0].statements:a}extractStandaloneModifiers(e,r){let i=Y(e,r).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let o=i[0].value.toLowerCase(),u=y=>i[y]?.value.toLowerCase(),s=y=>!!i[y]&&i[y].kind!=="selector";if(o==="on"&&u(1)==="first"&&i.length>2)return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(0,i[1].position.start)+e.slice(i[2].position.start)};if(o==="first"&&s(1))return {modifiers:{once:true,onceAsFirst:true},remainingInput:e.slice(i[1].position.start)};let l=x.STANDALONE_MODIFIERS[o];if(!l)return {modifiers:null,remainingInput:null};let c={},d=1;if(l==="once")c.once=true;else {let y=1;if(y<i.length){let v=i[y],h=i[y+1],E=v.kind==="identifier"&&h?.kind==="literal"&&/^\d+(ms|s|m)?$/.test(h.value);(v.kind==="keyword"||v.kind==="particle"||E)&&(y++,d++);}if(y<i.length){let v=i[y];if(v.kind==="literal"){let h=v.value.match(/^(\d+)(ms|s|m)?$/);if(h){let E=parseInt(h[1],10),C=h[2]||"ms";C==="s"?E*=1e3:C==="m"&&(E*=6e4),c[l]=E,d=y+1;}}}c[l]||(c[l]=l==="debounce"?300:100);}let m=i.slice(d);if(m.length===0)return {modifiers:null,remainingInput:null};let p=m[0].position.start,f=e.slice(p);return {modifiers:c,remainingInput:f}}stripAsyncModifier(e,r){let n=L(r)?.keywords?.async,i=new Set(["async"]);n?.primary&&i.add(n.primary.toLowerCase()),n?.alternatives?.forEach(l=>i.add(l.toLowerCase()));let a=Y(e,r).tokens,o=a.findIndex(l=>i.has(l.value.toLowerCase()));if(o===-1)return {remainingInput:null};let u=a[o],s=(e.slice(0,u.position.start)+e.slice(u.position.end)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}stripDoNotThrowModifier(e,r){let n=Y(e,r).tokens;for(let i=0;i<n.length-1;i++){if(n[i].value.toLowerCase()!=="do")continue;let a=-1;for(let l=i+1;l<=i+5&&l<n.length;l++){let c=n[l];if(c.normalized?.toLowerCase()==="throw"){a=l;break}let d=c.kind;if(d==="selector"||d==="literal"||d==="reference"||d==="conjunction")break}if(a===-1)continue;let o=n[i].position.start,u=n[a].position.end,s=(e.slice(0,o)+e.slice(u)).replace(/\s{2,}/g," ").trim();return s.length===0?{remainingInput:null}:{remainingInput:s}}return {remainingInput:null}}static droppedTokenCount(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").reduce((r,n)=>r+(parseInt(/left (\d+) token/.exec(n.message)?.[1]??"0",10)||0),0)}static unconsumedSpans(e){return (e.diagnostics??[]).filter(r=>r.code==="unconsumed-input").map(r=>/unconsumed: "(.*)"$/.exec(r.message)?.[1]).filter(r=>!!r).map(r=>r.replace(/\s+/g," ").trim())}static withoutSpanDiagnostics(e,r){return {...e,diagnostics:(e.diagnostics??[]).filter(n=>{if(n.code!=="unconsumed-input")return true;let i=/unconsumed: "(.*)"$/.exec(n.message)?.[1];return !i||i.replace(/\s+/g," ").trim()!==r})}}static sourceNounValue(e){if(e.kind==="selector")return Te(e.value);let r=(e.normalized??e.value).toLowerCase();return xe(r)?{type:"reference",value:r}:{type:"literal",value:e.value,dataType:"string"}}reclaimDanglingFromTail(e,r,n){let i=x.droppedTokenCount,a=x.unconsumedSpans(e);if(a.length===0)return null;let o=i(e),u=L(n)?.roleMarkers?.source,s=new Set;u?.primary&&s.add(u.primary),u?.alternatives?.forEach(c=>s.add(c));let l=Y(r,n).tokens;for(let c=0;c<l.length;c++){let d=l[c];if(d.normalized!=="source"&&!s.has(d.value))continue;let m=u?.position==="after"?c-1:c+1,p=l[m];if(!p||p.kind!=="identifier"&&p.kind!=="keyword")continue;let f=Math.min(d.position.start,p.position.start),y=Math.max(d.position.end,p.position.end),v=r.slice(f,y).replace(/\s+/g," ").trim();if(!a.some(E=>E===v||E.includes(v)))continue;let h=(r.slice(0,f).trimEnd()+" "+r.slice(y).trimStart()).trim();if(!(!h||h===r))try{let E=this.parse(h,n);if(!E||E.kind!=="event-handler")continue;let C=$r(E);if(i(C)<o)return {node:{...C,eventModifiers:{...C.eventModifiers,from:x.sourceNounValue(p)}},input:h}}catch{}}return null}reclaimEventCompoundTail(e,r,n){let i=x.unconsumedSpans(e);if(i.length===0)return null;let a=Se[n];if(!a)return null;let o=e.roles,u=o.get("event"),s=u?.type==="literal"&&typeof u.value=="string"?u.value:null;if(!s)return null;let l=d=>d.replace(/\s+/g," ").trim(),c=Y(r,n).tokens;for(let d of i)for(let m=1;m<c.length;m++)for(let p=m;p<c.length;p++){let f=l(r.slice(c[m].position.start,c[p].position.end));if(f.length>d.length)break;if(f!==d)continue;let y=c[m-1];if((a[y.value]??y.normalized)!==s)break;let h=l(r.slice(y.position.start,c[p].position.end)),E=a[h];if(!E)break;return o.set("event",{type:"literal",value:E,dataType:"string"}),{node:x.withoutSpanDiagnostics(e,d),input:r}}return null}reclaimResponseTypeTail(e,r,n){let i=x.unconsumedSpans(e);if(i.length===0)return null;let a=x.AS_MARKERS_BEFORE[n];if(!a)return null;let o=l=>l.replace(/\s+/g," ").trim(),u=x.droppedTokenCount(e),s=Y(r,n).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],d=s[l+1];if(!a.some(f=>c.value.toLowerCase()===f)||!x.RESPONSE_TYPE_WORDS.has(d.value.toLowerCase()))continue;let m=o(r.slice(c.position.start,d.position.end));if(!i.includes(m))continue;let p=(r.slice(0,c.position.start).trimEnd()+" "+r.slice(d.position.end).trimStart()).trim();if(!(!p||p===r))try{let f=this.parse(p,n);if(!f||f.kind!=="event-handler")continue;let y=$r(f);if(x.droppedTokenCount(y)>=u)continue;let v=x.findResponseTypeTarget(y);if(!v)continue;return v.roles.set("responseType",{type:"expression",raw:d.value}),{node:y,input:p}}catch{}}return null}static findResponseTypeTarget(e){let r=null,n=i=>{if(!i||typeof i!="object"||r)return;if(i.kind==="command"){let o=i;if(oe(o.action)?.roles.some(s=>s.role==="responseType"&&!s.required)&&!o.roles.has("responseType")){r=o;return}}let a=i;for(let o of ["body","statements","thenBranch","elseBranch","commands"]){let u=a[o];Array.isArray(u)&&u.forEach(s=>n(s));}};return n(e),r}reclaimCapturedDestinationTail(e,r,n){let i=x.unconsumedSpans(e);if(i.length===0)return null;let a=L(n)?.roleMarkers?.destination,o=new Set;if(a?.primary&&o.add(a.primary),a?.alternatives?.forEach(l=>o.add(l)),o.size===0)return null;let u=l=>l.replace(/\s+/g," ").trim(),s=Y(r,n).tokens;for(let l=0;l+1<s.length;l++){let c=s[l],d=s[l+1],m=o.has(c.value)&&d.normalized==="me",p=c.normalized==="me"&&o.has(d.value);if(!m&&!p)continue;let f=u(r.slice(c.position.start,d.position.end));if(!i.includes(f))continue;let y=false,v=h=>{if(!h||typeof h!="object"||y)return;if(h.kind==="command"){let C=h.roles.get("destination");if(C?.type==="reference"&&C.value==="me"){y=true;return}}let E=h;for(let C of ["body","statements","thenBranch","elseBranch","commands"]){let z=E[C];Array.isArray(z)&&z.forEach(g=>v(g));}};if(v(e),!!y)return {node:x.withoutSpanDiagnostics(e,f),input:r}}return null}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let n=[];for(;;){let i=e.mark(),a=e.peek();if(!a)break;if(!qr(a,r)){e.reset(i);break}e.advance();let o=e.peek();if(!o){e.reset(i);break}let u=o.normalized||o.value;e.advance(),n.push({type:"literal",value:u});}return n}};Ee.coverageMarkerSurfaces=new Map;Ee.LEAKED_RENDER_MARKERS={hi:["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"],tr:["olarak"],qu:["hina"]};Ee.AS_MARKERS_BEFORE={en:["as"],es:["como"],fr:["comme"],pt:["como"],it:["come"],de:["als"],id:["sebagai"],ms:["sebagai","sbg"],sw:["kuwa","kama"],th:["\u0E40\u0E1B\u0E47\u0E19"],vi:["nh\u01B0"],tl:["bilang"],he:["\u05DB"],ar:["\u0643\u0640"],pl:["jako"],ru:["\u043A\u0430\u043A"],uk:["\u044F\u043A"],zh:["\u7684","\u4F5C\u4E3A","\u5F53\u4F5C"]};Ee.AS_MARKERS_AFTER={ko:[["\uB85C"],["\uC73C\uB85C"]],qu:[["hina"]],tr:[["olarak"]],hi:[["\u0915\u0947","\u0930\u0942\u092A","\u092E\u0947\u0902"]]};Ee.enEventKeywordCache=new Map;Ee.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);Ee.RESPONSE_TYPE_WORDS=new Set(["json","text","html","xml","blob","arraybuffer","formdata","response"]);Ee.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"])};Ee.SOV_EVENT_MARKER_PHRASES={ko:[["\uD560","\uB54C"],["\uD560\uB54C"]]};Ee.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"])}};Ee.CONDITION_OPERATORS=new Set(["matches","match","contains","exists","has","have","equals","includes"]);Ee.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};var o0=Ee,u0=new o0;function s0(t,e){return u0.parse(t,e)}function Ii(t,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...t].sort((n,i)=>{let a=n[r]??99,o=i[r]??99;return a-o})}function sr(t,e){let r,n;if(t.markerOverride&&t.markerOverride[e.code]!==void 0)r=t.markerOverride[e.code],n=r?Re(t,e.code,r):void 0;else {let i=e.roleMarkers[t.role];if(i){r=i.primary;let a=Re(t,e.code,r)??[],o=[...new Set([...i.alternatives??[],...a])].filter(u=>u!==r);n=o.length?o:void 0;}}return {marker:r,alternatives:n}}function xr(t,e,r){r.roles.find(i=>i.role==="scope"&&!i.required)&&(t.push({type:"group",optional:true,tokens:[{type:"literal",value:"on"},{type:"role",role:"scope",optional:true,expectedTypes:["selector","reference"]}]}),e.scope={fromRole:"scope"});}function Ot(t,e,r,n){$i(t,e,r,n,"manner",{requireMarker:true});}function ji(t,e,r,n){$i(t,e,r,n,"recipient",{requireMarker:false});}function $i(t,e,r,n,i,a){let o=r.roles.find(s=>s.role===i&&!s.required);if(!o)return;let u=o.markerOverride?.[n];a.requireMarker&&!u||(t.push({type:"group",optional:true,tokens:[...(u?u.split(/\s+/):[]).map(s=>({type:"literal",value:s})),{type:"role",role:i,optional:true,expectedTypes:o.expectedTypes,...o.valueShape!==void 0?{valueShape:o.valueShape}:{}}]}),e[i]={fromRole:i});}function Vi(t){if(t.roles.some(n=>n.role==="patient"))return "patient";let e=t.roles.filter(n=>n.required),r=e.find(n=>n.role===t.primaryRole)??e[0];return !r||r.role==="event"?"patient":r.role}function qi(t,e,r){let n=t.roles.find(c=>c.role===r);if(!n||r==="patient")return [{type:"role",role:r,optional:false}];let{marker:i,alternatives:a}=sr(n,e),o={type:"role",role:r,optional:false,...n.valueShape!==void 0?{valueShape:n.valueShape}:{}};if(!i)return [o];let u=i.split(/\s+/).filter(Boolean),s={type:"group",optional:true,tokens:u.map(c=>({type:"literal",value:c,...u.length===1&&a?.length?{alternatives:a}:{}}))};return (e.roleMarkers[r]?.position??"before")==="after"?[o,s]:[s,o]}function Wi(t,e,r,n,i){for(let a of r.roles)a.required||i.has(a.role)||e[a.role]||!(a.markerOverride?.[n.code]??n.roleMarkers[a.role]?.primary)&&a.valueShape===void 0||(t.push({type:"group",optional:true,tokens:Ui(a,n)}),e[a.role]=a.default?{fromRole:a.role,default:a.default}:{fromRole:a.role});}function l0(t,e,r,n,i){let a=[];if(a.push({type:"role",role:"event",optional:false}),n.position==="after"){let f=n.primary.split(/\s+/);if(f.length>1)for(let y of f)a.push({type:"literal",value:y});else {let y=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(y);}}let o=Vi(t),u=e.roleMarkers.destination,s=t.roles.some(f=>f.role==="destination");u&&s&&o!=="destination"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]});let l=e.roleMarkers.source,c=t.roles.some(f=>f.role==="source");l&&c&&o!=="source"&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"source",optional:true},l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary}]}),a.push(...qi(t,e,o));let d=e.roleMarkers.patient;if(d&&o==="patient"){let f=d.alternatives?{type:"literal",value:d.primary,alternatives:d.alternatives}:{type:"literal",value:d.primary};a.push(f);}let m=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(m),o!=="source"&&a.push(...He(t,e.roleMarkers.source)),o!=="destination"&&a.push(...bt(t,e.roleMarkers.destination));let p={action:{value:t.action},event:{fromRole:"event"},[o]:{fromRole:o},...o==="destination"?{}:We(t),...o==="source"?{}:Ke(t)};return Wi(a,p,t,e,new Set(["event",o,"destination","source"])),{id:`${t.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${n.primary} {destination?} {${o}} ${d?.primary||""} ${r.primary}`,tokens:a},extraction:p}}function c0(t,e,r,n,i){let a=[],o=t.action==="swap",u=o?"destination":"patient";a.push({type:"role",role:u,optional:false});let s=e.roleMarkers.patient;if(s){let m=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(m);}if(a.push({type:"role",role:"event",optional:false}),n.position==="after"){let m=n.primary.split(/\s+/);if(m.length>1)for(let p of m)a.push({type:"literal",value:p});else {let p=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(p);}}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(l),a.push(...He(t,e.roleMarkers.source));let c=e.roleMarkers.destination;if(o&&c){let m=t.roles.find(p=>p.role==="patient")?.markerOverride?.[e.code];if(m&&m!==c.primary){let p=c.alternatives??[];p.includes(m)||(c={...c,alternatives:[...p,m]});}}a.push(...o?wo(t,c):bt(t,c));let d={action:{value:t.action},event:{fromRole:"event"},[u]:{fromRole:u},...o?{}:We(t),...Ke(t)};return ji(a,d,t,e.code),Ot(a,d,t,e.code),{id:`${t.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${n.primary} ${r.primary}`,tokens:a},extraction:d}}function d0(t,e,r,n,i){let a=t.roles.find(d=>d.role==="source");if(!a)return null;let{marker:o,alternatives:u}=sr(a,e),s=e.roleMarkers.patient;if(!o||o===n.primary||o===s?.primary)return null;let l=[];l.push({type:"role",role:"patient",optional:false}),s&&l.push(s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}),l.push({type:"role",role:"source",optional:false,...a.expectedTypes?{expectedTypes:a.expectedTypes}:{},...a.valueShape!==void 0?{valueShape:a.valueShape}:{}});for(let d of o.split(/\s+/))l.push(u&&o.split(/\s+/).length===1?{type:"literal",value:d,alternatives:u}:{type:"literal",value:d});if(l.push({type:"role",role:"event",optional:false}),n.position==="after"){let d=n.primary.split(/\s+/);if(d.length>1)for(let m of d)l.push({type:"literal",value:m});else l.push(n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary});}l.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary});let c={action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},source:{fromRole:"source"}};return ji(l,c,t,e.code),Ot(l,c,t,e.code),{id:`${t.action}-event-${e.code}-sov-source-fronted`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{patient} ${s?.primary||""} {source} ${o} {event} ${n.primary} ${r.primary}`,tokens:l},extraction:c}}function m0(t,e,r,n,i){let a=[];a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}let u=e.roleMarkers.destination;if(u&&(a.push({type:"role",role:"destination",optional:false}),a.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),a.push({type:"role",role:"event",optional:false}),n.position==="after"){let l=n.primary.split(/\s+/);if(l.length>1)for(let c of l)a.push({type:"literal",value:c});else {let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(s),{id:`${t.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${n.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function p0(t,e,r,n,i){let a=[];a.push({type:"role",role:"event",optional:false});let o=n.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&a.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&a.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};a.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(l),a.push(...He(t,e.roleMarkers.source)),a.push(...bt(t,e.roleMarkers.destination)),{id:`${t.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...We(t),...Ke(t)}}}function f0(t,e,r,n,i){let a=[];if(a.push({type:"role",role:"event",optional:false}),n.position==="after"){let u=n.primary.split(/\s+/);if(u.length>1)for(let s of u)a.push({type:"literal",value:s});else {let s=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(o),{id:`${t.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${n.primary} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function y0(t,e,r,n){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let a=[];a.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),a.push({type:"literal",value:i[0],alternatives:i.slice(1)}),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return a.push(u),{id:`${t.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(n.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${r.primary}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function h0(t,e,r,n,i){let a=[];if(a.push({type:"role",role:"event",optional:false}),n.position==="after"){let d=n.primary.split(/\s+/);if(d.length>1)for(let m of d)a.push({type:"literal",value:m});else {let m=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(m);}}let u=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.sovPosition??999,f=m.sovPosition??999;return p-f});for(let d of u){a.push({type:"role",role:d.role,optional:false});let{marker:m,alternatives:p}=sr(d,e);if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(s);let l=u.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(d=>[d.role,{fromRole:d.role}]))};return xr(a,c,t),{id:`${t.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${n.primary} ${l} ${r.primary}`,tokens:a},extraction:c}}function v0(t,e,r,n,i){let a=[],u=[...t.roles.filter(c=>c.required)].sort((c,d)=>{let m=c.sovPosition??999,p=d.sovPosition??999;return m-p});for(let c of u){a.push({type:"role",role:c.role,optional:false});let{marker:d,alternatives:m}=sr(c,e);d&&a.push(m?{type:"literal",value:d,alternatives:m}:{type:"literal",value:d});}if(a.push(r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary}),a.push({type:"role",role:"event",optional:false}),n.position==="after"){let c=n.primary.split(/\s+/);if(c.length>1)for(let d of c)a.push({type:"literal",value:d});else a.push(n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary});}let s=u.map(c=>`{${c.role}}`).join(" "),l={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))};return xr(a,l,t),{id:`${t.action}-event-${e.code}-sov-2role-event-last`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`${s} ${r.primary} {event} ${n.primary}`,tokens:a},extraction:l}}function E0(t,e,r,n,i){let a=[],u=[...t.roles.filter(v=>v.required)].sort((v,h)=>{let E=v.sovPosition??999,C=h.sovPosition??999;return E-C}),s=u[0];a.push({type:"role",role:s.role,optional:false});let{marker:l,alternatives:c}=sr(s,e);if(l){let v=c?{type:"literal",value:l,alternatives:c}:{type:"literal",value:l};a.push(v);}if(a.push({type:"role",role:"event",optional:false}),n.position==="after"){let v=n.primary.split(/\s+/);if(v.length>1)for(let h of v)a.push({type:"literal",value:h});else {let h=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(h);}}let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(d);let m=u[1];a.push({type:"role",role:m.role,optional:false});let{marker:p,alternatives:f}=sr(m,e);if(p){let v=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};a.push(v);}let y={action:{value:t.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[m.role]:{fromRole:m.role}};return xr(a,y,t),{id:`${t.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${s.role}} {event} ${n.primary} ${r.primary} {${m.role}}`,tokens:a},extraction:y}}function Ki(t,e,r){let n=Re(t,e.code,r.primary)??[],i=[...new Set([...r.alternatives??[],...n])].filter(a=>a!==r.primary);return i.length?i:void 0}function On(t,e,r,n,i){let a=[];if(n.position==="before"){let d=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=Vi(t);a.push(...qi(t,e,u));let s=e.roleMarkers.destination,l=t.roles.some(d=>d.role==="destination");s&&l&&u!=="destination"&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),u!=="source"&&a.push(...He(t,e.roleMarkers.source));let c={action:{value:t.action},event:{fromRole:"event"},[u]:{fromRole:u},...u==="destination"?{}:We(t),...u==="source"?{}:Ke(t)};return Wi(a,c,t,e,new Set(["event",u,"destination","source"])),{id:`${t.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${n.primary} {event} ${r.primary} {${u}} ${s?.primary||""} {destination?}`,tokens:a},extraction:c}}function g0(t,e,r,n,i){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let u=t.action==="swap";a.push({type:"role",role:u?"destination":"patient",optional:false});let s=u?void 0:e.roleMarkers.destination;if(s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...He(t,e.roleMarkers.source)),n.position==="before"){let c=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(c);}if(a.push({type:"role",role:"event",optional:false}),u){let c=t.roles.find(d=>d.role==="patient")?.markerOverride?.[e.code];c&&a.push({type:"group",optional:true,tokens:[{type:"literal",value:c},{type:"role",role:"patient",optional:false}]});}let l={action:{value:t.action},event:{fromRole:"event"},[u?"destination":"patient"]:{fromRole:u?"destination":"patient"},...u?{}:We(t),...Ke(t)};return Ot(a,l,t,e.code),{id:`${t.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${r.primary} {patient} ${s?.primary||""} {destination?} ${n.primary} {event}`,tokens:a},extraction:l}}function C0(t,e,r,n,i){let a=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of s){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Re(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Ki(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}if(n.position==="before"){let d=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let l=s.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(d=>[d.role,{fromRole:d.role}]))};return xr(a,c,t),{id:`${t.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${l} ${n.primary} {event}`,tokens:a},extraction:c}}function Rn(t,e,r,n,i){let a=[];if(n.position==="before"){let d=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(d);}a.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(o);let s=[...t.roles.filter(d=>d.required)].sort((d,m)=>{let p=d.svoPosition??999,f=m.svoPosition??999;return p-f});for(let d of s){let m,p;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)m=d.markerOverride[e.code],p=m?Re(d,e.code,m):void 0;else {let f=e.roleMarkers[d.role];f&&(m=f.primary,p=Ki(d,e,f));}if(m){let f=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};a.push(f);}a.push({type:"role",role:d.role,optional:false});}let l=s.map(d=>`{${d.role}}`).join(" "),c={action:{value:t.action},event:{fromRole:"event"},...Object.fromEntries(s.map(d=>[d.role,{fromRole:d.role}]))};return xr(a,c,t),{id:`${t.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${n.primary} {event} ${r.primary} ${l}`,tokens:a},extraction:c}}function w0(t,e,r,n,i){let a=[],o=e.eventHandler?.negationMarker;if(n.position==="before"){let l=n.alternatives?{type:"literal",value:n.primary,alternatives:n.alternatives}:{type:"literal",value:n.primary};a.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};a.push(l);}a.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(u),a.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&a.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),a.push(...He(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${n.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...We(t),...Ke(t)}}}function z0(t,e,r,n){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(a),i.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&i.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.push(...He(t,e.roleMarkers.source)),{id:`${t.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(n.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:t.action},event:{fromRole:"event"},patient:{fromRole:"patient"},...We(t),...Ke(t)}}}var dr={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function wr(t,e,r=dr){let n=`${t.action}-${e.code}-generated`,i=r.basePriority??100,a=e.keywords[t.action];if(!a)throw new Error(`No keyword translation for '${t.action}' in ${e.code}`);let o=D0(t,e,a),u=Rt(t,e),s=T0(t,e,a);return {id:n,language:e.code,command:t.action,priority:i,template:{format:s,tokens:o},extraction:u}}function k0(t,e,r=dr){if(t.roles.filter(u=>!u.required).length===0)return null;let i=t.roles.filter(u=>u.required),a={...t,roles:i};return {...wr(a,e,r),id:`${t.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:Rt(t,e)}}function Pn(t,e,r=dr){if(e.wordOrder!=="SOV")return null;let n=t.roles.filter(u=>u.required);if(n.length!==1)return null;let i=e.keywords[t.action];if(!i)return null;let a=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary},o=n.flatMap(u=>{let s=u.valuePrefixLiteral?.[e.code],l={type:"role",role:u.role,optional:false,expectedTypes:u.expectedTypes};return s?[{type:"literal",value:s},l]:[l]});return {id:`${t.action}-${e.code}-generated-verb-first`,language:e.code,command:t.action,priority:(r.basePriority??100)-20,template:{format:`${i.primary} <${n[0].role}>`,tokens:[a,...o]},extraction:Rt(t,e)}}function b0(t,e,r=dr){let n=[];if(n.push(wr(t,e,r)),r.generateSimpleVariants){let i=k0(t,e,r);i&&n.push(i);}for(let i of t.omitRoleVariants??[]){let a={...t,roles:t.roles.filter(u=>u.role!==i)},o=wr(a,e,r);n.push({...o,id:`${t.action}-${e.code}-generated-no-${i}`,priority:(r.basePriority??100)-8});}for(let i of t.widenTypeVariants??[]){if(i.excludeLanguages?.includes(e.code))continue;let a={...t,roles:t.roles.map(u=>u.role===i.role?{...u,expectedTypes:[...i.types]}:u)},o=wr(a,e,r);n.push({...o,id:`${t.action}-${e.code}-generated-${i.idSuffix}`,priority:(r.basePriority??100)-(i.priorityDelta??15)});}if(r.generateVerbFirstVariants!==false){let i=Pn(t,e,r);i&&n.push(i);}for(let i of t.rolePrefixLiteralVariants??[]){let a=i.literal[e.code];if(!a)continue;let{rolePrefixLiteralVariants:o,...u}=t,s={...u,roles:t.roles.map(m=>m.role===i.role?{...m,valuePrefixLiteral:{[e.code]:a}}:m)},l=i.priorityDelta??5,c=i.methodCarrier?{[i.methodCarrier]:{value:a}}:{},d=wr(s,e,r);if(n.push({...d,id:`${t.action}-${e.code}-generated-${i.idSuffix}`,priority:(r.basePriority??100)+l,extraction:{...d.extraction,...c}}),r.generateVerbFirstVariants!==false){let m=Pn(s,e,r);m&&n.push({...m,id:`${t.action}-${e.code}-generated-verb-first-${i.idSuffix}`,priority:(r.basePriority??100)-20+l,extraction:{...m.extraction,...c}});}}return n}function Hi(t,e=dr){let r=[],n=ju();for(let i of n){if(!t.keywords[i.action])continue;let a=b0(i,t,e);if(r.push(...a),t.eventHandler?.eventMarker){let o=A0(i,t,e);r.push(...o);}}return r}function A0(t,e,r=dr){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let n=[],i=e.eventHandler.eventMarker,a=e.keywords[t.action];if(!a)return [];if(t.roles.length===0)return [];if(t.action==="js")return [];let u=t.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)n.push(h0(t,e,a,i,r)),n.push(E0(t,e,a,i,r)),n.push(v0(t,e,a,i,r));else {n.push(l0(t,e,a,i,r)),n.push(c0(t,e,a,i,r));let s=d0(t,e,a,i,r);s&&n.push(s);let l=e.roleMarkers.destination;l&&l.primary!==i.primary&&n.push(m0(t,e,a,i,r));let c=i.primary.split(/\s+/),d=i.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&d&&n.push(p0(t,e,a,i,r)),n.push(f0(t,e,a,i,r));let m=y0(t,e,a,r);m&&n.push(m);}else e.wordOrder==="VSO"?u?(n.push(Rn(t,e,a,i,r)),n.push(C0(t,e,a,i,r))):(n.push(On(t,e,a,i,r)),n.push(g0(t,e,a,i,r)),e.eventHandler?.negationMarker&&n.push(w0(t,e,a,i,r)),e.tokenization?.prefixes&&n.push(z0(t,e,a,r))):u?n.push(Rn(t,e,a,i,r)):n.push(On(t,e,a,i,r));return n}function D0(t,e,r){let n=[],i=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},a=S0(t,e);switch(e.wordOrder){case "SVO":n.push(i),n.push(...a);break;case "SOV":n.push(...a),n.push(i);break;case "VSO":n.push(i),n.push(...a);break;default:n.push(i),n.push(...a);}return B0(n)}function B0(t){let e=[];for(let r of t){let n=e[e.length-1];if(n&&n.type==="literal"&&r.type==="literal"&&n.value===r.value){let i=[...n.alternatives??[],...r.alternatives??[]];i.length&&(e[e.length-1]={...n,alternatives:[...new Set(i)]});continue}e.push(r);}return e}function S0(t,e){let r=[],n=Ii(t.roles,e.wordOrder);for(let i of n){let a=Ui(i,e);i.required?r.push(...a):r.push({type:"group",optional:true,tokens:a});}return r}function Ui(t,e){let r=[],n=t.markerOverride?.[e.code],i=e.roleMarkers[t.role],a=t.renderOverride?.[e.code]==="",o={type:"role",role:t.role,optional:!t.required,expectedTypes:t.expectedTypes,...t.valueShape!==void 0?{valueShape:t.valueShape}:{}},u=t.valuePrefixLiteral?.[e.code],s=()=>{u&&r.push({type:"literal",value:u}),r.push(o);};if(n!==void 0){let l=n?n.split(/\s+/).filter(Boolean):[],c=n!==void 0&&n===t.markerOverride?.en,d=i?.position??(e.wordOrder==="SOV"&&!c?"after":"before"),m=t.markerOptional?.[e.code]===true,p=f=>{let y=l.length===1?Re(t,e.code,f)??[]:[],v={type:"literal",value:f,...y.length?{alternatives:y}:{},...a?{renderSuppress:true}:{}};r.push(m?{type:"group",optional:true,tokens:[v]}:v);};if(d==="before"){for(let f of l)p(f);s();}else {s();for(let f of l)p(f);}}else if(i){let l=()=>{let d=[...new Set([...i.alternatives??[],...Re(t,e.code,i.primary)??[]])].filter(m=>m!==i.primary);return {type:"literal",value:i.primary,...d.length?{alternatives:d}:{},...a?{renderSuppress:true}:{}}},c=d=>{if(!e.markersOptional&&!t.markerOptional?.[e.code]){r.push(d);return}r.push({type:"group",optional:true,...e.markersOptional&&!t.markerOptional?.[e.code]?{renderRequired:true}:{},tokens:[d]});};i.position==="before"?(i.primary&&c(l()),s()):(s(),c(l()));}else s();return r}function x0(t,e){let r={};for(let n of t.roles){let i=n.markerOverride?.[e.code],a=e.roleMarkers[n.role];if(n.valuePrefixLiteral?.[e.code])r[n.role]={marker:n.valuePrefixLiteral[e.code]};else if(i!==void 0)if(!i)r[n.role]={};else {let u=!/\s/.test(i.trim())?Re(n,e.code,i)??[]:[];r[n.role]=u.length?{marker:i,markerAlternatives:u}:{marker:i};}else if(a&&a.primary){let o=[...new Set([...a.alternatives??[],...Re(n,e.code,a.primary)??[]])].filter(u=>u!==a.primary);r[n.role]=o.length?{marker:a.primary,markerAlternatives:o}:{marker:a.primary};}else r[n.role]={};}return r}function Rt(t,e){let r=x0(t,e),n={};for(let i of t.roles){let a=r[i.role]||{};!i.required&&i.default?n[i.role]={...a,default:i.default}:n[i.role]=a;}return n}function T0(t,e,r){let n=[],a=Ii(t.roles,e.wordOrder).map(o=>{let u=ks(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":n.push(r.primary,...a);break;case "SOV":n.push(...a,r.primary);break;default:n.push(r.primary,...a);}return n.join(" ")}var F0=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),n=this.cache.get(r);if(!n){this.stats.misses++;return}if(this.isExpired(n)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),n.lastAccessed=Date.now(),this.cache.set(r,n),this.stats.hits++,n.result}set(t,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let n=this.makeKey(t,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(n,{result:r,createdAt:i,lastAccessed:i});}has(t,e){if(!this.config.enabled)return false;let r=this.makeKey(t,e),n=this.cache.get(r);return n?this.isExpired(n)?(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 F0;var L0=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to",minStemLength:2},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u305F\u3089",confidence:.85,conjugationType:"conditional-tara",minStemLength:2},{pattern:"\u308C\u3070",confidence:.82,conjugationType:"conditional-ba",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3057\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3067\u304F\u3060\u3055\u3044",confidence:.85,conjugationType:"request",minStemLength:2},{pattern:"\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304A\u304F",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u307F\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u3042\u308B",confidence:.82,conjugationType:"progressive",minStemLength:2},{pattern:"\u3066\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3067\u304F\u308C",confidence:.8,conjugationType:"casual-request",minStemLength:2},{pattern:"\u3061\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3058\u3083\u3063\u305F",confidence:.82,conjugationType:"contracted-past",minStemLength:2},{pattern:"\u3061\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u3058\u3083\u3046",confidence:.82,conjugationType:"contracted",minStemLength:2},{pattern:"\u307E\u3057\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u307E\u305B\u3093",confidence:.85,conjugationType:"negative",minStemLength:2},{pattern:"\u307E\u3059",confidence:.85,conjugationType:"polite",minStemLength:2},{pattern:"\u3066",confidence:.85,conjugationType:"te-form",minStemLength:2},{pattern:"\u305F",confidence:.85,conjugationType:"past",minStemLength:2},{pattern:"\u306A\u3044",confidence:.82,conjugationType:"negative",minStemLength:2},{pattern:"\u306A\u304B\u3063\u305F",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\u3089\u308C\u308B",confidence:.8,conjugationType:"potential",minStemLength:2},{pattern:"\u308C\u308B",confidence:.78,conjugationType:"potential",minStemLength:2},{pattern:"\u3089\u308C\u305F",confidence:.8,conjugationType:"passive",minStemLength:2},{pattern:"\u3055\u305B\u308B",confidence:.8,conjugationType:"causative",minStemLength:2},{pattern:"\u305B\u308B",confidence:.78,conjugationType:"causative",minStemLength:2},{pattern:"\u3088\u3046",confidence:.8,conjugationType:"volitional",minStemLength:2},{pattern:"\u308B",confidence:.75,conjugationType:"dictionary",minStemLength:3}],O0=[{pattern:"\u3057\u305F\u3089",confidence:.88,conjugationType:"conditional-tara"},{pattern:"\u3059\u308B\u3068",confidence:.88,conjugationType:"conditional-to"},{pattern:"\u3059\u308C\u3070",confidence:.85,conjugationType:"conditional-ba"},{pattern:"\u3057\u3066\u3044\u307E\u3059",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u3066\u3044\u308B",confidence:.85,conjugationType:"progressive"},{pattern:"\u3057\u307E\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3057\u307E\u3059",confidence:.85,conjugationType:"polite"},{pattern:"\u3057\u306A\u3044",confidence:.82,conjugationType:"negative"},{pattern:"\u3057\u3066",confidence:.85,conjugationType:"te-form"},{pattern:"\u3057\u305F",confidence:.85,conjugationType:"past"},{pattern:"\u3059\u308B",confidence:.88,conjugationType:"dictionary"}];function Xi(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function R0(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function P0(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903}function N0(t){for(let e of t)if(Xi(e)||R0(e)||P0(e))return true;return false}var Qi=class{constructor(){this.language="ja";}isNormalizable(t){if(!N0(t)||t.length<2)return false;let e=t[t.length-1];return Xi(e)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.trySuruNormalization(t);if(r)return r;for(let n of L0)if(t.endsWith(n.pattern)){let i=t.slice(0,-n.pattern.length),a=n.minStemLength??2;if(i.length<a)continue;let o={removedSuffixes:[n.pattern]};return n.conjugationType&&(o.conjugationType=n.conjugationType),Ne(i,n.confidence,o)}return Nr(t)}trySuruNormalization(t){for(let e of O0)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return Ne(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"suru-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\u3066\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3066","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3067\u3044\u306A\u304B\u3063\u305F",suffixes:["\u3067","\u3044","\u306A\u304B\u3063\u305F"],confidence:.8,minStemLength:2},{pattern:"\u3066\u3044\u306A\u3044",suffixes:["\u3066","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3067\u3044\u306A\u3044",suffixes:["\u3067","\u3044","\u306A\u3044"],confidence:.82,minStemLength:2},{pattern:"\u3066\u3044\u305F",suffixes:["\u3066","\u3044","\u305F"],confidence:.85,minStemLength:2},{pattern:"\u3067\u3044\u305F",suffixes:["\u3067","\u3044","\u305F"],confidence:.85,minStemLength:2}];for(let{pattern:r,suffixes:n,confidence:i,minStemLength:a}of e)if(t.endsWith(r)){let o=t.slice(0,-r.length);if(o.length<a)continue;return Ne(o,i,{removedSuffixes:n,conjugationType:"compound"})}return null}},ea={code:"ja",name:"Japanese",nativeName:"\u65E5\u672C\u8A9E",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:false,defaultVerbForm:"base",verb:{position:"end",suffixes:["\u308B","\u3066","\u305F","\u307E\u3059","\u306A\u3044"],subjectDrop:true},references:{me:"\u81EA\u5206",it:"\u305D\u308C",you:"\u3042\u306A\u305F",result:"\u7D50\u679C",event:"\u30A4\u30D9\u30F3\u30C8",target:"\u30BF\u30FC\u30B2\u30C3\u30C8",body:"\u30DC\u30C7\u30A3",document:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8",window:"\u30A6\u30A3\u30F3\u30C9\u30A6",detail:"\u8A73\u7D30"},possessive:{marker:"\u306E",markerPosition:"between",keywords:{\u79C1\u306E:"me",\u3042\u306A\u305F\u306E:"you",\u305D\u306E:"it"}},roleMarkers:{patient:{primary:"\u3092",position:"after"},destination:{primary:"\u306B",alternatives:["\u3078","\u3067","\u306E"],position:"after"},source:{primary:"\u304B\u3089",position:"after"},style:{primary:"\u3067",position:"after"},event:{primary:"\u3092",position:"after"}},keywords:{toggle:{primary:"\u5207\u308A\u66FF\u3048",alternatives:["\u5207\u308A\u66FF\u3048\u308B","\u30C8\u30B0\u30EB","\u30C8\u30B0\u30EB\u3059\u308B"],normalized:"toggle"},add:{primary:"\u8FFD\u52A0",alternatives:["\u8FFD\u52A0\u3059\u308B","\u52A0\u3048\u308B"],normalized:"add"},remove:{primary:"\u524A\u9664",alternatives:["\u524A\u9664\u3059\u308B","\u53D6\u308A\u9664\u304F"],normalized:"remove"},put:{primary:"\u7F6E\u304F",alternatives:["\u5165\u308C\u308B"],normalized:"put"},append:{primary:"\u672B\u5C3E\u8FFD\u52A0",alternatives:["\u672B\u5C3E\u306B\u8FFD\u52A0","\u30A2\u30DA\u30F3\u30C9"],normalized:"append"},prepend:{primary:"\u5148\u982D\u8FFD\u52A0",alternatives:["\u5148\u982D\u306B\u8FFD\u52A0","\u30D7\u30EA\u30DA\u30F3\u30C9"],normalized:"prepend"},take:{primary:"\u53D6\u308B",normalized:"take"},make:{primary:"\u4F5C\u308B",alternatives:["\u4F5C\u6210"],normalized:"make"},clone:{primary:"\u8907\u88FD",alternatives:["\u30AF\u30ED\u30FC\u30F3"],normalized:"clone"},swap:{primary:"\u4EA4\u63DB",alternatives:["\u30B9\u30EF\u30C3\u30D7","\u5165\u308C\u66FF\u3048"],normalized:"swap"},morph:{primary:"\u5909\u5F62",alternatives:["\u30E2\u30FC\u30D5","\u5909\u63DB"],normalized:"morph"},set:{primary:"\u8A2D\u5B9A",alternatives:["\u8A2D\u5B9A\u3059\u308B"],normalized:"set"},get:{primary:"\u53D6\u5F97",alternatives:["\u53D6\u5F97\u3059\u308B","\u30B2\u30C3\u30C8"],normalized:"get"},increment:{primary:"\u5897\u52A0",alternatives:["\u5897\u3084\u3059","\u30A4\u30F3\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"increment"},decrement:{primary:"\u6E1B\u5C11",alternatives:["\u6E1B\u3089\u3059","\u30C7\u30AF\u30EA\u30E1\u30F3\u30C8"],normalized:"decrement"},log:{primary:"\u8A18\u9332",alternatives:["\u30ED\u30B0","\u51FA\u529B"],normalized:"log"},show:{primary:"\u8868\u793A",alternatives:["\u8868\u793A\u3059\u308B","\u898B\u305B\u308B"],normalized:"show"},hide:{primary:"\u96A0\u3059",alternatives:["\u975E\u8868\u793A","\u975E\u8868\u793A\u306B\u3059\u308B"],normalized:"hide"},transition:{primary:"\u9077\u79FB",alternatives:["\u30C8\u30E9\u30F3\u30B8\u30B7\u30E7\u30F3","\u30A2\u30CB\u30E1\u30FC\u30B7\u30E7\u30F3"],normalized:"transition"},on:{primary:"\u3067",alternatives:["\u6642"],normalized:"on"},trigger:{primary:"\u5F15\u304D\u91D1",alternatives:["\u767A\u706B","\u30C8\u30EA\u30AC\u30FC"],normalized:"trigger"},send:{primary:"\u9001\u308B",alternatives:["\u9001\u4FE1"],normalized:"send"},focus:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9",normalized:"focus"},blur:{primary:"\u30D5\u30A9\u30FC\u30AB\u30B9\u89E3\u9664",alternatives:["\u30D5\u30A9\u30FC\u30AB\u30B9\u30A2\u30A6\u30C8","\u30D6\u30E9\u30FC","\u307C\u304B\u3057"],normalized:"blur"},empty:{primary:"\u7A7A\u306B",alternatives:["\u7A7A\u306B\u3059\u308B"],normalized:"empty"},open:{primary:"\u958B\u304F",alternatives:["\u30AA\u30FC\u30D7\u30F3"],normalized:"open"},close:{primary:"\u9589\u3058\u308B",alternatives:["\u30AF\u30ED\u30FC\u30BA"],normalized:"close"},select:{primary:"\u9078\u3076",alternatives:["\u30BB\u30EC\u30AF\u30C8"],normalized:"select"},clear:{primary:"\u30AF\u30EA\u30A2",alternatives:["\u6D88\u53BB"],normalized:"clear"},reset:{primary:"\u30EA\u30BB\u30C3\u30C8",alternatives:["\u518D\u8A2D\u5B9A"],normalized:"reset"},breakpoint:{primary:"\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8",normalized:"breakpoint"},go:{primary:"\u79FB\u52D5",alternatives:["\u884C\u304F","\u30CA\u30D3\u30B2\u30FC\u30C8"],normalized:"go"},scroll:{primary:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},push:{primary:"\u30D7\u30C3\u30B7\u30E5",normalized:"push"},replace:{primary:"\u7F6E\u63DB",alternatives:["\u7F6E\u304D\u63DB\u3048"],normalized:"replace"},process:{primary:"\u51E6\u7406",normalized:"process"},wait:{primary:"\u5F85\u3064",alternatives:["\u5F85\u6A5F"],normalized:"wait"},fetch:{primary:"\u30D5\u30A7\u30C3\u30C1",normalized:"fetch"},settle:{primary:"\u5B89\u5B9A",alternatives:["\u843D\u3061\u7740\u304F"],normalized:"settle"},if:{primary:"\u3082\u3057",normalized:"if"},when:{primary:"\u3068\u304D",alternatives:["\u3068\u304D\u306B"],normalized:"when"},changes:{primary:"\u5909\u308F\u3063\u305F\u3089",normalized:"changes"},where:{primary:"\u3069\u3053",normalized:"where"},else:{primary:"\u305D\u3046\u3067\u306A\u3051\u308C\u3070",alternatives:["\u305D\u308C\u4EE5\u5916"],normalized:"else"},unless:{primary:"\u306A\u3044\u9650\u308A",normalized:"unless"},repeat:{primary:"\u7E70\u308A\u8FD4\u3057",alternatives:["\u7E70\u308A\u8FD4\u3059","\u30EA\u30D4\u30FC\u30C8"],normalized:"repeat"},for:{primary:"\u305F\u3081\u306B",alternatives:["\u5404"],normalized:"for"},while:{primary:"\u306E\u9593",alternatives:["\u9593"],normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\u7D9A\u3051\u308B",alternatives:["\u7D99\u7D9A"],normalized:"continue"},halt:{primary:"\u505C\u6B62",alternatives:["\u6B62\u3081\u308B","\u30CF\u30EB\u30C8"],normalized:"halt"},throw:{primary:"\u6295\u3052\u308B",alternatives:["\u30B9\u30ED\u30FC"],normalized:"throw"},call:{primary:"\u547C\u3073\u51FA\u3057",alternatives:["\u30B3\u30FC\u30EB","\u547C\u3076"],normalized:"call"},return:{primary:"\u623B\u308B",alternatives:["\u8FD4\u3059","\u30EA\u30BF\u30FC\u30F3"],normalized:"return"},then:{primary:"\u305D\u308C\u304B\u3089",alternatives:["\u6B21\u306B","\u306A\u3089\u3070","\u306A\u3089"],normalized:"then"},and:{primary:"\u307E\u305F",alternatives:["\u3068","\u305D\u3057\u3066"],normalized:"and"},matches:{primary:"\u4E00\u81F4\u3059\u308B",normalized:"matches"},exists:{primary:"\u5B58\u5728\u3059\u308B",normalized:"exists"},is:{primary:"\u3067\u3042\u308B",normalized:"is"},no:{primary:"\u306A\u3044",normalized:"no"},end:{primary:"\u7D42\u308F\u308A",alternatives:["\u304A\u308F\u308A"],normalized:"end"},js:{primary:"JS\u5B9F\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u975E\u540C\u671F",alternatives:["\u30A2\u30B7\u30F3\u30AF"],normalized:"async"},tell:{primary:"\u4F1D\u3048\u308B",alternatives:["\u30C6\u30EB"],normalized:"tell"},default:{primary:"\u65E2\u5B9A",alternatives:["\u30C7\u30D5\u30A9\u30EB\u30C8"],normalized:"default"},init:{primary:"\u521D\u671F\u5316",normalized:"init"},behavior:{primary:"\u632F\u308B\u821E\u3044",alternatives:["\u30D3\u30D8\u30A4\u30D3\u30A2"],normalized:"behavior"},install:{primary:"\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB",alternatives:["\u5C0E\u5165"],normalized:"install"},measure:{primary:"\u6E2C\u5B9A",alternatives:["\u8A08\u6E2C","\u30E1\u30B8\u30E3\u30FC"],normalized:"measure"},beep:{primary:"\u30D3\u30FC\u30D7",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u30B3\u30D4\u30FC",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9078\u629E",normalized:"pick"},render:{primary:"\u63CF\u753B",normalized:"render"},into:{primary:"\u3078",alternatives:["\u306B"],normalized:"into"},before:{primary:"\u524D\u306B",alternatives:["\u524D"],normalized:"before"},after:{primary:"\u5F8C\u306B",alternatives:["\u5F8C"],normalized:"after"},until:{primary:"\u307E\u3067",alternatives:["\u8FC4"],normalized:"until"},event:{primary:"\u30A4\u30D9\u30F3\u30C8",alternatives:["\u4E8B\u8C61"],normalized:"event"},from:{primary:"\u304B\u3089",normalized:"from"},connect:{primary:"\u63A5\u7D9A",alternatives:["\u63A5\u7D9A\u3059\u308B"],normalized:"connect"},stream:{primary:"\u30B9\u30C8\u30EA\u30FC\u30E0",alternatives:["\u914D\u4FE1"],normalized:"stream"},live:{primary:"\u30E9\u30A4\u30D6",alternatives:["\u5B9F\u6642\u9593"],normalized:"live"},socket:{primary:"\u30BD\u30B1\u30C3\u30C8",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\u30D0\u30A4\u30F3\u30C9",alternatives:["\u7D50\u3073\u3064\u3051\u308B","bind"],normalized:"bind"},intercept:{primary:"\u30A4\u30F3\u30BF\u30FC\u30BB\u30D7\u30C8",alternatives:["\u508D\u53D7","intercept"],normalized:"intercept"},worker:{primary:"\u30EF\u30FC\u30AB\u30FC",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u30A4\u30D9\u30F3\u30C8\u30BD\u30FC\u30B9"],normalized:"eventsource"}},tokenization:{particles:["\u3092","\u306B","\u3067","\u304B\u3089","\u306E","\u304C","\u306F","\u3082","\u3078","\u3068"],boundaryStrategy:"particle"},eventHandler:{eventMarker:{primary:"\u3067",position:"after"},temporalMarkers:["\u6642","\u3068\u304D"]}},M0=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],_0=class{constructor(t=M0){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}},I0="()[]{},:;",j0=class{constructor(t=I0){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 Pt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let n=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!n)break;let i=r+n[0].length;if(t[i]==="("){let a=0,o=i;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;i=o;}r=i;}return r}function Gi(t,e){let r=t[e];if(r==="#"){let n=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!n)return null;let i=Pt(t,e+n[0].length);return t.slice(e,i)}if(r==="."){let n=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(n)return n[0];let i=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let a=Pt(t,e+i[0].length);return t.slice(e,a)}if(r==="@"){let n=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="*"){let n=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="["){let n=0,i=e;for(;i<t.length;){if(t[i]==="["&&n++,t[i]==="]"&&(n--,n===0)){let a=Pt(t,i+1);return t.slice(e,a)}i++;}return null}if(r==="<"){let n=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return n?n[0]:null}return null}var $0=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?Gi(t,e)!==null:false}extract(t,e){let r=Gi(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},V0=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 n=r[0],i=n.slice(1).split("(")[0],a=r[1];return {value:n,length:n.length,metadata:{modifierName:i,value:a?i==="queue"?a:parseInt(a,10):void 0}}}},q0=["http://","https://","//","./","../","/"];function W0(t,e){let r=1;for(let n=e;n<t.length;n++){let i=t[n];if(i==="{")r++;else if(i==="}"&&--r===0)return n+1}return -1}function K0(t,e){let r=t.slice(e),n=q0.find(a=>r.startsWith(a));if(!n)return null;let i=n.length;for(;i<r.length;){let a=r[i];if(a==="$"&&r[i+1]==="{"){let o=W0(r,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(a))break;i++;}return r.slice(0,i)}var H0=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=K0(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},U0=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 G0(t){let e=t.charCodeAt(0);return e>=12352&&e<=12447}function Y0(t){let e=t.charCodeAt(0);return e>=12448&&e<=12543}function Z0(t){let e=t.charCodeAt(0);return e>=19968&&e<=40879||e>=13312&&e<=19903}function Yi(t){return G0(t)||Y0(t)||Z0(t)}var J0=class{constructor(){this.name="japanese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Yi(t[e])}extract(t,e){if(!this.context)throw new Error("JapaneseKeywordExtractor: context not set");let r=e;this.context.isKeywordStart(t,e);let n="",i=e;for(;i<t.length&&Yi(t[i]);)n+=t[i],i++;let a=n,o=n.length;for(let c=n.length;c>0;c--){let d=n.substring(0,c);if(this.context.lookupKeyword(d)){a=d,o=c;break}}if(n=a,i=e+o,!n)return null;let u=this.context.lookupKeyword(n),s=u&&u.normalized!==u.native?u.normalized:void 0,l;if(!u&&this.context.normalizer){let c=this.context.normalizer.normalize(n);if(c.stem!==n&&c.confidence>=.7){let d=this.context.lookupKeyword(c.stem);d&&(l=d.normalized);}}return {value:n,length:i-r,metadata:{normalized:s||l}}}},Zi=new Map([["\u3092",{role:"patient",confidence:.95}],["\u306B",{role:"destination",confidence:.85}],["\u304C",{role:"subject",confidence:.9}],["\u306E",{role:"possessive",confidence:.9}],["\u3068",{role:"conjunction",confidence:.8}],["\u3067",{role:"instrument",confidence:.85}],["\u3078",{role:"direction",confidence:.85}],["\u3084",{role:"listing",confidence:.8}],["\u304B",{role:"question",confidence:.85}],["\u3082",{role:"also",confidence:.85}],["\u306F",{role:"topic",confidence:.9}]]),Ji=new Map([["\u304B\u3089",{role:"source",confidence:.95}],["\u307E\u3067",{role:"until",confidence:.95}],["\u3088\u308A",{role:"comparison",confidence:.9}],["\u3068\u3057\u3066",{role:"as",confidence:.9}],["\u306B\u3064\u3044\u3066",{role:"about",confidence:.9}],["\u306B\u3088\u3063\u3066",{role:"by-means",confidence:.9}],["\u306B\u3066",{role:"at-location",confidence:.85}]]),X0=class{constructor(){this.name="japanese-particle";}setContext(t){this._context=t;}longerKeywordStartsHere(t,e){if(!this._context)return false;for(let r=4;r>=2;r--){let n=t.slice(e,e+r);if(n.length===r&&this._context.isKeyword(n))return true}return false}canExtract(t,e){let r=t[e];if(Zi.has(r)&&!this.longerKeywordStartsHere(t,e))return true;for(let[n]of Ji)if(t.startsWith(n,e))return true;return false}extract(t,e){for(let[i,a]of Ji)if(t.startsWith(i,e))return {value:i,length:i.length,metadata:{role:a.role,confidence:a.confidence,variant:i}};let r=t[e];if(this.longerKeywordStartsHere(t,e))return null;let n=Zi.get(r);return n?{value:r,length:1,metadata:{role:n.role,confidence:n.confidence,variant:r}}:null}};function Q0(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function ed(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var rd=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Q0(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,n="",i=e;for(;i<t.length&&ed(t[i]);)n+=t[i],i++;if(!n)return null;let a=this.context.lookupKeyword(n),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:n,length:i-r,metadata:{normalized:o}}}};function td(){return [new H0,new V0,new U0,new $0]}var nd=new Set(["\u3092","\u306B","\u3067","\u304B\u3089","\u307E\u3067","\u3078","\u3068","\u306E","\u304C","\u306F","\u3082","\u3088\u308A"]),id=[{native:"\u3067\u306F\u306A\u3044",normalized:"not"},{native:"\u771F",normalized:"true"},{native:"\u507D",normalized:"false"},{native:"\u30CC\u30EB",normalized:"null"},{native:"\u672A\u5B9A\u7FA9",normalized:"undefined"},{native:"\u6700\u521D",normalized:"first"},{native:"\u6700\u5F8C",normalized:"last"},{native:"\u6B21",normalized:"next"},{native:"\u524D",normalized:"previous"},{native:"\u6700\u3082\u8FD1\u3044",normalized:"closest"},{native:"\u89AA",normalized:"parent"},{native:"\u306E\u4E2D",normalized:"in"},{native:"\u30AF\u30EA\u30C3\u30AF",normalized:"click"},{native:"\u5909\u66F4",normalized:"change"},{native:"\u9001\u4FE1",normalized:"submit"},{native:"\u5165\u529B",normalized:"input"},{native:"\u30ED\u30FC\u30C9",normalized:"load"},{native:"\u8AAD\u307F\u8FBC\u307F",normalized:"load"},{native:"\u30B9\u30AF\u30ED\u30FC\u30EB",normalized:"scroll"},{native:"\u30AD\u30FC\u30C0\u30A6\u30F3",normalized:"keydown"},{native:"\u30AD\u30FC\u30A2\u30C3\u30D7",normalized:"keyup"},{native:"\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC",normalized:"mouseover"},{native:"\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8",normalized:"mouseout"},{native:"\u30DE\u30A6\u30B9\u62BC\u4E0B",normalized:"mousedown"},{native:"\u30DE\u30A6\u30B9\u89E3\u653E",normalized:"mouseup"},{native:"\u307E\u305F\u306F",normalized:"or"},{native:"\u79C1",normalized:"me"},{native:"\u5BFE\u8C61",normalized:"target"},{native:"\u3057\u305F\u3089",normalized:"on"},{native:"\u3059\u308B\u3068",normalized:"on"},{native:"\u6642\u306B",normalized:"on"},{native:"\u79D2",normalized:"s"},{native:"\u30DF\u30EA\u79D2",normalized:"ms"},{native:"\u5206",normalized:"m"},{native:"\u6642\u9593",normalized:"h"},{native:"\u542B\u3080",normalized:"inclusive"},{native:"\u9664\u304F",normalized:"exclusive"},{native:"\u6587\u5B57",normalized:"characters"},{native:"\u30E9\u30F3\u30C0\u30E0",normalized:"random"}],ad=class extends Qe{constructor(){super(),this.language="ja",this.direction="ltr",this.initializeKeywordsFromProfile(ea,id),this.normalizer=new Qi,this.registerExtractors(td()),this.registerExtractor(new Je),this.registerExtractor(new Xe),this.registerExtractor(new rd),this.registerExtractor(new X0),this.registerExtractor(new J0),this.registerExtractor(new _0),this.registerExtractor(new j0);}classifyToken(t){return nd.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("'")||t.startsWith("\u300C")||/^\d/.test(t)?"literal":"identifier"}},od=new ad;lr("ja",od,ea);function ud(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function sd(t){for(let e of t)if(ud(e))return true;return false}var ld=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.85,conjugationType:"honorific-causal",minStemLength:1},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal",minStemLength:1},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional",minStemLength:1},{pattern:"\uC73C\uC2DC\uBA74",confidence:.85,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uC2DC\uBA74",confidence:.82,conjugationType:"honorific-conditional",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uD558\uACE0\uC11C",confidence:.85,conjugationType:"sequential-after",minStemLength:1},{pattern:"\uACE0\uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0 \uB098\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uACE0\uC11C",confidence:.82,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.85,conjugationType:"sequential-before",minStemLength:1},{pattern:"\uAE30\uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uAE30 \uC804\uC5D0",confidence:.82,conjugationType:"sequential-before",minStemLength:2},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate",minStemLength:1},{pattern:"\uC790\uB9C8\uC790",confidence:.85,conjugationType:"immediate",minStemLength:2},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD574",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.85,conjugationType:"obligation",minStemLength:1},{pattern:"\uC5B4\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC5B4\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574\uC694",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uC544\uC57C\uD574",confidence:.82,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uB2C8\uAE4C",confidence:.85,conjugationType:"causal-nikka",minStemLength:1},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae",minStemLength:1},{pattern:"\uC744\uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uC744 \uB54C",confidence:.85,conjugationType:"temporal-ttae",minStemLength:2},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon",minStemLength:1},{pattern:"\uC73C\uBA74",confidence:.85,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uB2C8\uAE4C",confidence:.82,conjugationType:"causal-nikka",minStemLength:2},{pattern:"\uBA74",confidence:.8,conjugationType:"conditional-myeon",minStemLength:2},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC2B5\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uB429\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:1},{pattern:"\u3142\uB2C8\uB2E4",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific",minStemLength:1},{pattern:"\uC138\uC694",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uC2ED\uC2DC\uC624",confidence:.82,conjugationType:"honorific",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite",minStemLength:1},{pattern:"\uC5B4\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uC544\uC694",confidence:.82,conjugationType:"polite",minStemLength:2},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past",minStemLength:1},{pattern:"\uD574",confidence:.8,conjugationType:"present",minStemLength:1},{pattern:"\uC5C8\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uC558\uC5B4",confidence:.82,conjugationType:"past",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive",minStemLength:1},{pattern:"\uACE0\uC788\uB2E4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uACE0\uC788\uC5B4",confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary",minStemLength:1},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC548\uD558\uB2E4",confidence:.82,conjugationType:"negative",minStemLength:1},{pattern:"\uC9C0\uC54A\uB2E4",confidence:.8,conjugationType:"negative",minStemLength:2},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative",minStemLength:1},{pattern:"\uB2E4",confidence:.75,conjugationType:"dictionary",minStemLength:2}],cd=[{pattern:"\uD558\uC2DC\uB2C8\uAE4C",confidence:.88,conjugationType:"honorific-causal"},{pattern:"\uD558\uC2E4\uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2E4 \uB54C",confidence:.88,conjugationType:"honorific-temporal"},{pattern:"\uD558\uC2DC\uBA74",confidence:.88,conjugationType:"honorific-conditional"},{pattern:"\uD558\uC168\uC5B4\uC694",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC168\uC5B4",confidence:.85,conjugationType:"honorific-past"},{pattern:"\uD558\uC2ED\uB2C8\uB2E4",confidence:.85,conjugationType:"honorific-polite"},{pattern:"\uD558\uACE0\uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0 \uB098\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uACE0\uC11C",confidence:.88,conjugationType:"sequential-after"},{pattern:"\uD558\uAE30\uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uAE30 \uC804\uC5D0",confidence:.88,conjugationType:"sequential-before"},{pattern:"\uD558\uC790\uB9C8\uC790",confidence:.88,conjugationType:"immediate"},{pattern:"\uD574\uC57C\uD574\uC694",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD574",confidence:.88,conjugationType:"obligation"},{pattern:"\uD574\uC57C\uD558\uB2E4",confidence:.88,conjugationType:"obligation"},{pattern:"\uD558\uB2C8\uAE4C",confidence:.88,conjugationType:"causal-nikka"},{pattern:"\uD560\uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD560 \uB54C",confidence:.88,conjugationType:"temporal-ttae"},{pattern:"\uD558\uBA74",confidence:.88,conjugationType:"conditional-myeon"},{pattern:"\uD558\uC600\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD588\uC2B5\uB2C8\uB2E4",confidence:.85,conjugationType:"past"},{pattern:"\uD569\uB2C8\uB2E4",confidence:.85,conjugationType:"polite"},{pattern:"\uD558\uC2ED\uC2DC\uC624",confidence:.85,conjugationType:"honorific"},{pattern:"\uD558\uC138\uC694",confidence:.85,conjugationType:"honorific"},{pattern:"\uD588\uC5B4\uC694",confidence:.85,conjugationType:"past"},{pattern:"\uD574\uC694",confidence:.85,conjugationType:"polite"},{pattern:"\uD588\uC5B4",confidence:.85,conjugationType:"past"},{pattern:"\uD574",confidence:.8,conjugationType:"present"},{pattern:"\uD558\uACE0\uC788\uC5B4\uC694",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uC5B4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD558\uACE0\uC788\uB2E4",confidence:.82,conjugationType:"progressive"},{pattern:"\uD574\uC11C",confidence:.82,conjugationType:"connective"},{pattern:"\uD558\uACE0",confidence:.8,conjugationType:"connective"},{pattern:"\uD558\uC9C0\uC54A\uC544\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uD558\uC9C0\uC54A\uB2E4",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574\uC694",confidence:.82,conjugationType:"negative"},{pattern:"\uC548\uD574",confidence:.82,conjugationType:"negative"},{pattern:"\uD574\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB77C",confidence:.82,conjugationType:"imperative"},{pattern:"\uD558\uB2E4",confidence:.88,conjugationType:"dictionary"}],aa=class{constructor(){this.language="ko";}isNormalizable(t){return !(!sd(t)||t.length<2)}normalize(t){let e=this.normalizeCompound(t);if(e)return e;let r=this.tryHadaNormalization(t);if(r)return r;for(let n of ld)if(t.endsWith(n.pattern)){let i=t.slice(0,-n.pattern.length),a=n.minStemLength??2;if(i.length<a)continue;let o={removedSuffixes:[n.pattern]};return n.conjugationType&&(o.conjugationType=n.conjugationType),Ne(i,n.confidence,o)}return Nr(t)}tryHadaNormalization(t){for(let e of cd)if(t.endsWith(e.pattern)){let r=t.slice(0,-e.pattern.length);if(r.length<1)continue;return Ne(r,e.confidence,{removedSuffixes:[e.pattern],conjugationType:e.conjugationType,originalForm:"hada-verb"})}return null}normalizeCompound(t){let e=[{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uC5B4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uC5B4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C\uC600\uB2E4",suffixes:["\uD558\uACE0\uB098\uC11C","\uC600\uB2E4"],confidence:.78,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD558\uACE0\uB098\uC11C",suffixes:["\uD558\uACE0","\uB098\uC11C"],confidence:.85,conjugationType:"sequential-after",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC5B4",suffixes:["\uD574\uC57C","\uD588\uC5B4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uB2E4",suffixes:["\uD574\uC57C","\uD588\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD574\uC57C\uD588\uC2B5\uB2C8\uB2E4",suffixes:["\uD574\uC57C","\uD588\uC2B5\uB2C8\uB2E4"],confidence:.8,conjugationType:"obligation",minStemLength:2},{pattern:"\uD558\uC2DC\uBA74\uC11C",suffixes:["\uD558\uC2DC","\uBA74\uC11C"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uC2DC\uBA70",suffixes:["\uD558\uC2DC","\uBA70"],confidence:.82,conjugationType:"connective",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uC5B4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uC5B4"],confidence:.8,conjugationType:"progressive",minStemLength:2},{pattern:"\uD558\uACE0\uC788\uC5C8\uB2E4",suffixes:["\uD558\uACE0","\uC788\uC5C8\uB2E4"],confidence:.8,conjugationType:"progressive",minStemLength:2}];for(let{pattern:r,suffixes:n,confidence:i,conjugationType:a,minStemLength:o}of e)if(t.endsWith(r)){let u=t.slice(0,-r.length);if(u.length<o)continue;return Ne(u,i,{removedSuffixes:n,conjugationType:a})}return null}},oa={code:"ko",name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4",regions:["east-asian","priority"],direction:"ltr",script:"hangul",wordOrder:"SOV",markingStrategy:"particle",usesSpaces:true,verb:{position:"end",suffixes:["\uB2E4","\uC694","\uB2C8\uB2E4","\uC138\uC694"],subjectDrop:true},references:{me:"\uB098",it:"\uADF8\uAC83",you:"\uB108",result:"\uACB0\uACFC",event:"\uC774\uBCA4\uD2B8",target:"\uB300\uC0C1",body:"\uBC14\uB514",document:"\uBB38\uC11C",window:"\uCC3D",detail:"\uC138\uBD80"},possessive:{marker:"\uC758",markerPosition:"between",specialForms:{me:"\uB0B4",it:"\uADF8\uAC83\uC758",you:"\uB124"},keywords:{\uB0B4:"me",\uB124:"you",\uADF8\uC758:"it"}},roleMarkers:{patient:{primary:"\uC744",alternatives:["\uB97C"],position:"after"},destination:{primary:"\uC5D0",alternatives:["\uC73C\uB85C","\uB85C","\uC758"],position:"after"},source:{primary:"\uC5D0\uC11C",alternatives:["\uBD80\uD130"],position:"after"},style:{primary:"\uB85C",alternatives:["\uC73C\uB85C"],position:"after"},event:{primary:"\uC744",alternatives:["\uB97C"],position:"after"}},keywords:{toggle:{primary:"\uD1A0\uAE00",normalized:"toggle"},add:{primary:"\uCD94\uAC00",normalized:"add"},remove:{primary:"\uC81C\uAC70",alternatives:["\uC0AD\uC81C"],normalized:"remove"},put:{primary:"\uB123\uB2E4",alternatives:["\uB123\uAE30","\uB193\uAE30","\uB123\uC73C\uC138\uC694"],normalized:"put"},append:{primary:"\uB367\uBD99\uC774\uB2E4",alternatives:["\uB05D\uC5D0\uCD94\uAC00"],normalized:"append"},prepend:{primary:"\uC55E\uC5D0\uCD94\uAC00",alternatives:["\uC120\uB450\uCD94\uAC00"],normalized:"prepend"},take:{primary:"\uAC00\uC838\uC624\uB2E4",alternatives:["\uAC00\uC838\uC624\uC138\uC694"],normalized:"take"},make:{primary:"\uB9CC\uB4E4\uB2E4",normalized:"make"},clone:{primary:"\uBCF5\uC81C",normalized:"clone"},swap:{primary:"\uAD50\uD658",alternatives:["\uBC14\uAFB8\uB2E4"],normalized:"swap"},morph:{primary:"\uBCC0\uD615",alternatives:["\uBCC0\uD658"],normalized:"morph"},set:{primary:"\uC124\uC815",normalized:"set"},get:{primary:"\uC5BB\uB2E4",alternatives:["\uC5BB\uC73C\uC138\uC694"],normalized:"get"},increment:{primary:"\uC99D\uAC00",normalized:"increment"},decrement:{primary:"\uAC10\uC18C",normalized:"decrement"},log:{primary:"\uB85C\uADF8",normalized:"log"},show:{primary:"\uBCF4\uC774\uB2E4",alternatives:["\uD45C\uC2DC","\uBCF4\uC774\uAE30","\uBCF4\uC774\uC138\uC694"],normalized:"show"},hide:{primary:"\uC228\uAE30\uB2E4",alternatives:["\uC228\uAE30\uAE30","\uC228\uAE30\uC138\uC694"],normalized:"hide"},transition:{primary:"\uD2B8\uB79C\uC9C0\uC158",alternatives:["\uC804\uD658"],normalized:"transition"},on:{primary:"\uC5D0",alternatives:["\uC2DC","\uD560 \uB54C"],normalized:"on"},trigger:{primary:"\uD2B8\uB9AC\uAC70",normalized:"trigger"},send:{primary:"\uBCF4\uB0B4\uB2E4",alternatives:["\uBCF4\uB0B4\uC138\uC694"],normalized:"send"},focus:{primary:"\uD3EC\uCEE4\uC2A4",normalized:"focus"},blur:{primary:"\uD3EC\uCEE4\uC2A4\uC544\uC6C3",alternatives:["\uBE14\uB7EC"],normalized:"blur"},empty:{primary:"\uBE44\uC6B0\uAE30",alternatives:["\uBE44\uC5B4\uC788\uB294"],normalized:"empty"},open:{primary:"\uC5F4\uAE30",normalized:"open"},close:{primary:"\uB2EB\uAE30",normalized:"close"},select:{primary:"\uACE0\uB974\uAE30",normalized:"select"},clear:{primary:"\uC9C0\uC6B0\uAE30",normalized:"clear"},reset:{primary:"\uC7AC\uC124\uC815",normalized:"reset"},breakpoint:{primary:"\uC911\uB2E8\uC810",normalized:"breakpoint"},click:{primary:"\uD074\uB9AD",normalized:"click"},hover:{primary:"\uD638\uBC84",normalized:"hover"},submit:{primary:"\uC81C\uCD9C",normalized:"submit"},input:{primary:"\uC785\uB825",normalized:"input"},change:{primary:"\uBCC0\uACBD",normalized:"change"},go:{primary:"\uC774\uB3D9",normalized:"go"},scroll:{primary:"\uC2A4\uD06C\uB864",normalized:"scroll"},push:{primary:"\uD478\uC2DC",normalized:"push"},replace:{primary:"\uAD50\uCCB4",alternatives:["\uBC14\uAFB8\uAE30"],normalized:"replace"},process:{primary:"\uCC98\uB9AC",normalized:"process"},wait:{primary:"\uB300\uAE30",normalized:"wait"},fetch:{primary:"\uD328\uCE58",alternatives:["\uAC00\uC838\uC624\uAE30"],normalized:"fetch"},settle:{primary:"\uC548\uC815",normalized:"settle"},if:{primary:"\uB9CC\uC57D",normalized:"if"},when:{primary:"\uB54C",normalized:"when"},changes:{primary:"\uBCC0\uACBD\uB418\uBA74",normalized:"changes"},where:{primary:"\uC5B4\uB514",normalized:"where"},else:{primary:"\uC544\uB2C8\uBA74",normalized:"else"},unless:{primary:"\uC544\uB2C8\uB77C\uBA74",normalized:"unless"},repeat:{primary:"\uBC18\uBCF5",normalized:"repeat"},for:{primary:"\uAC01\uAC01",normalized:"for"},while:{primary:"\uB3D9\uC548",normalized:"while"},forever:{primary:"forever",normalized:"forever"},continue:{primary:"\uACC4\uC18D",normalized:"continue"},halt:{primary:"\uC815\uC9C0",normalized:"halt"},throw:{primary:"\uB358\uC9C0\uB2E4",normalized:"throw"},call:{primary:"\uD638\uCD9C",normalized:"call"},return:{primary:"\uBC18\uD658",normalized:"return"},then:{primary:"\uADF8\uB2E4\uC74C",alternatives:["\uADF8\uB7F0\uD6C4"],normalized:"then"},and:{primary:"\uADF8\uB9AC\uACE0",alternatives:["\uB610\uD55C","\uBC0F"],normalized:"and"},matches:{primary:"\uC77C\uCE58",normalized:"matches"},exists:{primary:"\uC874\uC7AC",normalized:"exists"},no:{primary:"\uC5C6\uC74C",normalized:"no"},end:{primary:"\uB05D",alternatives:["\uB9C8\uCE68"],normalized:"end"},js:{primary:"JS\uC2E4\uD589",alternatives:["js"],normalized:"js"},async:{primary:"\uBE44\uB3D9\uAE30",normalized:"async"},tell:{primary:"\uB9D0\uD558\uB2E4",normalized:"tell"},default:{primary:"\uAE30\uBCF8\uAC12",normalized:"default"},init:{primary:"\uCD08\uAE30\uD654",normalized:"init"},behavior:{primary:"\uB3D9\uC791",normalized:"behavior"},install:{primary:"\uC124\uCE58",normalized:"install"},measure:{primary:"\uCE21\uC815",normalized:"measure"},beep:{primary:"\uBE44\uD504",normalized:"beep"},break:{primary:"\uC911\uB2E8",normalized:"break"},copy:{primary:"\uBCF5\uC0AC",normalized:"copy"},exit:{primary:"\uB098\uAC00\uAE30",normalized:"exit"},pick:{primary:"\uC120\uD0DD",normalized:"pick"},render:{primary:"\uB80C\uB354\uB9C1",normalized:"render"},into:{primary:"\uC73C\uB85C",normalized:"into"},before:{primary:"\uC804\uC5D0",normalized:"before"},after:{primary:"\uD6C4\uC5D0",normalized:"after"},until:{primary:"\uAE4C\uC9C0",normalized:"until"},event:{primary:"\uC774\uBCA4\uD2B8",normalized:"event"},from:{primary:"\uC5D0\uC11C",normalized:"from"},connect:{primary:"\uC5F0\uACB0",alternatives:["\uC811\uC18D"],normalized:"connect"},stream:{primary:"\uC2A4\uD2B8\uB9BC",alternatives:["\uC2A4\uD2B8\uB9AC\uBC0D"],normalized:"stream"},live:{primary:"\uC2E4\uC2DC\uAC04",alternatives:["\uB77C\uC774\uBE0C"],normalized:"live"},socket:{primary:"\uC18C\uCF13",alternatives:["websocket"],normalized:"socket"},bind:{primary:"\uBC14\uC778\uB4DC",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\uAC00\uB85C\uCC44\uAE30",alternatives:["\uC778\uD130\uC149\uD2B8","intercept"],normalized:"intercept"},worker:{primary:"\uC6CC\uCEE4",alternatives:["worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\uC774\uBCA4\uD2B8\uC18C\uC2A4"],normalized:"eventsource"}},tokenization:{particles:["\uC744","\uB97C","\uC774","\uAC00","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uC73C\uB85C","\uB85C","\uC640","\uACFC","\uB3C4"],boundaryStrategy:"space"},eventHandler:{eventMarker:{primary:"\uD560 \uB54C",alternatives:["\uD560\uB54C","\uB54C","\uC5D0"],position:"after"},temporalMarkers:["\uD560 \uB54C","\uD560\uB54C","\uB54C"]}},dd=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],md=class{constructor(t=dd){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}},pd="()[]{},:;",fd=class{constructor(t=pd){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 Nt(t,e){let r=e;for(;r<t.length&&t[r]===":";){let n=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!n)break;let i=r+n[0].length;if(t[i]==="("){let a=0,o=i;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;i=o;}r=i;}return r}function ra(t,e){let r=t[e];if(r==="#"){let n=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!n)return null;let i=Nt(t,e+n[0].length);return t.slice(e,i)}if(r==="."){let n=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(n)return n[0];let i=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let a=Nt(t,e+i[0].length);return t.slice(e,a)}if(r==="@"){let n=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="*"){let n=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="["){let n=0,i=e;for(;i<t.length;){if(t[i]==="["&&n++,t[i]==="]"&&(n--,n===0)){let a=Nt(t,i+1);return t.slice(e,a)}i++;}return null}if(r==="<"){let n=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return n?n[0]:null}return null}var yd=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ra(t,e)!==null:false}extract(t,e){let r=ra(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},hd=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 n=r[0],i=n.slice(1).split("(")[0],a=r[1];return {value:n,length:n.length,metadata:{modifierName:i,value:a?i==="queue"?a:parseInt(a,10):void 0}}}},vd=["http://","https://","//","./","../","/"];function Ed(t,e){let r=1;for(let n=e;n<t.length;n++){let i=t[n];if(i==="{")r++;else if(i==="}"&&--r===0)return n+1}return -1}function gd(t,e){let r=t.slice(e),n=vd.find(a=>r.startsWith(a));if(!n)return null;let i=n.length;for(;i<r.length;){let a=r[i];if(a==="$"&&r[i+1]==="{"){let o=Ed(r,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(a))break;i++;}return r.slice(0,i)}var Cd=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=gd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},wd=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 zd(t){let e=t.charCodeAt(0);return e>=44032&&e<=55203}function kd(t){let e=t.charCodeAt(0);return e>=4352&&e<=4607||e>=12592&&e<=12687}function Mt(t){return zd(t)||kd(t)}var bd=["\uD560\uB54C","\uD558\uBA74","\uD558\uB2C8\uAE4C","\uD560 \uB54C"],Ad=class{constructor(){this.name="korean-keyword";}setContext(t){this.context=t;}canExtract(t,e){return Mt(t[e])}extract(t,e){if(!this.context)throw new Error("KoreanKeywordExtractor: context not set");let r=e,n=6;for(let d=Math.min(n,t.length-r);d>=2;d--){let m=t.slice(r,r+d),p=true;for(let y=0;y<m.length;y++)if(!Mt(m[y])){p=false;break}if(!p)continue;let f=this.context.lookupKeyword(m);if(f)return {value:m,length:d,metadata:{normalized:f.normalized!==f.native?f.normalized:void 0}};if(this.context.normalizer){let y=this.context.normalizer.normalize(m);if(y.stem!==m&&y.confidence>=.7){let v=this.context.lookupKeyword(y.stem);if(v)return {value:m,length:d,metadata:{normalized:v.normalized,stem:y.stem,stemConfidence:y.confidence}}}}}let i="",a=e;for(;a<t.length&&Mt(t[a])&&!(i.length>0&&this.context.isKeywordStart(t,a));)i+=t[a],a++;if(!i)return null;for(let d of bd)if(i.endsWith(d)&&i.length>d.length){let m=i.slice(0,-d.length),p=this.context.lookupKeyword(m);if(p)return {value:m,length:m.length,metadata:{normalized:p.normalized,hasSuffix:true,suffix:d,stem:m}}}let o=this.context.lookupKeyword(i),u=o&&o.normalized!==o.native?o.normalized:void 0;i.includes("\uD1A0\uAE00")&&(console.log(`[KO DEBUG] word="${i}"`),console.log(`[KO DEBUG] keywordEntry=${o?"FOUND":"NOT FOUND"}`),console.log(`[KO DEBUG] normalizer=${this.context.normalizer?"EXISTS":"MISSING"}`));let s,l,c;if(!o&&this.context.normalizer){let d=this.context.normalizer.normalize(i);if(d.stem!==i&&d.confidence>=.7){let m=this.context.lookupKeyword(d.stem);m&&(s=m.normalized,l=d.stem,c=d.confidence,i.includes("\uD1A0\uAE00")&&console.log(`[KO DEBUG] word="${i}", stem="${d.stem}", normalized="${s}"`));}}return {value:i,length:a-r,metadata:{normalized:u||s,stem:l,stemConfidence:c}}}},ta=new Map([["\uC774",{role:"agent",confidence:.85,variant:"consonant",description:"subject marker (after consonant)"}],["\uAC00",{role:"agent",confidence:.85,variant:"vowel",description:"subject marker (after vowel)"}],["\uC744",{role:"patient",confidence:.95,variant:"consonant",description:"object marker (after consonant)"}],["\uB97C",{role:"patient",confidence:.95,variant:"vowel",description:"object marker (after vowel)"}],["\uC740",{role:"agent",confidence:.75,variant:"consonant",description:"topic marker (after consonant)"}],["\uB294",{role:"agent",confidence:.75,variant:"vowel",description:"topic marker (after vowel)"}],["\uC5D0",{role:"destination",confidence:.85,description:"at/to marker"}],["\uB85C",{role:"destination",confidence:.85,variant:"vowel",description:"to/by means (after vowel or \u3139)"}],["\uC640",{role:"style",confidence:.7,variant:"vowel",description:"and/with (after vowel)"}],["\uACFC",{role:"style",confidence:.7,variant:"consonant",description:"and/with (after consonant)"}],["\uC758",{role:"patient",confidence:.6,description:"possessive marker"}],["\uB3C4",{role:"patient",confidence:.65,description:"also/too marker"}],["\uB9CC",{role:"patient",confidence:.65,description:"only marker"}]]),na=new Map([["\uC5D0\uC11C",{role:"source",confidence:.8,description:"at/from marker (action location)"}],["\uC73C\uB85C",{role:"destination",confidence:.85,variant:"consonant",description:"to/by means (after consonant)"}],["\uBD80\uD130",{role:"source",confidence:.9,description:"from/since marker"}],["\uAE4C\uC9C0",{role:"destination",confidence:.75,description:"until/to marker"}],["\uCC98\uB7FC",{role:"manner",confidence:.8,description:"like/as marker"}],["\uBCF4\uB2E4",{role:"source",confidence:.75,description:"than marker"}]]);function ia(t){if(!t)return false;let e=t.codePointAt(0);return e>=44032&&e<=55203}var Dd=class{constructor(){this.name="korean-particle";}setContext(t){this._context=t,this._context;}canExtract(t,e){let r=t[e];if(ta.has(r)&&!ia(t[e+1]))return true;for(let[n]of na)if(t.startsWith(n,e))return true;return false}extract(t,e){for(let[i,a]of na)if(t.startsWith(i,e))return {value:i,length:i.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleVariant:a.variant}};let r=t[e],n=ta.get(r);return n&&!ia(t[e+1])?{value:r,length:1,metadata:{particleRole:n.role,particleConfidence:n.confidence,particleVariant:n.variant}}:null}};function Bd(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Sd(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var xd=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Bd(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,n="",i=e;for(;i<t.length&&Sd(t[i]);)n+=t[i],i++;if(!n)return null;let a=this.context.lookupKeyword(n),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:n,length:i-r,metadata:{normalized:o}}}};function Td(){return [new Cd,new hd,new wd,new yd]}var Fd=new Set(["\uC774","\uAC00","\uC744","\uB97C","\uC740","\uB294","\uC5D0","\uC5D0\uC11C","\uB85C","\uC73C\uB85C","\uC640","\uACFC","\uC758","\uB3C4","\uB9CC","\uBD80\uD130","\uAE4C\uC9C0","\uCC98\uB7FC","\uBCF4\uB2E4"]),Ld=[{native:"\uCC38",normalized:"true"},{native:"\uAC70\uC9D3",normalized:"false"},{native:"\uB110",normalized:"null"},{native:"\uBBF8\uC815\uC758",normalized:"undefined"},{native:"\uC815\uC758\uC548\uB428",normalized:"undefined"},{native:"\uCCAB\uBC88\uC9F8",normalized:"first"},{native:"\uB9C8\uC9C0\uB9C9",normalized:"last"},{native:"\uB2E4\uC74C",normalized:"next"},{native:"\uC774\uC804",normalized:"previous"},{native:"\uAC00\uC7A5\uAC00\uAE4C\uC6B4",normalized:"closest"},{native:"\uBD80\uBAA8",normalized:"parent"},{native:"\uC548\uC5D0",normalized:"in"},{native:"\uD074\uB9AD",normalized:"click"},{native:"\uB354\uBE14\uD074\uB9AD",normalized:"dblclick"},{native:"\uBCC0\uACBD",normalized:"change"},{native:"\uC81C\uCD9C",normalized:"submit"},{native:"\uC785\uB825",normalized:"input"},{native:"\uB85C\uB4DC",normalized:"load"},{native:"\uC2A4\uD06C\uB864",normalized:"scroll"},{native:"\uD0A4\uB2E4\uC6B4",normalized:"keydown"},{native:"\uD0A4\uC5C5",normalized:"keyup"},{native:"\uB9C8\uC6B0\uC2A4\uC624\uBC84",normalized:"mouseover"},{native:"\uB9C8\uC6B0\uC2A4\uC544\uC6C3",normalized:"mouseout"},{native:"\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4",normalized:"mousedown"},{native:"\uB9C8\uC6B0\uC2A4\uC5C5",normalized:"mouseup"},{native:"\uB0B4",normalized:"my"},{native:"\uADF8\uAC83\uC758",normalized:"its"},{native:"\uADF8\uB2E4\uC74C",normalized:"then"},{native:"\uADF8\uB7F0\uD6C4",normalized:"then"},{native:"\uADF8\uB7EC\uBA74",normalized:"then"},{native:"\uADF8\uB9AC\uACE0",normalized:"and"},{native:"\uB610\uB294",normalized:"or"},{native:"\uC544\uB2C8",normalized:"not"},{native:"\uC774\uB2E4",normalized:"is"},{native:"\uCD08",normalized:"s"},{native:"\uBC00\uB9AC\uCD08",normalized:"ms"},{native:"\uBD84",normalized:"m"},{native:"\uC2DC\uAC04",normalized:"h"},{native:"\uD3EC\uD568",normalized:"inclusive"},{native:"\uC81C\uC678",normalized:"exclusive"},{native:"\uBB38\uC790",normalized:"characters"},{native:"\uBB34\uC791\uC704",normalized:"random"}],Od=class extends Qe{constructor(){super(),this.language="ko",this.direction="ltr",this.initializeKeywordsFromProfile(oa,Ld),this.normalizer=new aa,this.registerExtractors(Td()),this.registerExtractor(new Je),this.registerExtractor(new Xe),this.registerExtractor(new xd),this.registerExtractor(new Dd),this.registerExtractor(new Ad),this.registerExtractor(new md),this.registerExtractor(new fd);}classifyToken(t){return Fd.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":"identifier"}},Rd=new Od;lr("ko",Rd,oa);var ca={code:"zh",name:"Chinese",nativeName:"\u4E2D\u6587",regions:["east-asian","priority"],direction:"ltr",script:"cjk",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:false,verb:{position:"second",subjectDrop:true},references:{me:"\u6211",it:"\u5B83",you:"\u4F60",result:"\u7ED3\u679C",event:"\u4E8B\u4EF6",target:"\u76EE\u6807",body:"\u4E3B\u4F53",document:"\u6587\u6863",window:"\u7A97\u53E3",detail:"\u8BE6\u60C5"},possessive:{marker:"\u7684",markerPosition:"between",keywords:{\u6211\u7684:"me",\u4F60\u7684:"you",\u5B83\u7684:"it",\u4ED6\u7684:"it",\u5979\u7684:"it"}},roleMarkers:{destination:{primary:"\u5728",alternatives:["\u5230","\u4E8E"],position:"before"},source:{primary:"\u4ECE",alternatives:["\u7531"],position:"before"},patient:{primary:"\u628A",position:"before"},style:{primary:"\u7528",alternatives:["\u4EE5"],position:"before"}},keywords:{toggle:{primary:"\u5207\u6362",normalized:"toggle"},add:{primary:"\u6DFB\u52A0",alternatives:["\u52A0"],normalized:"add"},remove:{primary:"\u79FB\u9664",alternatives:["\u5220\u9664","\u53BB\u6389"],normalized:"remove"},put:{primary:"\u653E\u7F6E",alternatives:["\u653E","\u653E\u5165"],normalized:"put"},append:{primary:"\u8FFD\u52A0",alternatives:["\u9644\u52A0"],normalized:"append"},prepend:{primary:"\u524D\u7F6E",alternatives:["\u9884\u7F6E"],normalized:"prepend"},take:{primary:"\u62FF\u53D6",normalized:"take"},make:{primary:"\u5236\u4F5C",normalized:"make"},clone:{primary:"\u514B\u9686",normalized:"clone"},swap:{primary:"\u4EA4\u6362",normalized:"swap"},morph:{primary:"\u53D8\u5F62",alternatives:["\u8F6C\u6362"],normalized:"morph"},set:{primary:"\u8BBE\u7F6E",alternatives:["\u8BBE\u5B9A"],normalized:"set"},get:{primary:"\u83B7\u53D6",alternatives:["\u83B7\u5F97","\u53D6\u5F97"],normalized:"get"},increment:{primary:"\u589E\u52A0",normalized:"increment"},decrement:{primary:"\u51CF\u5C11",normalized:"decrement"},log:{primary:"\u65E5\u5FD7",normalized:"log"},show:{primary:"\u663E\u793A",alternatives:["\u5C55\u793A"],normalized:"show"},hide:{primary:"\u9690\u85CF",normalized:"hide"},transition:{primary:"\u8FC7\u6E21",normalized:"transition"},on:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},trigger:{primary:"\u89E6\u53D1",normalized:"trigger"},send:{primary:"\u53D1\u9001",normalized:"send"},focus:{primary:"\u805A\u7126",alternatives:["\u53D6\u5F97\u7126\u9EDE"],normalized:"focus"},blur:{primary:"\u5931\u7126",alternatives:["\u5931\u53BB\u7126\u9EDE"],normalized:"blur"},empty:{primary:"\u6E05\u7A7A",alternatives:["\u7A7A\u7684"],normalized:"empty"},open:{primary:"\u6253\u5F00",normalized:"open"},close:{primary:"\u5173\u95ED",normalized:"close"},select:{primary:"\u9009\u62E9",normalized:"select"},clear:{primary:"\u6E05\u9664",normalized:"clear"},reset:{primary:"\u91CD\u7F6E",normalized:"reset"},breakpoint:{primary:"\u65AD\u70B9",normalized:"breakpoint"},click:{primary:"\u70B9\u51FB",normalized:"click"},hover:{primary:"\u60AC\u505C",alternatives:["\u60AC\u6D6E"],normalized:"hover"},submit:{primary:"\u63D0\u4EA4",alternatives:["\u9001\u51FA"],normalized:"submit"},input:{primary:"\u8F93\u5165",normalized:"input"},change:{primary:"\u53D8\u5316",alternatives:["\u6539\u53D8"],normalized:"change"},go:{primary:"\u524D\u5F80",normalized:"go"},scroll:{primary:"\u6EDA\u52A8",alternatives:["\u6372\u52D5"],normalized:"scroll"},push:{primary:"\u63A8\u9001",normalized:"push"},replace:{primary:"\u66FF\u6362",normalized:"replace"},process:{primary:"\u5904\u7406",normalized:"process"},wait:{primary:"\u7B49\u5F85",normalized:"wait"},fetch:{primary:"\u6293\u53D6",normalized:"fetch"},settle:{primary:"\u7A33\u5B9A",normalized:"settle"},if:{primary:"\u5982\u679C",normalized:"if"},unless:{primary:"\u9664\u975E",normalized:"unless"},when:{primary:"\u4F55\u65F6",normalized:"when"},changes:{primary:"\u6539\u53D8\u65F6",normalized:"changes"},where:{primary:"\u54EA\u91CC",normalized:"where"},else:{primary:"\u5426\u5219",normalized:"else"},matches:{primary:"\u5339\u914D",normalized:"matches"},repeat:{primary:"\u91CD\u590D",normalized:"repeat"},forever:{primary:"forever",normalized:"forever"},for:{primary:"\u4E3A",normalized:"for"},while:{primary:"\u6301\u7EED",normalized:"while"},continue:{primary:"\u7EE7\u7EED",normalized:"continue"},halt:{primary:"\u505C\u6B62",normalized:"halt"},throw:{primary:"\u629B\u51FA",normalized:"throw"},call:{primary:"\u8C03\u7528",normalized:"call"},return:{primary:"\u8FD4\u56DE",normalized:"return"},then:{primary:"\u7136\u540E",alternatives:["\u63A5\u7740","\u90A3\u4E48"],normalized:"then"},and:{primary:"\u5E76\u4E14",alternatives:["\u548C","\u800C\u4E14"],normalized:"and"},exists:{primary:"\u5B58\u5728",normalized:"exists"},end:{primary:"\u7ED3\u675F",alternatives:["\u7EC8\u6B62","\u5B8C"],normalized:"end"},js:{primary:"JS\u6267\u884C",alternatives:["js"],normalized:"js"},async:{primary:"\u5F02\u6B65",normalized:"async"},tell:{primary:"\u544A\u8BC9",normalized:"tell"},default:{primary:"\u9ED8\u8BA4",normalized:"default"},init:{primary:"\u521D\u59CB\u5316",normalized:"init"},behavior:{primary:"\u884C\u4E3A",normalized:"behavior"},install:{primary:"\u5B89\u88C5",normalized:"install"},measure:{primary:"\u6D4B\u91CF",normalized:"measure"},beep:{primary:"\u8702\u9E23",normalized:"beep"},break:{primary:"\u4E2D\u65AD",normalized:"break"},copy:{primary:"\u590D\u5236",normalized:"copy"},exit:{primary:"\u9000\u51FA",normalized:"exit"},pick:{primary:"\u9009\u53D6",normalized:"pick"},render:{primary:"\u6E32\u67D3",normalized:"render"},into:{primary:"\u8FDB\u5165",normalized:"into"},before:{primary:"\u4E4B\u524D",normalized:"before"},after:{primary:"\u4E4B\u540E",normalized:"after"},until:{primary:"\u76F4\u5230",normalized:"until"},event:{primary:"\u4E8B\u4EF6",normalized:"event"},from:{primary:"\u4ECE",normalized:"from"},connect:{primary:"\u8FDE\u63A5",alternatives:["\u8FDE\u63A5\u5668"],normalized:"connect"},stream:{primary:"\u6D41",alternatives:["\u6D41\u5F0F\u4F20\u8F93"],normalized:"stream"},live:{primary:"\u5B9E\u65F6",alternatives:["\u76F4\u64AD"],normalized:"live"},socket:{primary:"\u5957\u63A5\u5B57",alternatives:["websocket","socket"],normalized:"socket"},bind:{primary:"\u7ED1\u5B9A",alternatives:["bind"],normalized:"bind"},intercept:{primary:"\u62E6\u622A",alternatives:["intercept"],normalized:"intercept"},worker:{primary:"\u5DE5\u4F5C\u7EBF\u7A0B",alternatives:["\u5DE5\u4F5C\u8005","worker"],normalized:"worker"},eventsource:{primary:"eventsource",alternatives:["\u4E8B\u4EF6\u6E90"],normalized:"eventsource"}},tokenization:{boundaryStrategy:"character"},eventHandler:{keyword:{primary:"\u5F53",alternatives:["\u5728...\u65F6"],normalized:"on"},sourceMarker:{primary:"\u4ECE",position:"before"},eventMarker:{primary:"\u5F53",alternatives:["\u5728"],position:"before"},temporalMarkers:["\u5F53","\u5728...\u65F6","\u4E00"]}},Pd=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Nd=class{constructor(t=Pd){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}},Md="()[]{},:;",_d=class{constructor(t=Md){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 _t(t,e){let r=e;for(;r<t.length&&t[r]===":";){let n=t.slice(r).match(/^::?[a-zA-Z][a-zA-Z0-9-]*/);if(!n)break;let i=r+n[0].length;if(t[i]==="("){let a=0,o=i;for(;o<t.length;){if(t[o]==="(")a++;else if(t[o]===")"&&(a--,a===0)){o++;break}o++;}if(a!==0)break;i=o;}r=i;}return r}function ua(t,e){let r=t[e];if(r==="#"){let n=t.slice(e).match(/^#[a-zA-Z_][\w-]*/);if(!n)return null;let i=_t(t,e+n[0].length);return t.slice(e,i)}if(r==="."){let n=t.slice(e).match(/^\.\{[a-zA-Z_$][\w$]*\}/);if(n)return n[0];let i=t.slice(e).match(/^\.[a-zA-Z_][\w-]*/);if(!i)return null;let a=_t(t,e+i[0].length);return t.slice(e,a)}if(r==="@"){let n=t.slice(e).match(/^@[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="*"){let n=t.slice(e).match(/^\*(?:--)?[a-zA-Z_][\w-]*/);return n?n[0]:null}if(r==="["){let n=0,i=e;for(;i<t.length;){if(t[i]==="["&&n++,t[i]==="]"&&(n--,n===0)){let a=_t(t,i+1);return t.slice(e,a)}i++;}return null}if(r==="<"){let n=t.slice(e).match(/^<(?=[\w.#[])[\w-]*(?:[#.][\w-]+|\[[^\]]+\]|::?[a-zA-Z][a-zA-Z0-9-]*(?:\([^)]*\))?)*\s*\/>/);return n?n[0]:null}return null}var Id=class{constructor(){this.name="css-selector";}canExtract(t,e){let r=t[e];return r==="#"||r==="."||r==="["||r==="<"?true:r==="@"||r==="*"?ua(t,e)!==null:false}extract(t,e){let r=ua(t,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},jd=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 n=r[0],i=n.slice(1).split("(")[0],a=r[1];return {value:n,length:n.length,metadata:{modifierName:i,value:a?i==="queue"?a:parseInt(a,10):void 0}}}},$d=["http://","https://","//","./","../","/"];function Vd(t,e){let r=1;for(let n=e;n<t.length;n++){let i=t[n];if(i==="{")r++;else if(i==="}"&&--r===0)return n+1}return -1}function qd(t,e){let r=t.slice(e),n=$d.find(a=>r.startsWith(a));if(!n)return null;let i=n.length;for(;i<r.length;){let a=r[i];if(a==="$"&&r[i+1]==="{"){let o=Vd(r,i+2);if(o!==-1){i=o;continue}}if(/\s/.test(a))break;i++;}return r.slice(0,i)}var Wd=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=qd(t,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Kd=class{constructor(){this.name="variable-ref";}canExtract(t,e){let r=t[e];return (r===":"||r==="$"||r==="^")&&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 It(t){let e=t.charCodeAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=63744&&e<=64255||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=194560&&e<=195103}var Hd=class{constructor(){this.name="chinese-keyword";}setContext(t){this.context=t;}canExtract(t,e){return It(t[e])}extract(t,e){if(!this.context)throw new Error("ChineseKeywordExtractor: context not set");let r=e,n=null;if(this.context.isKeywordStart(t,e))for(let o=10;o>=1;o--){let u=t.slice(e,e+o);if([...u].every(s=>It(s))){let s=this.context.lookupKeyword(u);if(s){n={word:u,entry:s};break}}}if(n)return {value:n.word,length:n.word.length,metadata:{normalized:n.entry.normalized}};let i="",a=e;for(;a<t.length&&It(t[a])&&(i+=t[a],a++,!(a<t.length&&this.context.isKeywordStart(t,a))););return i?{value:i,length:a-r,metadata:{}}:null}},sa=new Map([["\u628A",{role:"patient",confidence:.95,description:"ba-construction object marker"}],["\u5728",{role:"location",confidence:.85,description:"at/in/on location marker"}],["\u4ECE",{role:"source",confidence:.9,description:"from marker"}],["\u5230",{role:"destination",confidence:.9,description:"to/until marker"}],["\u5411",{role:"destination",confidence:.85,description:"towards marker"}],["\u7ED9",{role:"destination",confidence:.85,description:"to/for recipient marker"}],["\u5BF9",{role:"destination",confidence:.8,description:"to/towards marker"}],["\u7528",{role:"instrument",confidence:.85,description:"with/using marker"}],["\u88AB",{role:"agent",confidence:.8,description:"by (passive) marker"}],["\u8BA9",{role:"agent",confidence:.75,description:"let/make causative marker"}],["\u7684",{role:"possessive",confidence:.9,description:"possessive/attributive marker"}],["\u5730",{role:"manner",confidence:.85,description:"adverbial marker"}],["\u5F97",{role:"manner",confidence:.8,description:"complement marker"}],["\u4E86",{role:"aspect",confidence:.7,description:"completion aspect marker"}],["\u7740",{role:"aspect",confidence:.7,description:"progressive aspect marker"}],["\u8FC7",{role:"aspect",confidence:.7,description:"experiential aspect marker"}],["\u5417",{role:"mood",confidence:.75,description:"question particle"}],["\u5462",{role:"mood",confidence:.7,description:"question/emphasis particle"}],["\u5427",{role:"mood",confidence:.7,description:"suggestion particle"}]]),la=new Map([["\u7136\u540E",{role:"sequence",confidence:.9,description:"then/afterwards"}],["\u63A5\u7740",{role:"sequence",confidence:.85,description:"next/following"}],["\u5E76\u4E14",{role:"conjunction",confidence:.85,description:"and/moreover"}],["\u6216\u8005",{role:"conjunction",confidence:.85,description:"or"}],["\u5982\u679C",{role:"condition",confidence:.9,description:"if"}],["\u90A3\u4E48",{role:"consequence",confidence:.85,description:"then"}],["\u5426\u5219",{role:"alternative",confidence:.85,description:"otherwise"}]]),Ud=class{constructor(){this.name="chinese-particle";}setContext(t){this._context=t;}longerKeywordAt(t,e,r){let n=this._context;if(!n)return false;let i=Math.min(10,t.length-e);for(let a=i;a>r;a--)if(n.lookupKeyword(t.slice(e,e+a)))return true;return false}canExtract(t,e){let r=t[e];if(sa.has(r)&&!this.longerKeywordAt(t,e,1))return true;for(let[n]of la)if(t.startsWith(n,e)&&!this.longerKeywordAt(t,e,n.length))return true;return false}extract(t,e){for(let[i,a]of la)if(t.startsWith(i,e)&&!this.longerKeywordAt(t,e,i.length))return {value:i,length:i.length,metadata:{particleRole:a.role,particleConfidence:a.confidence,particleDescription:a.description}};let r=t[e],n=sa.get(r);return n&&!this.longerKeywordAt(t,e,1)?{value:r,length:1,metadata:{particleRole:n.role,particleConfidence:n.confidence,particleDescription:n.description}}:null}};function Gd(t){let e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Yd(t){let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var Zd=class{constructor(){this.name="ascii-identifier";}setContext(t){this.context=t;}canExtract(t,e){return Gd(t[e])}extract(t,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let r=e,n="",i=e;for(;i<t.length&&Yd(t[i]);)n+=t[i],i++;if(!n)return null;let a=this.context.lookupKeyword(n),o=a&&a.normalized!==a.native?a.normalized:void 0;return {value:n,length:i-r,metadata:{normalized:o}}}};function Jd(){return [new Wd,new jd,new Kd,new Id]}var Xd=new Set(["\u628A","\u5728","\u4ECE","\u5230","\u5411","\u7ED9","\u5BF9","\u7528","\u88AB","\u8BA9","\u7684","\u5730","\u5F97","\u4E86","\u7740","\u8FC7","\u5417","\u5462","\u5427"]),Qd=[{native:"\u771F",normalized:"true"},{native:"\u5047",normalized:"false"},{native:"\u7A7A",normalized:"null"},{native:"\u672A\u5B9A\u4E49",normalized:"undefined"},{native:"\u7B49\u4E8E",normalized:"equals"},{native:"\u7B2C\u4E00\u4E2A",normalized:"first"},{native:"\u9996\u4E2A",normalized:"first"},{native:"\u6700\u540E\u4E00\u4E2A",normalized:"last"},{native:"\u672B\u4E2A",normalized:"last"},{native:"\u4E0B\u4E00\u4E2A",normalized:"next"},{native:"\u4E0A\u4E00\u4E2A",normalized:"previous"},{native:"\u6700\u8FD1\u7684",normalized:"closest"},{native:"\u7236\u7EA7",normalized:"parent"},{native:"\u70B9\u51FB",normalized:"click"},{native:"\u53CC\u51FB",normalized:"dblclick"},{native:"\u8F93\u5165",normalized:"input"},{native:"\u53D8\u66F4",normalized:"change"},{native:"\u6539\u53D8",normalized:"change"},{native:"\u63D0\u4EA4",normalized:"submit"},{native:"\u6309\u952E",normalized:"keydown"},{native:"\u91CA\u653E\u952E",normalized:"keyup"},{native:"\u9F20\u6807\u79FB\u5165",normalized:"mouseover"},{native:"\u9F20\u6807\u79FB\u51FA",normalized:"mouseout"},{native:"\u83B7\u5F97\u7126\u70B9",normalized:"focus"},{native:"\u5931\u53BB\u7126\u70B9",normalized:"blur"},{native:"\u52A0\u8F7D",normalized:"load"},{native:"\u6EDA\u52A8",normalized:"scroll"},{native:"\u6211\u7684",normalized:"my"},{native:"\u5B83\u7684",normalized:"its"},{native:"\u79D2",normalized:"s"},{native:"\u6BEB\u79D2",normalized:"ms"},{native:"\u5206\u949F",normalized:"m"},{native:"\u5C0F\u65F6",normalized:"h"},{native:"\u548C",normalized:"and"},{native:"\u6216\u8005",normalized:"or"},{native:"\u6216",normalized:"or"},{native:"\u4E0D",normalized:"not"},{native:"\u975E",normalized:"not"},{native:"\u662F",normalized:"is"},{native:"\u82E5",normalized:"if"},{native:"\u4E0D\u7136",normalized:"else"},{native:"\u5FAA\u73AF",normalized:"repeat"},{native:"\u904D\u5386",normalized:"for"},{native:"\u6BCF\u4E2A",normalized:"for"},{native:"\u4E3A\u6BCF",normalized:"for"},{native:"\u4E2D\u6B62",normalized:"halt"},{native:"\u629B",normalized:"throw"},{native:"\u547C\u53EB",normalized:"call"},{native:"\u56DE",normalized:"return"},{native:"\u811A\u672C",normalized:"js"},{native:"\u901A\u77E5",normalized:"tell"},{native:"\u7F3A\u7701",normalized:"default"},{native:"\u521D\u59CB",normalized:"init"},{native:"\u52A8\u4F5C",normalized:"behavior"},{native:"\u6FC0\u53D1",normalized:"trigger"},{native:"\u5BF9\u7126",normalized:"focus"},{native:"\u6A21\u7CCA",normalized:"blur"},{native:"\u8DF3\u8F6C",normalized:"go"},{native:"\u5BFC\u822A",normalized:"go"},{native:"\u6293\u53D6",normalized:"fetch"},{native:"\u83B7\u53D6\u6570\u636E",normalized:"fetch"},{native:"\u5B89\u5B9A",normalized:"settle"},{native:"\u62FF\u53D6",normalized:"take"},{native:"\u53D6",normalized:"take"},{native:"\u521B\u5EFA",normalized:"make"},{native:"\u514B\u9686",normalized:"clone"},{native:"\u8BB0\u5F55",normalized:"log"},{native:"\u6253\u5370",normalized:"log"},{native:"\u52A8\u753B",normalized:"transition"},{native:"\u5230\u91CC\u9762",normalized:"into"},{native:"\u91CC",normalized:"into"},{native:"\u524D",normalized:"before"},{native:"\u540E",normalized:"after"},{native:"\u90A3\u4E48",normalized:"then"},{native:"\u5B8C",normalized:"end"},{native:"\u4F5C\u4E3A",normalized:"as"},{native:"\u5305\u542B",normalized:"inclusive"},{native:"\u6392\u9664",normalized:"exclusive"},{native:"\u5B57\u7B26",normalized:"characters"},{native:"\u968F\u673A",normalized:"random"}],em=class extends Qe{constructor(){super(),this.language="zh",this.direction="ltr",this.initializeKeywordsFromProfile(ca,Qd),this.registerExtractors(Jd()),this.registerExtractor(new Je),this.registerExtractor(new Xe),this.registerExtractor(new Zd),this.registerExtractor(new Ud),this.registerExtractor(new Hd),this.registerExtractor(new Nd),this.registerExtractor(new _d);}classifyToken(t){return Xd.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("'")||t.startsWith("\u201C")||t.startsWith("\u2018")||/^\d/.test(t)?"literal":"identifier"}},rm=new em;lr("zh",rm,ca);function Qr(t){let e=t.getAttribute("data-lang");if(e)return Xr(e);let r=t.getAttribute("data-hyperscript-lang")??t.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return Xr(r);let n=t.closest?.("[lang]")?.getAttribute("lang");if(n)return Xr(n);let i=typeof document<"u"?document.documentElement?.lang:null;return i&&i!=="en"?Xr(i):null}function Xr(t){return t.split("-")[0].toLowerCase()}var da={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],beep:[["patient",""]],behavior:[["patient",""]],bind:[["destination",""],["source","to"]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],eventsource:[],exit:[],fetch:[["source",""],["style","with"],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""],["manner","in new"]],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"],["manner","using view"]],on:[["event",""],["source","from"]],open:[["patient",""],["style","as"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"],["manner","using view"]],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"],["manner","using view"]],take:[["patient",""],["source","from"],["recipient","for"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"],["duration","for"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],when:[["condition",""]],while:[["condition",""]],worker:[]};var tm=new Set(["repeat","for","while","tell"]),nm=new Set(["js"]);function et(t){switch(t.kind){case "event-handler":return am(t);case "compound":return ma(t);case "loop":return im(t);default:return om(t)}}function im(t){let e={kind:"command",action:t.action,roles:t.roles};return ma({statements:[e,...t.body],chainType:"then"})}function am(t){let e=["on"],r=t.roles.get("event");r&&e.push(r.type==="literal"?String(r.value):Tr(r));let n=t.roles.get("source");if(n&&e.push("from",Tr(n)),t.body&&t.body.length>0){let i=t.body.map(et);e.push(i.join(" "));}return e.join(" ")}function ma(t){let e=t.chainType==="async"?"async":t.chainType,r=t.statements.map(et),n=r[0]??"";for(let i=1;i<r.length;i++){let a=t.statements[i-1],o=t.statements[i],u=a.kind==="command"&&tm.has(a.action),s=a.kind==="command"&&a.action==="bind"&&o.kind==="command"&&o.action==="bind";a.kind==="command"&&nm.has(a.action)&&(n+=" end"),n+=(u||s?" ":` ${e} `)+r[i];}return n}function om(t){let e=da[t.action];if(e){let n=[t.action];for(let[i,a]of e){let o=t.roles.get(i);o&&((i==="destination"||i==="source")&&o.type==="reference"&&o.value==="me"||(a&&n.push(a),n.push(Tr(o))));}return n.join(" ")}let r=[t.action];for(let[,n]of t.roles)r.push(Tr(n));return r.join(" ")}function Tr(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 um(t);case "expression":return t.raw;case "flag":return t.enabled?`+${t.name}`:`~${t.name}`}}function um(t){let e=Tr(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 sm={confidenceThreshold:.5,strategy:"semantic"};function lm(t,e){return typeof t=="number"?t:t[e]??t["*"]??.5}var cm=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function dm(t){let e=t.match(cm);if(!e)return null;let r=e[1],n=t.slice(r.length);return n?{prefix:r,commands:n}:null}function pa(t){function e(i,a,o){try{return t.isLanguageRegistered(a)?t.translateSingle(i,a,o):null}catch{return null}}function r(i,a,o){try{let u=o(i,a);return u!==i?u:null}catch{return null}}function n(i,a,o){if(o.strategy==="semantic"||o.strategy==="auto"){let u=lm(o.confidenceThreshold,a),s=e(i,a,u);if(s!==null)return s}if((o.strategy==="auto"||o.strategy==="i18n")&&o.i18nToEnglish){let u=r(i,a,o.i18nToEnglish);if(u!==null)return u}return null}return function(a,o,u={}){if(o==="en")return a;let s={...sm,...u},l=n(a,o,s);if(l!==null)return l;let c=dm(a);if(c){let d=n(c.commands,o,s);if(d!==null)return c.prefix+d}return a}}var jt=pa({isLanguageRegistered:Gn,translateSingle(t,e,r){let n=Pi(t,e);return n.confidence<r||!n.node?null:et(n.node)}});var $t=new WeakSet;function mm(t){return (t.config?.attributes??"_, script, data-script").split(",").map(r=>r.trim()).filter(Boolean)}function pm(t,e){for(let r of e)if(t.hasAttribute(r))return r;return null}function fa(t,e){if(typeof t.addBeforeProcessHook!="function"){console.warn("[hyperscript-i18n] _hyperscript.addBeforeProcessHook is unavailable \u2014 this build of _hyperscript.org is not supported. Load a current version from https://unpkg.com/hyperscript.org.");return}let r=mm(t),n=[...r.map(a=>`[${a}]`),'script[type="text/hyperscript"]'].join(", "),i=a=>{if($t.has(a))return;if(a instanceof HTMLScriptElement&&a.type==="text/hyperscript"){let l=a.textContent??"";if(!l)return;let c=e(l,a);$t.add(a),c!=null&&c!==l&&(a.textContent=c);return}let o=pm(a,r);if(!o)return;let u=a.getAttribute(o);if(!u)return;let s=e(u,a);$t.add(a),s!=null&&s!==u&&a.setAttribute(o,s);};t.addBeforeProcessHook(a=>{!a||typeof a.querySelectorAll!="function"||(typeof a.matches=="function"&&a.matches(n)&&i(a),a.querySelectorAll(n).forEach(i));});}var fm=new Set(["me","my","i","it","its","you","your"]);function ym(t){for(let e of t?.features??[])for(let r of e.events??[])if(typeof r.on=="string"&&fm.has(r.on.toLowerCase()))return r.on}function ha(t,e){if(typeof t.parse!="function")return true;try{let r=t.parse(e);return r?.errors&&r.errors.length>0?!1:ym(r)===void 0}catch{return false}}var ya=new Set;function va(t,e,r){ya.has(t)||(ya.add(t),console.warn(`[hyperscript-i18n] Translation for lang="${t}" rendered hyperscript the host parser rejects (or reads as a handler for an event named like me/it/you) \u2014 falling back to the original text. Source: "${e.length>60?e.slice(0,60)+"\u2026":e}" \u2192 "${r.length>60?r.slice(0,60)+"\u2026":r}". Further elements in this language stay quiet \u2014 enable { debug: true } for per-element detail.`));}function Vt(t={}){return function(r){let n=r;fa(n,(i,a)=>{let o=hm(a,t);if(!o||o==="en")return i;let u=jt(i,o,t);if(u!==i){if(t.validateWithHost!==false&&!ha(n,u))return t.debug?console.log(`[hyperscript-i18n] ${o}: host rejected "${u}" \u2014 keeping "${i}"`):va(o,i,u),i;t.debug&&console.log(`[hyperscript-i18n] ${o}: "${i}" \u2192 "${u}"`);}return u});}}function hm(t,e){if(e.languageAttribute){let n=t.getAttribute(e.languageAttribute);if(n)return n.split("-")[0].toLowerCase()}let r=Qr(t);return r||(e.defaultLanguage??null)}function Ea(t,e,r={}){return e==="en"?t:jt(t,e,r)}Un(t=>Hi(t));function ga(){typeof _hyperscript<"u"&&_hyperscript.use&&_hyperscript.use(Vt());}var Pf=["ja","ko","zh"];ga();
6
+ exports.plugin=Vt;exports.preprocess=Ea;exports.resolveLanguage=Qr;exports.supportedLanguages=Pf;return exports;})({});