@lokascript/hyperscript-adapter 2.1.0 → 2.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 (32) hide show
  1. package/dist/hyperscript-i18n-ar.global.js +4 -4
  2. package/dist/hyperscript-i18n-bn.global.js +4 -4
  3. package/dist/hyperscript-i18n-de.global.js +4 -4
  4. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  5. package/dist/hyperscript-i18n-en.global.js +6 -6
  6. package/dist/hyperscript-i18n-es.global.js +4 -4
  7. package/dist/hyperscript-i18n-fr.global.js +4 -4
  8. package/dist/hyperscript-i18n-he.global.js +4 -4
  9. package/dist/hyperscript-i18n-hi.global.js +4 -4
  10. package/dist/hyperscript-i18n-id.global.js +4 -4
  11. package/dist/hyperscript-i18n-it.global.js +4 -4
  12. package/dist/hyperscript-i18n-ja.global.js +4 -4
  13. package/dist/hyperscript-i18n-ko.global.js +4 -4
  14. package/dist/hyperscript-i18n-ms.global.js +4 -4
  15. package/dist/hyperscript-i18n-pl.global.js +4 -4
  16. package/dist/hyperscript-i18n-pt.global.js +4 -4
  17. package/dist/hyperscript-i18n-qu.global.js +4 -4
  18. package/dist/hyperscript-i18n-ru.global.js +4 -4
  19. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  20. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  21. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-sw.global.js +4 -4
  23. package/dist/hyperscript-i18n-th.global.js +4 -4
  24. package/dist/hyperscript-i18n-tl.global.js +4 -4
  25. package/dist/hyperscript-i18n-tr.global.js +4 -4
  26. package/dist/hyperscript-i18n-uk.global.js +4 -4
  27. package/dist/hyperscript-i18n-vi.global.js +4 -4
  28. package/dist/hyperscript-i18n-western.global.js +4 -4
  29. package/dist/hyperscript-i18n-zh.global.js +4 -4
  30. package/dist/hyperscript-i18n.global.js +41 -27
  31. package/dist/hyperscript-i18n.global.js.map +1 -1
  32. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- var HyperscriptI18n=(function(exports){'use strict';function P(n,e){return e?{type:"literal",value:n,dataType:e}:{type:"literal",value:n}}function fe(n,e){return e?{type:"selector",value:n,selectorKind:e}:{type:"selector",value:n}}function oe(n){return {type:"reference",value:n}}function he(n,e){return {type:"property-path",object:n,property:e}}var Tt=class{constructor(n){this.namespace=n,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let n=process.env.DEBUG||"";return n==="*"||n.includes("framework:*")||n.includes(`framework:${this.namespace}`)}return false}log(n,e,...t){if(!this.enabled)return;let r=`[framework:${this.namespace}]`,o=new Date().toISOString();switch(n){case "debug":console.debug(`${o} ${r} DEBUG:`,e,...t);break;case "info":console.info(`${o} ${r} INFO:`,e,...t);break;case "warn":console.warn(`${o} ${r} WARN:`,e,...t);break;case "error":console.error(`${o} ${r} ERROR:`,e,...t);break}}debug(n,...e){this.log("debug",n,...e);}info(n,...e){this.log("info",n,...e);}warn(n,...e){this.log("warn",n,...e);}error(n,...e){this.log("error",n,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function kt(n){return new Tt(n)}function B(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function At(n,e){return n?.possessive?.keywords?.[e]}var H=class z{constructor(){this.logger=kt("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,r){let o=e.mark(),i=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let l=[];for(let c=0;c<10;c++){let u=e.peek(c);if(u)l.push({type:u.type,value:u.value,kind:u.kind});else break}this.logger.debug("Input tokens (first 10):",l),this.logger.debug("Profile code:",r?.code);}this.currentProfile=r,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,i);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(i.entries()).map(([l,c])=>[l,JSON.stringify(c)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(o),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-o.position,confidence:a}}matchBest(e,t,r){let o=[];for(let s of t){let a=e.mark(),l=this.matchPattern(e,s,r);l&&o.push(l),e.reset(a);}if(o.length===0)return null;o.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;if(l!==0)return l;let c=a.confidence-s.confidence;return Math.abs(c)>.001?c:a.consumedTokens-s.consumedTokens});let i=o[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,r,o){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,l=null;for(let c=0;c<t.length;c++){let u=t[c];this.logger.debug(" >> Matching pattern token:",JSON.stringify(u,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"),u.type==="role"&&u.greedy){let v=this.collectStopMarkers(t,c+1);if(o)for(let E of o)v.add(E);let g=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,v))break;g.push(E.value),e.advance();}if(g.length>0){r.set(u.role,{type:"expression",raw:g.join(" ")}),a=null,l=null;continue}else {if(u.optional)continue;return false}}if(u.type==="group"){let v=this.collectStopMarkers(t,c+1);if(o)for(let E of o)v.add(E);if(this.matchGroupToken(e,u,r,v)){a=null,l=null;continue}if(this.isOptional(u))continue;return false}let p=u.type==="role"&&u.optional===true,f=p?e.mark():null;if(u.type==="role"&&!p){let v=c+1<t.length?t[c+1]:null;if(v?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,v.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(u))continue;if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),r.delete(l),a=null,l=null;let E=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let y=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Match result:",y),y){p?(a=f,l=u.role):(a=null,l=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(u)){if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),r.delete(l),a=null,l=null;let v=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Backtrack retry result:",v),v)continue}return false}}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",r?JSON.stringify({type:r.type,value:r.value,kind:r.kind}):"null"),!r)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let o=this.getMatchType(r,t.value);if(this.logger.debug(" >>> matchType for",r.value,"vs",t.value,":",o),o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(r,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let o=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",o?JSON.stringify({value:o.value,kind:o.kind}):"null"),!o)return t.optional||false;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!B(i.type,t.expectedTypes)?t.optional||false:(r.set(t.role,i),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!B(s.type,t.expectedTypes)?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!B(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!B(l.type,t.expectedTypes)?t.optional||false:(r.set(t.role,l),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!B(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",o?JSON.stringify({value:o.value,kind:o.kind}):"null");let u=this.tokenToSemanticValue(o);return this.logger.debug(" >>> tokenToSemanticValue returned:",u?JSON.stringify(u):"null"),u?(this.logger.debug(" >>> Validating type:",u.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!B(u.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),r.set(t.role,u),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=t.normalized||t.value,o=this.safeToLowerCase(r),i=At(this.currentProfile,o);if(!i)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),he(oe(i),c)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<z.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<z.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<z.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(u===0){e.advance();break}u--;}if(p.kind==="punctuation"&&p.value==="("&&u++,p.kind==="punctuation"&&p.value===","){e.advance();continue}c.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return !i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),he(fe(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let s=o.value.slice(1);return he(fe(t.value),s)}matchGroupToken(e,t,r,o){let i=e.mark(),s=new Set(r.keys());if(this.matchTokenSequence(e,t.tokens,r,o))return true;e.reset(i);for(let c of r.keys())s.has(c)||r.delete(c);if(!t.optional)return false;let l=this.getGroupLeadingMarker(t);if(l)for(let c=1;c<=z.MAX_MARKER_SCAN;c++){let u=e.peek(c);if(!u)break;if((u.normalized||u.value).toLowerCase()===l){this.logger.debug(" >> MARKER SCAN: found",l,"at offset",c,"- skipping intervening tokens");for(let f=0;f<c;f++)e.advance();if(this.matchTokenSequence(e,t.tokens,r,o))return true;e.reset(i);for(let f of r.keys())s.has(f)||r.delete(f);break}}return true}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let r=new Set;for(let o=t;o<e.length;o++){let i=e[o];if(i.type==="literal"){if(r.add(i.value.toLowerCase()),i.alternatives)for(let s of i.alternatives)r.add(s.toLowerCase());break}if(i.type==="group"){for(let s of i.tokens)if(s.type==="literal"){if(r.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)r.add(a.toLowerCase());break}if(!i.optional)break}}return r}isStopMarker(e,t){return t.size===0?false:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return fe(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return P(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return oe(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return P(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let o=e.slice(1,-1);return P(o,"string")}if(e==="true")return P(true,"boolean");if(e==="false")return P(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?P(e,"duration"):P(o,"number")}let r=parseFloat(e);return isNaN(r)?P(e,"string"):P(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))t.has(r)||(o.value!==void 0?t.set(r,{type:"literal",value:o.value}):o.default&&t.set(r,o.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,o=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")o+=1,t.has(c.role)&&(r+=1);else if(c.type==="group"){for(let u of c.tokens)if(u.type==="role"){let d=i(u.role),p=.8;o+=p,t.has(u.role)?r+=p:d&&(r+=p*.6);}}let s=o>0?r/o:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let o of t.alternatives)if(r.has(o))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,o={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[i,s]of t.entries()){let a=o[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=this.safeToLowerCase(t.value);if(z.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(o);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=true,i.modifierName){case "once":t.once=true;break;case "debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case "throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case "queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance();}return r?t:void 0}};H.MAX_MARKER_SCAN=3;H.MAX_PROPERTY_DEPTH=10;H.MAX_METHOD_ARGS=20;H.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var xt=H;new xt;var Oe=class{constructor(){this.name="string-literal";}canExtract(n,e){let t=n[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(n,e){let t=n[e];if(t==="\u201C"){let i=1;for(;e+i<n.length;){if(n[e+i]==="\u201D")return i++,{value:n.substring(e,e+i),length:i};i++;}return null}if(t==="\u2018"){let i=1;for(;e+i<n.length;){if(n[e+i]==="\u2019")return i++,{value:n.substring(e,e+i),length:i};i++;}return null}let r=1,o=false;for(;e+r<n.length;){let i=n[e+r];if(o){o=false,r++;continue}if(i==="\\"){o=true,r++;continue}if(i===t)return r++,{value:n.substring(e,e+r),length:r};r++;}return null}},Ne=class{constructor(){this.name="number";}canExtract(n,e){return /\d/.test(n[e])}extract(n,e){let t=0,r=false;for(;e+t<n.length;){let s=n[e+t];if(/\d/.test(s))t++;else if(s==="."&&!r)r=true,t++;else break}if(t===0)return null;let o=n.substring(e,e+t),i=e+t;if(i<n.length){let s=n.slice(i),a=[{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 c of a)if(s.startsWith(c.pattern))return {value:o+c.suffix,length:t+c.pattern.length,metadata:{hasTimeUnit:true}};if(s.startsWith("ms"))return {value:o+"ms",length:t+2,metadata:{hasTimeUnit:true}};let l=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let c of l)if(s.startsWith(c.pattern))return {value:o+c.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(s))return {value:o+s[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:o,length:t}}};function Ct(n){return "setContext"in n&&typeof n.setContext=="function"}function Pt(n){let e={language:n.language,direction:n.direction,lookupKeyword:n.lookupKeyword.bind(n),isKeyword:n.isKeyword.bind(n),isKeywordStart:n.isKeywordStart.bind(n)};return n.normalizer?{...e,normalizer:n.normalizer}:e}var Rt=new Set(["me","you","it","result","event","target","body"]);function _e(n,e=Rt){return e.has(n)}var M=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;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(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function w(n,e){return {start:n,end:e}}function S(n,e,t,r){if(typeof n=="object"){let{value:i,kind:s,position:a,normalized:l,stem:c,stemConfidence:u,metadata:d}=n;return {value:i,kind:s,position:a,...l!==void 0&&{normalized:l},...c!==void 0&&{stem:c},...u!==void 0&&{stemConfidence:u},...d!==void 0&&{metadata:d}}}let o=n;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof r=="string")return {value:o,kind:e,position:t,normalized:r};if(r){let{normalized:i,stem:s,stemConfidence:a,metadata:l}=r;return {value:o,kind:e,position:t,...i!==void 0&&{normalized:i},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...l!==void 0&&{metadata:l}}}return {value:o,kind:e,position:t}}function I(n){return /\s/.test(n)}function Ot(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function Nt(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function _(n){return /\d/.test(n)}function _t(n){return /[a-zA-Z]/.test(n)}function A(n){return /[a-zA-Z0-9_-]/.test(n)}function It(n,e){if(e>=n.length)return null;let t=n[e];if(!Ot(t))return null;let r=e,o="";if(t==="#"||t==="."){for(o+=n[r++];r<n.length&&A(n[r]);)o+=n[r++];if(o.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let s=r+1;for(;s<n.length&&A(n[s]);)s++;if(s<n.length&&n[s]==="(")return o}}else if(t==="["){let i=1,s=false,a=null,l=false;for(o+=n[r++];r<n.length&&i>0;){let c=n[r];o+=c,l?l=false:c==="\\"?l=true:s?c===a&&(s=false,a=null):c==='"'||c==="'"||c==="`"?(s=true,a=c):c==="["?i++:c==="]"&&i--,r++;}if(i!==0)return null}else if(t==="@"){for(o+=n[r++];r<n.length&&A(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="*"){for(o+=n[r++];r<n.length&&A(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="<"){if(o+=n[r++],r>=n.length||!_t(n[r]))return null;for(;r<n.length&&A(n[r]);)o+=n[r++];for(;r<n.length;){let i=n[r];if(i==="."){if(o+=n[r++],r>=n.length||!A(n[r]))return null;for(;r<n.length&&A(n[r]);)o+=n[r++];}else if(i==="#"){if(o+=n[r++],r>=n.length||!A(n[r]))return null;for(;r<n.length&&A(n[r]);)o+=n[r++];}else if(i==="["){let s=1,a=false,l=null,c=false;for(o+=n[r++];r<n.length&&s>0;){let u=n[r];o+=u,c?c=false:u==="\\"?c=true:a?u===l&&(a=false,l=null):u==='"'||u==="'"||u==="`"?(a=true,l=u):u==="["?s++:u==="]"&&s--,r++;}if(s!==0)return null}else break}for(;r<n.length&&I(n[r]);)o+=n[r++];if(r<n.length&&n[r]==="/")for(o+=n[r++];r<n.length&&I(n[r]);)o+=n[r++];if(r>=n.length||n[r]!==">")return null;o+=n[r++];}return o||null}function Mt(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return false;if(e+2>=n.length)return true;let r=n[e+2];return I(r)||r==="*"||!A(r)}function Lt(n,e){if(e>=n.length)return null;let t=n[e];if(!Nt(t)||t==="'"&&Mt(n,e))return null;let o={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!o)return null;let i=e+1,s=t,a=false;for(;i<n.length;){let l=n[i];if(s+=l,a)a=false;else if(l==="\\")a=true;else if(l===o)return s;i++;}return s}function Dt(n,e){if(e>=n.length)return false;let t=n[e],r=n[e+1]||"",o=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(o)||t==="."&&(r==="/"||r==="."&&o==="/"))return true;let i=n.slice(e,e+8).toLowerCase();return !!(i.startsWith("http://")||i.startsWith("https://"))}function $t(n,e){if(!Dt(n,e))return null;let t=e,r="",o=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let i=n[t];if(i==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=i,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(o.test(i))r+=i,t++;else break}return r.length<2?null:r}function Bt(n,e){if(e>=n.length)return null;let t=n[e];if(!_(t)&&t!=="-"&&t!=="+")return null;let r=e,o="";if((n[r]==="-"||n[r]==="+")&&(o+=n[r++]),r>=n.length||!_(n[r]))return null;for(;r<n.length&&_(n[r]);)o+=n[r++];if(r<n.length&&n[r]===".")for(o+=n[r++];r<n.length&&_(n[r]);)o+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?o+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(o+=n[r])),o}var zt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];function ie(n){return e=>{let t=e.charCodeAt(0);return n.some(([r,o])=>t>=r&&t<=o)}}new Set(zt);var Me=class Le{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Ct(e)&&e.setContext(Pt(this)),this.extractors.push(e);}registerExtractors(e){for(let t of e)this.registerExtractor(t);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&I(e[r]);)r++;if(r>=e.length)break;let o=false;for(let i of this.extractors)if(i.canExtract(e,r)){let s=i.extract(e,r);if(s){let a=s.metadata?.normalized,l=s.metadata?.stem,c=s.metadata?.stemConfidence,u={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(u[p]=f);let d={};a&&(d.normalized=a),l&&(d.stem=l),c!==void 0&&(d.stemConfidence=c),Object.keys(u).length>0&&(d.metadata=u),t.push(S(s.value,this.classifyToken(s.value),w(r,r+s.length),Object.keys(d).length>0?d:void 0)),r+=s.length,o=true;break}}if(!o){let i=e[r],s=this.classifyUnknownChar(i);t.push(S(i,s,w(r,r+1))),r++;}}return new M(t,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,r){if(e[t]!==".")return false;let o=r[r.length-1],i=o&&o.position.end<t;if(o&&!i&&(o.kind==="identifier"||o.kind==="keyword"||o.kind==="selector"))return r.push(S(".","operator",w(t,t+1))),true;let l=t+1;for(;l<e.length&&A(e[l]);)l++;return l<e.length&&e[l]==="("?(r.push(S(".","operator",w(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[o,i]of Object.entries(e.keywords))if(r.set(i.primary,{native:i.primary,normalized:i.normalized||o}),i.alternatives)for(let s of i.alternatives)r.set(s,{native:s,normalized:i.normalized||o});}if(e.references){for(let[o,i]of Object.entries(e.references))r.set(i,{native:i,normalized:o});for(let o of Object.keys(e.references))r.has(o)||r.set(o,{native:o,normalized:o});}if(e.roleMarkers){for(let[o,i]of Object.entries(e.roleMarkers))if(i.primary&&r.set(i.primary,{native:i.primary,normalized:o}),i.alternatives)for(let s of i.alternatives)r.set(s,{native:s,normalized:o});}if(e.possessive?.keywords)for(let[o,i]of Object.entries(e.possessive.keywords))r.set(o,{native:o,normalized:i});for(let o of t)r.set(o.native,o);this.profileKeywords=Array.from(r.values()).sort((o,i)=>i.native.length-o.native.length),this.profileKeywordMap=new Map;for(let o of this.profileKeywords){this.profileKeywordMap.set(o.native.toLowerCase(),o);let i=this.removeDiacritics(o.native);i!==o.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),o);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let r of this.profileKeywords)if(e.slice(t).startsWith(r.native))return S(r.native,"keyword",w(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(o=>r.startsWith(o.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,r){let o=this.tryNormalize(e);if(!o)return null;let i=this.lookupKeyword(o.stem);if(!i)return null;let s={normalized:i.normalized,stem:o.stem,stemConfidence:o.confidence};return S(e,"keyword",w(t,r),s)}trySelector(e,t){let r=It(e,t);return r?S(r,"selector",w(t,t+r.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let r=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let o=r[0].replace(/(\s|\.)$/,""),i=o.slice(1).split("(")[0],s=r[1];return {...S(o,"event-modifier",w(t,t+o.length)),metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let r=Lt(e,t);return r?S(r,"literal",w(t,t+r.length)):null}tryNumber(e,t){let r=Bt(e,t);return r?S(r,"literal",w(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,o=false){let i=t;if(o)for(;i<e.length&&I(e[i]);)i++;let s=e.slice(i);for(let a of r){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let u=s[a.length]||"";if(A(u))continue}return {suffix:a.suffix,endPos:i+a.length}}}return null}parseBaseNumber(e,t,r=true){let o=t,i="";if(r&&(e[o]==="-"||e[o]==="+")&&(i+=e[o++]),o>=e.length||!_(e[o]))return null;for(;o<e.length&&_(e[o]);)i+=e[o++];if(o<e.length&&e[o]===".")for(i+=e[o++];o<e.length&&_(e[o]);)i+=e[o++];return !i||i==="-"||i==="+"?null:{number:i,endPos:o}}tryNumberWithTimeUnits(e,t,r,o={}){let{allowSign:i=true,skipWhitespace:s=false}=o,a=this.parseBaseNumber(e,t,i);if(!a)return null;let{number:l,endPos:c}=a,u=[...r,...Le.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,c,u,s);return d&&(l+=d.suffix,c=d.endPos),S(l,"literal",w(t,c))}tryUrl(e,t){let r=$t(e,t);return r?S(r,"url",w(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!A(e[t+1]))return null;let r=t+1;for(;r<e.length&&A(e[r]);)r++;let o=e.slice(t,r);return S(o,"identifier",w(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return S(r,"operator",w(t,t+2));let o=e[t];return ["<",">","!","+","-","*","/","="].includes(o)?S(o,"operator",w(t,t+1)):["(",")","{","}",",",";",":"].includes(o)?S(o,"punctuation",w(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let o of r)if(e.slice(t,t+o.length)===o)return S(o,"particle",w(t,t+o.length));return null}};Me.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var De=Me;function $e(n){return {stem:n,confidence:1}}function Be(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}var Vt=new Map,qt=new Map,Ft=new Map;function Wt(n,e,t){Vt.set(n,e),qt.set(n,t),Ft.delete(n);}function jt(n){let e=n.charCodeAt(0);return e>=1536&&e<=1791||e>=1872&&e<=1919||e>=2208&&e<=2303||e>=64336&&e<=65023||e>=65136&&e<=65279}function Ut(n){for(let e of n)if(jt(e))return true;return false}function Gt(n){return n.replace(/[\u064B-\u0652\u0670]/g,"")}var Kt=[{pattern:"\u0648\u0627\u0644",confidencePenalty:.15,prefixType:"conjunction"},{pattern:"\u0641\u0627\u0644",confidencePenalty:.15,prefixType:"conjunction"},{pattern:"\u0628\u0627\u0644",confidencePenalty:.15,prefixType:"preposition"},{pattern:"\u0643\u0627\u0644",confidencePenalty:.15,prefixType:"preposition"},{pattern:"\u0644\u0644",confidencePenalty:.12,prefixType:"preposition"}],Ht=[{pattern:"\u0627\u0644",confidencePenalty:.08,prefixType:"article",minRemaining:2},{pattern:"\u0648",confidencePenalty:.08,prefixType:"conjunction",minRemaining:3},{pattern:"\u0641",confidencePenalty:.08,prefixType:"conjunction",minRemaining:3},{pattern:"\u0628",confidencePenalty:.1,prefixType:"preposition",minRemaining:3},{pattern:"\u0644",confidencePenalty:.1,prefixType:"preposition",minRemaining:3},{pattern:"\u0643",confidencePenalty:.1,prefixType:"preposition",minRemaining:3}],Yt=[{pattern:"\u064A",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u062A",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0646",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0623",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0627",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3}],Xt=[{pattern:"\u0648\u0646",confidencePenalty:.1,type:"masculine-plural"},{pattern:"\u064A\u0646",confidencePenalty:.1,type:"masculine-plural-accusative"},{pattern:"\u0627\u062A",confidencePenalty:.1,type:"feminine-plural"},{pattern:"\u0627\u0646",confidencePenalty:.1,type:"dual-nominative"},{pattern:"\u064A\u0646",confidencePenalty:.1,type:"dual-accusative"},{pattern:"\u0647\u0627",confidencePenalty:.1,type:"pronoun-her"},{pattern:"\u0647\u0645",confidencePenalty:.1,type:"pronoun-them"},{pattern:"\u0647\u0646",confidencePenalty:.1,type:"pronoun-them-f"},{pattern:"\u0646\u0627",confidencePenalty:.1,type:"pronoun-us"},{pattern:"\u0643\u0645",confidencePenalty:.1,type:"pronoun-you-pl"},{pattern:"\u0643",confidencePenalty:.08,type:"pronoun-you"},{pattern:"\u0647",confidencePenalty:.08,type:"pronoun-him"},{pattern:"\u064A",confidencePenalty:.08,type:"pronoun-me"},{pattern:"\u0629",confidencePenalty:.08,type:"feminine"}],qe=class{constructor(){this.language="ar";}isNormalizable(n){return !(!Ut(n)||n.length<2)}normalize(n){let e=Gt(n),t=1,r=[],o=[];for(let s of Kt)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length);if(a.length>=2){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}if(r.length===0){for(let s of Ht)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length),l=s.minRemaining??2;if(a.length>=l){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}}if(!(e.endsWith("\u0627\u062A")||e.endsWith("\u0629")||e.endsWith("\u0648\u0646")||e.endsWith("\u064A\u0646")||e.endsWith("\u0647\u0627")||e.endsWith("\u0647\u0645")||e.endsWith("\u0647\u0646")||e.endsWith("\u0646\u0627")||e.endsWith("\u0643\u0645"))&&(r.length===0||r[0]==="\u0648"||r[0]==="\u0641")){for(let s of Yt)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length),l=s.minRemaining??3;if(a.length>=l){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}}for(let s of Xt)if(e.endsWith(s.pattern)){let a=e.slice(0,-s.pattern.length);a.length>=2&&(e=a,t-=s.confidencePenalty,o.push(s.pattern));}return t=Math.max(.5,t),r.length===0&&o.length===0?$e(n):Be(e,t,{removedPrefixes:r,removedSuffixes:o})}},Fe={code:"ar",name:"Arabic",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",direction:"rtl",script:"arabic",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"\u0623\u0646\u0627",it:"\u0647\u0648",you:"\u0623\u0646\u062A",result:"\u0627\u0644\u0646\u062A\u064A\u062C\u0629",event:"\u0627\u0644\u062D\u062F\u062B",target:"\u0627\u0644\u0647\u062F\u0641",body:"\u0627\u0644\u062C\u0633\u0645"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u0644\u064A",it:"\u0644\u0647",you:"\u0644\u0643"},keywords:{\u0644\u064A:"me",\u0644\u0643:"you",\u0644\u0647:"it",\u0644\u0647\u0627:"it"}},roleMarkers:{destination:{primary:"\u0639\u0644\u0649",alternatives:["\u0641\u064A","\u0625\u0644\u0649","\u0628","\u0642\u0628\u0644","\u0628\u0639\u062F"],position:"before"},source:{primary:"\u0645\u0646",position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0628\u0640",alternatives:["\u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645"],position:"before"}},keywords:{toggle:{primary:"\u0628\u062F\u0651\u0644",alternatives:["\u0628\u062F\u0644","\u063A\u064A\u0651\u0631","\u063A\u064A\u0631"],normalized:"toggle"},add:{primary:"\u0623\u0636\u0641",alternatives:["\u0627\u0636\u0641"],normalized:"add"},remove:{primary:"\u0627\u062D\u0630\u0641",alternatives:["\u0623\u0632\u0644","\u0627\u0645\u0633\u062D"],normalized:"remove"},put:{primary:"\u0636\u0639",alternatives:["\u0627\u062C\u0639\u0644"],normalized:"put"},append:{primary:"\u0623\u0644\u062D\u0642",normalized:"append"},prepend:{primary:"\u0633\u0628\u0642",normalized:"prepend"},take:{primary:"\u062E\u0630",normalized:"take"},make:{primary:"\u0627\u0635\u0646\u0639",alternatives:["\u0623\u0646\u0634\u0626"],normalized:"make"},clone:{primary:"\u0627\u0633\u062A\u0646\u0633\u062E",normalized:"clone"},swap:{primary:"\u0627\u0633\u062A\u0628\u062F\u0644",alternatives:["\u062A\u0628\u0627\u062F\u0644"],normalized:"swap"},morph:{primary:"\u062D\u0648\u0651\u0644",normalized:"morph"},set:{primary:"\u0627\u0636\u0628\u0637",alternatives:["\u0639\u064A\u0651\u0646","\u062D\u062F\u062F"],normalized:"set"},get:{primary:"\u0627\u062D\u0635\u0644",normalized:"get"},increment:{primary:"\u0632\u0650\u062F",alternatives:["\u0632\u062F","\u0627\u0631\u0641\u0639"],normalized:"increment"},decrement:{primary:"\u0623\u0646\u0642\u0635",alternatives:["\u0627\u0646\u0642\u0635","\u0642\u0644\u0644"],normalized:"decrement"},log:{primary:"\u0633\u062C\u0644",normalized:"log"},show:{primary:"\u0627\u0638\u0647\u0631",alternatives:["\u0623\u0638\u0647\u0631","\u0627\u0639\u0631\u0636"],normalized:"show"},hide:{primary:"\u0627\u062E\u0641",alternatives:["\u0623\u062E\u0641\u0650","\u0627\u062E\u0641\u064A","\u0623\u062E\u0641"],normalized:"hide"},transition:{primary:"\u0627\u0646\u062A\u0642\u0627\u0644",alternatives:["\u0627\u0646\u062A\u0642\u0644"],normalized:"transition"},on:{primary:"\u0639\u0644\u0649",alternatives:["\u0639\u0646\u062F","\u0644\u062F\u0649","\u062D\u064A\u0646"],normalized:"on"},trigger:{primary:"\u062A\u0634\u063A\u064A\u0644",alternatives:["\u0623\u0637\u0644\u0642","\u0641\u0639\u0651\u0644"],normalized:"trigger"},send:{primary:"\u0623\u0631\u0633\u0644",normalized:"send"},focus:{primary:"\u062A\u0631\u0643\u064A\u0632",alternatives:["\u0631\u0643\u0632"],normalized:"focus"},blur:{primary:"\u0636\u0628\u0627\u0628\u064A\u0629",alternatives:["\u0634\u0648\u0634"],normalized:"blur"},go:{primary:"\u0627\u0630\u0647\u0628",normalized:"go"},wait:{primary:"\u0627\u0646\u062A\u0638\u0631",normalized:"wait"},fetch:{primary:"\u0627\u062D\u0636\u0631",alternatives:["\u062C\u0644\u0628"],normalized:"fetch"},settle:{primary:"\u0627\u0633\u062A\u0642\u0631",normalized:"settle"},if:{primary:"\u0625\u0630\u0627",normalized:"if"},when:{primary:"\u0639\u0646\u062F\u0645\u0627",normalized:"when"},where:{primary:"\u0623\u064A\u0646",normalized:"where"},else:{primary:"\u0648\u0625\u0644\u0627",alternatives:["\u062E\u0644\u0627\u0641 \u0630\u0644\u0643"],normalized:"else"},repeat:{primary:"\u0643\u0631\u0631",normalized:"repeat"},for:{primary:"\u0644\u0643\u0644",normalized:"for"},while:{primary:"\u0628\u064A\u0646\u0645\u0627",normalized:"while"},continue:{primary:"\u0648\u0627\u0635\u0644",normalized:"continue"},halt:{primary:"\u0623\u0648\u0642\u0641",normalized:"halt"},throw:{primary:"\u0627\u0631\u0645",alternatives:["\u0627\u0631\u0645\u0650"],normalized:"throw"},call:{primary:"\u0627\u0633\u062A\u062F\u0639",alternatives:["\u0646\u0627\u062F\u0650"],normalized:"call"},return:{primary:"\u0627\u0631\u062C\u0639",alternatives:["\u0639\u064F\u062F"],normalized:"return"},then:{primary:"\u062B\u0645",alternatives:["\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"],normalized:"then"},and:{primary:"\u0648\u0623\u064A\u0636\u0627\u064B",alternatives:["\u0623\u064A\u0636\u0627\u064B"],normalized:"and"},end:{primary:"\u0646\u0647\u0627\u064A\u0629",alternatives:["\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"],normalized:"end"},js:{primary:"\u062C\u0627\u0641\u0627\u0633\u0643\u0631\u0628\u062A",alternatives:["js"],normalized:"js"},async:{primary:"\u0645\u062A\u0632\u0627\u0645\u0646",normalized:"async"},tell:{primary:"\u0623\u062E\u0628\u0631",normalized:"tell"},default:{primary:"\u0627\u0641\u062A\u0631\u0627\u0636\u064A",normalized:"default"},init:{primary:"\u062A\u0647\u064A\u0626\u0629",alternatives:["\u0628\u062F\u0621"],normalized:"init"},behavior:{primary:"\u0633\u0644\u0648\u0643",normalized:"behavior"},install:{primary:"\u062A\u062B\u0628\u064A\u062A",alternatives:["\u062B\u0628\u0651\u062A"],normalized:"install"},measure:{primary:"\u0642\u064A\u0627\u0633",alternatives:["\u0642\u0650\u0633"],normalized:"measure"},beep:{primary:"\u0635\u0641\u0651\u0631",normalized:"beep"},break:{primary:"\u062A\u0648\u0642\u0641",normalized:"break"},copy:{primary:"\u0627\u0646\u0633\u062E",normalized:"copy"},exit:{primary:"\u0627\u062E\u0631\u062C",normalized:"exit"},pick:{primary:"\u0627\u062E\u062A\u0631",normalized:"pick"},render:{primary:"\u0627\u0631\u0633\u0645",normalized:"render"},into:{primary:"\u0641\u064A",alternatives:["\u0625\u0644\u0649"],normalized:"into"},before:{primary:"\u0642\u0628\u0644",normalized:"before"},after:{primary:"\u0628\u0639\u062F",normalized:"after"},until:{primary:"\u062D\u062A\u0649",normalized:"until"},event:{primary:"\u062D\u062F\u062B",normalized:"event"},from:{primary:"\u0645\u0646",normalized:"from"}},tokenization:{prefixes:["\u0627\u0644","\u0648","\u0641","\u0628","\u0643","\u0644"]},eventHandler:{eventMarker:{primary:"\u0639\u0646\u062F",alternatives:["\u0641\u064A","\u0644\u062F\u0649","\u0639\u0646\u062F\u0645\u0627","\u062D\u064A\u0646","\u062D\u064A\u0646\u0645\u0627","\u0644\u0645\u0651\u0627","\u0644\u0645\u0627"],position:"before"},temporalMarkers:["\u0639\u0646\u062F\u0645\u0627","\u062D\u064A\u0646","\u0644\u0645\u0651\u0627"],negationMarker:{primary:"\u0639\u062F\u0645",alternatives:["\u0639\u062F\u0645"],position:"before"}}},Jt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Qt=class{constructor(n=Jt){this.name="operator",this.operators=[...n].sort((e,t)=>t.length-e.length);}canExtract(n,e){return this.operators.some(t=>n.startsWith(t,e))}extract(n,e){for(let t of this.operators)if(n.startsWith(t,e))return {value:t,length:t.length};return null}},Zt="()[]{},:;",er=class{constructor(n=Zt){this.punctuation=n,this.name="punctuation";}canExtract(n,e){return this.punctuation.includes(n[e])}extract(n,e){let t=n[e];return this.punctuation.includes(t)?{value:t,length:1}:null}};function tr(n,e){let t=n[e];if(t==="#"){let r=n.slice(e).match(/^#[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="."){let r=n.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="["){let r=0,o=e;for(;o<n.length;){if(n[o]==="["&&r++,n[o]==="]"&&(r--,r===0))return n.slice(e,o+1);o++;}return null}if(t==="<"){let r=n.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return r?r[0]:null}return null}var rr=class{constructor(){this.name="css-selector";}canExtract(n,e){let t=n[e];return t==="#"||t==="."||t==="["||t==="<"}extract(n,e){let t=tr(n,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},nr=class{constructor(){this.name="event-modifier";}canExtract(n,e){if(n[e]!==".")return false;let t=n.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(t)}extract(n,e){let t=n.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!t)return null;let r=t[0],o=r.slice(1).split("(")[0],i=t[1];return {value:r,length:r.length,metadata:{modifierName:o,value:i?o==="queue"?i:parseInt(i,10):void 0}}}};function or(n,e){let t=n.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let r=t.match(/^https?:\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("//")){let r=t.match(/^\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("./")||t.startsWith("../")){let r=t.match(/^\.\.?\/[^\s]*/);return r?r[0]:null}if(t.startsWith("/")){let r=t.match(/^\/[^\s]*/);return r?r[0]:null}return null}var ir=class{constructor(){this.name="url";}canExtract(n,e){let t=n.slice(e);return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")}extract(n,e){let t=or(n,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},sr=class{constructor(){this.name="variable-ref";}canExtract(n,e){return n[e]===":"&&e+1<n.length&&/[a-zA-Z_]/.test(n[e+1])}extract(n,e){if(!this.canExtract(n,e))return null;let t=1;for(;e+t<n.length&&/[a-zA-Z0-9_]/.test(n[e+t]);)t++;return {value:n.substring(e,e+t),length:t,metadata:{type:"variable-reference"}}}},ze=ie([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),ar=new Set(["\u0641\u064A","\u0639\u0644\u0649","\u0645\u0646","\u0625\u0644\u0649","\u0627\u0644\u0649","\u0645\u0639","\u0639\u0646","\u0642\u0628\u0644","\u0628\u0639\u062F","\u0628\u064A\u0646"]),lr=class{constructor(){this.name="arabic-keyword";}setContext(n){this.context=n;}canExtract(n,e){return ze(n[e])}extract(n,e){if(!this.context)throw new Error("ArabicKeywordExtractor: context not set");let t=e;this.context.isKeywordStart(n,e);let r="",o=e;for(;o<n.length&&(ze(n[o])||n[o]==="\u0640");)r+=n[o],o++;if(!r)return null;let i=this.context.lookupKeyword(r),s=i&&i.normalized!==i.native?i.normalized:void 0;if(ar.has(r))return {value:r,length:o-t,metadata:{prepositionValue:r,normalized:s}};let a,l,c;if(!i&&this.context.normalizer){let u=this.context.normalizer.normalize(r);if(u.stem!==r&&u.confidence>=.7){let d=this.context.lookupKeyword(u.stem);d&&(a=d.normalized,l=u.stem,c=u.confidence);}}return {value:r,length:o-t,metadata:{normalized:s||a,stem:l,stemConfidence:c}}}},Y=ie([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),X=new Map([["\u0648",{normalized:"and",type:"conjunction"}],["\u0641",{normalized:"then",type:"conjunction"}],["\u0628",{normalized:"with",type:"preposition"}],["\u0644",{normalized:"to",type:"preposition"}],["\u0643",{normalized:"like",type:"preposition"}],["\u0648\u0644",{normalized:"and-to",type:"conjunction"}],["\u0648\u0628",{normalized:"and-with",type:"conjunction"}],["\u0648\u0643",{normalized:"and-like",type:"conjunction"}],["\u0641\u0644",{normalized:"then-to",type:"conjunction"}],["\u0641\u0628",{normalized:"then-with",type:"conjunction"}],["\u0641\u0643",{normalized:"then-like",type:"conjunction"}]]),ur=class{constructor(){this.name="arabic-proclitic";}setContext(n){this.context=n;}canExtract(n,e){let t=n[e];return X.has(t)||e+1<n.length&&X.has(n.slice(e,e+2))}extract(n,e){if(!this.context)throw new Error("ArabicProcliticExtractor: context not set");let t=e;for(;t<n.length&&(Y(n[t])||n[t]==="\u0640");)t++;let r=n.slice(e,t);if(this.context.isKeyword(r))return null;if(e+2<=n.length){let c=n.slice(e,e+2),u=X.get(c);if(u){let d=e+2;if(d<n.length&&Y(n[d])){let p=0,f=d;for(;f<n.length&&Y(n[f]);)p++,f++;if(p>=2)if(X.get(n[e])){let y=n.slice(e+1,t);if(!this.context.isKeyword(y))return {value:c,length:2,metadata:{procliticType:u.type,normalized:u.normalized}}}else return {value:c,length:2,metadata:{procliticType:u.type,normalized:u.normalized}}}}}let o=n[e],i=X.get(o);if(!i)return null;let s=e+1;if(s>=n.length||!Y(n[s]))return null;let a=0,l=s;for(;l<n.length&&Y(n[l]);)a++,l++;return a<2?null:{value:o,length:1,metadata:{procliticType:i.type,normalized:i.normalized}}}},cr=ie([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),Ve=new Map([["\u0639\u0646\u062F\u0645\u0627",{normalized:"on",formality:"formal",confidence:.95,description:"when (formal MSA)"}],["\u062D\u064A\u0646\u0645\u0627",{normalized:"on",formality:"formal",confidence:.93,description:"when/whenever (formal)"}],["\u0639\u0646\u062F",{normalized:"on",formality:"neutral",confidence:.88,description:"at/when (neutral)"}],["\u062D\u064A\u0646",{normalized:"on",formality:"neutral",confidence:.85,description:"when/time (neutral)"}],["\u0644\u0645\u0651\u0627",{normalized:"on",formality:"dialectal",confidence:.7,description:"when (dialectal, with shadda)"}],["\u0644\u0645\u0627",{normalized:"on",formality:"dialectal",confidence:.68,description:"when (dialectal, no diacritic)"}],["\u0644\u062F\u0649",{normalized:"on",formality:"neutral",confidence:.82,description:"at/with (temporal)"}]]),dr=class{constructor(){this.name="arabic-temporal";}setContext(n){this._context=n,this._context;}canExtract(n,e){for(let[t]of Ve)if(n.startsWith(t,e))return true;return false}extract(n,e){let t=Array.from(Ve.entries()).sort(([r],[o])=>o.length-r.length);for(let[r,o]of t)if(n.startsWith(r,e)){let i=e+r.length;if(i>=n.length||/\s/.test(n[i])||!cr(n[i]))return {value:r,length:r.length,metadata:{temporalFormality:o.formality,temporalConfidence:o.confidence,normalized:o.normalized,description:o.description}}}return null}};function pr(n){let e=n.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function fr(n){let e=n.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var hr=class{constructor(){this.name="ascii-identifier";}setContext(n){this.context=n;}canExtract(n,e){return pr(n[e])}extract(n,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let t=e,r="",o=e;for(;o<n.length&&fr(n[o]);)r+=n[o],o++;if(!r)return null;let i=this.context.lookupKeyword(r),s=i&&i.normalized!==i.native?i.normalized:void 0;return {value:r,length:o-t,metadata:{normalized:s}}}};function mr(){return [new ir,new nr,new sr,new rr]}var yr=new Set(["\u0648\u0644","\u0648\u0628","\u0648\u0643","\u0641\u0644","\u0641\u0628","\u0641\u0643"]),vr=new Set(["\u0641\u064A","\u0639\u0644\u0649","\u0645\u0646","\u0625\u0644\u0649","\u0627\u0644\u0649","\u0645\u0639","\u0639\u0646","\u0642\u0628\u0644","\u0628\u0639\u062F","\u0628\u064A\u0646","\u0628","\u0644","\u0643"]),gr=[{native:"\u0635\u062D\u064A\u062D",normalized:"true"},{native:"\u062E\u0637\u0623",normalized:"false"},{native:"null",normalized:"null"},{native:"\u0641\u0627\u0631\u063A",normalized:"null"},{native:"\u063A\u064A\u0631 \u0645\u0639\u0631\u0641",normalized:"undefined"},{native:"\u0627\u0644\u0623\u0648\u0644",normalized:"first"},{native:"\u0623\u0648\u0644",normalized:"first"},{native:"\u0627\u0644\u0623\u062E\u064A\u0631",normalized:"last"},{native:"\u0622\u062E\u0631",normalized:"last"},{native:"\u0627\u0644\u062A\u0627\u0644\u064A",normalized:"next"},{native:"\u0627\u0644\u0633\u0627\u0628\u0642",normalized:"previous"},{native:"\u0627\u0644\u0623\u0642\u0631\u0628",normalized:"closest"},{native:"\u0627\u0644\u0623\u0628",normalized:"parent"},{native:"\u0627\u0644\u0646\u0642\u0631",normalized:"click"},{native:"\u0646\u0642\u0631",normalized:"click"},{native:"\u0627\u0644\u0625\u062F\u062E\u0627\u0644",normalized:"input"},{native:"\u0625\u062F\u062E\u0627\u0644",normalized:"input"},{native:"\u0627\u0644\u062A\u063A\u064A\u064A\u0631",normalized:"change"},{native:"\u062A\u063A\u064A\u064A\u0631",normalized:"change"},{native:"\u0627\u0644\u0625\u0631\u0633\u0627\u0644",normalized:"submit"},{native:"\u0625\u0631\u0633\u0627\u0644",normalized:"submit"},{native:"\u0627\u0644\u062A\u0631\u0643\u064A\u0632",normalized:"focus"},{native:"\u0641\u0642\u062F\u0627\u0646 \u0627\u0644\u062A\u0631\u0643\u064A\u0632",normalized:"blur"},{native:"\u0636\u063A\u0637",normalized:"keydown"},{native:"\u0631\u0641\u0639",normalized:"keyup"},{native:"\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0641\u0623\u0631\u0629",normalized:"mouseover"},{native:"\u0645\u063A\u0627\u062F\u0631\u0629 \u0627\u0644\u0641\u0623\u0631\u0629",normalized:"mouseout"},{native:"\u062A\u062D\u0645\u064A\u0644",normalized:"load"},{native:"\u062A\u0645\u0631\u064A\u0631",normalized:"scroll"},{native:"\u0647\u064A",normalized:"it"},{native:"\u062B\u0627\u0646\u064A\u0629",normalized:"s"},{native:"\u062B\u0648\u0627\u0646\u064A",normalized:"s"},{native:"\u0645\u0644\u064A \u062B\u0627\u0646\u064A\u0629",normalized:"ms"},{native:"\u062F\u0642\u064A\u0642\u0629",normalized:"m"},{native:"\u062F\u0642\u0627\u0626\u0642",normalized:"m"},{native:"\u0633\u0627\u0639\u0629",normalized:"h"},{native:"\u0633\u0627\u0639\u0627\u062A",normalized:"h"},{native:"\u0639\u0646\u062F\u0645\u0627",normalized:"on"},{native:"\u062D\u064A\u0646\u0645\u0627",normalized:"on"},{native:"\u0639\u0646\u062F",normalized:"on"},{native:"\u062D\u064A\u0646",normalized:"on"},{native:"\u0644\u0645\u0651\u0627",normalized:"on"},{native:"\u0644\u0645\u0627",normalized:"on"},{native:"\u0644\u062F\u0649",normalized:"on"}],br=class extends De{constructor(){super(),this.language="ar",this.direction="rtl",this.initializeKeywordsFromProfile(Fe,gr),this.normalizer=new qe,this.registerExtractors(mr()),this.registerExtractor(new Oe),this.registerExtractor(new Ne),this.registerExtractor(new hr),this.registerExtractor(new dr),this.registerExtractor(new ur),this.registerExtractor(new lr),this.registerExtractor(new Qt),this.registerExtractor(new er);}tokenizeWithExtractors(n){let e=[],t=0;for(;t<n.length;){for(;t<n.length&&I(n[t]);)t++;if(t>=n.length)break;let r=false;for(let o of this.extractors)if(o.canExtract(n,t)){let i=o.extract(n,t);if(i){let s=i.metadata?.normalized,a=i.metadata?.stem,l=i.metadata?.stemConfidence,c={};if(i.metadata)for(let[p,f]of Object.entries(i.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(c[p]=f);let u;c.procliticType==="conjunction"?u="conjunction":c.procliticType==="preposition"?u="particle":u=this.classifyToken(i.value);let d={};s&&(d.normalized=s),a&&(d.stem=a),l!==void 0&&(d.stemConfidence=l),Object.keys(c).length>0&&(d.metadata=c),e.push(S(i.value,u,w(t,t+i.length),Object.keys(d).length>0?d:void 0)),t+=i.length,r=true;break}}if(!r){let o=n[t],i=this.classifyUnknownChar(o);e.push(S(o,i,w(t,t+1))),t++;}}return new M(e,this.language)}classifyToken(n){return yr.has(n)?"conjunction":vr.has(n)?"particle":this.isKeyword(n)?"keyword":n.startsWith("/")||n.startsWith("./")||n.startsWith("../")||n.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(n)?"event-modifier":n.startsWith("#")||n.startsWith(".")||n.startsWith("[")||n.startsWith("*")||n.startsWith("<")?"selector":n.startsWith('"')||n.startsWith("'")||/^\d/.test(n)?"literal":"identifier"}},Er=new br;Wt("ar",Er,Fe);var wr=Object.defineProperty,Sr=Object.getOwnPropertyNames,Je=(n,e)=>function(){return n&&(e=(0, n[Sr(n)[0]])(n=0)),e},Tr=(n,e)=>{for(var t in e)wr(n,t,{get:e[t],enumerable:true});};function We(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`))}function x(n,e,t={},r){let o=Qe[n],i=We(o,t),s=Ze[n],a=s?We(s,t):void 0;return {code:n,message:i,severity:e,...r&&{role:r},...a&&{suggestion:a}}}var m,Qe,Ze,kr=Je({"src/generators/schema-error-codes.ts"(){m={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Qe={[m.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[m.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[m.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[m.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[m.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[m.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.",[m.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.",[m.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[m.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[m.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[m.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[m.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[m.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[m.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[m.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[m.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[m.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Ze={[m.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[m.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[m.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[m.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[m.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[m.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[m.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[m.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[m.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[m.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[m.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[m.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[m.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[m.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),et={};Tr(et,{SchemaErrorCodes:()=>m,formatValidationResults:()=>Nr,getValidationStats:()=>_r,validateAllKeywordCollisions:()=>Mr,validateAllSchemas:()=>Or,validateCommandSchema:()=>tt,validateKeywordCollisions:()=>rt,validateRoleValues:()=>Ir});function Ar(n,e){return {action:n,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function tt(n){let e=[];for(let r of n.roles)r.expectedTypes.includes("literal")&&r.expectedTypes.includes("selector")&&(r.role==="patient"&&ve.has(n.action)?e.push(x(m.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:r.role,command:n.action},r.role)):e.push(x(m.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:r.role},r.role))),r.expectedTypes.length>3&&!ve.has(n.action)&&e.push(x(m.TOO_MANY_EXPECTED_TYPES,"warning",{role:r.role,count:r.expectedTypes.length},r.role));for(let r of n.roles)r.selectorKinds&&r.selectorKinds.length>0&&(r.expectedTypes.includes("selector")||e.push(x(m.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:r.role},r.role)));switch(n.action){case "transition":xr(n,e);break;case "on":Cr(n,e);break;case "if":case "unless":Pr(n,e);break;case "repeat":case "for":case "while":Rr(n,e);break}return n.roles.filter(r=>r.required).length===0&&(nt.has(n.action)?e.push(x(m.NO_REQUIRED_ROLES_EXPECTED,"note",{command:n.action})):e.push(x(m.NO_REQUIRED_ROLES,"warning",{}))),Ar(n.action,e)}function xr(n,e){let t=n.roles.find(o=>o.role==="patient"),r=n.roles.find(o=>o.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(x(m.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!r&&e.push(x(m.TRANSITION_MISSING_GOAL,"error",{}));}function Cr(n,e){let t=n.roles.find(r=>r.role==="event");t||e.push(x(m.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(x(m.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Pr(n,e){let t=n.roles.find(r=>r.role==="condition");t||e.push(x(m.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(x(m.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Rr(n,e){n.action==="for"?n.roles.find(r=>r.role==="source")||e.push(x(m.FOR_LOOP_MISSING_SOURCE,"warning",{})):n.action==="while"&&(n.roles.find(r=>r.role==="condition")||e.push(x(m.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Or(n,e={}){let t=new Map,{includeNotes:r=false}=e;for(let[o,i]of Object.entries(n)){let s=tt(i),a=s.items.some(c=>c.severity==="warning"||c.severity==="error"),l=r&&s.items.some(c=>c.severity==="note");(a||l)&&t.set(o,s);}return t}function Nr(n,e={}){let t=[],{showNotes:r=false,showCodes:o=true}=e;for(let[i,s]of n){let a=s.items.filter(u=>u.severity==="error"),l=s.items.filter(u=>u.severity==="warning"),c=s.items.filter(u=>u.severity==="note");if(a.length>0){t.push(` \u274C ${i}:`);for(let u of a){let d=o?` [${u.code}]`:"";t.push(` ERROR${d}: ${u.message}`),u.suggestion&&t.push(` \u{1F4A1} Suggestion: ${u.suggestion}`);}}if(l.length>0){t.push(` \u26A0\uFE0F ${i}:`);for(let u of l){let d=o?` [${u.code}]`:"";t.push(` ${d?`${u.code}: `:""}${u.message}`),u.suggestion&&t.push(` \u{1F4A1} ${u.suggestion}`);}}if(r&&c.length>0){t.push(` \u2139\uFE0F ${i}:`);for(let u of c){let d=o?` [${u.code}]`:"";t.push(` ${d?`${u.code}: `:""}${u.message}`);}}}return t.join(`
2
- `)}function _r(n){let e=0,t=0,r=0,o={};for(let i of n.values())for(let s of i.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&r++,o[s.code]=(o[s.code]||0)+1;return {totalCommands:n.size,errors:e,warnings:t,notes:r,byCode:o}}function Ir(n,e){let t=[];for(let r of e){let o=n.roles.find(i=>i.role===r.role);o&&(o.expectedTypes.length>0&&!o.expectedTypes.includes(r.type)&&(o.expectedTypes.includes("expression")||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects type [${o.expectedTypes.join(", ")}], got '${r.type}'`,code:m.VALUE_TYPE_MISMATCH})),r.type==="selector"&&r.selectorKind&&o.selectorKinds&&o.selectorKinds.length>0&&(o.selectorKinds.includes(r.selectorKind)||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects selector kind [${o.selectorKinds.join(", ")}], got '${r.selectorKind}'`,code:m.SELECTOR_KIND_MISMATCH})));}return t}function rt(n){let e=[];if(!n.keywords)return {language:n.code,collisions:e};let t=new Map;for(let[o,i]of Object.entries(n.keywords)){if(!i||!i.primary)continue;let s=t.get(i.primary)||[];if(s.push({command:o,isPrimary:true}),t.set(i.primary,s),i.alternatives)for(let a of i.alternatives){let l=t.get(a)||[];l.push({command:o,isPrimary:false}),t.set(a,l);}}for(let[o,i]of t){let s=[...new Set(i.map(c=>c.command))];if(s.length<=1)continue;let a=i.filter(c=>c.isPrimary).length,l;a>=2?l="primary-primary":a===1?l="primary-alternative":l="alternative-alternative",e.push({keyword:o,commands:s.sort(),type:l});}let r={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((o,i)=>r[o.type]-r[i.type]),{language:n.code,collisions:e}}function Mr(n){let e=[];for(let[,t]of Object.entries(n)){let r=rt(t);r.collisions.length>0&&e.push(r);}return e.sort((t,r)=>t.language.localeCompare(r.language))}var ve,nt,Lr=Je({"src/generators/schema-validator.ts"(){kr(),ve=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),nt=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function Q(n){let e="complex";return n.startsWith("#")&&!n.includes(" ")?e="id":n.startsWith(".")&&!n.includes(" ")?e="class":n.startsWith("[")&&n.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(n)&&(e="element"),{type:"selector",value:n,selectorKind:e}}function T(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function je(n){return _e(n)}function L(n){return {type:"reference",value:n}}function me(n,e){return {type:"property-path",object:n,property:e}}function se(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function Ue(n,e,t,r,o,i){let s=new Map;s.set("event",n);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),a}function Ge(n,e="then",t){let r={kind:"compound",action:"compound",roles:new Map,statements:n,chainType:e};return t!==void 0&&(r.metadata=t),r}function Ke(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Dr(n,e){return n.possessive?.keywords?.[e]}var F=new Map,W=new Map,ae=new Map,ge=null;function ot(n,e){let t={...n};for(let r of Object.keys(e)){let o=e[r],i=n[r];o!==void 0&&(typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?t[r]=ot(i,o):t[r]=o);}return t}function $r(n,e){return ot(n,e)}function Ee(n){if(!n.extends)return n;let e=W.get(n.extends);if(!e)return console.warn(`[Registry] Profile '${n.code}' extends '${n.extends}' but base is not registered. Make sure to import the base language before the variant.`),n;let t=Ee(e);return $r(t,n)}function it(n){ge=n;}var He=new Map;function j(n){return n.split("-")[0]}function U(n){return n.includes("-")}function Br(n){let e=F.get(n);if(!e&&U(n)){let t=j(n);e=F.get(t);}if(!e){let t=Array.from(F.keys()).join(", ");throw new Error(`Language '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return e}function zr(n){let e=W.get(n);if(!e&&U(n)){let t=j(n);e=W.get(t);}if(!e){let t=Array.from(W.keys()).join(", ");throw new Error(`Language profile '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return Ee(e)}function Vr(n){let e=F.get(n);return !e&&U(n)&&(e=F.get(j(n))),e}function D(n){let e=W.get(n);return !e&&U(n)&&(e=W.get(j(n))),e?Ee(e):void 0}function st(){return Array.from(F.keys())}function qr(n,e){return Br(e).tokenize(n)}function q(n){let e=ae.get(n);if(!e&&U(n)&&(e=ae.get(j(n))),e)return e;let t=He.get(n);if(!t&&U(n)&&(t=He.get(j(n))),t)return ae.set(n,t),t;if(!ge)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=zr(n),o=ge(r);return ae.set(n,o),o}var le=class J{constructor(){this.stemMatchCount=0,this.totalKeywordMatches=0;}matchPattern(e,t){let r=e.mark(),o=new Map;if(this.currentProfile=D(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,o))return e.reset(r),null;let s=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-r.position,confidence:s}}matchBest(e,t){let r=[];for(let i of t){let s=e.mark(),a=this.matchPattern(e,i);a&&r.push(a),e.reset(s);}if(r.length===0)return null;r.sort((i,s)=>{let a=s.pattern.priority-i.pattern.priority;return a!==0?a:s.confidence-i.confidence});let o=r[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r){let o=t[0],i=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!i)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,r)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(!r)return false;let o=this.getMatchType(r,t.value);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(r,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.skipNoiseWords(e);let o=e.peek();if(!o)return t.optional||false;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(i.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,i),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Ke(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,l),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Ke(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);let u=this.tokenToSemanticValue(o);return !u||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(u.type)?t.optional||false:(r.set(t.role,u),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),o=Dr(this.currentProfile,r);if(!o)return null;let i=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(i),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let l=a;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()),me(L(o),l)}return e.reset(i),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<J.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<J.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<J.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(u===0){e.advance();break}u--;}if(p.kind==="punctuation"&&p.value==="("&&u++,p.kind==="punctuation"&&p.value===","){e.advance();continue}c.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return !i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),me(Q(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let s=o.value.slice(1);return me(Q(t.value),s)}matchGroupToken(e,t,r){let o=e.mark(),i=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(o);for(let a of r.keys())i.has(a)||r.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return Q(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return je(t)?L(t):T(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return L(e.value);let r=e.value.toLowerCase();return je(r)?L(r):{type:"expression",raw:e.value};case "url":return T(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let o=e.slice(1,-1);return T(o,"string")}if(e==="true")return T(true,"boolean");if(e==="false")return T(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?T(e,"duration"):T(o,"number")}let r=parseFloat(e);return isNaN(r)?T(e,"string"):T(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))t.has(r)||(o.value!==void 0?t.set(r,{type:"literal",value:o.value}):o.default&&t.set(r,o.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,o=0,i=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")o+=1,t.has(c.role)&&(r+=1);else if(c.type==="group"){for(let u of c.tokens)if(u.type==="role"){let d=i(u.role),p=.8;o+=p,t.has(u.role)?r+=p:d&&(r+=p*.6);}}let s=o>0?r/o:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let o of t.alternatives)if(r.has(o))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,o={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[i,s]of t.entries()){let a=o[i];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(J.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&(i.kind==="selector"||i.kind==="identifier"))return;e.reset(o);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=true,i.modifierName){case "once":t.once=true;break;case "debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case "throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case "queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance();}return r?t:void 0}};le.MAX_PROPERTY_DEPTH=10;le.MAX_METHOD_ARGS=20;le.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var at=le,V=new at;function Wr(n){return Vr(n)}function ye(n,e){return qr(n,e)}function lt(){return st()}var jr={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var Gr={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","INVALID_CSS_PROPERTY"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"toggle command requires an argument"},{condition:"Class names are valid CSS identifiers",errorCode:"NO_VALID_CLASS_NAMES",message:"toggle command: no valid class names found"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to toggle",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",INVALID_CSS_PROPERTY:"Check CSS property name syntax (use kebab-case)"}},Kr={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},Hr={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},Yr={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"}}],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"}},Xr={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},Jr={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Qr={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},Zr={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},en={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},tn={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},rn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},nn={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},on={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},sn={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},an={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},ln={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},un={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},cn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},dn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},pn={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},fn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},hn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},mn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to",ja:"\u306B",ar:"\u0625\u0644\u0649",es:"a",ko:"\uC5D0\uAC8C",zh:"\u5230",tr:"-e",pt:"para",fr:"\xE0",de:"an",id:"ke",qu:"-man",sw:"kwa"}}]},yn={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},vn={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},gn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},bn={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},En={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:2},{role:"source",description:"The collection to iterate over",required:true,expectedTypes:["selector","reference","expression"],svoPosition:2,sovPosition:1,markerOverride:{en:"in"}}]},wn={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Sn={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Tn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},kn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},An={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},xn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Cn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Pn={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},Rn={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},On={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Nn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},_n={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},In={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},Mn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Ln={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Dn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},$n={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Bn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},zn={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},Vn={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}]},qn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Fn={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}]},Wn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},jn={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},Un={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ut={toggle:Gr,add:Kr,remove:Hr,put:Yr,set:Xr,show:Jr,hide:Qr,on:Zr,trigger:en,wait:tn,fetch:rn,increment:nn,decrement:on,append:sn,prepend:an,log:ln,get:un,take:cn,make:dn,halt:pn,settle:fn,throw:hn,send:mn,if:yn,unless:vn,else:gn,repeat:bn,for:En,while:wn,continue:Sn,go:Tn,transition:kn,clone:An,focus:xn,blur:Cn,call:Pn,return:Rn,js:On,async:Nn,tell:_n,default:In,init:Mn,behavior:Ln,install:Dn,measure:$n,swap:Bn,morph:zn,beep:Vn,break:qn,copy:Fn,exit:Wn,pick:jn,render:Un,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Gn(){return Object.values(ut).filter(n=>n.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Lr(),et)).then(({validateAllSchemas:n,formatValidationResults:e})=>{let t=n(ut);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(n=>{console.debug("Schema validation skipped:",n);});var G=class R{parse(e,t){let{modifiers:r,remainingInput:o}=this.extractStandaloneModifiers(e,t),i=o||e,s=ye(i,t),a=q(t);if(a.length===0)throw new Error(`No patterns available for language: ${t}`);let l=[...a].sort((y,v)=>v.priority-y.priority),c=l.filter(y=>y.command==="on"),u=V.matchBest(s,c);if(u){let y=this.buildEventHandler(u,s,t);return r?this.applyModifiers(y,r):y}let d=l.filter(y=>y.command!=="on"),p=V.matchBest(s,d);if(p)return this.buildCommand(p,t);let f=this.trySOVEventExtraction(i,t,l);if(f)return r?this.applyModifiers(f,r):f;let h=this.tryCompoundCommandParsing(s,d,t);if(h)return h;throw new Error(`Could not parse input in ${t}: ${i}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return lt()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[o,i]of e.captured)r[o]=i;return se(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let o=e.captured.get("event");if(!o)throw new Error("Event handler pattern matched but no event captured");let i=V.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,r),a=o;s.length>0&&o.type==="literal"&&(a={type:"literal",value:[String(o.value),...s.map(d=>String("value"in d?d.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"){let u=c.value,d={};for(let[h,y]of e.captured)h!=="event"&&h!=="action"&&h!=="continues"&&(d[h]=y);let p=se(u,d,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let h=q(r).filter(g=>g.command!=="on").sort((g,E)=>E.priority-g.priority),y=q(r).filter(g=>g.id.startsWith("grammar-")&&g.id.includes("-continuation")).sort((g,E)=>E.priority-g.priority),v=this.parseBodyWithGrammarPatterns(t,h,y,r);v.length>0?l=[p,...v]:l=[p];}else l=[p];}else {let u=q(r).filter(d=>d.command!=="on").sort((d,p)=>p.priority-d.priority);l=this.parseBodyWithClauses(t,u,r);}return Ue(a,l,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let o=[],i=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),l=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c),i.length=0;}e.advance();continue}if(l){if(i.length>0){let c=this.parseClause(i,t,r);o.push(...c);}e.advance();break}i.push(s),e.advance();}if(i.length>0){let s=this.parseClause(i,t,r);o.push(...s);}return o.length>1?[Ge(o,"then",{sourceLanguage:r})]:o}parseClause(e,t,r){if(e.length===0)return [];let o=new M(e,r),i=[];for(;!o.isAtEnd();){let s=V.matchBest(o,t);s?i.push(this.buildCommand(s,r)):o.advance();}if(i.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,r);if(s.length>0)return s}return i}static buildVerbLookup(e){let t=new Map;for(let[r,o]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(r)&&(t.set(o.primary.toLowerCase(),r),o.alternatives))for(let i of o.alternatives)t.set(i.toLowerCase(),r);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[r,o]of Object.entries(e.roleMarkers))if(o&&(t.set(o.primary,r),o.alternatives))for(let i of o.alternatives)t.has(i)||t.set(i,r);return t}parseSOVClauseByVerbAnchoring(e,t){let r=D(t);if(!r||r.wordOrder!=="SOV")return [];let o=R.buildVerbLookup(r),i=R.buildMarkerToRoleLookup(r),s=[],a=0;for(;a<e.length;){let l=-1,c="";for(let h=a;h<e.length;h++){let y=e[h],v=o.get(y.value.toLowerCase()),g=y.normalized?o.get(y.normalized.toLowerCase()):void 0,E=v||g;if(E){l=h,c=E;break}}if(l===-1)break;let u=e.slice(a,l),d=e.length;for(let h=l+1;h<e.length;h++){let y=e[h];if(y.kind==="conjunction"||this.isThenKeyword(y.value,t)){d=h;break}if(h>l+1&&(o.get(y.value.toLowerCase())||(y.normalized?o.get(y.normalized.toLowerCase()):void 0))){d=h;break}}let p=e.slice(l+1,d),f=this.extractRolesFromMarkedTokens(u,p,i,c,t);if(s.push(se(c,f,{sourceLanguage:t,confidence:.7})),a=d,a<e.length){let h=e[a];(h.kind==="conjunction"||this.isThenKeyword(h.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,r,o,i){let s={},a=l=>{let c=[];for(let u of l){let d=r.get(u.value);if(d&&u.kind==="particle"&&c.length>0){let p=this.tokensToSemanticValue(c);if(p){let f=this.mapRoleForCommand(d,o,s);f&&(s[f]=p);}c=[];}else c.push(u);}if(c.length>0){let u=this.tokensToSemanticValue(c);u&&(s.patient?s.destination||(s.destination=u):s.patient=u);}};return a(e),a(t),s}mapRoleForCommand(e,t,r){return r[e]?e==="patient"&&!r.destination?"destination":e==="destination"&&!r.patient?"patient":e==="source"&&!r.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(i=>i.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let r=t.map(i=>i.value).join(""),o=t[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Q(r):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?T(r):o.kind==="reference"?L(r):T(r)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return Q(t);if(t.startsWith('"')||t.startsWith("'"))return T(t);if(/^-?\d+(\.\d+)?$/.test(t))return T(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return T(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return T(false);let r=e.normalized?.toLowerCase();return r==="me"||r==="it"||r==="you"||r==="result"||r==="body"?L(r):e.kind==="reference"?L(e.normalized||"me"):T(t)}parseBodyWithGrammarPatterns(e,t,r,o){let i=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,o)){e.advance();continue}if(s&&this.isEndKeyword(s.value,o)){e.advance();break}let a=false;if(r.length>0){let l=V.matchBest(e,r);if(l){let c=l.pattern.command,u={};for(let[f,h]of l.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(u[f]=h);let d=se(c,u,{sourceLanguage:o,patternId:l.pattern.id});i.push(d),a=true;let p=l.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!a){let l=V.matchBest(e,t);l&&(i.push(this.buildCommand(l,o)),a=true);}a||e.advance();}return i}tryCompoundCommandParsing(e,t,r){let o=e.tokens;if(!o.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,r)))return null;let s=new M(o,r),a=this.parseBodyWithClauses(s,t,r);return a.length===0?null:a.length===1?a[0]:Ge(a,"then",{sourceLanguage:r,confidence:.65})}trySOVEventExtraction(e,t,r){let o=R.SOV_EVENT_MARKERS[t];if(!o)return null;let s=ye(e,t).tokens,a=jr[t],l=new Set;if(a)for(let b of Object.keys(a))l.add(b.toLowerCase());let c=R.SOV_SOURCE_MARKERS[t],u=-1,d="",p="",f=1;for(let b=0;b<s.length;b++){let k=s[b],O=k.value.toLowerCase(),N=O,$="",ce=O.indexOf("[");ce>0&&(N=O.slice(0,ce),$=k.value.slice(ce));let de=k.normalized?.toLowerCase(),Ce=de&&R.KNOWN_EVENTS.has(de),Pe=l.has(O)||l.has(N),St=R.KNOWN_EVENTS.has(N);if(Ce||Pe||St){let K;if(Ce?K=de:Pe?K=a?.[O]??a?.[N]??N:K=N,o.size>0){let re=1,pe=s[b+1];pe&&pe.kind==="selector"&&pe.value.startsWith("[")&&(re=2);let ne=s[b+re];if(ne&&(ne.kind==="particle"||ne.kind==="keyword")&&o.has(ne.value)){u=b,d=K,p=$||(re===2?s[b+1].value:""),f=re+1;break}}else {u=b,d=K,p=$,f=1;break}}}if(u===-1)return null;let h=new Set;for(let b=u;b<u+f;b++)h.add(b);if(c){let b=u+f;if(b<s.length){let k=s[b];(k.kind==="particle"||k.kind==="keyword")&&c.markers.has(k.value)&&h.add(b);}for(let k=0;k<u;k++){let O=s[k],N=O.value.toLowerCase(),$=O.normalized?.toLowerCase();if(c.windowTokens.has(N)||$&&c.windowTokens.has($)){h.add(k);break}}}let y=s.filter((b,k)=>!h.has(k));if(y.length===0)return null;let v=r.filter(b=>b.command!=="on"),g=new M(y,t),E=this.parseBodyWithClauses(g,v,t);if(E.length===0)return null;let xe={sourceLanguage:t,confidence:.75};return p&&(xe.keyFilter=p),Ue({type:"literal",value:d},E,void 0,xe)}isThenKeyword(e,t){let r={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (r[t]||r.en).has(e.toLowerCase())}isEndKeyword(e,t){let r={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (r[t]||r.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let o=ye(e,t).tokens;if(o.length===0)return {modifiers:null,remainingInput:null};let s=o[0].value.toLowerCase(),a=R.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let l={},c=1;if(a==="once")l.once=true;else {let f=1;if(f<o.length){let h=o[f];(h.kind==="keyword"||h.kind==="particle")&&(f++,c++);}if(f<o.length){let h=o[f];if(h.kind==="literal"){let y=h.value.match(/^(\d+)(ms|s|m)?$/);if(y){let v=parseInt(y[1],10),g=y[2]||"ms";g==="s"?v*=1e3:g==="m"&&(v*=6e4),l[a]=v,c=f+1;}}}l[a]||(l[a]=a==="debounce"?300:100);}let u=o.slice(c);if(u.length===0)return {modifiers:null,remainingInput:null};let d=u[0].position.start,p=e.slice(d);return {modifiers:l,remainingInput:p}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let r=[];for(;;){let o=e.mark(),i=e.peek();if(!i)break;let s=(i.normalized||i.value).toLowerCase();if(!R.OR_KEYWORDS.has(s)){e.reset(o);break}e.advance();let a=e.peek();if(!a){e.reset(o);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),r.push({type:"literal",value:l});}return r}};G.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);G.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"])};G.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"])}};G.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};G.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Kn=G,Hn=new Kn;function we(n,e){return Hn.parse(n,e)}var be=class{constructor(n={}){this.cache=new Map,this.config={maxSize:n.maxSize??1e3,ttlMs:n.ttlMs??0,enabled:n.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(n,e){return `${e}:${n}`}isExpired(n){return this.config.ttlMs===0?false:Date.now()-n.createdAt>this.config.ttlMs}evictLRU(){let n=this.cache.keys().next().value;n!==void 0&&(this.cache.delete(n),this.stats.evictions++);}get(n,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(n,e),r=this.cache.get(t);if(!r){this.stats.misses++;return}if(this.isExpired(r)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),r.lastAccessed=Date.now(),this.cache.set(t,r),this.stats.hits++,r.result}set(n,e,t){if(!this.config.enabled||t.confidence===0)return;let r=this.makeKey(n,e),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(r,{result:t,createdAt:o,lastAccessed:o});}has(n,e){if(!this.config.enabled)return false;let t=this.makeKey(n,e),r=this.cache.get(t);return r?this.isExpired(r)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(n,e){let t=this.makeKey(n,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let n=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:n>0?this.stats.hits/n:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(n){if(n.maxSize!==void 0)for(this.config.maxSize=n.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();n.ttlMs!==void 0&&(this.config.ttlMs=n.ttlMs),n.enabled!==void 0&&(this.config.enabled=n.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},Yn=new be;var Xn=class{constructor(n={}){this.patternMatcher=new at,this.languages=new Set(st()),n.cache===false?this.cache=new be({enabled:false}):this.cache=n.cache?new be(n.cache):Yn;}analyze(n,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(n,e);if(t)return t;let r=this.analyzeUncached(n,e);return this.cache.set(n,e,r),r}analyzeUncached(n,e){try{try{let s=we(n,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=Wr(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let r=t.tokenize(n),o=q(e);if(o.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let i=this.patternMatcher.matchBest(r,o);if(i){let s=this.buildSemanticNode(i);return {confidence:i.confidence,command:{name:i.pattern.command,roles:i.captured},node:s,tokensConsumed:i.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(n){return this.languages.has(n)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(n){this.cache.configure(n);}buildSemanticNode(n){return {kind:"command",action:n.pattern.command,roles:n.captured,metadata:{patternId:n.pattern.id}}}};function ct(n){return new Xn(n)}var Jn=.5;function dt(n,e=Jn){return n.confidence>=e&&n.command!==void 0}function pt(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...n].sort((r,o)=>{let i=r[t]??99,s=o[t]??99;return i-s})}function Qn(n,e){let t=n.markerOverride?.[e.code],r=e.roleMarkers[n.role];if(t!==void 0)return {primary:t,position:r?.position??"before",isOverride:true};if(r&&r.primary){let o={primary:r.primary,position:r.position,isOverride:false};return r.alternatives&&(o.alternatives=r.alternatives),o}return null}function Zn(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)i.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}}let s=e.roleMarkers.destination;s&&i.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};i.push(c);}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(l),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function eo(n,e,t,r,o){let i=[];i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(l);}if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let l=r.primary.split(/\s+/);if(l.length>1)for(let c of l)i.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(a),{id:`${n.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(o.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function to(n,e,t,r,o){let i=[];i.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};i.push(c);}let a=e.roleMarkers.destination;if(a&&(i.push({type:"role",role:"destination",optional:false}),i.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),i.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)i.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(l),{id:`${n.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(o.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function ro(n,e,t,r,o){let i=[];i.push({type:"role",role:"event",optional:false});let s=r.alternatives?.filter(u=>!u.includes(" ")&&u.length>1)||[];s.length>0&&i.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&i.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),i.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.patient;if(l){let u=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};i.push(u);}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(c),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(o.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function no(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let l of a)i.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(s),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function oo(n,e,t,r){let o=e.eventHandler?.temporalMarkers;if(!o||o.length===0)return null;let i=[];i.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&i.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),i.push({type:"literal",value:o[0],alternatives:o.slice(1)}),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(l);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(a),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${o[0]} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function io(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let d of u)i.push({type:"literal",value:d});else {let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(d);}}let a=[...n.roles.filter(u=>u.required)].sort((u,d)=>{let p=u.sovPosition??999,f=d.sovPosition??999;return p-f});for(let u of a){i.push({type:"role",role:u.role,optional:false});let d,p;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)d=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(l);let c=a.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`{event} ${r.primary} ${c} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(a.map(u=>[u.role,{fromRole:u.role}]))}}}function so(n,e,t,r,o){let i=[],a=[...n.roles.filter(h=>h.required)].sort((h,y)=>{let v=h.sovPosition??999,g=y.sovPosition??999;return v-g}),l=a[0];i.push({type:"role",role:l.role,optional:false});let c;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)c=l.markerOverride[e.code];else {let h=e.roleMarkers[l.role];h&&(c=h.primary);}if(c&&i.push({type:"literal",value:c}),i.push({type:"role",role:"event",optional:false}),r.position==="after"){let h=r.primary.split(/\s+/);if(h.length>1)for(let y of h)i.push({type:"literal",value:y});else {let y=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(y);}}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(u);let d=a[1];i.push({type:"role",role:d.role,optional:false});let p,f;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)p=d.markerOverride[e.code];else {let h=e.roleMarkers[d.role];h&&(p=h.primary,f=h.alternatives);}if(p){let h=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};i.push(h);}return {id:`${n.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`{${l.role}} {event} ${r.primary} ${t.primary} {${d.role}}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},[l.role]:{fromRole:l.role},[d.role]:{fromRole:d.role}}}}function Ye(n,e,t,r,o){let i=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}i.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&i.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`${r.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ao(n,e,t,r,o){let i=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&i.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}return i.push({type:"role",role:"event",optional:false}),{id:`${n.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(o.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${r.primary} {event}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function lo(n,e,t,r,o){let i=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s);let l=[...n.roles.filter(u=>u.required)].sort((u,d)=>{let p=u.svoPosition??999,f=d.svoPosition??999;return p-f});for(let u of l){let d,p;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)d=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}i.push({type:"role",role:u.role,optional:false});}if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}i.push({type:"role",role:"event",optional:false});let c=l.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`${t.primary} ${c} ${r.primary} {event}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(u=>[u.role,{fromRole:u.role}]))}}}function Xe(n,e,t,r,o){let i=[];if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}i.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s);let l=[...n.roles.filter(u=>u.required)].sort((u,d)=>{let p=u.svoPosition??999,f=d.svoPosition??999;return p-f});for(let u of l){let d,p;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)d=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}i.push({type:"role",role:u.role,optional:false});}let c=l.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${c}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(u=>[u.role,{fromRole:u.role}]))}}}function uo(n,e,t,r,o){let i=[],s=e.eventHandler?.negationMarker;if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c);}if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(c);}i.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(a),i.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.destination;return l&&i.push({type:"group",optional:true,tokens:[l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${l?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function co(n,e,t,r){let o=[];o.push({type:"literal",value:"and",alternatives:["then"]}),o.push({type:"role",role:"event",optional:false});let i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(i),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&o.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var Z={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function ft(n,e,t=Z){let r=`${n.action}-${e.code}-generated`,o=t.basePriority??100,i=e.keywords[n.action];if(!i)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let s=mo(n,e,i),a=mt(n,e),l=bo(n,e,i);return {id:r,language:e.code,command:n.action,priority:o,template:{format:l,tokens:s},extraction:a}}function po(n,e,t=Z){if(n.roles.filter(a=>!a.required).length===0)return null;let o=n.roles.filter(a=>a.required),i={...n,roles:o};return {...ft(i,e,t),id:`${n.action}-${e.code}-simple`,priority:(t.basePriority??100)-5,extraction:mt(n,e)}}function fo(n,e,t=Z){let r=[];if(r.push(ft(n,e,t)),t.generateSimpleVariants){let o=po(n,e,t);o&&r.push(o);}return r}function ht(n,e=Z){let t=[],r=Gn();for(let o of r){if(!n.keywords[o.action])continue;let i=fo(o,n,e);if(t.push(...i),n.eventHandler?.eventMarker){let s=ho(o,n,e);t.push(...s);}}return t}function ho(n,e,t=Z){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let r=[],o=e.eventHandler.eventMarker,i=e.keywords[n.action];if(!i)return [];let a=n.roles.filter(l=>l.required).length===2;if(e.wordOrder==="SOV")if(a)r.push(io(n,e,i,o,t)),r.push(so(n,e,i,o,t));else {r.push(Zn(n,e,i,o,t)),r.push(eo(n,e,i,o,t));let l=e.roleMarkers.destination;l&&l.primary!==o.primary&&r.push(to(n,e,i,o,t));let c=o.primary.split(/\s+/),u=o.alternatives?.some(p=>!p.includes(" ")&&p.length>1);c.length>1&&u&&r.push(ro(n,e,i,o,t)),r.push(no(n,e,i,o,t));let d=oo(n,e,i,t);d&&r.push(d);}else e.wordOrder==="VSO"?a?(r.push(Xe(n,e,i,o,t)),r.push(lo(n,e,i,o,t))):(r.push(Ye(n,e,i,o,t)),r.push(ao(n,e,i,o,t)),e.eventHandler?.negationMarker&&r.push(uo(n,e,i,o,t)),e.tokenization?.prefixes&&r.push(co(n,e,i,t))):a?r.push(Xe(n,e,i,o,t)):r.push(Ye(n,e,i,o,t));return r}function mo(n,e,t){let r=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},i=yo(n,e);switch(e.wordOrder){case "SVO":r.push(o),r.push(...i);break;case "SOV":r.push(...i),r.push(o);break;case "VSO":r.push(o),r.push(...i);break;default:r.push(o),r.push(...i);}return r}function yo(n,e){let t=[],r=pt(n.roles,e.wordOrder);for(let o of r){let i=vo(o,e);o.required?t.push(...i):t.push({type:"group",optional:true,tokens:i});}return t}function vo(n,e){let t=[],r=n.markerOverride?.[e.code],o=e.roleMarkers[n.role],i={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(o?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(i)):(t.push(i),r&&t.push({type:"literal",value:r}));else if(o)if(o.position==="before"){if(o.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(s);}t.push(i);}else {t.push(i);let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(s);}else t.push(i);return t}function go(n,e){let t={};for(let r of n.roles){let o=r.markerOverride?.[e.code],i=e.roleMarkers[r.role];o!==void 0?t[r.role]=o?{marker:o}:{}:i&&i.primary?t[r.role]=i.alternatives?{marker:i.primary,markerAlternatives:i.alternatives}:{marker:i.primary}:t[r.role]={};}return t}function mt(n,e){let t=go(n,e),r={};for(let o of n.roles){let i=t[o.role]||{};!o.required&&o.default?r[o.role]={...i,default:o.default}:r[o.role]=i;}return r}function bo(n,e,t){let r=[],i=pt(n.roles,e.wordOrder).map(s=>{let a=Qn(s,e),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(e.wordOrder){case "SVO":case "VSO":r.push(t.primary,...i);break;case "SOV":r.push(...i,t.primary);break;default:r.push(t.primary,...i);}return r.join(" ")}function ue(n){let e=n.getAttribute("data-lang");if(e)return Se(e);let t=n.getAttribute("data-hyperscript-lang")??n.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return Se(t);let r=typeof document<"u"?document.documentElement?.lang:null;return r&&r!=="en"?Se(r):null}function Se(n){return n.split("-")[0].toLowerCase()}var yt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function te(n){switch(n.kind){case "event-handler":return Eo(n);case "compound":return wo(n);default:return So(n)}}function Eo(n){let e=["on"],t=n.roles.get("event");t&&e.push(ee(t));let r=n.roles.get("source");if(r&&e.push("from",ee(r)),n.body&&n.body.length>0){let o=n.body.map(te);e.push(o.join(" then "));}return e.join(" ")}function wo(n){let e=n.chainType==="async"?"async":n.chainType;return n.statements.map(te).join(` ${e} `)}function So(n){let e=yt[n.action];if(e){let r=[n.action];for(let[o,i]of e){let s=n.roles.get(o);s&&(o==="destination"&&s.type==="reference"&&s.value==="me"||(i&&r.push(i),r.push(ee(s))));}return r.join(" ")}let t=[n.action];for(let[,r]of n.roles)t.push(ee(r));return t.join(" ")}function ee(n){switch(n.type){case "literal":return typeof n.value=="string"&&n.dataType==="string"?`"${n.value}"`:String(n.value);case "selector":return n.value;case "reference":return n.value;case "property-path":return To(n);case "expression":return n.raw;case "flag":return n.enabled?`+${n.name}`:`~${n.name}`}}function To(n){let e=ee(n.object),t=n.property;if(n.object.type==="reference")switch(n.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var gt=.5,ko={confidenceThreshold:gt,strategy:"semantic",fallbackToOriginal:true};function Ao(n,e){return typeof n=="number"?n:n[e]??n["*"]??gt}var Te=null;function xo(){return Te||(Te=ct()),Te}function ke(n,e,t={}){let r={...ko,...t},o=vt(n,e,r);if(o!==null)return o;let i=Po(n);if(i){let s=vt(i.commands,e,r);if(s!==null)return i.prefix+s}return n}function vt(n,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let r=Ao(t.confidenceThreshold,e),o=bt(n,e,r);if(o!==null)return o}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let r=Ro(n,e,t.i18nToEnglish);if(r!==null)return r}return null}var Co=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Po(n){let e=n.match(Co);if(!e)return null;let t=e[1],r=n.slice(t.length);return r?{prefix:t,commands:r}:null}function bt(n,e,t){try{let r=No(n,e);if(r.length>1)return _o(r,e,t);let o=xo();if(!o.supportsLanguage(e))return null;let i=o.analyze(n,e);if(!dt(i,t))return null;if(i.node)return te(i.node);let s=we(n,e);return te(s)}catch{return null}}function Ro(n,e,t){try{let r=t(n,e);return r!==n?r:null}catch{return null}}function Oo(n){let e=["then"],t=D(n);if(t?.keywords?.then){let r=t.keywords.then;if(r.primary&&r.primary!=="then"&&e.push(r.primary),r.alternatives)for(let o of r.alternatives)e.includes(o)||e.push(o);}return e}function No(n,e){let r=Oo(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`\\s+(?:${r.join("|")})\\s+`,"i"),i=n.split(`
4
- `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of i){let l=a.split(o);s.push(...l);}return s}function _o(n,e,t){let r=[];for(let o of n){let i=bt(o.trim(),e,t);if(i===null)return null;r.push(i);}return r.join(" then ")}function Ae(n={}){return function(t){let{internals:r}=t,o=r.runtime,i=o.getScript.bind(o);o.getScript=function(s){let a=i(s);if(!a)return null;let l=Io(s,n);if(!l||l==="en")return a;let c=ke(a,l,n);return n.debug&&c!==a&&console.log(`[hyperscript-i18n] ${l}: "${a}" \u2192 "${c}"`),c};}}function Io(n,e){if(e.languageAttribute){let r=n.getAttribute(e.languageAttribute);if(r)return r.split("-")[0].toLowerCase()}let t=ue(n);return t||(e.defaultLanguage??null)}function Et(n,e,t={}){return e==="en"?n:ke(n,e,t)}it(n=>ht(n));function wt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Ae()),Mo());}function Mo(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(r=>{let o=e.getInternalData(r);o.initialized&&(o.initialized=false);}),e.processNode(document.body);}var Gi=["ar"];wt();exports.plugin=Ae;exports.preprocess=Et;exports.resolveLanguage=ue;exports.supportedLanguages=Gi;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function R(n,e){return e?{type:"literal",value:n,dataType:e}:{type:"literal",value:n}}function he(n,e){return e?{type:"selector",value:n,selectorKind:e}:{type:"selector",value:n}}function ie(n){return {type:"reference",value:n}}function ye(n,e){return {type:"property-path",object:n,property:e}}var Nt=class{constructor(n){this.namespace=n,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let n=process.env.DEBUG||"";return n==="*"||n.includes("framework:*")||n.includes(`framework:${this.namespace}`)}return false}log(n,e,...t){if(!this.enabled)return;let r=`[framework:${this.namespace}]`,o=new Date().toISOString();switch(n){case "debug":console.debug(`${o} ${r} DEBUG:`,e,...t);break;case "info":console.info(`${o} ${r} INFO:`,e,...t);break;case "warn":console.warn(`${o} ${r} WARN:`,e,...t);break;case "error":console.error(`${o} ${r} ERROR:`,e,...t);break}}debug(n,...e){this.log("debug",n,...e);}info(n,...e){this.log("info",n,...e);}warn(n,...e){this.log("warn",n,...e);}error(n,...e){this.log("error",n,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function Ot(n){return new Nt(n)}function V(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function _t(n,e){return n?.possessive?.keywords?.[e]}var Y=class z{constructor(){this.logger=Ot("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,r){let o=e.mark(),i=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let c=[];for(let u=0;u<10;u++){let l=e.peek(u);if(l)c.push({type:l.type,value:l.value,kind:l.kind});else break}this.logger.debug("Input tokens (first 10):",c),this.logger.debug("Profile code:",r?.code);}this.currentProfile=r,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,i);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(i.entries()).map(([c,u])=>[c,JSON.stringify(u)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(o),null;let a=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-o.position,confidence:a}}matchBest(e,t,r){let o=[];for(let s of t){let a=e.mark(),c=this.matchPattern(e,s,r);c&&o.push(c),e.reset(a);}if(o.length===0)return null;o.sort((s,a)=>{let c=a.pattern.priority-s.pattern.priority;if(c!==0)return c;let u=a.confidence-s.confidence;return Math.abs(u)>.001?u:a.consumedTokens-s.consumedTokens});let i=o[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,r,o){let i=t[0],s=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,c=null;for(let u=0;u<t.length;u++){let l=t[u];this.logger.debug(" >> Matching pattern token:",JSON.stringify(l,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"),l.type==="role"&&l.greedy){let y=this.collectStopMarkers(t,u+1);if(o)for(let E of o)y.add(E);let g=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,y))break;g.push(E.value),e.advance();}if(g.length>0){r.set(l.role,{type:"expression",raw:g.join(" ")}),a=null,c=null;continue}else {if(l.optional)continue;return false}}if(l.type==="group"){let y=this.collectStopMarkers(t,u+1);if(o)for(let E of o)y.add(E);if(this.matchGroupToken(e,l,r,y)){a=null,c=null;continue}if(this.isOptional(l))continue;return false}let p=l.type==="role"&&l.optional===true,f=p?e.mark():null;if(l.type==="role"&&!p){let y=u+1<t.length?t[u+1]:null;if(y?.type==="literal"){let g=e.peek();if(g&&this.getMatchType(g,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(l))continue;if(a&&c){this.logger.debug(" >> BACKTRACKING: undoing optional role",c),e.reset(a),r.delete(c),a=null,c=null;let E=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let v=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Match result:",v),v){p?(a=f,c=l.role):(a=null,c=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(l)){if(a&&c){this.logger.debug(" >> BACKTRACKING: undoing optional role",c),e.reset(a),r.delete(c),a=null,c=null;let y=this.matchPatternToken(e,l,r);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return false}}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",r?JSON.stringify({type:r.type,value:r.value,kind:r.kind}):"null"),!r)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let o=this.getMatchType(r,t.value);if(this.logger.debug(" >>> matchType for",r.value,"vs",t.value,":",o),o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(r,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let o=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",o?JSON.stringify({value:o.value,kind:o.kind}):"null"),!o)return t.optional||false;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!V(i.type,t.expectedTypes)?t.optional||false:(r.set(t.role,i),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!V(s.type,t.expectedTypes)?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!V(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let c=this.tryMatchPropertyAccessExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!V(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!V(u.type,t.expectedTypes)?t.optional||false:(r.set(t.role,u),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",o?JSON.stringify({value:o.value,kind:o.kind}):"null");let l=this.tokenToSemanticValue(o);return this.logger.debug(" >>> tokenToSemanticValue returned:",l?JSON.stringify(l):"null"),l?(this.logger.debug(" >>> Validating type:",l.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!V(l.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),r.set(t.role,l),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=t.normalized||t.value,o=this.safeToLowerCase(r),i=_t(this.currentProfile,o);if(!i)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let c=a.value;a.kind==="selector"&&c.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(c)&&(c=c.substring(1));let u=c;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)u+=e.peek().value,e.advance();let l=e.peek();return l?.kind==="literal"&&l.value.startsWith("(")&&(u+=l.value,e.advance()),ye(ie(i),u)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<z.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<z.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let u=[],l=0;for(;!e.isAtEnd()&&u.length<z.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(l===0){e.advance();break}l--;}if(p.kind==="punctuation"&&p.value==="("&&l++,p.kind==="punctuation"&&p.value===","){e.advance();continue}u.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return !i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),ye(he(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let s=o.value.slice(1);return ye(he(t.value),s)}matchGroupToken(e,t,r,o){let i=e.mark(),s=new Set(r.keys());if(this.matchTokenSequence(e,t.tokens,r,o))return true;e.reset(i);for(let u of r.keys())s.has(u)||r.delete(u);if(!t.optional)return false;let c=this.getGroupLeadingMarker(t);if(c)for(let u=1;u<=z.MAX_MARKER_SCAN;u++){let l=e.peek(u);if(!l)break;if((l.normalized||l.value).toLowerCase()===c){this.logger.debug(" >> MARKER SCAN: found",c,"at offset",u,"- skipping intervening tokens");for(let f=0;f<u;f++)e.advance();if(this.matchTokenSequence(e,t.tokens,r,o))return true;e.reset(i);for(let f of r.keys())s.has(f)||r.delete(f);break}}return true}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let r=new Set;for(let o=t;o<e.length;o++){let i=e[o];if(i.type==="literal"){if(r.add(i.value.toLowerCase()),i.alternatives)for(let s of i.alternatives)r.add(s.toLowerCase());break}if(i.type==="group"){for(let s of i.tokens)if(s.type==="literal"){if(r.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)r.add(a.toLowerCase());break}if(!i.optional)break}}return r}isStopMarker(e,t){return t.size===0?false:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return he(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return R(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return ie(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return R(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let o=e.slice(1,-1);return R(o,"string")}if(e==="true")return R(true,"boolean");if(e==="false")return R(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?R(e,"duration"):R(o,"number")}let r=parseFloat(e);return isNaN(r)?R(e,"string"):R(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))t.has(r)||(o.value!==void 0?t.set(r,{type:"literal",value:o.value}):o.default&&t.set(r,o.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,o=0,i=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")o+=1,t.has(u.role)&&(r+=1);else if(u.type==="group"){for(let l of u.tokens)if(l.type==="role"){let d=i(l.role),p=.8;o+=p,t.has(l.role)?r+=p:d&&(r+=p*.6);}}let s=o>0?r/o:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let u=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-u);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let c=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+c)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let o of t.alternatives)if(r.has(o))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,o={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[i,s]of t.entries()){let a=o[i];if(!a||a.length===0)continue;let c="metadata"in s?s.metadata:void 0;if(c&&typeof c.prepositionValue=="string"){let u=c.prepositionValue;a.includes(u)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=this.safeToLowerCase(t.value);if(z.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&i.kind==="selector")return;e.reset(o);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=true,i.modifierName){case "once":t.once=true;break;case "debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case "throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case "queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance();}return r?t:void 0}};Y.MAX_MARKER_SCAN=3;Y.MAX_PROPERTY_DEPTH=10;Y.MAX_METHOD_ARGS=20;Y.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var It=Y;new It;var Ie=class{constructor(){this.name="string-literal";}canExtract(n,e){let t=n[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(n,e){let t=n[e];if(t==="\u201C"){let i=1;for(;e+i<n.length;){if(n[e+i]==="\u201D")return i++,{value:n.substring(e,e+i),length:i};i++;}return null}if(t==="\u2018"){let i=1;for(;e+i<n.length;){if(n[e+i]==="\u2019")return i++,{value:n.substring(e,e+i),length:i};i++;}return null}let r=1,o=false;for(;e+r<n.length;){let i=n[e+r];if(o){o=false,r++;continue}if(i==="\\"){o=true,r++;continue}if(i===t)return r++,{value:n.substring(e,e+r),length:r};r++;}return null}},Me=class{constructor(){this.name="number";}canExtract(n,e){return /\d/.test(n[e])}extract(n,e){let t=0,r=false;for(;e+t<n.length;){let s=n[e+t];if(/\d/.test(s))t++;else if(s==="."&&!r)r=true,t++;else break}if(t===0)return null;let o=n.substring(e,e+t),i=e+t;if(i<n.length){let s=n.slice(i),a=[{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 u of a)if(s.startsWith(u.pattern))return {value:o+u.suffix,length:t+u.pattern.length,metadata:{hasTimeUnit:true}};if(s.startsWith("ms"))return {value:o+"ms",length:t+2,metadata:{hasTimeUnit:true}};let c=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let u of c)if(s.startsWith(u.pattern))return {value:o+u.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(s))return {value:o+s[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:o,length:t}}};function Mt(n){return "setContext"in n&&typeof n.setContext=="function"}function Lt(n){let e={language:n.language,direction:n.direction,lookupKeyword:n.lookupKeyword.bind(n),isKeyword:n.isKeyword.bind(n),isKeywordStart:n.isKeywordStart.bind(n)};return n.normalizer?{...e,normalizer:n.normalizer}:e}var $t=new Set(["me","you","it","result","event","target","body"]);function Le(n,e=$t){return e.has(n)}var L=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;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(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function S(n,e){return {start:n,end:e}}function w(n,e,t,r){if(typeof n=="object"){let{value:i,kind:s,position:a,normalized:c,stem:u,stemConfidence:l,metadata:d}=n;return {value:i,kind:s,position:a,...c!==void 0&&{normalized:c},...u!==void 0&&{stem:u},...l!==void 0&&{stemConfidence:l},...d!==void 0&&{metadata:d}}}let o=n;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof r=="string")return {value:o,kind:e,position:t,normalized:r};if(r){let{normalized:i,stem:s,stemConfidence:a,metadata:c}=r;return {value:o,kind:e,position:t,...i!==void 0&&{normalized:i},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...c!==void 0&&{metadata:c}}}return {value:o,kind:e,position:t}}function M(n){return /\s/.test(n)}function Bt(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function Vt(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function I(n){return /\d/.test(n)}function zt(n){return /[a-zA-Z]/.test(n)}function x(n){return /[a-zA-Z0-9_-]/.test(n)}function qt(n,e){if(e>=n.length)return null;let t=n[e];if(!Bt(t))return null;let r=e,o="";if(t==="#"||t==="."){for(o+=n[r++];r<n.length&&x(n[r]);)o+=n[r++];if(o.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let s=r+1;for(;s<n.length&&x(n[s]);)s++;if(s<n.length&&n[s]==="(")return o}}else if(t==="["){let i=1,s=false,a=null,c=false;for(o+=n[r++];r<n.length&&i>0;){let u=n[r];o+=u,c?c=false:u==="\\"?c=true:s?u===a&&(s=false,a=null):u==='"'||u==="'"||u==="`"?(s=true,a=u):u==="["?i++:u==="]"&&i--,r++;}if(i!==0)return null}else if(t==="@"){for(o+=n[r++];r<n.length&&x(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="*"){for(o+=n[r++];r<n.length&&x(n[r]);)o+=n[r++];if(o.length<=1)return null}else if(t==="<"){if(o+=n[r++],r>=n.length||!zt(n[r]))return null;for(;r<n.length&&x(n[r]);)o+=n[r++];for(;r<n.length;){let i=n[r];if(i==="."){if(o+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)o+=n[r++];}else if(i==="#"){if(o+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)o+=n[r++];}else if(i==="["){let s=1,a=false,c=null,u=false;for(o+=n[r++];r<n.length&&s>0;){let l=n[r];o+=l,u?u=false:l==="\\"?u=true:a?l===c&&(a=false,c=null):l==='"'||l==="'"||l==="`"?(a=true,c=l):l==="["?s++:l==="]"&&s--,r++;}if(s!==0)return null}else break}for(;r<n.length&&M(n[r]);)o+=n[r++];if(r<n.length&&n[r]==="/")for(o+=n[r++];r<n.length&&M(n[r]);)o+=n[r++];if(r>=n.length||n[r]!==">")return null;o+=n[r++];}return o||null}function Ft(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return false;if(e+2>=n.length)return true;let r=n[e+2];return M(r)||r==="*"||!x(r)}function Wt(n,e){if(e>=n.length)return null;let t=n[e];if(!Vt(t)||t==="'"&&Ft(n,e))return null;let o={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!o)return null;let i=e+1,s=t,a=false;for(;i<n.length;){let c=n[i];if(s+=c,a)a=false;else if(c==="\\")a=true;else if(c===o)return s;i++;}return s}function jt(n,e){if(e>=n.length)return false;let t=n[e],r=n[e+1]||"",o=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(o)||t==="."&&(r==="/"||r==="."&&o==="/"))return true;let i=n.slice(e,e+8).toLowerCase();return !!(i.startsWith("http://")||i.startsWith("https://"))}function Ut(n,e){if(!jt(n,e))return null;let t=e,r="",o=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let i=n[t];if(i==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=i,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(o.test(i))r+=i,t++;else break}return r.length<2?null:r}function Kt(n,e){if(e>=n.length)return null;let t=n[e];if(!I(t)&&t!=="-"&&t!=="+")return null;let r=e,o="";if((n[r]==="-"||n[r]==="+")&&(o+=n[r++]),r>=n.length||!I(n[r]))return null;for(;r<n.length&&I(n[r]);)o+=n[r++];if(r<n.length&&n[r]===".")for(o+=n[r++];r<n.length&&I(n[r]);)o+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?o+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(o+=n[r])),o}var Gt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];function se(n){return e=>{let t=e.charCodeAt(0);return n.some(([r,o])=>t>=r&&t<=o)}}new Set(Gt);var De=class Be{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Mt(e)&&e.setContext(Lt(this)),this.extractors.push(e);}registerExtractors(e){for(let t of e)this.registerExtractor(t);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&M(e[r]);)r++;if(r>=e.length)break;let o=false;for(let i of this.extractors)if(i.canExtract(e,r)){let s=i.extract(e,r);if(s){let a=s.metadata?.normalized,c=s.metadata?.stem,u=s.metadata?.stemConfidence,l={};if(s.metadata)for(let[p,f]of Object.entries(s.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(l[p]=f);let d={};a&&(d.normalized=a),c&&(d.stem=c),u!==void 0&&(d.stemConfidence=u),Object.keys(l).length>0&&(d.metadata=l),t.push(w(s.value,this.classifyToken(s.value),S(r,r+s.length),Object.keys(d).length>0?d:void 0)),r+=s.length,o=true;break}}if(!o){let i=e[r],s=this.classifyUnknownChar(i);t.push(w(i,s,S(r,r+1))),r++;}}return new L(t,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,r){if(e[t]!==".")return false;let o=r[r.length-1],i=o&&o.position.end<t;if(o&&!i&&(o.kind==="identifier"||o.kind==="keyword"||o.kind==="selector"))return r.push(w(".","operator",S(t,t+1))),true;let c=t+1;for(;c<e.length&&x(e[c]);)c++;return c<e.length&&e[c]==="("?(r.push(w(".","operator",S(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[o,i]of Object.entries(e.keywords))if(r.set(i.primary,{native:i.primary,normalized:i.normalized||o}),i.alternatives)for(let s of i.alternatives)r.set(s,{native:s,normalized:i.normalized||o});}if(e.references){for(let[o,i]of Object.entries(e.references))r.set(i,{native:i,normalized:o});for(let o of Object.keys(e.references))r.has(o)||r.set(o,{native:o,normalized:o});}if(e.roleMarkers){for(let[o,i]of Object.entries(e.roleMarkers))if(i.primary&&r.set(i.primary,{native:i.primary,normalized:o}),i.alternatives)for(let s of i.alternatives)r.set(s,{native:s,normalized:o});}if(e.possessive?.keywords)for(let[o,i]of Object.entries(e.possessive.keywords))r.set(o,{native:o,normalized:i});for(let o of t)r.set(o.native,o);this.profileKeywords=Array.from(r.values()).sort((o,i)=>i.native.length-o.native.length),this.profileKeywordMap=new Map;for(let o of this.profileKeywords){this.profileKeywordMap.set(o.native.toLowerCase(),o);let i=this.removeDiacritics(o.native);i!==o.native&&!this.profileKeywordMap.has(i.toLowerCase())&&this.profileKeywordMap.set(i.toLowerCase(),o);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let r of this.profileKeywords)if(e.slice(t).startsWith(r.native))return w(r.native,"keyword",S(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(o=>r.startsWith(o.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,r){let o=this.tryNormalize(e);if(!o)return null;let i=this.lookupKeyword(o.stem);if(!i)return null;let s={normalized:i.normalized,stem:o.stem,stemConfidence:o.confidence};return w(e,"keyword",S(t,r),s)}trySelector(e,t){let r=qt(e,t);return r?w(r,"selector",S(t,t+r.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let r=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let o=r[0].replace(/(\s|\.)$/,""),i=o.slice(1).split("(")[0],s=r[1];return {...w(o,"event-modifier",S(t,t+o.length)),metadata:{modifierName:i,value:s?i==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let r=Wt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryNumber(e,t){let r=Kt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,o=false){let i=t;if(o)for(;i<e.length&&M(e[i]);)i++;let s=e.slice(i);for(let a of r){let c=s.slice(0,a.length);if(a.caseInsensitive?c.toLowerCase()===a.pattern.toLowerCase():c===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let l=s[a.length]||"";if(x(l))continue}return {suffix:a.suffix,endPos:i+a.length}}}return null}parseBaseNumber(e,t,r=true){let o=t,i="";if(r&&(e[o]==="-"||e[o]==="+")&&(i+=e[o++]),o>=e.length||!I(e[o]))return null;for(;o<e.length&&I(e[o]);)i+=e[o++];if(o<e.length&&e[o]===".")for(i+=e[o++];o<e.length&&I(e[o]);)i+=e[o++];return !i||i==="-"||i==="+"?null:{number:i,endPos:o}}tryNumberWithTimeUnits(e,t,r,o={}){let{allowSign:i=true,skipWhitespace:s=false}=o,a=this.parseBaseNumber(e,t,i);if(!a)return null;let{number:c,endPos:u}=a,l=[...r,...Be.STANDARD_TIME_UNITS],d=this.tryMatchTimeUnit(e,u,l,s);return d&&(c+=d.suffix,u=d.endPos),w(c,"literal",S(t,u))}tryUrl(e,t){let r=Ut(e,t);return r?w(r,"url",S(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!x(e[t+1]))return null;let r=t+1;for(;r<e.length&&x(e[r]);)r++;let o=e.slice(t,r);return w(o,"identifier",S(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return w(r,"operator",S(t,t+2));let o=e[t];return ["<",">","!","+","-","*","/","="].includes(o)?w(o,"operator",S(t,t+1)):["(",")","{","}",",",";",":"].includes(o)?w(o,"punctuation",S(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let o of r)if(e.slice(t,t+o.length)===o)return w(o,"particle",S(t,t+o.length));return null}};De.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var Ve=De;function ze(n){return {stem:n,confidence:1}}function qe(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}var Ht=new Map,Yt=new Map,Xt=new Map;function Jt(n,e,t){Ht.set(n,e),Yt.set(n,t),Xt.delete(n);}function Qt(n){let e=n.charCodeAt(0);return e>=1536&&e<=1791||e>=1872&&e<=1919||e>=2208&&e<=2303||e>=64336&&e<=65023||e>=65136&&e<=65279}function Zt(n){for(let e of n)if(Qt(e))return true;return false}function er(n){return n.replace(/[\u064B-\u0652\u0670]/g,"")}var tr=[{pattern:"\u0648\u0627\u0644",confidencePenalty:.15,prefixType:"conjunction"},{pattern:"\u0641\u0627\u0644",confidencePenalty:.15,prefixType:"conjunction"},{pattern:"\u0628\u0627\u0644",confidencePenalty:.15,prefixType:"preposition"},{pattern:"\u0643\u0627\u0644",confidencePenalty:.15,prefixType:"preposition"},{pattern:"\u0644\u0644",confidencePenalty:.12,prefixType:"preposition"}],rr=[{pattern:"\u0627\u0644",confidencePenalty:.08,prefixType:"article",minRemaining:2},{pattern:"\u0648",confidencePenalty:.08,prefixType:"conjunction",minRemaining:3},{pattern:"\u0641",confidencePenalty:.08,prefixType:"conjunction",minRemaining:3},{pattern:"\u0628",confidencePenalty:.1,prefixType:"preposition",minRemaining:3},{pattern:"\u0644",confidencePenalty:.1,prefixType:"preposition",minRemaining:3},{pattern:"\u0643",confidencePenalty:.1,prefixType:"preposition",minRemaining:3}],nr=[{pattern:"\u064A",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u062A",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0646",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0623",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"\u0627",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3}],or=[{pattern:"\u0648\u0646",confidencePenalty:.1,type:"masculine-plural"},{pattern:"\u064A\u0646",confidencePenalty:.1,type:"masculine-plural-accusative"},{pattern:"\u0627\u062A",confidencePenalty:.1,type:"feminine-plural"},{pattern:"\u0627\u0646",confidencePenalty:.1,type:"dual-nominative"},{pattern:"\u064A\u0646",confidencePenalty:.1,type:"dual-accusative"},{pattern:"\u0647\u0627",confidencePenalty:.1,type:"pronoun-her"},{pattern:"\u0647\u0645",confidencePenalty:.1,type:"pronoun-them"},{pattern:"\u0647\u0646",confidencePenalty:.1,type:"pronoun-them-f"},{pattern:"\u0646\u0627",confidencePenalty:.1,type:"pronoun-us"},{pattern:"\u0643\u0645",confidencePenalty:.1,type:"pronoun-you-pl"},{pattern:"\u0643",confidencePenalty:.08,type:"pronoun-you"},{pattern:"\u0647",confidencePenalty:.08,type:"pronoun-him"},{pattern:"\u064A",confidencePenalty:.08,type:"pronoun-me"},{pattern:"\u0629",confidencePenalty:.08,type:"feminine"}],je=class{constructor(){this.language="ar";}isNormalizable(n){return !(!Zt(n)||n.length<2)}normalize(n){let e=er(n),t=1,r=[],o=[];for(let s of tr)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length);if(a.length>=2){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}if(r.length===0){for(let s of rr)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length),c=s.minRemaining??2;if(a.length>=c){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}}if(!(e.endsWith("\u0627\u062A")||e.endsWith("\u0629")||e.endsWith("\u0648\u0646")||e.endsWith("\u064A\u0646")||e.endsWith("\u0647\u0627")||e.endsWith("\u0647\u0645")||e.endsWith("\u0647\u0646")||e.endsWith("\u0646\u0627")||e.endsWith("\u0643\u0645"))&&(r.length===0||r[0]==="\u0648"||r[0]==="\u0641")){for(let s of nr)if(e.startsWith(s.pattern)){let a=e.slice(s.pattern.length),c=s.minRemaining??3;if(a.length>=c){e=a,t-=s.confidencePenalty,r.push(s.pattern);break}}}for(let s of or)if(e.endsWith(s.pattern)){let a=e.slice(0,-s.pattern.length);a.length>=2&&(e=a,t-=s.confidencePenalty,o.push(s.pattern));}return t=Math.max(.5,t),r.length===0&&o.length===0?ze(n):qe(e,t,{removedPrefixes:r,removedSuffixes:o})}},Ue={code:"ar",name:"Arabic",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",regions:["priority"],direction:"rtl",script:"arabic",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,verb:{position:"start",subjectDrop:true},references:{me:"\u0623\u0646\u0627",it:"\u0647\u0648",you:"\u0623\u0646\u062A",result:"\u0627\u0644\u0646\u062A\u064A\u062C\u0629",event:"\u0627\u0644\u062D\u062F\u062B",target:"\u0627\u0644\u0647\u062F\u0641",body:"\u0627\u0644\u062C\u0633\u0645"},possessive:{marker:"",markerPosition:"after-object",usePossessiveAdjectives:true,specialForms:{me:"\u0644\u064A",it:"\u0644\u0647",you:"\u0644\u0643"},keywords:{\u0644\u064A:"me",\u0644\u0643:"you",\u0644\u0647:"it",\u0644\u0647\u0627:"it"}},roleMarkers:{destination:{primary:"\u0639\u0644\u0649",alternatives:["\u0641\u064A","\u0625\u0644\u0649","\u0628","\u0642\u0628\u0644","\u0628\u0639\u062F"],position:"before"},source:{primary:"\u0645\u0646",position:"before"},patient:{primary:"",position:"before"},style:{primary:"\u0628\u0640",alternatives:["\u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645"],position:"before"}},keywords:{toggle:{primary:"\u0628\u062F\u0651\u0644",alternatives:["\u0628\u062F\u0644","\u063A\u064A\u0651\u0631","\u063A\u064A\u0631"],normalized:"toggle"},add:{primary:"\u0623\u0636\u0641",alternatives:["\u0627\u0636\u0641"],normalized:"add"},remove:{primary:"\u0627\u062D\u0630\u0641",alternatives:["\u0623\u0632\u0644","\u0627\u0645\u0633\u062D"],normalized:"remove"},put:{primary:"\u0636\u0639",alternatives:["\u0627\u062C\u0639\u0644"],normalized:"put"},append:{primary:"\u0623\u0644\u062D\u0642",normalized:"append"},prepend:{primary:"\u0633\u0628\u0642",normalized:"prepend"},take:{primary:"\u062E\u0630",normalized:"take"},make:{primary:"\u0627\u0635\u0646\u0639",alternatives:["\u0623\u0646\u0634\u0626"],normalized:"make"},clone:{primary:"\u0627\u0633\u062A\u0646\u0633\u062E",normalized:"clone"},swap:{primary:"\u0627\u0633\u062A\u0628\u062F\u0644",alternatives:["\u062A\u0628\u0627\u062F\u0644"],normalized:"swap"},morph:{primary:"\u062D\u0648\u0651\u0644",normalized:"morph"},set:{primary:"\u0627\u0636\u0628\u0637",alternatives:["\u0639\u064A\u0651\u0646","\u062D\u062F\u062F"],normalized:"set"},get:{primary:"\u0627\u062D\u0635\u0644",normalized:"get"},increment:{primary:"\u0632\u0650\u062F",alternatives:["\u0632\u062F","\u0627\u0631\u0641\u0639"],normalized:"increment"},decrement:{primary:"\u0623\u0646\u0642\u0635",alternatives:["\u0627\u0646\u0642\u0635","\u0642\u0644\u0644"],normalized:"decrement"},log:{primary:"\u0633\u062C\u0644",normalized:"log"},show:{primary:"\u0627\u0638\u0647\u0631",alternatives:["\u0623\u0638\u0647\u0631","\u0627\u0639\u0631\u0636"],normalized:"show"},hide:{primary:"\u0627\u062E\u0641",alternatives:["\u0623\u062E\u0641\u0650","\u0627\u062E\u0641\u064A","\u0623\u062E\u0641"],normalized:"hide"},transition:{primary:"\u0627\u0646\u062A\u0642\u0627\u0644",alternatives:["\u0627\u0646\u062A\u0642\u0644"],normalized:"transition"},on:{primary:"\u0639\u0644\u0649",alternatives:["\u0639\u0646\u062F","\u0644\u062F\u0649","\u062D\u064A\u0646"],normalized:"on"},trigger:{primary:"\u062A\u0634\u063A\u064A\u0644",alternatives:["\u0623\u0637\u0644\u0642","\u0641\u0639\u0651\u0644"],normalized:"trigger"},send:{primary:"\u0623\u0631\u0633\u0644",normalized:"send"},focus:{primary:"\u062A\u0631\u0643\u064A\u0632",alternatives:["\u0631\u0643\u0632"],normalized:"focus"},blur:{primary:"\u0636\u0628\u0627\u0628\u064A\u0629",alternatives:["\u0634\u0648\u0634"],normalized:"blur"},go:{primary:"\u0627\u0630\u0647\u0628",normalized:"go"},wait:{primary:"\u0627\u0646\u062A\u0638\u0631",normalized:"wait"},fetch:{primary:"\u0627\u062D\u0636\u0631",alternatives:["\u062C\u0644\u0628"],normalized:"fetch"},settle:{primary:"\u0627\u0633\u062A\u0642\u0631",normalized:"settle"},if:{primary:"\u0625\u0630\u0627",normalized:"if"},when:{primary:"\u0639\u0646\u062F\u0645\u0627",normalized:"when"},where:{primary:"\u0623\u064A\u0646",normalized:"where"},else:{primary:"\u0648\u0625\u0644\u0627",alternatives:["\u062E\u0644\u0627\u0641 \u0630\u0644\u0643"],normalized:"else"},repeat:{primary:"\u0643\u0631\u0631",normalized:"repeat"},for:{primary:"\u0644\u0643\u0644",normalized:"for"},while:{primary:"\u0628\u064A\u0646\u0645\u0627",normalized:"while"},continue:{primary:"\u0648\u0627\u0635\u0644",normalized:"continue"},halt:{primary:"\u0623\u0648\u0642\u0641",normalized:"halt"},throw:{primary:"\u0627\u0631\u0645",alternatives:["\u0627\u0631\u0645\u0650"],normalized:"throw"},call:{primary:"\u0627\u0633\u062A\u062F\u0639",alternatives:["\u0646\u0627\u062F\u0650"],normalized:"call"},return:{primary:"\u0627\u0631\u062C\u0639",alternatives:["\u0639\u064F\u062F"],normalized:"return"},then:{primary:"\u062B\u0645",alternatives:["\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"],normalized:"then"},and:{primary:"\u0648\u0623\u064A\u0636\u0627\u064B",alternatives:["\u0623\u064A\u0636\u0627\u064B"],normalized:"and"},end:{primary:"\u0646\u0647\u0627\u064A\u0629",alternatives:["\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"],normalized:"end"},js:{primary:"\u062C\u0627\u0641\u0627\u0633\u0643\u0631\u0628\u062A",alternatives:["js"],normalized:"js"},async:{primary:"\u0645\u062A\u0632\u0627\u0645\u0646",normalized:"async"},tell:{primary:"\u0623\u062E\u0628\u0631",normalized:"tell"},default:{primary:"\u0627\u0641\u062A\u0631\u0627\u0636\u064A",normalized:"default"},init:{primary:"\u062A\u0647\u064A\u0626\u0629",alternatives:["\u0628\u062F\u0621"],normalized:"init"},behavior:{primary:"\u0633\u0644\u0648\u0643",normalized:"behavior"},install:{primary:"\u062A\u062B\u0628\u064A\u062A",alternatives:["\u062B\u0628\u0651\u062A"],normalized:"install"},measure:{primary:"\u0642\u064A\u0627\u0633",alternatives:["\u0642\u0650\u0633"],normalized:"measure"},beep:{primary:"\u0635\u0641\u0651\u0631",normalized:"beep"},break:{primary:"\u062A\u0648\u0642\u0641",normalized:"break"},copy:{primary:"\u0627\u0646\u0633\u062E",normalized:"copy"},exit:{primary:"\u0627\u062E\u0631\u062C",normalized:"exit"},pick:{primary:"\u0627\u062E\u062A\u0631",normalized:"pick"},render:{primary:"\u0627\u0631\u0633\u0645",normalized:"render"},into:{primary:"\u0641\u064A",alternatives:["\u0625\u0644\u0649"],normalized:"into"},before:{primary:"\u0642\u0628\u0644",normalized:"before"},after:{primary:"\u0628\u0639\u062F",normalized:"after"},until:{primary:"\u062D\u062A\u0649",normalized:"until"},event:{primary:"\u062D\u062F\u062B",normalized:"event"},from:{primary:"\u0645\u0646",normalized:"from"}},tokenization:{prefixes:["\u0627\u0644","\u0648","\u0641","\u0628","\u0643","\u0644"]},eventHandler:{eventMarker:{primary:"\u0639\u0646\u062F",alternatives:["\u0641\u064A","\u0644\u062F\u0649","\u0639\u0646\u062F\u0645\u0627","\u062D\u064A\u0646","\u062D\u064A\u0646\u0645\u0627","\u0644\u0645\u0651\u0627","\u0644\u0645\u0627"],position:"before"},temporalMarkers:["\u0639\u0646\u062F\u0645\u0627","\u062D\u064A\u0646","\u0644\u0645\u0651\u0627"],negationMarker:{primary:"\u0639\u062F\u0645",alternatives:["\u0639\u062F\u0645"],position:"before"}}},ir=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],sr=class{constructor(n=ir){this.name="operator",this.operators=[...n].sort((e,t)=>t.length-e.length);}canExtract(n,e){return this.operators.some(t=>n.startsWith(t,e))}extract(n,e){for(let t of this.operators)if(n.startsWith(t,e))return {value:t,length:t.length};return null}},ar="()[]{},:;",cr=class{constructor(n=ar){this.punctuation=n,this.name="punctuation";}canExtract(n,e){return this.punctuation.includes(n[e])}extract(n,e){let t=n[e];return this.punctuation.includes(t)?{value:t,length:1}:null}};function lr(n,e){let t=n[e];if(t==="#"){let r=n.slice(e).match(/^#[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="."){let r=n.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="["){let r=0,o=e;for(;o<n.length;){if(n[o]==="["&&r++,n[o]==="]"&&(r--,r===0))return n.slice(e,o+1);o++;}return null}if(t==="<"){let r=n.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return r?r[0]:null}return null}var ur=class{constructor(){this.name="css-selector";}canExtract(n,e){let t=n[e];return t==="#"||t==="."||t==="["||t==="<"}extract(n,e){let t=lr(n,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},dr=class{constructor(){this.name="event-modifier";}canExtract(n,e){if(n[e]!==".")return false;let t=n.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(t)}extract(n,e){let t=n.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!t)return null;let r=t[0],o=r.slice(1).split("(")[0],i=t[1];return {value:r,length:r.length,metadata:{modifierName:o,value:i?o==="queue"?i:parseInt(i,10):void 0}}}};function pr(n,e){let t=n.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let r=t.match(/^https?:\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("//")){let r=t.match(/^\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("./")||t.startsWith("../")){let r=t.match(/^\.\.?\/[^\s]*/);return r?r[0]:null}if(t.startsWith("/")){let r=t.match(/^\/[^\s]*/);return r?r[0]:null}return null}var fr=class{constructor(){this.name="url";}canExtract(n,e){let t=n.slice(e);return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")}extract(n,e){let t=pr(n,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},mr=class{constructor(){this.name="variable-ref";}canExtract(n,e){return n[e]===":"&&e+1<n.length&&/[a-zA-Z_]/.test(n[e+1])}extract(n,e){if(!this.canExtract(n,e))return null;let t=1;for(;e+t<n.length&&/[a-zA-Z0-9_]/.test(n[e+t]);)t++;return {value:n.substring(e,e+t),length:t,metadata:{type:"variable-reference"}}}},Fe=se([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),hr=new Set(["\u0641\u064A","\u0639\u0644\u0649","\u0645\u0646","\u0625\u0644\u0649","\u0627\u0644\u0649","\u0645\u0639","\u0639\u0646","\u0642\u0628\u0644","\u0628\u0639\u062F","\u0628\u064A\u0646"]),yr=class{constructor(){this.name="arabic-keyword";}setContext(n){this.context=n;}canExtract(n,e){return Fe(n[e])}extract(n,e){if(!this.context)throw new Error("ArabicKeywordExtractor: context not set");let t=e;this.context.isKeywordStart(n,e);let r="",o=e;for(;o<n.length&&(Fe(n[o])||n[o]==="\u0640");)r+=n[o],o++;if(!r)return null;let i=this.context.lookupKeyword(r),s=i&&i.normalized!==i.native?i.normalized:void 0;if(hr.has(r))return {value:r,length:o-t,metadata:{prepositionValue:r,normalized:s}};let a,c,u;if(!i&&this.context.normalizer){let l=this.context.normalizer.normalize(r);if(l.stem!==r&&l.confidence>=.7){let d=this.context.lookupKeyword(l.stem);d&&(a=d.normalized,c=l.stem,u=l.confidence);}}return {value:r,length:o-t,metadata:{normalized:s||a,stem:c,stemConfidence:u}}}},X=se([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),J=new Map([["\u0648",{normalized:"and",type:"conjunction"}],["\u0641",{normalized:"then",type:"conjunction"}],["\u0628",{normalized:"with",type:"preposition"}],["\u0644",{normalized:"to",type:"preposition"}],["\u0643",{normalized:"like",type:"preposition"}],["\u0648\u0644",{normalized:"and-to",type:"conjunction"}],["\u0648\u0628",{normalized:"and-with",type:"conjunction"}],["\u0648\u0643",{normalized:"and-like",type:"conjunction"}],["\u0641\u0644",{normalized:"then-to",type:"conjunction"}],["\u0641\u0628",{normalized:"then-with",type:"conjunction"}],["\u0641\u0643",{normalized:"then-like",type:"conjunction"}]]),vr=class{constructor(){this.name="arabic-proclitic";}setContext(n){this.context=n;}canExtract(n,e){let t=n[e];return J.has(t)||e+1<n.length&&J.has(n.slice(e,e+2))}extract(n,e){if(!this.context)throw new Error("ArabicProcliticExtractor: context not set");let t=e;for(;t<n.length&&(X(n[t])||n[t]==="\u0640");)t++;let r=n.slice(e,t);if(this.context.isKeyword(r))return null;if(e+2<=n.length){let u=n.slice(e,e+2),l=J.get(u);if(l){let d=e+2;if(d<n.length&&X(n[d])){let p=0,f=d;for(;f<n.length&&X(n[f]);)p++,f++;if(p>=2)if(J.get(n[e])){let v=n.slice(e+1,t);if(!this.context.isKeyword(v))return {value:u,length:2,metadata:{procliticType:l.type,normalized:l.normalized}}}else return {value:u,length:2,metadata:{procliticType:l.type,normalized:l.normalized}}}}}let o=n[e],i=J.get(o);if(!i)return null;let s=e+1;if(s>=n.length||!X(n[s]))return null;let a=0,c=s;for(;c<n.length&&X(n[c]);)a++,c++;return a<2?null:{value:o,length:1,metadata:{procliticType:i.type,normalized:i.normalized}}}},gr=se([[1536,1791],[1872,1919],[2208,2303],[64336,65023],[65136,65279]]),We=new Map([["\u0639\u0646\u062F\u0645\u0627",{normalized:"on",formality:"formal",confidence:.95,description:"when (formal MSA)"}],["\u062D\u064A\u0646\u0645\u0627",{normalized:"on",formality:"formal",confidence:.93,description:"when/whenever (formal)"}],["\u0639\u0646\u062F",{normalized:"on",formality:"neutral",confidence:.88,description:"at/when (neutral)"}],["\u062D\u064A\u0646",{normalized:"on",formality:"neutral",confidence:.85,description:"when/time (neutral)"}],["\u0644\u0645\u0651\u0627",{normalized:"on",formality:"dialectal",confidence:.7,description:"when (dialectal, with shadda)"}],["\u0644\u0645\u0627",{normalized:"on",formality:"dialectal",confidence:.68,description:"when (dialectal, no diacritic)"}],["\u0644\u062F\u0649",{normalized:"on",formality:"neutral",confidence:.82,description:"at/with (temporal)"}]]),br=class{constructor(){this.name="arabic-temporal";}setContext(n){this._context=n,this._context;}canExtract(n,e){for(let[t]of We)if(n.startsWith(t,e))return true;return false}extract(n,e){let t=Array.from(We.entries()).sort(([r],[o])=>o.length-r.length);for(let[r,o]of t)if(n.startsWith(r,e)){let i=e+r.length;if(i>=n.length||/\s/.test(n[i])||!gr(n[i]))return {value:r,length:r.length,metadata:{temporalFormality:o.formality,temporalConfidence:o.confidence,normalized:o.normalized,description:o.description}}}return null}};function Er(n){let e=n.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Sr(n){let e=n.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}var wr=class{constructor(){this.name="ascii-identifier";}setContext(n){this.context=n;}canExtract(n,e){return Er(n[e])}extract(n,e){if(!this.context)throw new Error("AsciiIdentifierExtractor: context not set");let t=e,r="",o=e;for(;o<n.length&&Sr(n[o]);)r+=n[o],o++;if(!r)return null;let i=this.context.lookupKeyword(r),s=i&&i.normalized!==i.native?i.normalized:void 0;return {value:r,length:o-t,metadata:{normalized:s}}}};function Tr(){return [new fr,new dr,new mr,new ur]}var kr=new Set(["\u0648\u0644","\u0648\u0628","\u0648\u0643","\u0641\u0644","\u0641\u0628","\u0641\u0643"]),xr=new Set(["\u0641\u064A","\u0639\u0644\u0649","\u0645\u0646","\u0625\u0644\u0649","\u0627\u0644\u0649","\u0645\u0639","\u0639\u0646","\u0642\u0628\u0644","\u0628\u0639\u062F","\u0628\u064A\u0646","\u0628","\u0644","\u0643"]),Ar=[{native:"\u0635\u062D\u064A\u062D",normalized:"true"},{native:"\u062E\u0637\u0623",normalized:"false"},{native:"null",normalized:"null"},{native:"\u0641\u0627\u0631\u063A",normalized:"null"},{native:"\u063A\u064A\u0631 \u0645\u0639\u0631\u0641",normalized:"undefined"},{native:"\u0627\u0644\u0623\u0648\u0644",normalized:"first"},{native:"\u0623\u0648\u0644",normalized:"first"},{native:"\u0627\u0644\u0623\u062E\u064A\u0631",normalized:"last"},{native:"\u0622\u062E\u0631",normalized:"last"},{native:"\u0627\u0644\u062A\u0627\u0644\u064A",normalized:"next"},{native:"\u0627\u0644\u0633\u0627\u0628\u0642",normalized:"previous"},{native:"\u0627\u0644\u0623\u0642\u0631\u0628",normalized:"closest"},{native:"\u0627\u0644\u0623\u0628",normalized:"parent"},{native:"\u0627\u0644\u0646\u0642\u0631",normalized:"click"},{native:"\u0646\u0642\u0631",normalized:"click"},{native:"\u0627\u0644\u0625\u062F\u062E\u0627\u0644",normalized:"input"},{native:"\u0625\u062F\u062E\u0627\u0644",normalized:"input"},{native:"\u0627\u0644\u062A\u063A\u064A\u064A\u0631",normalized:"change"},{native:"\u062A\u063A\u064A\u064A\u0631",normalized:"change"},{native:"\u0627\u0644\u0625\u0631\u0633\u0627\u0644",normalized:"submit"},{native:"\u0625\u0631\u0633\u0627\u0644",normalized:"submit"},{native:"\u0627\u0644\u062A\u0631\u0643\u064A\u0632",normalized:"focus"},{native:"\u0641\u0642\u062F\u0627\u0646 \u0627\u0644\u062A\u0631\u0643\u064A\u0632",normalized:"blur"},{native:"\u0636\u063A\u0637",normalized:"keydown"},{native:"\u0631\u0641\u0639",normalized:"keyup"},{native:"\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0641\u0623\u0631\u0629",normalized:"mouseover"},{native:"\u0645\u063A\u0627\u062F\u0631\u0629 \u0627\u0644\u0641\u0623\u0631\u0629",normalized:"mouseout"},{native:"\u062A\u062D\u0645\u064A\u0644",normalized:"load"},{native:"\u062A\u0645\u0631\u064A\u0631",normalized:"scroll"},{native:"\u0647\u064A",normalized:"it"},{native:"\u062B\u0627\u0646\u064A\u0629",normalized:"s"},{native:"\u062B\u0648\u0627\u0646\u064A",normalized:"s"},{native:"\u0645\u0644\u064A \u062B\u0627\u0646\u064A\u0629",normalized:"ms"},{native:"\u062F\u0642\u064A\u0642\u0629",normalized:"m"},{native:"\u062F\u0642\u0627\u0626\u0642",normalized:"m"},{native:"\u0633\u0627\u0639\u0629",normalized:"h"},{native:"\u0633\u0627\u0639\u0627\u062A",normalized:"h"},{native:"\u0639\u0646\u062F\u0645\u0627",normalized:"on"},{native:"\u062D\u064A\u0646\u0645\u0627",normalized:"on"},{native:"\u0639\u0646\u062F",normalized:"on"},{native:"\u062D\u064A\u0646",normalized:"on"},{native:"\u0644\u0645\u0651\u0627",normalized:"on"},{native:"\u0644\u0645\u0627",normalized:"on"},{native:"\u0644\u062F\u0649",normalized:"on"}],Cr=class extends Ve{constructor(){super(),this.language="ar",this.direction="rtl",this.initializeKeywordsFromProfile(Ue,Ar),this.normalizer=new je,this.registerExtractors(Tr()),this.registerExtractor(new Ie),this.registerExtractor(new Me),this.registerExtractor(new wr),this.registerExtractor(new br),this.registerExtractor(new vr),this.registerExtractor(new yr),this.registerExtractor(new sr),this.registerExtractor(new cr);}tokenizeWithExtractors(n){let e=[],t=0;for(;t<n.length;){for(;t<n.length&&M(n[t]);)t++;if(t>=n.length)break;let r=false;for(let o of this.extractors)if(o.canExtract(n,t)){let i=o.extract(n,t);if(i){let s=i.metadata?.normalized,a=i.metadata?.stem,c=i.metadata?.stemConfidence,u={};if(i.metadata)for(let[p,f]of Object.entries(i.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(u[p]=f);let l;u.procliticType==="conjunction"?l="conjunction":u.procliticType==="preposition"?l="particle":l=this.classifyToken(i.value);let d={};s&&(d.normalized=s),a&&(d.stem=a),c!==void 0&&(d.stemConfidence=c),Object.keys(u).length>0&&(d.metadata=u),e.push(w(i.value,l,S(t,t+i.length),Object.keys(d).length>0?d:void 0)),t+=i.length,r=true;break}}if(!r){let o=n[t],i=this.classifyUnknownChar(o);e.push(w(o,i,S(t,t+1))),t++;}}return new L(e,this.language)}classifyToken(n){return kr.has(n)?"conjunction":xr.has(n)?"particle":this.isKeyword(n)?"keyword":n.startsWith("/")||n.startsWith("./")||n.startsWith("../")||n.startsWith("http")?"url":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(n)?"event-modifier":n.startsWith("#")||n.startsWith(".")||n.startsWith("[")||n.startsWith("*")||n.startsWith("<")?"selector":n.startsWith('"')||n.startsWith("'")||/^\d/.test(n)?"literal":"identifier"}},Pr=new Cr;Jt("ar",Pr,Ue);var Rr=Object.defineProperty,Nr=Object.getOwnPropertyNames,ot=(n,e)=>function(){return n&&(e=(0, n[Nr(n)[0]])(n=0)),e},Or=(n,e)=>{for(var t in e)Rr(n,t,{get:e[t],enumerable:true});};function Ke(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`))}function A(n,e,t={},r){let o=it[n],i=Ke(o,t),s=st[n],a=s?Ke(s,t):void 0;return {code:n,message:i,severity:e,...r&&{role:r},...a&&{suggestion:a}}}var h,it,st,_r=ot({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},it={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.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.",[h.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.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[h.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[h.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[h.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},st={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[h.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[h.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[h.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),at={};Or(at,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Vr,getValidationStats:()=>zr,validateAllKeywordCollisions:()=>Fr,validateAllSchemas:()=>Br,validateCommandSchema:()=>ct,validateKeywordCollisions:()=>lt,validateRoleValues:()=>qr});function Ir(n,e){return {action:n,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function ct(n){let e=[];for(let r of n.roles)r.expectedTypes.includes("literal")&&r.expectedTypes.includes("selector")&&(r.role==="patient"&&Ee.has(n.action)?e.push(A(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:r.role,command:n.action},r.role)):e.push(A(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:r.role},r.role))),r.expectedTypes.length>3&&!Ee.has(n.action)&&e.push(A(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:r.role,count:r.expectedTypes.length},r.role));for(let r of n.roles)r.selectorKinds&&r.selectorKinds.length>0&&(r.expectedTypes.includes("selector")||e.push(A(h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:r.role},r.role)));switch(n.action){case "transition":Mr(n,e);break;case "on":Lr(n,e);break;case "if":case "unless":$r(n,e);break;case "repeat":case "for":case "while":Dr(n,e);break}return n.roles.filter(r=>r.required).length===0&&(ut.has(n.action)?e.push(A(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:n.action})):e.push(A(h.NO_REQUIRED_ROLES,"warning",{}))),Ir(n.action,e)}function Mr(n,e){let t=n.roles.find(o=>o.role==="patient"),r=n.roles.find(o=>o.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(A(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!r&&e.push(A(h.TRANSITION_MISSING_GOAL,"error",{}));}function Lr(n,e){let t=n.roles.find(r=>r.role==="event");t||e.push(A(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(A(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function $r(n,e){let t=n.roles.find(r=>r.role==="condition");t||e.push(A(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(A(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Dr(n,e){n.action==="for"?n.roles.find(r=>r.role==="source")||e.push(A(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):n.action==="while"&&(n.roles.find(r=>r.role==="condition")||e.push(A(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Br(n,e={}){let t=new Map,{includeNotes:r=false}=e;for(let[o,i]of Object.entries(n)){let s=ct(i),a=s.items.some(u=>u.severity==="warning"||u.severity==="error"),c=r&&s.items.some(u=>u.severity==="note");(a||c)&&t.set(o,s);}return t}function Vr(n,e={}){let t=[],{showNotes:r=false,showCodes:o=true}=e;for(let[i,s]of n){let a=s.items.filter(l=>l.severity==="error"),c=s.items.filter(l=>l.severity==="warning"),u=s.items.filter(l=>l.severity==="note");if(a.length>0){t.push(` \u274C ${i}:`);for(let l of a){let d=o?` [${l.code}]`:"";t.push(` ERROR${d}: ${l.message}`),l.suggestion&&t.push(` \u{1F4A1} Suggestion: ${l.suggestion}`);}}if(c.length>0){t.push(` \u26A0\uFE0F ${i}:`);for(let l of c){let d=o?` [${l.code}]`:"";t.push(` ${d?`${l.code}: `:""}${l.message}`),l.suggestion&&t.push(` \u{1F4A1} ${l.suggestion}`);}}if(r&&u.length>0){t.push(` \u2139\uFE0F ${i}:`);for(let l of u){let d=o?` [${l.code}]`:"";t.push(` ${d?`${l.code}: `:""}${l.message}`);}}}return t.join(`
2
+ `)}function zr(n){let e=0,t=0,r=0,o={};for(let i of n.values())for(let s of i.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&r++,o[s.code]=(o[s.code]||0)+1;return {totalCommands:n.size,errors:e,warnings:t,notes:r,byCode:o}}function qr(n,e){let t=[];for(let r of e){let o=n.roles.find(i=>i.role===r.role);o&&(o.expectedTypes.length>0&&!o.expectedTypes.includes(r.type)&&(o.expectedTypes.includes("expression")||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects type [${o.expectedTypes.join(", ")}], got '${r.type}'`,code:h.VALUE_TYPE_MISMATCH})),r.type==="selector"&&r.selectorKind&&o.selectorKinds&&o.selectorKinds.length>0&&(o.selectorKinds.includes(r.selectorKind)||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects selector kind [${o.selectorKinds.join(", ")}], got '${r.selectorKind}'`,code:h.SELECTOR_KIND_MISMATCH})));}return t}function lt(n){let e=[];if(!n.keywords)return {language:n.code,collisions:e};let t=new Map;for(let[o,i]of Object.entries(n.keywords)){if(!i||!i.primary)continue;let s=t.get(i.primary)||[];if(s.push({command:o,isPrimary:true}),t.set(i.primary,s),i.alternatives)for(let a of i.alternatives){let c=t.get(a)||[];c.push({command:o,isPrimary:false}),t.set(a,c);}}for(let[o,i]of t){let s=[...new Set(i.map(u=>u.command))];if(s.length<=1)continue;let a=i.filter(u=>u.isPrimary).length,c;a>=2?c="primary-primary":a===1?c="primary-alternative":c="alternative-alternative",e.push({keyword:o,commands:s.sort(),type:c});}let r={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((o,i)=>r[o.type]-r[i.type]),{language:n.code,collisions:e}}function Fr(n){let e=[];for(let[,t]of Object.entries(n)){let r=lt(t);r.collisions.length>0&&e.push(r);}return e.sort((t,r)=>t.language.localeCompare(r.language))}var Ee,ut,Wr=ot({"src/generators/schema-validator.ts"(){_r(),Ee=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),ut=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function Z(n){let e="complex";return n.startsWith("#")&&!n.includes(" ")?e="id":n.startsWith(".")&&!n.includes(" ")?e="class":n.startsWith("[")&&n.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(n)&&(e="element"),{type:"selector",value:n,selectorKind:e}}function T(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function Ge(n){return Le(n)}function $(n){return {type:"reference",value:n}}function ve(n,e){return {type:"property-path",object:n,property:e}}function ae(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function He(n,e,t,r,o,i){let s=new Map;s.set("event",n);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),a}function Ye(n,e="then",t){let r={kind:"compound",action:"compound",roles:new Map,statements:n,chainType:e};return t!==void 0&&(r.metadata=t),r}function Xe(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function jr(n,e){return n.possessive?.keywords?.[e]}var W=new Map,j=new Map,ce=new Map,Se=null;function dt(n,e){let t={...n};for(let r of Object.keys(e)){let o=e[r],i=n[r];o!==void 0&&(typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?t[r]=dt(i,o):t[r]=o);}return t}function Ur(n,e){return dt(n,e)}function Te(n){if(!n.extends)return n;let e=j.get(n.extends);if(!e)return console.warn(`[Registry] Profile '${n.code}' extends '${n.extends}' but base is not registered. Make sure to import the base language before the variant.`),n;let t=Te(e);return Ur(t,n)}function pt(n){Se=n;}var Je=new Map;function U(n){return n.split("-")[0]}function K(n){return n.includes("-")}function Kr(n){let e=W.get(n);if(!e&&K(n)){let t=U(n);e=W.get(t);}if(!e){let t=Array.from(W.keys()).join(", ");throw new Error(`Language '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return e}function Gr(n){let e=j.get(n);if(!e&&K(n)){let t=U(n);e=j.get(t);}if(!e){let t=Array.from(j.keys()).join(", ");throw new Error(`Language profile '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return Te(e)}function Hr(n){let e=W.get(n);return !e&&K(n)&&(e=W.get(U(n))),e}function D(n){let e=j.get(n);return !e&&K(n)&&(e=j.get(U(n))),e?Te(e):void 0}function ft(){return Array.from(W.keys())}function Yr(n,e){return Kr(e).tokenize(n)}function F(n){let e=ce.get(n);if(!e&&K(n)&&(e=ce.get(U(n))),e)return e;let t=Je.get(n);if(!t&&K(n)&&(t=Je.get(U(n))),t)return ce.set(n,t),t;if(!Se)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=Gr(n),o=Se(r);return ce.set(n,o),o}var ge=.8,Jr=.6,Qr=.15,Zr=.5,Qe=.15,Ze=.1,et=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"]),en={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"]},tn=class{calculate(n){return this.calculateWithBreakdown(n).final}calculateWithBreakdown(n){let e=this.scoreRoleCoverage(n),t=this.scoreStemPenalty(n),r=this.scoreLanguageBoost(n),o=this.scoreLanguageAdjustment(n),i=e;return i=Math.max(Zr,i+t),i=Math.min(1,i+r),i=Math.max(0,Math.min(1,i+o)),{roleCoverage:e,stemPenalty:t,languageBoost:r,languageAdjustment:o,final:i}}scoreRoleCoverage(n){let{pattern:e,captured:t}=n,r=0,o=0,i=s=>e.extraction?.[s]?.default!==void 0;for(let s of e.template.tokens)if(s.type==="role")o+=1,t.has(s.role)&&(r+=1);else if(s.type==="group")for(let a of s.tokens)a.type==="role"&&(o+=ge,t.has(a.role)?r+=ge:i(a.role)&&(r+=ge*Jr));return o>0?r/o:1}scoreStemPenalty(n){let{stemMatchCount:e,totalKeywordMatches:t}=n;return e<=0||t<=0?0:-(e/t)*Qr}scoreLanguageBoost(n){let{pattern:e}=n;if(e.language!=="ar")return 0;let t=e.template.tokens[0];return !t||t.type!=="literal"?0:et.has(t.value)||t.alternatives?.some(r=>et.has(r))?Qe:0}scoreLanguageAdjustment(n){let{pattern:e,captured:t}=n;if(e.language!=="ar")return 0;let r=0;for(let[o,i]of t.entries()){let s=en[o];if(!s||s.length===0)continue;let a="metadata"in i?i.metadata:void 0;a&&typeof a.prepositionValue=="string"&&(s.includes(a.prepositionValue)?r+=.1:r-=.1);}return Math.max(-Ze,Math.min(Ze,r))}},rn=new tn,ue=class Q{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??rn;}matchPattern(e,t){let r=e.mark(),o=new Map;if(this.currentProfile=D(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,o))return e.reset(r),null;let s=this.confidenceModel.calculate({pattern:t,captured:o,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-r.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let r=[],o=e.position();for(let s of t){let a=e.mark(),c=`${o}:${s.id}`,u;this.matchCache.has(c)?u=this.matchCache.get(c):(u=this.matchPattern(e,s),this.matchCache.set(c,u)),u&&r.push(u),e.reset(a);}if(r.length===0)return null;r.sort((s,a)=>{let c=a.pattern.priority-s.pattern.priority;return c!==0?c:a.confidence-s.confidence});let i=r[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,r){let o=t[0],i=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!i)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,r)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(!r)return false;let o=this.getMatchType(r,t.value);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let i of t.alternatives){let s=this.getMatchType(r,i);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.skipNoiseWords(e);let o=e.peek();if(!o)return t.optional||false;let i=this.tryMatchPossessiveExpression(e);if(i)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(i.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,i),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Xe(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let c=this.tryMatchPropertyAccessExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,c),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!Xe(u.type,t.expectedTypes)?t.optional||false:(r.set(t.role,u),true);let l=this.tokenToSemanticValue(o);return !l||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)?t.optional||false:(r.set(t.role,l),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),o=jr(this.currentProfile,r);if(!o)return null;let i=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(i),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let c=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),ve($(o),c)}return e.reset(i),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<Q.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${i.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="operator"||o.value!==".")return e.reset(r),null;e.advance();let i=e.peek();if(!i||i.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${i.value}`,a=1;for(;!e.isAtEnd()&&a<Q.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let l=e.peek();if(!l||l.kind!=="identifier")break;e.advance(),s+=`.${l.value}`,a++;}let c=e.peek();if(c&&c.kind==="punctuation"&&c.value==="("){e.advance();let u=[],l=0;for(;!e.isAtEnd()&&u.length<Q.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(l===0){e.advance();break}l--;}if(p.kind==="punctuation"&&p.value==="("&&l++,p.kind==="punctuation"&&p.value===","){e.advance();continue}u.push(p.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="'s")return e.reset(r),null;e.advance();let i=e.peek();return !i||i.kind!=="selector"&&i.kind!=="identifier"?(e.reset(r),null):(e.advance(),ve(Z(t.value),i.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let o=e.peek();if(!o||o.kind!=="selector"||!o.value.startsWith("."))return e.reset(r),null;let i=e.peek(1);i&&i.kind,e.advance();let s=o.value.slice(1);return ve(Z(t.value),s)}matchGroupToken(e,t,r){let o=e.mark(),i=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(o);for(let a of r.keys())i.has(a)||r.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return Z(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return Ge(t)?$(t):T(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return $(e.value);let r=e.value.toLowerCase();return Ge(r)?$(r):{type:"expression",raw:e.value};case "url":return T(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let o=e.slice(1,-1);return T(o,"string")}if(e==="true")return T(true,"boolean");if(e==="false")return T(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let o=parseFloat(t[1]);return t[2]?T(e,"duration"):T(o,"number")}let r=parseFloat(e);return isNaN(r)?T(e,"string"):T(r,"number")}applyExtractionRules(e,t){for(let[r,o]of Object.entries(e.extraction))t.has(r)||(o.value!==void 0?t.set(r,{type:"literal",value:o.value}):o.default&&t.set(r,o.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(Q.ENGLISH_NOISE_WORDS.has(r)){let o=e.mark();e.advance();let i=e.peek();if(i&&(i.kind==="selector"||i.kind==="identifier"))return;e.reset(o);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let o=e.peek();if(!o||o.kind!=="event-modifier")break;let i=o.metadata;if(!i)break;switch(r=true,i.modifierName){case "once":t.once=true;break;case "debounce":typeof i.value=="number"&&(t.debounce=i.value);break;case "throttle":typeof i.value=="number"&&(t.throttle=i.value);break;case "queue":(i.value==="first"||i.value==="last"||i.value==="all"||i.value==="none")&&(t.queue=i.value);break}e.advance();}return r?t:void 0}};ue.MAX_PROPERTY_DEPTH=10;ue.MAX_METHOD_ARGS=20;ue.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var mt=ue,q=new mt;function nn(n){return Hr(n)}function be(n,e){return Yr(n,e)}function ht(){return ft()}var on={ko:{\uD074\uB9AD:"click",\uC785\uB825:"input",\uBCC0\uACBD:"change",\uC81C\uCD9C:"submit",\uD0A4\uB2E4\uC6B4:"keydown",\uD0A4\uC5C5:"keyup",\uB9C8\uC6B0\uC2A4\uC624\uBC84:"mouseover",\uB9C8\uC6B0\uC2A4\uC544\uC6C3:"mouseout",\uB9C8\uC6B0\uC2A4\uB2E4\uC6B4:"mousedown",\uB9C8\uC6B0\uC2A4\uC5C5:"mouseup",\uD3EC\uCEE4\uC2A4:"focus",\uBE14\uB7EC:"blur",\uB85C\uB4DC:"load",\uB9AC\uC0AC\uC774\uC988:"resize",\uC2A4\uD06C\uB864:"scroll"},ja:{\u30AF\u30EA\u30C3\u30AF:"click",\u5165\u529B:"input",\u5909\u66F4:"change",\u9001\u4FE1:"submit",\u30AD\u30FC\u30C0\u30A6\u30F3:"keydown",\u30AD\u30FC\u30A2\u30C3\u30D7:"keyup",\u30AD\u30FC\u30D7\u30EC\u30B9:"keypress",\u30DE\u30A6\u30B9\u30AA\u30FC\u30D0\u30FC:"mouseover",\u30DE\u30A6\u30B9\u30A2\u30A6\u30C8:"mouseout",\u30DE\u30A6\u30B9\u62BC\u4E0B:"mousedown",\u30DE\u30A6\u30B9\u89E3\u653E:"mouseup",\u30D5\u30A9\u30FC\u30AB\u30B9:"focus",\u30D6\u30E9\u30FC:"blur",\u30ED\u30FC\u30C9:"load",\u8AAD\u307F\u8FBC\u307F:"load",\u30B5\u30A4\u30BA\u5909\u66F4:"resize",\u30B9\u30AF\u30ED\u30FC\u30EB:"scroll"},ar:{\u0627\u0644\u0646\u0642\u0631:"click",\u0646\u0642\u0631:"click",\u0627\u0644\u0625\u062F\u062E\u0627\u0644:"input",\u0625\u062F\u062E\u0627\u0644:"input",\u0627\u0644\u062A\u063A\u064A\u064A\u0631:"change",\u062A\u063A\u064A\u064A\u0631:"change",\u0627\u0644\u0625\u0631\u0633\u0627\u0644:"submit",\u0625\u0631\u0633\u0627\u0644:"submit","\u0636\u063A\u0637 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keydown","\u0631\u0641\u0639 \u0627\u0644\u0645\u0641\u062A\u0627\u062D":"keyup","\u062A\u0645\u0631\u064A\u0631 \u0627\u0644\u0645\u0627\u0648\u0633":"mouseover",\u0627\u0644\u062A\u0631\u0643\u064A\u0632:"focus",\u062A\u062D\u0645\u064A\u0644:"load",\u062A\u0645\u0631\u064A\u0631:"scroll"},es:{clic:"click",click:"click",entrada:"input",cambio:"change",env\u00EDo:"submit",enviar:"submit","tecla abajo":"keydown","tecla arriba":"keyup","rat\xF3n encima":"mouseover","rat\xF3n fuera":"mouseout",enfoque:"focus",desenfoque:"blur",carga:"load",desplazamiento:"scroll"},tr:{t\u0131klama:"click",t\u0131kla:"click",t\u0131k:"click",giri\u015F:"input",girdi:"input",de\u011Fi\u015Fiklik:"change",de\u011Fi\u015Fim:"change",g\u00F6nderme:"submit",g\u00F6nder:"submit",tu\u015Fbasma:"keydown",tu\u015Fb\u0131rakma:"keyup",fare_bas:"mousedown",fare_b\u0131rak:"mouseup",farei\u00E7inde:"mouseover",fared\u0131\u015F\u0131nda:"mouseout",odaklanma:"focus",odak:"focus",bulan\u0131kl\u0131k:"blur",y\u00FCkleme:"load",y\u00FCkle:"load",boyut_de\u011Fi\u015Ftir:"resize",kayd\u0131rma:"scroll"},pt:{clique:"click",clicar:"click",click:"click",entrada:"input",inserir:"input",mudan\u00E7a:"change",mudanca:"change",alterar:"change",envio:"submit",enviar:"submit","tecla baixo":"keydown","tecla cima":"keyup","pressionar tecla":"keydown","soltar tecla":"keyup","mouse sobre":"mouseover","mouse fora":"mouseout",foco:"focus",focar:"focus",desfoque:"blur",desfocar:"blur",carregar:"load",carregamento:"load",rolagem:"scroll",rolar:"scroll"},zh:{\u70B9\u51FB:"click",\u5355\u51FB:"click",\u53CC\u51FB:"dblclick",\u8F93\u5165:"input",\u6539\u53D8:"change",\u53D8\u5316:"change",\u53D8\u66F4:"change",\u63D0\u4EA4:"submit",\u53D1\u9001:"submit",\u6309\u952E:"keydown",\u952E\u5165:"keydown",\u677E\u952E:"keyup",\u9F20\u6807\u8FDB\u5165:"mouseover",\u9F20\u6807\u79FB\u5165:"mouseover",\u9F20\u6807\u79BB\u5F00:"mouseout",\u9F20\u6807\u79FB\u51FA:"mouseout",\u7126\u70B9:"focus",\u805A\u7126:"focus",\u5931\u7126:"blur",\u6A21\u7CCA:"blur",\u52A0\u8F7D:"load",\u8F7D\u5165:"load",\u6EDA\u52A8:"scroll"},fr:{clic:"click",cliquer:"click",click:"click",saisie:"input",entr\u00E9e:"input",changement:"change",changer:"change",soumettre:"submit",soumission:"submit",envoi:"submit","touche bas":"keydown","touche haut":"keyup","souris dessus":"mouseover","souris dehors":"mouseout",focus:"focus",focaliser:"focus",d\u00E9focus:"blur",d\u00E9focaliser:"blur",chargement:"load",charger:"load",d\u00E9filement:"scroll",d\u00E9filer:"scroll"},de:{klick:"click",klicken:"click",click:"click",eingabe:"input",eingeben:"input",\u00E4nderung:"change",\u00E4ndern:"change",absenden:"submit",einreichen:"submit","taste runter":"keydown","taste hoch":"keyup","maus \xFCber":"mouseover","maus raus":"mouseout",fokus:"focus",fokussieren:"focus",defokussieren:"blur",unsch\u00E4rfe:"blur",laden:"load",ladung:"load",scrollen:"scroll",bl\u00E4ttern:"scroll"},id:{klik:"click",click:"click",masukan:"input",input:"input",ubah:"change",perubahan:"change",kirim:"submit","tekan tombol":"keydown","lepas tombol":"keyup","mouse masuk":"mouseover","mouse keluar":"mouseout",fokus:"focus",blur:"blur",muat:"load",memuat:"load",gulir:"scroll",menggulir:"scroll"},bn:{\u0995\u09CD\u09B2\u09BF\u0995:"click",\u0987\u09A8\u09AA\u09C1\u099F:"input",\u099C\u09AE\u09BE:"submit",\u09B2\u09CB\u09A1:"load",\u09B8\u09CD\u0995\u09CD\u09B0\u09CB\u09B2:"scroll",\u09B0\u09BF\u09B8\u09BE\u0987\u099C:"resize",\u099D\u09BE\u09AA\u09B8\u09BE:"blur",\u09AB\u09CB\u0995\u09BE\u09B8:"focus",\u09AA\u09B0\u09BF\u09AC\u09B0\u09CD\u09A4\u09A8:"change"},qu:{click:"click","\xF1it'iy":"click",\u00F1itiy:"click",yaykuchiy:"input",yaykuy:"input",tikray:"change","t'ikray":"change",apachiy:"submit",kachay:"submit","llave uray":"keydown","llave hawa":"keyup","q'away":"focus",qhaway:"focus",paqariy:"blur","mana q'away":"blur",cargay:"load",apakuy:"load",apamuy:"load",kunray:"scroll",muyuy:"scroll",hatun_kay:"resize"},sw:{bofya:"click",click:"click",kubofya:"click",ingiza:"input",kubadilisha:"change",mabadiliko:"change",tuma:"submit",kutuma:"submit","bonyeza chini":"keydown","bonyeza juu":"keyup","panya juu":"mouseover","panya nje":"mouseout",lenga:"focus",kulenga:"focus",blur:"blur",pakia:"load",kupakia:"load",sogeza:"scroll",kusogeza:"scroll"}};var an={action:"toggle",description:"Toggle a class or attribute on/off",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to toggle",required:true,expectedTypes:["selector"],selectorKinds:["class","attribute"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],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)"}},cn={action:"add",description:"Add a class or attribute to an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to add",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES","PROPERTY_REQUIRES_VALUE"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"add command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to add",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers",PROPERTY_REQUIRES_VALUE:"When adding a property (*prop), provide a value argument"}},ln={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},un={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"}}],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"}},dn={action:"set",description:"Set a property or variable to a value",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The property or variable to set",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ja:"\u3092",ko:"\uB97C",tr:"i",ar:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The value to set",required:true,expectedTypes:["literal","expression","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",es:"a",pt:"para",fr:"\xE0",de:"auf",id:"ke",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",ar:"\u0625\u0644\u0649",sw:"kwenye",tl:"sa",bn:"\u09A4\u09C7",qu:"man"}}],errorCodes:["MISSING_TARGET","INVALID_TARGET","MISSING_VALUE","INVALID_SYNTAX"],preconditions:[{condition:"Command has a target variable or property",errorCode:"MISSING_TARGET",message:"set command requires a target"},{condition:"Target is a valid variable or property reference",errorCode:"INVALID_TARGET",message:"set command target must be a string or object literal"},{condition:'Value is specified with "to" keyword',errorCode:"MISSING_VALUE",message:'set command requires a value (use "to" keyword)'}],recoveryHints:{MISSING_TARGET:"Add a target: set :variable to value OR set element.property to value",INVALID_TARGET:'Use local variable (:name), element property (el.prop), or "the X of Y" syntax',MISSING_VALUE:'Add "to <value>" to specify what to set',INVALID_SYNTAX:"Use syntax: set <target> to <value>"}},pn={action:"show",description:"Make an element visible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to show",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},fn={action:"hide",description:"Make an element invisible",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The element to hide",required:true,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1},{role:"style",description:"Animation style (fade, slide, etc.)",required:false,expectedTypes:["literal"],svoPosition:2,sovPosition:2}]},mn={action:"on",description:"Handle an event",category:"event",primaryRole:"event",hasBody:true,roles:[{role:"event",description:"The event to handle",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to listen on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},hn={action:"trigger",description:"Trigger/dispatch an event",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to trigger (supports namespaced events like draggable:start)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},yn={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},vn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},gn={action:"increment",description:"Increment a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to increment",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to increment by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},bn={action:"decrement",description:"Decrement a numeric value",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to decrement",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"quantity",description:"Amount to decrement by (defaults to 1)",required:false,expectedTypes:["literal"],default:{type:"literal",value:1,dataType:"number"},svoPosition:2,sovPosition:2,markerOverride:{en:"by"}}]},En={action:"append",description:"Append content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to append",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to append to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},Sn={action:"prepend",description:"Prepend content to an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to prepend",required:true,expectedTypes:["literal","selector","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The element to prepend to",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"to"}}]},wn={action:"log",description:"Log a value to the console",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The value to log",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1}]},Tn={action:"get",description:"Get a value from a source",category:"variable",primaryRole:"source",roles:[{role:"source",description:"The source to get from",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2,markerOverride:{en:"",es:"",pt:"",fr:"",de:"",ja:"\u3092",zh:"",ko:"\uB97C",ar:"\u0639\u0644\u0649",tr:"i",id:"",sw:"",tl:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"destination",description:"Where to store the result (optional)",required:false,expectedTypes:["reference"],svoPosition:2,sovPosition:1}]},kn={action:"take",description:"Take content from a source element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The class or element to take",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to take from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},xn={action:"make",description:"Create a new element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element type or selector to create",required:true,expectedTypes:["literal","selector"],svoPosition:1,sovPosition:1}]},An={action:"halt",description:"Halt/stop execution or event propagation",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"What to halt (event, default, bubbling, etc.)",required:false,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Cn={action:"settle",description:"Wait for animations/transitions to settle",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"The element to settle (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Pn={action:"throw",description:"Throw an error",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The error message or object to throw",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Rn={action:"send",description:"Send an event to an element",category:"event",primaryRole:"event",roles:[{role:"event",description:"The event to send",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],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"}}]},Nn={action:"if",description:"Conditional execution",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},On={action:"unless",description:"Negated conditional execution (executes when condition is false)",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to evaluate (body executes when false)",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},_n={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},In={action:"repeat",description:"Repeat a block of commands",category:"control-flow",primaryRole:"loopType",hasBody:true,roles:[{role:"loopType",description:"Loop variant: forever, times, for, while, until, until-event",required:true,expectedTypes:["literal"],svoPosition:0,sovPosition:0},{role:"quantity",description:"Number of times to repeat",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"event",description:"Event to wait for (terminates loop)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"source",description:"Element to listen for event on",required:false,expectedTypes:["selector","reference"],svoPosition:3,sovPosition:3}],notes:'Can also use "repeat forever", "repeat until condition", or "repeat until event X from Y"'},Mn={action:"for",description:"Iterate over a collection",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The iteration variable",required:true,expectedTypes:["reference"],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"}}]},Ln={action:"while",description:"Loop while condition is true",category:"control-flow",primaryRole:"condition",hasBody:true,roles:[{role:"condition",description:"The condition to check",required:true,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},$n={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Dn={action:"go",description:"Navigate to a URL",category:"navigation",primaryRole:"destination",roles:[{role:"destination",description:"The URL to navigate to",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"},renderOverride:{en:""}}]},Bn={action:"transition",description:"Transition an element with animation",category:"dom-visibility",primaryRole:"patient",roles:[{role:"patient",description:"The property to transition (opacity, *background-color, etc.)",required:true,expectedTypes:["literal"],svoPosition:1,sovPosition:2,markerOverride:{en:"",ar:"",tl:"",sw:""}},{role:"goal",description:"The target value to transition to",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:3,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man",es:"a",pt:"para",fr:"\xE0",de:"auf",ja:"\u306B",ko:"\uC73C\uB85C",tr:"e",id:"ke"}},{role:"destination",description:"The target element (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:3,sovPosition:1},{role:"duration",description:"Transition duration (over 500ms, for 2 seconds)",required:false,expectedTypes:["literal"],svoPosition:4,sovPosition:4,markerOverride:{en:"over"}},{role:"style",description:"Easing function (ease-in, linear, etc.)",required:false,expectedTypes:["literal"],svoPosition:5,sovPosition:5}]},Vn={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},zn={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},qn={action:"blur",description:"Remove focus from an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to blur (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Fn={action:"call",description:"Call a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The function to call",required:true,expectedTypes:["expression","reference"],svoPosition:1,sovPosition:1}]},Wn={action:"return",description:"Return a value from a function",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The value to return",required:false,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1}]},jn={action:"js",description:"Execute raw JavaScript code",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The JavaScript code to execute",required:false,expectedTypes:["expression"],svoPosition:1,sovPosition:1}]},Un={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Kn={action:"tell",description:"Execute commands in context of another element",category:"control-flow",primaryRole:"destination",hasBody:true,roles:[{role:"destination",description:"The element to tell",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}}]},Gn={action:"default",description:"Set a default value for a variable",category:"variable",primaryRole:"destination",roles:[{role:"destination",description:"The variable to set default for",required:true,expectedTypes:["reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"",ar:"",tl:"",sw:"",bn:"\u0995\u09C7",qu:"ta"}},{role:"patient",description:"The default value",required:true,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"to",ar:"\u0625\u0644\u0649",tl:"sa",sw:"kwenye",bn:"\u09A4\u09C7",qu:"man"}}]},Hn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Yn={action:"behavior",description:"Define a reusable behavior",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[{role:"patient",description:"The behavior name (PascalCase identifier)",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1}]},Xn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},Jn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Qn={action:"swap",description:"Swap DOM content using various strategies (innerHTML, outerHTML, delete, etc.)",category:"dom-content",primaryRole:"destination",roles:[{role:"method",description:"The swap strategy (innerHTML, outerHTML, beforebegin, afterend, delete)",required:false,expectedTypes:["literal"],svoPosition:1,sovPosition:3,markerOverride:{en:""}},{role:"destination",description:"The element to swap content in/for",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"of"}},{role:"patient",description:"The content to swap in (optional for delete)",required:false,expectedTypes:["literal","expression","selector"],svoPosition:3,sovPosition:2,markerOverride:{en:"with"}}]},Zn={action:"morph",description:"Morph an element into another using DOM diffing",category:"dom-content",primaryRole:"destination",roles:[{role:"destination",description:"The element to morph",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:""}},{role:"patient",description:"The target content/element to morph into",required:true,expectedTypes:["literal","expression","selector"],svoPosition:2,sovPosition:2,markerOverride:{en:"to"}}]},eo={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}]},to={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},ro={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}]},no={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},oo={action:"pick",description:"Select a random element from a collection",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The items to pick from",required:true,expectedTypes:["literal","expression","reference"],svoPosition:1,sovPosition:1},{role:"source",description:'The array to pick from (with "from" keyword)',required:false,expectedTypes:["reference","expression"],svoPosition:2,sovPosition:2}]},io={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},yt={toggle:an,add:cn,remove:ln,put:un,set:dn,show:pn,hide:fn,on:mn,trigger:hn,wait:yn,fetch:vn,increment:gn,decrement:bn,append:En,prepend:Sn,log:wn,get:Tn,take:kn,make:xn,halt:An,settle:Cn,throw:Pn,send:Rn,if:Nn,unless:On,else:_n,repeat:In,for:Mn,while:Ln,continue:$n,go:Dn,transition:Bn,clone:Vn,focus:zn,blur:qn,call:Fn,return:Wn,js:jn,async:Un,tell:Kn,default:Gn,init:Hn,behavior:Yn,install:Xn,measure:Jn,swap:Qn,morph:Zn,beep:eo,break:to,copy:ro,exit:no,pick:oo,render:io,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function so(){return Object.values(yt).filter(n=>n.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Wr(),at)).then(({validateAllSchemas:n,formatValidationResults:e})=>{let t=n(yt);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(n=>{console.debug("Schema validation skipped:",n);});var tt=class extends Error{constructor(n,e,t,r){super(n),this.name="SemanticParseError",this.language=e,this.input=t,this.diagnostics=r;}};function P(n,e,t){return {message:n,severity:e,source:"semantic-parser",...t&&{code:t}}}function le(n,e){return e.length===0?n:{...n,diagnostics:e}}var G=class N{parse(e,t){let{modifiers:r,remainingInput:o}=this.extractStandaloneModifiers(e,t),i=o||e,s=[],a=be(i,t),c=F(t);if(c.length===0)throw new tt(`No patterns available for language: ${t}`,t,i,[P(`No patterns registered for language '${t}'`,"error","no-patterns")]);let u=[...c].sort((y,g)=>g.priority-y.priority),l=u.filter(y=>y.command==="on"),d=q.matchBest(a,l);if(d){s.push(P(`event pattern matched: ${d.pattern.id} (confidence: ${d.confidence.toFixed(2)})`,"info","pattern-match"));let y=this.buildEventHandler(d,a,t),g=r?this.applyModifiers(y,r):y;return le(g,s)}s.push(P(`event patterns: ${l.length} tried, no match`,"info","stage-event"));let p=u.filter(y=>y.command!=="on"),f=q.matchBest(a,p);if(f)return s.push(P(`command pattern matched: ${f.pattern.id} (confidence: ${f.confidence.toFixed(2)})`,"info","pattern-match")),le(this.buildCommand(f,t),s);s.push(P(`command patterns: ${p.length} tried, no match`,"info","stage-command"));let m=this.trySOVEventExtraction(i,t,u);if(m){s.push(P("SOV event extraction succeeded","info","stage-sov"));let y=r?this.applyModifiers(m,r):m;return le(y,s)}s.push(P("SOV event extraction: no event keyword found","info","stage-sov"));let v=this.tryCompoundCommandParsing(a,p,t);if(v)return s.push(P("compound command parsing succeeded","info","stage-compound")),le(v,s);throw s.push(P("compound parsing: no then-keywords or no command matches","info","stage-compound")),s.push(P(`all parse stages exhausted for "${i}"`,"error","parse-failed")),new tt(`Could not parse input in ${t}: ${i}`,t,i,s)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return ht()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[o,i]of e.captured)r[o]=i;return ae(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let o=e.captured.get("event");if(!o)throw new Error("Event handler pattern matched but no event captured");let i=q.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,r),a=o;s.length>0&&o.type==="literal"&&(a={type:"literal",value:[String(o.value),...s.map(d=>String("value"in d?d.value:""))].join(" or ")});let c,u=e.captured.get("action");if(u&&u.type==="literal"){let l=u.value,d={};for(let[m,v]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(d[m]=v);let p=ae(l,d,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=F(r).filter(g=>g.command!=="on").sort((g,E)=>E.priority-g.priority),v=F(r).filter(g=>g.id.startsWith("grammar-")&&g.id.includes("-continuation")).sort((g,E)=>E.priority-g.priority),y=this.parseBodyWithGrammarPatterns(t,m,v,r);y.length>0?c=[p,...y]:c=[p];}else c=[p];}else {let l=F(r).filter(d=>d.command!=="on").sort((d,p)=>p.priority-d.priority);c=this.parseBodyWithClauses(t,l,r);}return He(a,c,i,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let o=[],i=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),c=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(i.length>0){let u=this.parseClause(i,t,r);o.push(...u),i.length=0;}e.advance();continue}if(c){if(i.length>0){let u=this.parseClause(i,t,r);o.push(...u);}e.advance();break}i.push(s),e.advance();}if(i.length>0){let s=this.parseClause(i,t,r);o.push(...s);}return o.length>1?[Ye(o,"then",{sourceLanguage:r})]:o}parseClause(e,t,r){if(e.length===0)return [];let o=new L(e,r),i=[];for(;!o.isAtEnd();){let s=q.matchBest(o,t);s?i.push(this.buildCommand(s,r)):o.advance();}if(i.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,r);if(s.length>0)return s}return i}static buildVerbLookup(e){let t=new Map;for(let[r,o]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(r)&&(t.set(o.primary.toLowerCase(),r),o.alternatives))for(let i of o.alternatives)t.set(i.toLowerCase(),r);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[r,o]of Object.entries(e.roleMarkers))if(o&&(t.set(o.primary,r),o.alternatives))for(let i of o.alternatives)t.has(i)||t.set(i,r);return t}parseSOVClauseByVerbAnchoring(e,t){let r=D(t);if(!r||r.wordOrder!=="SOV")return [];let o=N.buildVerbLookup(r),i=N.buildMarkerToRoleLookup(r),s=[],a=0;for(;a<e.length;){let c=-1,u="";for(let m=a;m<e.length;m++){let v=e[m],y=o.get(v.value.toLowerCase()),g=v.normalized?o.get(v.normalized.toLowerCase()):void 0,E=y||g;if(E){c=m,u=E;break}}if(c===-1)break;let l=e.slice(a,c),d=e.length;for(let m=c+1;m<e.length;m++){let v=e[m];if(v.kind==="conjunction"||this.isThenKeyword(v.value,t)){d=m;break}if(m>c+1&&(o.get(v.value.toLowerCase())||(v.normalized?o.get(v.normalized.toLowerCase()):void 0))){d=m;break}}let p=e.slice(c+1,d),f=this.extractRolesFromMarkedTokens(l,p,i,u,t);if(s.push(ae(u,f,{sourceLanguage:t,confidence:.7})),a=d,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,r,o,i){let s={},a=c=>{let u=[];for(let l of c){let d=r.get(l.value);if(d&&l.kind==="particle"&&u.length>0){let p=this.tokensToSemanticValue(u);if(p){let f=this.mapRoleForCommand(d,o,s);f&&(s[f]=p);}u=[];}else u.push(l);}if(u.length>0){let l=this.tokensToSemanticValue(u);l&&(s.patient?s.destination||(s.destination=l):s.patient=l);}};return a(e),a(t),s}mapRoleForCommand(e,t,r){return r[e]?e==="patient"&&!r.destination?"destination":e==="destination"&&!r.patient?"patient":e==="source"&&!r.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(i=>i.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let r=t.map(i=>i.value).join(""),o=t[0];return o.kind==="selector"||o.value.startsWith("#")||o.value.startsWith(".")||o.value.startsWith("@")||o.value.startsWith("*")?Z(r):o.kind==="literal"||o.value.startsWith('"')||o.value.startsWith("'")?T(r):o.kind==="reference"?$(r):T(r)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return Z(t);if(t.startsWith('"')||t.startsWith("'"))return T(t);if(/^-?\d+(\.\d+)?$/.test(t))return T(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return T(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return T(false);let r=e.normalized?.toLowerCase();return r==="me"||r==="it"||r==="you"||r==="result"||r==="body"?$(r):e.kind==="reference"?$(e.normalized||"me"):T(t)}parseBodyWithGrammarPatterns(e,t,r,o){let i=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,o)){e.advance();continue}if(s&&this.isEndKeyword(s.value,o)){e.advance();break}let a=false;if(r.length>0){let c=q.matchBest(e,r);if(c){let u=c.pattern.command,l={};for(let[f,m]of c.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(l[f]=m);let d=ae(u,l,{sourceLanguage:o,patternId:c.pattern.id});i.push(d),a=true;let p=c.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!a){let c=q.matchBest(e,t);c&&(i.push(this.buildCommand(c,o)),a=true);}a||e.advance();}return i}tryCompoundCommandParsing(e,t,r){let o=e.tokens;if(!o.some(c=>c.kind==="conjunction"||c.kind==="keyword"&&this.isThenKeyword(c.value,r)))return null;let s=new L(o,r),a=this.parseBodyWithClauses(s,t,r);return a.length===0?null:a.length===1?a[0]:Ye(a,"then",{sourceLanguage:r,confidence:.65})}trySOVEventExtraction(e,t,r){let o=N.SOV_EVENT_MARKERS[t];if(!o)return null;let s=be(e,t).tokens,a=on[t],c=new Set;if(a)for(let b of Object.keys(a))c.add(b.toLowerCase());let u=N.SOV_SOURCE_MARKERS[t],l=-1,d="",p="",f=1;for(let b=0;b<s.length;b++){let k=s[b],O=k.value.toLowerCase(),_=O,B="",pe=O.indexOf("[");pe>0&&(_=O.slice(0,pe),B=k.value.slice(pe));let fe=k.normalized?.toLowerCase(),Ne=fe&&N.KNOWN_EVENTS.has(fe),Oe=c.has(O)||c.has(_),Rt=N.KNOWN_EVENTS.has(_);if(Ne||Oe||Rt){let H;if(Ne?H=fe:Oe?H=a?.[O]??a?.[_]??_:H=_,o.size>0){let ne=1,me=s[b+1];me&&me.kind==="selector"&&me.value.startsWith("[")&&(ne=2);let oe=s[b+ne];if(oe&&(oe.kind==="particle"||oe.kind==="keyword")&&o.has(oe.value)){l=b,d=H,p=B||(ne===2?s[b+1].value:""),f=ne+1;break}}else {l=b,d=H,p=B,f=1;break}}}if(l===-1)return null;let m=new Set;for(let b=l;b<l+f;b++)m.add(b);if(u){let b=l+f;if(b<s.length){let k=s[b];(k.kind==="particle"||k.kind==="keyword")&&u.markers.has(k.value)&&m.add(b);}for(let k=0;k<l;k++){let O=s[k],_=O.value.toLowerCase(),B=O.normalized?.toLowerCase();if(u.windowTokens.has(_)||B&&u.windowTokens.has(B)){m.add(k);break}}}let v=s.filter((b,k)=>!m.has(k));if(v.length===0)return null;let y=r.filter(b=>b.command!=="on"),g=new L(v,t),E=this.parseBodyWithClauses(g,y,t);if(E.length===0)return null;let Re={sourceLanguage:t,confidence:.75};return p&&(Re.keyFilter=p),He({type:"literal",value:d},E,void 0,Re)}isThenKeyword(e,t){let r={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (r[t]||r.en).has(e.toLowerCase())}isEndKeyword(e,t){let r={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (r[t]||r.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let o=be(e,t).tokens;if(o.length===0)return {modifiers:null,remainingInput:null};let s=o[0].value.toLowerCase(),a=N.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let c={},u=1;if(a==="once")c.once=true;else {let f=1;if(f<o.length){let m=o[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,u++);}if(f<o.length){let m=o[f];if(m.kind==="literal"){let v=m.value.match(/^(\d+)(ms|s|m)?$/);if(v){let y=parseInt(v[1],10),g=v[2]||"ms";g==="s"?y*=1e3:g==="m"&&(y*=6e4),c[a]=y,u=f+1;}}}c[a]||(c[a]=a==="debounce"?300:100);}let l=o.slice(u);if(l.length===0)return {modifiers:null,remainingInput:null};let d=l[0].position.start,p=e.slice(d);return {modifiers:c,remainingInput:p}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let r=[];for(;;){let o=e.mark(),i=e.peek();if(!i)break;let s=(i.normalized||i.value).toLowerCase();if(!N.OR_KEYWORDS.has(s)){e.reset(o);break}e.advance();let a=e.peek();if(!a){e.reset(o);break}let c=(a.normalized||a.value).toLowerCase();e.advance(),r.push({type:"literal",value:c});}return r}};G.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);G.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"])};G.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"])}};G.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};G.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var ao=G,co=new ao;function ke(n,e){return co.parse(n,e)}var we=class{constructor(n={}){this.cache=new Map,this.config={maxSize:n.maxSize??1e3,ttlMs:n.ttlMs??0,enabled:n.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(n,e){return `${e}:${n}`}isExpired(n){return this.config.ttlMs===0?false:Date.now()-n.createdAt>this.config.ttlMs}evictLRU(){let n=this.cache.keys().next().value;n!==void 0&&(this.cache.delete(n),this.stats.evictions++);}get(n,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(n,e),r=this.cache.get(t);if(!r){this.stats.misses++;return}if(this.isExpired(r)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),r.lastAccessed=Date.now(),this.cache.set(t,r),this.stats.hits++,r.result}set(n,e,t){if(!this.config.enabled||t.confidence===0)return;let r=this.makeKey(n,e),o=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(r,{result:t,createdAt:o,lastAccessed:o});}has(n,e){if(!this.config.enabled)return false;let t=this.makeKey(n,e),r=this.cache.get(t);return r?this.isExpired(r)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(n,e){let t=this.makeKey(n,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let n=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:n>0?this.stats.hits/n:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(n){if(n.maxSize!==void 0)for(this.config.maxSize=n.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();n.ttlMs!==void 0&&(this.config.ttlMs=n.ttlMs),n.enabled!==void 0&&(this.config.enabled=n.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},lo=new we;var uo=class{constructor(n={}){this.patternMatcher=new mt,this.languages=new Set(ft()),n.cache===false?this.cache=new we({enabled:false}):this.cache=n.cache?new we(n.cache):lo;}analyze(n,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(n,e);if(t)return t;let r=this.analyzeUncached(n,e);return this.cache.set(n,e,r),r}analyzeUncached(n,e){try{try{let s=ke(n,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=nn(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let r=t.tokenize(n),o=F(e);if(o.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let i=this.patternMatcher.matchBest(r,o);if(i){let s=this.buildSemanticNode(i);return {confidence:i.confidence,command:{name:i.pattern.command,roles:i.captured},node:s,tokensConsumed:i.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(n){return this.languages.has(n)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(n){this.cache.configure(n);}buildSemanticNode(n){return {kind:"command",action:n.pattern.command,roles:n.captured,metadata:{patternId:n.pattern.id}}}};function vt(n){return new uo(n)}var po=.5;function gt(n,e=po){return n.confidence>=e&&n.command!==void 0}function bt(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...n].sort((r,o)=>{let i=r[t]??99,s=o[t]??99;return i-s})}function fo(n,e){let t=n.markerOverride?.[e.code],r=e.roleMarkers[n.role];if(t!==void 0)return {primary:t,position:r?.position??"before",isOverride:true};if(r&&r.primary){let o={primary:r.primary,position:r.position,isOverride:false};return r.alternatives&&(o.alternatives=r.alternatives),o}return null}function mo(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let l of u)i.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}}let s=e.roleMarkers.destination;s&&i.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};i.push(u);}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(c),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ho(n,e,t,r,o){let i=[];i.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};i.push(c);}if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)i.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(a),{id:`${n.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(o.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function yo(n,e,t,r,o){let i=[];i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(u);}let a=e.roleMarkers.destination;if(a&&(i.push({type:"role",role:"destination",optional:false}),i.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),i.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let l of u)i.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(c),{id:`${n.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(o.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function vo(n,e,t,r,o){let i=[];i.push({type:"role",role:"event",optional:false});let s=r.alternatives?.filter(l=>!l.includes(" ")&&l.length>1)||[];s.length>0&&i.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&i.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),i.push({type:"role",role:"patient",optional:false});let c=e.roleMarkers.patient;if(c){let l=c.alternatives?{type:"literal",value:c.primary,alternatives:c.alternatives}:{type:"literal",value:c.primary};i.push(l);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(u),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(o.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function go(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let c of a)i.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(s),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function bo(n,e,t,r){let o=e.eventHandler?.temporalMarkers;if(!o||o.length===0)return null;let i=[];i.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&i.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),i.push({type:"literal",value:o[0],alternatives:o.slice(1)}),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(c);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return i.push(a),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${o[0]} {patient} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function Eo(n,e,t,r,o){let i=[];if(i.push({type:"role",role:"event",optional:false}),r.position==="after"){let l=r.primary.split(/\s+/);if(l.length>1)for(let d of l)i.push({type:"literal",value:d});else {let d=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(d);}}let a=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.sovPosition??999,f=d.sovPosition??999;return p-f});for(let l of a){i.push({type:"role",role:l.role,optional:false});let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(c);let u=a.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`{event} ${r.primary} ${u} ${t.primary}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(a.map(l=>[l.role,{fromRole:l.role}]))}}}function So(n,e,t,r,o){let i=[],a=[...n.roles.filter(m=>m.required)].sort((m,v)=>{let y=m.sovPosition??999,g=v.sovPosition??999;return y-g}),c=a[0];i.push({type:"role",role:c.role,optional:false});let u;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)u=c.markerOverride[e.code];else {let m=e.roleMarkers[c.role];m&&(u=m.primary);}if(u&&i.push({type:"literal",value:u}),i.push({type:"role",role:"event",optional:false}),r.position==="after"){let m=r.primary.split(/\s+/);if(m.length>1)for(let v of m)i.push({type:"literal",value:v});else {let v=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(v);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(l);let d=a[1];i.push({type:"role",role:d.role,optional:false});let p,f;if(d.markerOverride&&d.markerOverride[e.code]!==void 0)p=d.markerOverride[e.code];else {let m=e.roleMarkers[d.role];m&&(p=m.primary,f=m.alternatives);}if(p){let m=f?{type:"literal",value:p,alternatives:f}:{type:"literal",value:p};i.push(m);}return {id:`${n.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`{${c.role}} {event} ${r.primary} ${t.primary} {${d.role}}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},[c.role]:{fromRole:c.role},[d.role]:{fromRole:d.role}}}}function rt(n,e,t,r,o){let i=[];if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c);}i.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&i.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(o.basePriority??100)+50,template:{format:`${r.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function wo(n,e,t,r,o){let i=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s),i.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&i.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(c);}return i.push({type:"role",role:"event",optional:false}),{id:`${n.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(o.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${r.primary} {event}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function To(n,e,t,r,o){let i=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s);let c=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.svoPosition??999,f=d.svoPosition??999;return p-f});for(let l of c){let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}i.push({type:"role",role:l.role,optional:false});}if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}i.push({type:"role",role:"event",optional:false});let u=c.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`${t.primary} ${u} ${r.primary} {event}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(c.map(l=>[l.role,{fromRole:l.role}]))}}}function nt(n,e,t,r,o){let i=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(l);}i.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(s);let c=[...n.roles.filter(l=>l.required)].sort((l,d)=>{let p=l.svoPosition??999,f=d.svoPosition??999;return p-f});for(let l of c){let d,p;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)d=l.markerOverride[e.code];else {let f=e.roleMarkers[l.role];f&&(d=f.primary,p=f.alternatives);}if(d){let f=p?{type:"literal",value:d,alternatives:p}:{type:"literal",value:d};i.push(f);}i.push({type:"role",role:l.role,optional:false});}let u=c.map(l=>`{${l.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(o.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${u}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(c.map(l=>[l.role,{fromRole:l.role}]))}}}function ko(n,e,t,r,o){let i=[],s=e.eventHandler?.negationMarker;if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};i.push(u);}if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};i.push(u);}i.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(a),i.push({type:"role",role:"patient",optional:false});let c=e.roleMarkers.destination;return c&&i.push({type:"group",optional:true,tokens:[c.alternatives?{type:"literal",value:c.primary,alternatives:c.alternatives}:{type:"literal",value:c.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(o.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${c?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function xo(n,e,t,r){let o=[];o.push({type:"literal",value:"and",alternatives:["then"]}),o.push({type:"role",role:"event",optional:false});let i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(i),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&o.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var ee={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function Et(n,e,t=ee){let r=`${n.action}-${e.code}-generated`,o=t.basePriority??100,i=e.keywords[n.action];if(!i)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let s=Ro(n,e,i),a=wt(n,e),c=Io(n,e,i);return {id:r,language:e.code,command:n.action,priority:o,template:{format:c,tokens:s},extraction:a}}function Ao(n,e,t=ee){if(n.roles.filter(a=>!a.required).length===0)return null;let o=n.roles.filter(a=>a.required),i={...n,roles:o};return {...Et(i,e,t),id:`${n.action}-${e.code}-generated-simple`,priority:(t.basePriority??100)-5,extraction:wt(n,e)}}function Co(n,e,t=ee){let r=[];if(r.push(Et(n,e,t)),t.generateSimpleVariants){let o=Ao(n,e,t);o&&r.push(o);}return r}function St(n,e=ee){let t=[],r=so();for(let o of r){if(!n.keywords[o.action])continue;let i=Co(o,n,e);if(t.push(...i),n.eventHandler?.eventMarker){let s=Po(o,n,e);t.push(...s);}}return t}function Po(n,e,t=ee){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let r=[],o=e.eventHandler.eventMarker,i=e.keywords[n.action];if(!i)return [];let a=n.roles.filter(c=>c.required).length===2;if(e.wordOrder==="SOV")if(a)r.push(Eo(n,e,i,o,t)),r.push(So(n,e,i,o,t));else {r.push(mo(n,e,i,o,t)),r.push(ho(n,e,i,o,t));let c=e.roleMarkers.destination;c&&c.primary!==o.primary&&r.push(yo(n,e,i,o,t));let u=o.primary.split(/\s+/),l=o.alternatives?.some(p=>!p.includes(" ")&&p.length>1);u.length>1&&l&&r.push(vo(n,e,i,o,t)),r.push(go(n,e,i,o,t));let d=bo(n,e,i,t);d&&r.push(d);}else e.wordOrder==="VSO"?a?(r.push(nt(n,e,i,o,t)),r.push(To(n,e,i,o,t))):(r.push(rt(n,e,i,o,t)),r.push(wo(n,e,i,o,t)),e.eventHandler?.negationMarker&&r.push(ko(n,e,i,o,t)),e.tokenization?.prefixes&&r.push(xo(n,e,i,t))):a?r.push(nt(n,e,i,o,t)):r.push(rt(n,e,i,o,t));return r}function Ro(n,e,t){let r=[],o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},i=No(n,e);switch(e.wordOrder){case "SVO":r.push(o),r.push(...i);break;case "SOV":r.push(...i),r.push(o);break;case "VSO":r.push(o),r.push(...i);break;default:r.push(o),r.push(...i);}return r}function No(n,e){let t=[],r=bt(n.roles,e.wordOrder);for(let o of r){let i=Oo(o,e);o.required?t.push(...i):t.push({type:"group",optional:true,tokens:i});}return t}function Oo(n,e){let t=[],r=n.markerOverride?.[e.code],o=e.roleMarkers[n.role],i={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(o?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(i)):(t.push(i),r&&t.push({type:"literal",value:r}));else if(o)if(o.position==="before"){if(o.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(s);}t.push(i);}else {t.push(i);let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};t.push(s);}else t.push(i);return t}function _o(n,e){let t={};for(let r of n.roles){let o=r.markerOverride?.[e.code],i=e.roleMarkers[r.role];o!==void 0?t[r.role]=o?{marker:o}:{}:i&&i.primary?t[r.role]=i.alternatives?{marker:i.primary,markerAlternatives:i.alternatives}:{marker:i.primary}:t[r.role]={};}return t}function wt(n,e){let t=_o(n,e),r={};for(let o of n.roles){let i=t[o.role]||{};!o.required&&o.default?r[o.role]={...i,default:o.default}:r[o.role]=i;}return r}function Io(n,e,t){let r=[],i=bt(n.roles,e.wordOrder).map(s=>{let a=fo(s,e),c="";return a&&a.primary?a.position==="before"?c=`${a.primary} {${s.role}}`:c=`{${s.role}} ${a.primary}`:c=`{${s.role}}`,s.required?c:`[${c}]`});switch(e.wordOrder){case "SVO":case "VSO":r.push(t.primary,...i);break;case "SOV":r.push(...i,t.primary);break;default:r.push(t.primary,...i);}return r.join(" ")}function de(n){let e=n.getAttribute("data-lang");if(e)return xe(e);let t=n.getAttribute("data-hyperscript-lang")??n.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return xe(t);let r=typeof document<"u"?document.documentElement?.lang:null;return r&&r!=="en"?xe(r):null}function xe(n){return n.split("-")[0].toLowerCase()}var Tt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function re(n){switch(n.kind){case "event-handler":return Mo(n);case "compound":return Lo(n);default:return $o(n)}}function Mo(n){let e=["on"],t=n.roles.get("event");t&&e.push(te(t));let r=n.roles.get("source");if(r&&e.push("from",te(r)),n.body&&n.body.length>0){let o=n.body.map(re);e.push(o.join(" then "));}return e.join(" ")}function Lo(n){let e=n.chainType==="async"?"async":n.chainType;return n.statements.map(re).join(` ${e} `)}function $o(n){let e=Tt[n.action];if(e){let r=[n.action];for(let[o,i]of e){let s=n.roles.get(o);s&&(o==="destination"&&s.type==="reference"&&s.value==="me"||(i&&r.push(i),r.push(te(s))));}return r.join(" ")}let t=[n.action];for(let[,r]of n.roles)t.push(te(r));return t.join(" ")}function te(n){switch(n.type){case "literal":return typeof n.value=="string"&&n.dataType==="string"?`"${n.value}"`:String(n.value);case "selector":return n.value;case "reference":return n.value;case "property-path":return Do(n);case "expression":return n.raw;case "flag":return n.enabled?`+${n.name}`:`~${n.name}`}}function Do(n){let e=te(n.object),t=n.property;if(n.object.type==="reference")switch(n.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var xt=.5,Bo={confidenceThreshold:xt,strategy:"semantic",fallbackToOriginal:true};function Vo(n,e){return typeof n=="number"?n:n[e]??n["*"]??xt}var Ae=null;function zo(){return Ae||(Ae=vt()),Ae}function Ce(n,e,t={}){let r={...Bo,...t},o=kt(n,e,r);if(o!==null)return o;let i=Fo(n);if(i){let s=kt(i.commands,e,r);if(s!==null)return i.prefix+s}return n}function kt(n,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let r=Vo(t.confidenceThreshold,e),o=At(n,e,r);if(o!==null)return o}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let r=Wo(n,e,t.i18nToEnglish);if(r!==null)return r}return null}var qo=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Fo(n){let e=n.match(qo);if(!e)return null;let t=e[1],r=n.slice(t.length);return r?{prefix:t,commands:r}:null}function At(n,e,t){try{let r=Uo(n,e);if(r.length>1)return Ko(r,e,t);let o=zo();if(!o.supportsLanguage(e))return null;let i=o.analyze(n,e);if(!gt(i,t))return null;if(i.node)return re(i.node);let s=ke(n,e);return re(s)}catch{return null}}function Wo(n,e,t){try{let r=t(n,e);return r!==n?r:null}catch{return null}}function jo(n){let e=["then"],t=D(n);if(t?.keywords?.then){let r=t.keywords.then;if(r.primary&&r.primary!=="then"&&e.push(r.primary),r.alternatives)for(let o of r.alternatives)e.includes(o)||e.push(o);}return e}function Uo(n,e){let r=jo(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`\\s+(?:${r.join("|")})\\s+`,"i"),i=n.split(`
4
+ `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of i){let c=a.split(o);s.push(...c);}return s}function Ko(n,e,t){let r=[];for(let o of n){let i=At(o.trim(),e,t);if(i===null)return null;r.push(i);}return r.join(" then ")}function Pe(n={}){return function(t){let{internals:r}=t,o=r.runtime,i=o.getScript.bind(o);o.getScript=function(s){let a=i(s);if(!a)return null;let c=Go(s,n);if(!c||c==="en")return a;let u=Ce(a,c,n);return n.debug&&u!==a&&console.log(`[hyperscript-i18n] ${c}: "${a}" \u2192 "${u}"`),u};}}function Go(n,e){if(e.languageAttribute){let r=n.getAttribute(e.languageAttribute);if(r)return r.split("-")[0].toLowerCase()}let t=de(n);return t||(e.defaultLanguage??null)}function Ct(n,e,t={}){return e==="en"?n:Ce(n,e,t)}pt(n=>St(n));function Pt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Pe()),Ho());}function Ho(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(r=>{let o=e.getInternalData(r);o.initialized&&(o.initialized=false);}),e.processNode(document.body);}var ls=["ar"];Pt();exports.plugin=Pe;exports.preprocess=Ct;exports.resolveLanguage=de;exports.supportedLanguages=ls;return exports;})({});