@hyperscript-tools/multilingual 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +118 -0
- package/dist/hyperscript-i18n-ar.global.js +4 -0
- package/dist/hyperscript-i18n-bn.global.js +4 -0
- package/dist/hyperscript-i18n-de.global.js +4 -0
- package/dist/hyperscript-i18n-east-asian.global.js +4 -0
- package/dist/hyperscript-i18n-en.global.js +6 -0
- package/dist/hyperscript-i18n-es.global.js +4 -0
- package/dist/hyperscript-i18n-fr.global.js +4 -0
- package/dist/hyperscript-i18n-he.global.js +4 -0
- package/dist/hyperscript-i18n-hi.global.js +4 -0
- package/dist/hyperscript-i18n-id.global.js +4 -0
- package/dist/hyperscript-i18n-it.global.js +4 -0
- package/dist/hyperscript-i18n-ja.global.js +4 -0
- package/dist/hyperscript-i18n-ko.global.js +4 -0
- package/dist/hyperscript-i18n-lite.global.js +1 -0
- package/dist/hyperscript-i18n-ms.global.js +4 -0
- package/dist/hyperscript-i18n-pl.global.js +4 -0
- package/dist/hyperscript-i18n-pt.global.js +4 -0
- package/dist/hyperscript-i18n-qu.global.js +4 -0
- package/dist/hyperscript-i18n-ru.global.js +4 -0
- package/dist/hyperscript-i18n-slavic.global.js +4 -0
- package/dist/hyperscript-i18n-south-asian.global.js +4 -0
- package/dist/hyperscript-i18n-southeast-asian.global.js +4 -0
- package/dist/hyperscript-i18n-sw.global.js +4 -0
- package/dist/hyperscript-i18n-th.global.js +4 -0
- package/dist/hyperscript-i18n-tl.global.js +4 -0
- package/dist/hyperscript-i18n-tr.global.js +4 -0
- package/dist/hyperscript-i18n-uk.global.js +4 -0
- package/dist/hyperscript-i18n-vi.global.js +4 -0
- package/dist/hyperscript-i18n-western.global.js +4 -0
- package/dist/hyperscript-i18n-zh.global.js +4 -0
- package/dist/hyperscript-i18n.global.js +63 -0
- package/package.json +101 -4
- package/scripts/copy-bundles.mjs +25 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var HyperscriptI18n=(function(exports){'use strict';function B(i,e){return e?{type:"literal",value:i,dataType:e}:{type:"literal",value:i}}function ne(i,e){return e?{type:"selector",value:i,selectorKind:e}:{type:"selector",value:i}}function H(i){return {type:"reference",value:i}}function oe(i,e){return {type:"property-path",object:i,property:e}}var xe=new Set(["me","you","it","result","event","target","body"]);function fe(i,e=xe){return e.has(i)}var kr=class{constructor(i){this.namespace=i,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let i=process.env.DEBUG||"";return i==="*"||i.includes("framework:*")||i.includes(`framework:${this.namespace}`)}return false}log(i,e,...r){if(!this.enabled)return;let t=`[framework:${this.namespace}]`,a=new Date().toISOString();switch(i){case "debug":console.debug(`${a} ${t} DEBUG:`,e,...r);break;case "info":console.info(`${a} ${t} INFO:`,e,...r);break;case "warn":console.warn(`${a} ${t} WARN:`,e,...r);break;case "error":console.error(`${a} ${t} ERROR:`,e,...r);break}}debug(i,...e){this.log("debug",i,...e);}info(i,...e){this.log("info",i,...e);}warn(i,...e){this.log("warn",i,...e);}error(i,...e){this.log("error",i,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function br(i){return new kr(i)}function j(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Cr(i,e){return i?.possessive?.keywords?.[e]}var Y=class ${constructor(){this.logger=br("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,r,t){let a=e.mark(),n=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",r.id),this.logger.debug("Pattern command:",r.command),this.logger.debug("Pattern language:",r.language),this.logger.debug("Pattern template:",JSON.stringify(r.template,null,2)),this.logger.isEnabled()){let s=[];for(let l=0;l<10;l++){let c=e.peek(l);if(c)s.push({type:c.type,value:c.value,kind:c.kind});else break}this.logger.debug("Input tokens (first 10):",s),this.logger.debug("Profile code:",t?.code);}this.currentProfile=t,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(r.template.tokens,null,2));let o=this.matchTokenSequence(e,r.template.tokens,n);if(this.logger.debug("matchTokenSequence returned:",o),this.logger.debug("Captured roles:",Array.from(n.entries()).map(([s,l])=>[s,JSON.stringify(l)])),!o)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(a),null;let u=this.calculateConfidence(r,n);return this.applyExtractionRules(r,n),{pattern:r,captured:n,consumedTokens:e.position()-a.position,confidence:u}}matchBest(e,r,t){let a=[];for(let o of r){let u=e.mark(),s=this.matchPattern(e,o,t);s&&a.push(s),e.reset(u);}if(a.length===0)return null;a.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;if(s!==0)return s;let l=u.confidence-o.confidence;return Math.abs(l)>.001?l:u.consumedTokens-o.consumedTokens});let n=a[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t,a){let n=r[0],o=n?.type==="literal"&&(n.value==="and"||n.value==="then"||n.alternatives?.includes("and")||n.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();let u=null,s=null;for(let l=0;l<r.length;l++){let c=r[l];this.logger.debug(" >> Matching pattern token:",JSON.stringify(c,null,2));let m=e.peek();if(this.logger.debug(" >> Current input token:",m?JSON.stringify({type:m.type,value:m.value,kind:m.kind}):"EOF"),c.type==="role"&&c.greedy){let h=this.collectStopMarkers(r,l+1);if(a)for(let z of a)h.add(z);let E=[];for(;!e.isAtEnd();){let z=e.peek();if(!z||this.isStopMarker(z,h))break;E.push(z.value),e.advance();}if(E.length>0){t.set(c.role,{type:"expression",raw:E.join(" ")}),u=null,s=null;continue}else {if(c.optional)continue;return false}}if(c.type==="group"){let h=this.collectStopMarkers(r,l+1);if(a)for(let z of a)h.add(z);if(this.matchGroupToken(e,c,t,h)){u=null,s=null;continue}if(this.isOptional(c))continue;return false}let p=c.type==="role"&&c.optional===true,d=p?e.mark():null;if(c.type==="role"&&!p){let h=l+1<r.length?r[l+1]:null;if(h?.type==="literal"){let E=e.peek();if(E&&this.getMatchType(E,h.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(c))continue;if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let z=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",z),z)continue}return false}}}let v=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Match result:",v),v){p?(u=d,s=c.role):(u=null,s=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(c)){if(u&&s){this.logger.debug(" >> BACKTRACKING: undoing optional role",s),e.reset(u),t.delete(s),u=null,s=null;let h=this.matchPatternToken(e,c,t);if(this.logger.debug(" >> Backtrack retry result:",h),h)continue}return false}}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",r.value),this.logger.debug(" >>> matchLiteralToken: got token",t?JSON.stringify({type:t.type,value:t.value,kind:t.kind}):"null"),!t)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let a=this.getMatchType(t,r.value);if(this.logger.debug(" >>> matchType for",t.value,"vs",r.value,":",a),a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",r.role),this.logger.debug(" >>> matchRoleToken: expected types",r.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",r.optional),this.skipNoiseWords(e);let a=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null"),!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!j(n.type,r.expectedTypes)?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!j(o.type,r.expectedTypes)?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!j(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!j(s.type,r.expectedTypes)?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!j(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",a?JSON.stringify({value:a.value,kind:a.kind}):"null");let c=this.tokenToSemanticValue(a);return this.logger.debug(" >>> tokenToSemanticValue returned:",c?JSON.stringify(c):"null"),c?(this.logger.debug(" >>> Validating type:",c.type,"against expected:",r.expectedTypes),r.expectedTypes&&r.expectedTypes.length>0&&!j(c.type,r.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",r.optional||false),r.optional||false):(this.logger.debug(" >>> Type validation PASSED"),t.set(r.role,c),e.advance(),true)):r.optional||false}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=r.normalized||r.value,a=this.safeToLowerCase(t),n=Cr(this.currentProfile,a);if(!n)return null;let o=e.mark();e.advance();let u=e.peek();if(!u)return e.reset(o),null;if(u.kind==="identifier"||u.kind==="keyword"&&!this.isStructuralKeyword(u.value)||u.kind==="selector"&&u.value.startsWith("*")||u.kind==="selector"&&u.value.startsWith("@")||u.kind==="selector"&&u.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u.value)){e.advance();let s=u.value;u.kind==="selector"&&s.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s)&&(s=s.substring(1));let l=s;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),oe(H(n),l)}return e.reset(o),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<$.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<$.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<$.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),oe(ne(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||typeof r.value!="string"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return oe(ne(r.value),o)}matchGroupToken(e,r,t,a){let n=e.mark(),o=new Set(t.keys());if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let l of t.keys())o.has(l)||t.delete(l);if(!r.optional)return false;let s=this.getGroupLeadingMarker(r);if(s)for(let l=1;l<=$.MAX_MARKER_SCAN;l++){let c=e.peek(l);if(!c)break;if((c.normalized||c.value).toLowerCase()===s){this.logger.debug(" >> MARKER SCAN: found",s,"at offset",l,"- skipping intervening tokens");for(let d=0;d<l;d++)e.advance();if(this.matchTokenSequence(e,r.tokens,t,a))return true;e.reset(n);for(let d of t.keys())o.has(d)||t.delete(d);break}}return true}getGroupLeadingMarker(e){let r=e.tokens[0];return r?.type==="literal"?r.value.toLowerCase():null}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===r.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,r){let t=new Set;for(let a=r;a<e.length;a++){let n=e[a];if(n.type==="literal"){if(t.add(n.value.toLowerCase()),n.alternatives)for(let o of n.alternatives)t.add(o.toLowerCase());break}if(n.type==="group"){for(let o of n.tokens)if(o.type==="literal"){if(t.add(o.value.toLowerCase()),o.alternatives)for(let u of o.alternatives)t.add(u.toLowerCase());break}if(!n.optional)break}}return t}isStopMarker(e,r){return r.size===0?false:!!(r.has(e.value.toLowerCase())||e.normalized&&r.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return ne(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=e.normalized||e.value;this.safeToLowerCase(r);return B(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return H(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return B(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return B(a,"string")}if(e==="true")return B(true,"boolean");if(e==="false")return B(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?B(e,"duration"):B(a,"number")}let t=parseFloat(e);return isNaN(t)?B(e,"string"):B(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,r){let t=0,a=0,n=l=>e.extraction?.[l]?.default!==void 0;for(let l of e.template.tokens)if(l.type==="role")a+=1,r.has(l.role)&&(t+=1);else if(l.type==="group"){for(let c of l.tokens)if(c.type==="role"){let m=n(c.role),p=.8;a+=p,r.has(c.role)?t+=p:m&&(t+=p*.6);}}let o=a>0?t/a:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let l=this.stemMatchCount/this.totalKeywordMatches*.15;o=Math.max(.5,o-l);}let u=this.calculateVSOConfidenceBoost(e);o=Math.min(1,o+u);let s=this.arabicPrepositionDisambiguation(e,r);return o=Math.max(0,Math.min(1,o+s)),o}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let r=e.template.tokens[0];if(!r||r.type!=="literal")return 0;let t=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(t.has(r.value))return .15;if(r.alternatives){for(let a of r.alternatives)if(t.has(a))return .15}return 0}arabicPrepositionDisambiguation(e,r){if(e.language!=="ar")return 0;let t=0,a={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[n,o]of r.entries()){let u=a[n];if(!u||u.length===0)continue;let s="metadata"in o?o.metadata:void 0;if(s&&typeof s.prepositionValue=="string"){let l=s.prepositionValue;u.includes(l)?t+=.1:t-=.1;}}return Math.max(-0.1,Math.min(.1,t))}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=this.safeToLowerCase(r.value);if($.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&n.kind==="selector")return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};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 Ar=Y;new Ar;var Fe=class{constructor(){this.name="string-literal";}canExtract(i,e){let r=i[e];return r==='"'||r==="'"||r==="`"||r==="\u201C"||r==="\u2018"}extract(i,e){let r=i[e];if(r==="\u201C"){let n=1;for(;e+n<i.length;){if(i[e+n]==="\u201D")return n++,{value:i.substring(e,e+n),length:n};n++;}return null}if(r==="\u2018"){let n=1;for(;e+n<i.length;){if(i[e+n]==="\u2019")return n++,{value:i.substring(e,e+n),length:n};n++;}return null}let t=1,a=false;for(;e+t<i.length;){let n=i[e+t];if(a){a=false,t++;continue}if(n==="\\"){a=true,t++;continue}if(n===r)return t++,{value:i.substring(e,e+t),length:t};t++;}return null}},Te=class{constructor(){this.name="number";}canExtract(i,e){return /\d/.test(i[e])}extract(i,e){let r=0,t=false;for(;e+r<i.length;){let o=i[e+r];if(/\d/.test(o))r++;else if(o==="."&&!t)t=true,r++;else break}if(r===0)return null;let a=i.substring(e,e+r),n=e+r;if(n<i.length){let o=i.slice(n),u=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let l of u)if(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+l.pattern.length,metadata:{hasTimeUnit:true}};if(o.startsWith("ms"))return {value:a+"ms",length:r+2,metadata:{hasTimeUnit:true}};let s=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let l of s)if(o.startsWith(l.pattern))return {value:a+l.suffix,length:r+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(o))return {value:a+o[0],length:r+1,metadata:{hasTimeUnit:true}}}return {value:a,length:r}}};function wr(i){return "setContext"in i&&typeof i.setContext=="function"}function Dr(i){let e={language:i.language,direction:i.direction,lookupKeyword:i.lookupKeyword.bind(i),isKeyword:i.isKeyword.bind(i),isKeywordStart:i.isKeywordStart.bind(i)};return i.normalizer?{...e,normalizer:i.normalizer}:e}var J=class{constructor(i,e){this.pos=0,this.tokens=i,this.language=e;}peek(i=0){let e=this.pos+i;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(i){this.pos=i.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(i){let e=[];for(;!this.isAtEnd()&&i(this.peek());)e.push(this.advance());return e}skipWhile(i){for(;!this.isAtEnd()&&i(this.peek());)this.advance();}};function k(i,e){return {start:i,end:e}}function b(i,e,r,t){if(typeof i=="object"){let{value:n,kind:o,position:u,normalized:s,stem:l,stemConfidence:c,metadata:m}=i;return {value:n,kind:o,position:u,...s!==void 0&&{normalized:s},...l!==void 0&&{stem:l},...c!==void 0&&{stemConfidence:c},...m!==void 0&&{metadata:m}}}let a=i;if(!e||!r)throw new Error("createToken requires kind and position parameters");if(typeof t=="string")return {value:a,kind:e,position:r,normalized:t};if(t){let{normalized:n,stem:o,stemConfidence:u,metadata:s}=t;return {value:a,kind:e,position:r,...n!==void 0&&{normalized:n},...o!==void 0&&{stem:o},...u!==void 0&&{stemConfidence:u},...s!==void 0&&{metadata:s}}}return {value:a,kind:e,position:r}}function G(i){return /\s/.test(i)}function xr(i){return i==="#"||i==="."||i==="["||i==="@"||i==="*"||i==="<"}function Br(i){return i==='"'||i==="'"||i==="`"||i==="\u300C"||i==="\u300D"}function O(i){return /\d/.test(i)}function Sr(i){return /[a-zA-Z]/.test(i)}function w(i){return /[a-zA-Z0-9_-]/.test(i)}function Fr(i,e){if(e>=i.length)return null;let r=i[e];if(!xr(r))return null;let t=e,a="";if(r==="#"||r==="."){for(a+=i[t++];t<i.length&&w(i[t]);)a+=i[t++];if(a.length<=1)return null;if(t<i.length&&i[t]==="."&&r==="#"){let o=t+1;for(;o<i.length&&w(i[o]);)o++;if(o<i.length&&i[o]==="(")return a}}else if(r==="["){let n=1,o=false,u=null,s=false;for(a+=i[t++];t<i.length&&n>0;){let l=i[t];a+=l,s?s=false:l==="\\"?s=true:o?l===u&&(o=false,u=null):l==='"'||l==="'"||l==="`"?(o=true,u=l):l==="["?n++:l==="]"&&n--,t++;}if(n!==0)return null}else if(r==="@"){for(a+=i[t++];t<i.length&&w(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="*"){for(a+=i[t++];t<i.length&&w(i[t]);)a+=i[t++];if(a.length<=1)return null}else if(r==="<"){if(a+=i[t++],t>=i.length||!Sr(i[t]))return null;for(;t<i.length&&w(i[t]);)a+=i[t++];for(;t<i.length;){let n=i[t];if(n==="."){if(a+=i[t++],t>=i.length||!w(i[t]))return null;for(;t<i.length&&w(i[t]);)a+=i[t++];}else if(n==="#"){if(a+=i[t++],t>=i.length||!w(i[t]))return null;for(;t<i.length&&w(i[t]);)a+=i[t++];}else if(n==="["){let o=1,u=false,s=null,l=false;for(a+=i[t++];t<i.length&&o>0;){let c=i[t];a+=c,l?l=false:c==="\\"?l=true:u?c===s&&(u=false,s=null):c==='"'||c==="'"||c==="`"?(u=true,s=c):c==="["?o++:c==="]"&&o--,t++;}if(o!==0)return null}else break}for(;t<i.length&&G(i[t]);)a+=i[t++];if(t<i.length&&i[t]==="/")for(a+=i[t++];t<i.length&&G(i[t]);)a+=i[t++];if(t>=i.length||i[t]!==">")return null;a+=i[t++];}return a||null}function Tr(i,e){if(e>=i.length||i[e]!=="'"||e+1>=i.length||i[e+1].toLowerCase()!=="s")return false;if(e+2>=i.length)return true;let t=i[e+2];return G(t)||t==="*"||!w(t)}function Pr(i,e){if(e>=i.length)return null;let r=i[e];if(!Br(r)||r==="'"&&Tr(i,e))return null;let a={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[r];if(!a)return null;let n=e+1,o=r,u=false;for(;n<i.length;){let s=i[n];if(o+=s,u)u=false;else if(s==="\\")u=true;else if(s===a)return o;n++;}return o}function Rr(i,e){if(e>=i.length)return false;let r=i[e],t=i[e+1]||"",a=i[e+2]||"";if(r==="/"&&t!=="/"&&/[a-zA-Z0-9._-]/.test(t)||r==="/"&&t==="/"&&/[a-zA-Z]/.test(a)||r==="."&&(t==="/"||t==="."&&a==="/"))return true;let n=i.slice(e,e+8).toLowerCase();return !!(n.startsWith("http://")||n.startsWith("https://"))}function _r(i,e){if(!Rr(i,e))return null;let r=e,t="",a=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;r<i.length;){let n=i[r];if(n==="#"){if(t.length>0&&/[a-zA-Z0-9/.]$/.test(t))for(t+=n,r++;r<i.length&&/[a-zA-Z0-9_-]/.test(i[r]);)t+=i[r++];break}if(a.test(n))t+=n,r++;else break}return t.length<2?null:t}function Or(i,e){if(e>=i.length)return null;let r=i[e];if(!O(r)&&r!=="-"&&r!=="+")return null;let t=e,a="";if((i[t]==="-"||i[t]==="+")&&(a+=i[t++]),t>=i.length||!O(i[t]))return null;for(;t<i.length&&O(i[t]);)a+=i[t++];if(t<i.length&&i[t]===".")for(a+=i[t++];t<i.length&&O(i[t]);)a+=i[t++];return t<i.length&&(i.slice(t,t+2)==="ms"?a+="ms":(i[t]==="s"||i[t]==="m"||i[t]==="h")&&(a+=i[t])),a}var Nr=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(Nr);var Pe=class Re{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){wr(e)&&e.setContext(Dr(this)),this.extractors.push(e);}registerExtractors(e){for(let r of e)this.registerExtractor(r);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let r=[],t=0;for(;t<e.length;){for(;t<e.length&&G(e[t]);)t++;if(t>=e.length)break;let a=false;for(let n of this.extractors)if(n.canExtract(e,t)){let o=n.extract(e,t);if(o){let u=o.metadata?.normalized,s=o.metadata?.stem,l=o.metadata?.stemConfidence,c={};if(o.metadata)for(let[p,d]of Object.entries(o.metadata))p!=="normalized"&&p!=="stem"&&p!=="stemConfidence"&&(c[p]=d);let m={};u&&(m.normalized=u),s&&(m.stem=s),l!==void 0&&(m.stemConfidence=l),Object.keys(c).length>0&&(m.metadata=c),r.push(b(o.value,this.classifyToken(o.value),k(t,t+o.length),Object.keys(m).length>0?m:void 0)),t+=o.length,a=true;break}}if(!a){let n=e[t],o=this.classifyUnknownChar(n);r.push(b(n,o,k(t,t+1))),t++;}}return new J(r,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,r,t){if(e[r]!==".")return false;let a=t[t.length-1],n=a&&a.position.end<r;if(a&&!n&&(a.kind==="identifier"||a.kind==="keyword"||a.kind==="selector"))return t.push(b(".","operator",k(r,r+1))),true;let s=r+1;for(;s<e.length&&w(e[s]);)s++;return s<e.length&&e[s]==="("?(t.push(b(".","operator",k(r,r+1))),true):false}initializeKeywordsFromProfile(e,r=[]){let t=new Map;if(e.keywords){for(let[a,n]of Object.entries(e.keywords))if(t.set(n.primary,{native:n.primary,normalized:n.normalized||a}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:n.normalized||a});}if(e.references){for(let[a,n]of Object.entries(e.references))t.set(n,{native:n,normalized:a});for(let a of Object.keys(e.references))t.has(a)||t.set(a,{native:a,normalized:a});}if(e.roleMarkers){for(let[a,n]of Object.entries(e.roleMarkers))if(n.primary&&t.set(n.primary,{native:n.primary,normalized:a}),n.alternatives)for(let o of n.alternatives)t.set(o,{native:o,normalized:a});}if(e.possessive?.keywords)for(let[a,n]of Object.entries(e.possessive.keywords))t.set(a,{native:a,normalized:n});for(let a of r)t.set(a.native,a);this.profileKeywords=Array.from(t.values()).sort((a,n)=>n.native.length-a.native.length),this.profileKeywordMap=new Map;for(let a of this.profileKeywords){this.profileKeywordMap.set(a.native.toLowerCase(),a);let n=this.removeDiacritics(a.native);n!==a.native&&!this.profileKeywordMap.has(n.toLowerCase())&&this.profileKeywordMap.set(n.toLowerCase(),a);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,r){for(let t of this.profileKeywords)if(e.slice(r).startsWith(t.native))return b(t.native,"keyword",k(r,r+t.native.length),t.normalized);return null}isKeywordStart(e,r){let t=e.slice(r);return this.profileKeywords.some(a=>t.startsWith(a.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let r=this.normalizer.normalize(e);return r.stem!==e&&r.confidence>=.7?r:null}tryMorphKeywordMatch(e,r,t){let a=this.tryNormalize(e);if(!a)return null;let n=this.lookupKeyword(a.stem);if(!n)return null;let o={normalized:n.normalized,stem:a.stem,stemConfidence:a.confidence};return b(e,"keyword",k(r,t),o)}trySelector(e,r){let t=Fr(e,r);return t?b(t,"selector",k(r,r+t.length)):null}tryEventModifier(e,r){if(e[r]!==".")return null;let t=e.slice(r).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!t)return null;let a=t[0].replace(/(\s|\.)$/,""),n=a.slice(1).split("(")[0],o=t[1];return {...b(a,"event-modifier",k(r,r+a.length)),metadata:{modifierName:n,value:o?n==="queue"?o:parseInt(o,10):void 0}}}tryString(e,r){let t=Pr(e,r);return t?b(t,"literal",k(r,r+t.length)):null}tryNumber(e,r){let t=Or(e,r);return t?b(t,"literal",k(r,r+t.length)):null}tryMatchTimeUnit(e,r,t,a=false){let n=r;if(a)for(;n<e.length&&G(e[n]);)n++;let o=e.slice(n);for(let u of t){let s=o.slice(0,u.length);if(u.caseInsensitive?s.toLowerCase()===u.pattern.toLowerCase():s===u.pattern){if(u.notFollowedBy&&(o[u.length]||"")===u.notFollowedBy)continue;if(u.checkBoundary){let c=o[u.length]||"";if(w(c))continue}return {suffix:u.suffix,endPos:n+u.length}}}return null}parseBaseNumber(e,r,t=true){let a=r,n="";if(t&&(e[a]==="-"||e[a]==="+")&&(n+=e[a++]),a>=e.length||!O(e[a]))return null;for(;a<e.length&&O(e[a]);)n+=e[a++];if(a<e.length&&e[a]===".")for(n+=e[a++];a<e.length&&O(e[a]);)n+=e[a++];return !n||n==="-"||n==="+"?null:{number:n,endPos:a}}tryNumberWithTimeUnits(e,r,t,a={}){let{allowSign:n=true,skipWhitespace:o=false}=a,u=this.parseBaseNumber(e,r,n);if(!u)return null;let{number:s,endPos:l}=u,c=[...t,...Re.STANDARD_TIME_UNITS],m=this.tryMatchTimeUnit(e,l,c,o);return m&&(s+=m.suffix,l=m.endPos),b(s,"literal",k(r,l))}tryUrl(e,r){let t=_r(e,r);return t?b(t,"url",k(r,r+t.length)):null}tryVariableRef(e,r){if(e[r]!==":"||r+1>=e.length||!w(e[r+1]))return null;let t=r+1;for(;t<e.length&&w(e[t]);)t++;let a=e.slice(r,t);return b(a,"identifier",k(r,t))}tryOperator(e,r){let t=e.slice(r,r+2);if(["==","!=","<=",">=","&&","||","->"].includes(t))return b(t,"operator",k(r,r+2));let a=e[r];return ["<",">","!","+","-","*","/","="].includes(a)?b(a,"operator",k(r,r+1)):["(",")","{","}",",",";",":"].includes(a)?b(a,"punctuation",k(r,r+1)):null}tryMultiCharParticle(e,r,t){for(let a of t)if(e.slice(r,r+a.length)===a)return b(a,"particle",k(r,r+a.length));return null}};Pe.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 _e=Pe;var Mr=Object.defineProperty,Ir=Object.getOwnPropertyNames,He=(i,e)=>function(){return i&&(e=(0, i[Ir(i)[0]])(i=0)),e},Lr=(i,e)=>{for(var r in e)Mr(i,r,{get:e[r],enumerable:true});};function Oe(i,e){return i.replace(/\{(\w+)\}/g,(r,t)=>String(e[t]??`{${t}}`))}function D(i,e,r={},t){let a=Ge[i],n=Oe(a,r),o=Ye[i],u=o?Oe(o,r):void 0;return {code:i,message:n,severity:e,...t&&{role:t},...u&&{suggestion:u}}}var f,Ge,Ye,jr=He({"src/generators/schema-error-codes.ts"(){f={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Ge={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[f.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[f.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[f.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[f.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[f.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[f.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[f.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[f.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[f.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[f.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[f.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[f.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},Ye={[f.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[f.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[f.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[f.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[f.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[f.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[f.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[f.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[f.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[f.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[f.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[f.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[f.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),Je={};Lr(Je,{SchemaErrorCodes:()=>f,formatValidationResults:()=>Hr,getValidationStats:()=>Gr,validateAllKeywordCollisions:()=>Jr,validateAllSchemas:()=>Ur,validateCommandSchema:()=>Xe,validateKeywordCollisions:()=>Qe,validateRoleValues:()=>Yr});function $r(i,e){return {action:i,items:e}}function Xe(i){let e=[];for(let t of i.roles)t.expectedTypes.includes("literal")&&t.expectedTypes.includes("selector")&&(t.role==="patient"&&Ee.has(i.action)?e.push(D(f.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:t.role,command:i.action},t.role)):e.push(D(f.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:t.role},t.role))),t.expectedTypes.length>3&&!Ee.has(i.action)&&e.push(D(f.TOO_MANY_EXPECTED_TYPES,"warning",{role:t.role,count:t.expectedTypes.length},t.role));for(let t of i.roles)t.selectorKinds&&t.selectorKinds.length>0&&(t.expectedTypes.includes("selector")||e.push(D(f.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:t.role},t.role)));switch(i.action){case "transition":Vr(i,e);break;case "on":qr(i,e);break;case "if":case "unless":Wr(i,e);break;case "repeat":case "for":case "while":Kr(i,e);break}return i.roles.filter(t=>t.required).length===0&&(Ze.has(i.action)?e.push(D(f.NO_REQUIRED_ROLES_EXPECTED,"note",{command:i.action})):e.push(D(f.NO_REQUIRED_ROLES,"warning",{}))),$r(i.action,e)}function Vr(i,e){let r=i.roles.find(a=>a.role==="patient"),t=i.roles.find(a=>a.role==="goal");r&&r.expectedTypes.includes("selector")&&e.push(D(f.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),r&&!t&&e.push(D(f.TRANSITION_MISSING_GOAL,"error",{}));}function qr(i,e){let r=i.roles.find(t=>t.role==="event");r||e.push(D(f.EVENT_HANDLER_MISSING_EVENT,"warning",{})),r&&!r.required&&e.push(D(f.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Wr(i,e){let r=i.roles.find(t=>t.role==="condition");r||e.push(D(f.CONDITIONAL_MISSING_CONDITION,"warning",{})),r&&!r.required&&e.push(D(f.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Kr(i,e){i.action==="for"?i.roles.find(t=>t.role==="source")||e.push(D(f.FOR_LOOP_MISSING_SOURCE,"warning",{})):i.action==="while"&&(i.roles.find(t=>t.role==="condition")||e.push(D(f.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Ur(i,e={}){let r=new Map,{includeNotes:t=false}=e;for(let[a,n]of Object.entries(i)){let o=Xe(n),u=o.items.some(l=>l.severity==="warning"||l.severity==="error"),s=t&&o.items.some(l=>l.severity==="note");(u||s)&&r.set(a,o);}return r}function Hr(i,e={}){let r=[],{showNotes:t=false,showCodes:a=true}=e;for(let[n,o]of i){let u=o.items.filter(c=>c.severity==="error"),s=o.items.filter(c=>c.severity==="warning"),l=o.items.filter(c=>c.severity==="note");if(u.length>0){r.push(` \u274C ${n}:`);for(let c of u){let m=a?` [${c.code}]`:"";r.push(` ERROR${m}: ${c.message}`),c.suggestion&&r.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(s.length>0){r.push(` \u26A0\uFE0F ${n}:`);for(let c of s){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`),c.suggestion&&r.push(` \u{1F4A1} ${c.suggestion}`);}}if(t&&l.length>0){r.push(` \u2139\uFE0F ${n}:`);for(let c of l){let m=a?` [${c.code}]`:"";r.push(` ${m?`${c.code}: `:""}${c.message}`);}}}return r.join(`
|
|
2
|
+
`)}function Gr(i){let e=0,r=0,t=0,a={};for(let n of i.values())for(let o of n.items)o.severity==="error"?e++:o.severity==="warning"?r++:o.severity==="note"&&t++,a[o.code]=(a[o.code]||0)+1;return {totalCommands:i.size,errors:e,warnings:r,notes:t,byCode:a}}function Yr(i,e){let r=[];for(let t of e){let a=i.roles.find(n=>n.role===t.role);a&&(a.expectedTypes.length>0&&!a.expectedTypes.includes(t.type)&&(a.expectedTypes.includes("expression")||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects type [${a.expectedTypes.join(", ")}], got '${t.type}'`,code:f.VALUE_TYPE_MISMATCH})),t.type==="selector"&&t.selectorKind&&a.selectorKinds&&a.selectorKinds.length>0&&(a.selectorKinds.includes(t.selectorKind)||r.push({level:"error",role:t.role,message:`${i.action}.${t.role} expects selector kind [${a.selectorKinds.join(", ")}], got '${t.selectorKind}'`,code:f.SELECTOR_KIND_MISMATCH})));}return r}function Qe(i){let e=[];if(!i.keywords)return {language:i.code,collisions:e};let r=new Map;for(let[a,n]of Object.entries(i.keywords)){if(!n||!n.primary)continue;let o=r.get(n.primary)||[];if(o.push({command:a,isPrimary:true}),r.set(n.primary,o),n.alternatives)for(let u of n.alternatives){let s=r.get(u)||[];s.push({command:a,isPrimary:false}),r.set(u,s);}}for(let[a,n]of r){let o=[...new Set(n.map(l=>l.command))];if(o.length<=1)continue;let u=n.filter(l=>l.isPrimary).length,s;u>=2?s="primary-primary":u===1?s="primary-alternative":s="alternative-alternative",e.push({keyword:a,commands:o.sort(),type:s});}let t={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((a,n)=>t[a.type]-t[n.type]),{language:i.code,collisions:e}}function Jr(i){let e=[];for(let[,r]of Object.entries(i)){let t=Qe(r);t.collisions.length>0&&e.push(t);}return e.sort((r,t)=>r.language.localeCompare(t.language))}var Ee,Ze,Xr=He({"src/generators/schema-validator.ts"(){jr(),Ee=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Ze=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep","empty","open","close","select","clear","reset","breakpoint"]);}});var M=new Map,T=new Map,X=new Map,ge=null;function er(i,e){let r={...i};for(let t of Object.keys(e)){let a=e[t],n=i[t];a!==void 0&&(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof n=="object"&&n!==null&&!Array.isArray(n)?r[t]=er(n,a):r[t]=a);}return r}function Qr(i,e){return er(i,e)}function ze(i){if(!i.extends)return i;let e=T.get(i.extends);if(!e)return console.warn(`[Registry] Profile '${i.code}' extends '${i.extends}' but base is not registered. Make sure to import the base language before the variant.`),i;let r=ze(e);return Qr(r,i)}function rr(i,e,r){M.set(i,e),T.set(i,r),X.delete(i);}function tr(i){ge=i;}var Ne=new Map;function q(i){return i.split("-")[0]}function W(i){return i.includes("-")}function Zr(i){let e=M.get(i);if(!e&&W(i)){let r=q(i);e=M.get(r);}if(!e){let r=Array.from(M.keys()).join(", ");throw new Error(`Language '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return e}function et(i){let e=T.get(i);if(!e&&W(i)){let r=q(i);e=T.get(r);}if(!e){let r=Array.from(T.keys()).join(", ");throw new Error(`Language profile '${i}' is not registered. Registered languages: ${r||"none"}. Import the language module first: import '@lokascript/semantic/languages/${i}';`)}return ze(e)}function I(i){let e=T.get(i);return !e&&W(i)&&(e=T.get(q(i))),e?ze(e):void 0}function rt(){return Array.from(M.keys())}function ir(i){if(M.has(i)&&T.has(i))return true;if(W(i)){let e=q(i);return M.has(e)&&T.has(e)}return false}function tt(i,e){return Zr(e).tokenize(i)}function V(i){let e=X.get(i);if(!e&&W(i)&&(e=X.get(q(i))),e)return e;let r=Ne.get(i);if(!r&&W(i)&&(r=Ne.get(q(i))),r)return X.set(i,r),r;if(!ge)throw new Error(`No patterns registered for language '${i}'. Either import the language module or set a pattern generator.`);let t=et(i),a=ge(t);return X.set(i,a),a}function Z(i){let e="complex";return i.startsWith("#")&&!i.includes(" ")?e="id":i.startsWith(".")&&!i.includes(" ")?e="class":i.startsWith("[")&&i.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(i)&&(e="element"),{type:"selector",value:i,selectorKind:e}}function C(i,e){let r={type:"literal",value:i};return e!==void 0?{type:"literal",value:i,dataType:e}:r}function Me(i){return fe(i)}function N(i){return {type:"reference",value:i}}function he(i,e){return {type:"property-path",object:i,property:e}}function ue(i,e,r){let t={kind:"command",action:i,roles:new Map(Object.entries(e))};return r!==void 0?{...t,metadata:r}:t}function Ie(i,e,r,t,a,n){let o=new Map;o.set("event",i);let u={kind:"event-handler",action:"on",roles:o,body:e};return r!==void 0&&(u.eventModifiers=r),t!==void 0&&(u.metadata=t),u}function Le(i,e="then",r){let t={kind:"compound",action:"compound",roles:new Map,statements:i,chainType:e};return r!==void 0&&(t.metadata=r),t}function je(i,e){return !e||e.length===0||e.includes(i)||e.includes("expression")?true:i==="property-path"?e.some(r=>["selector","reference","expression"].includes(r)):false}function Bt(i,e){return i.possessive?.keywords?.[e]}var ve=.8,St=.6,Ft=.15,Tt=.5,$e=.15,Ve=.1,qe=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"]),Pt={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"]},Rt=class{calculate(i){return this.calculateWithBreakdown(i).final}calculateWithBreakdown(i){let e=this.scoreRoleCoverage(i),r=this.scoreStemPenalty(i),t=this.scoreLanguageBoost(i),a=this.scoreLanguageAdjustment(i),n=e;return n=Math.max(Tt,n+r),n=Math.min(1,n+t),n=Math.max(0,Math.min(1,n+a)),{roleCoverage:e,stemPenalty:r,languageBoost:t,languageAdjustment:a,final:n}}scoreRoleCoverage(i){let{pattern:e,captured:r}=i,t=0,a=0,n=o=>e.extraction?.[o]?.default!==void 0;for(let o of e.template.tokens)if(o.type==="role")a+=1,r.has(o.role)&&(t+=1);else if(o.type==="group")for(let u of o.tokens)u.type==="role"&&(a+=ve,r.has(u.role)?t+=ve:n(u.role)&&(t+=ve*St));return a>0?t/a:1}scoreStemPenalty(i){let{stemMatchCount:e,totalKeywordMatches:r}=i;return e<=0||r<=0?0:-(e/r)*Ft}scoreLanguageBoost(i){let{pattern:e}=i;if(e.language!=="ar")return 0;let r=e.template.tokens[0];return !r||r.type!=="literal"?0:qe.has(r.value)||r.alternatives?.some(t=>qe.has(t))?$e:0}scoreLanguageAdjustment(i){let{pattern:e,captured:r}=i;if(e.language!=="ar")return 0;let t=0;for(let[a,n]of r.entries()){let o=Pt[a];if(!o||o.length===0)continue;let u="metadata"in n?n.metadata:void 0;u&&typeof u.prepositionValue=="string"&&(o.includes(u.prepositionValue)?t+=.1:t-=.1);}return Math.max(-Ve,Math.min(Ve,t))}},_t=new Rt,le=class Q{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??_t;}matchPattern(e,r){let t=e.mark(),a=new Map;if(this.currentProfile=I(r.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,r.template.tokens,a))return e.reset(t),null;let o=this.confidenceModel.calculate({pattern:r,captured:a,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(r,a),{pattern:r,captured:a,consumedTokens:e.position()-t.position,confidence:o}}matchBest(e,r){this.matchCache.clear();let t=[],a=e.position();for(let o of r){let u=e.mark(),s=`${a}:${o.id}`,l;this.matchCache.has(s)?l=this.matchCache.get(s):(l=this.matchPattern(e,o),this.matchCache.set(s,l)),l&&t.push(l),e.reset(u);}if(t.length===0)return null;t.sort((o,u)=>{let s=u.pattern.priority-o.pattern.priority;return s!==0?s:u.confidence-o.confidence});let n=t[0];return this.matchPattern(e,n.pattern),n}matchTokenSequence(e,r,t){let a=r[0],n=a?.type==="literal"&&(a.value==="and"||a.value==="then"||a.alternatives?.includes("and")||a.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!n)for(;e.peek()?.kind==="conjunction";)e.advance();for(let o of r)if(!this.matchPatternToken(e,o,t)){if(this.isOptional(o))continue;return false}return true}matchPatternToken(e,r,t){switch(r.type){case "literal":return this.matchLiteralToken(e,r);case "role":return this.matchRoleToken(e,r,t);case "group":return this.matchGroupToken(e,r,t);default:return false}}matchLiteralToken(e,r){let t=e.peek();if(!t)return false;let a=this.getMatchType(t,r.value);if(a!=="none")return this.totalKeywordMatches++,a==="stem"&&this.stemMatchCount++,e.advance(),true;if(r.alternatives)for(let n of r.alternatives){let o=this.getMatchType(t,n);if(o!=="none")return this.totalKeywordMatches++,o==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,r,t){this.skipNoiseWords(e);let a=e.peek();if(!a)return r.optional||false;let n=this.tryMatchPossessiveExpression(e);if(n)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(n.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,n),true);let o=this.tryMatchMethodCallExpression(e);if(o)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(o.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,o),true);let u=this.tryMatchPossessiveSelectorExpression(e);if(u)return r.expectedTypes&&r.expectedTypes.length>0&&!je(u.type,r.expectedTypes)?r.optional||false:(t.set(r.role,u),true);let s=this.tryMatchPropertyAccessExpression(e);if(s)return r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(s.type)&&!r.expectedTypes.includes("expression")?r.optional||false:(t.set(r.role,s),true);let l=this.tryMatchSelectorPropertyExpression(e);if(l)return r.expectedTypes&&r.expectedTypes.length>0&&!je(l.type,r.expectedTypes)?r.optional||false:(t.set(r.role,l),true);let c=this.tokenToSemanticValue(a);return !c||r.expectedTypes&&r.expectedTypes.length>0&&!r.expectedTypes.includes(c.type)?r.optional||false:(t.set(r.role,c),e.advance(),true)}tryMatchPossessiveExpression(e){let r=e.peek();if(!r||!this.currentProfile)return null;let t=(r.normalized||r.value).toLowerCase(),a=Bt(this.currentProfile,t);if(!a)return null;let n=e.mark();e.advance();let o=e.peek();if(!o)return e.reset(n),null;if(o.kind==="identifier"||o.kind==="keyword"&&!this.isStructuralKeyword(o.value)||o.kind==="selector"&&o.value.startsWith("*")||o.kind==="selector"&&o.value.startsWith("@")||o.kind==="selector"&&o.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(o.value)){e.advance();let u=o.value;o.kind==="selector"&&u.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(u)&&(u=u.substring(1));let s=u;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)s+=e.peek().value,e.advance();let l=e.peek();return l?.kind==="literal"&&l.value.startsWith("(")&&(s+=l.value,e.advance()),he(N(a),s)}return e.reset(n),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=e.peek();if(!o||o.kind!=="punctuation"||o.value!=="(")return e.reset(t),null;e.advance();let u=[];for(;!e.isAtEnd()&&u.length<Q.MAX_METHOD_ARGS;){let l=e.peek();if(!l)break;if(l.kind==="punctuation"&&l.value===")"){e.advance();break}if(l.kind==="punctuation"&&l.value===","){e.advance();continue}u.push(l.value),e.advance();}return {type:"expression",raw:`${r.value}.${n.value}(${u.join(", ")})`}}tryMatchPropertyAccessExpression(e){let r=e.peek();if(!r||r.kind!=="identifier"&&r.kind!=="keyword")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="operator"||a.value!==".")return e.reset(t),null;e.advance();let n=e.peek();if(!n||n.kind!=="identifier")return e.reset(t),null;e.advance();let o=`${r.value}.${n.value}`,u=1;for(;!e.isAtEnd()&&u<Q.MAX_PROPERTY_DEPTH;){let l=e.peek();if(!l||l.kind!=="operator"||l.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),o+=`.${c.value}`,u++;}let s=e.peek();if(s&&s.kind==="punctuation"&&s.value==="("){e.advance();let l=[],c=0;for(;!e.isAtEnd()&&l.length<Q.MAX_METHOD_ARGS;){let p=e.peek();if(!p)break;if(p.kind==="punctuation"&&p.value===")"){if(c===0){e.advance();break}c--;}if(p.kind==="punctuation"&&p.value==="("&&c++,p.kind==="punctuation"&&p.value===","){e.advance();continue}l.push(p.value),e.advance();}return {type:"expression",raw:`${o}(${l.join(", ")})`}}return {type:"expression",raw:o}}tryMatchPossessiveSelectorExpression(e){let r=e.peek();if(!r||r.kind!=="selector")return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="punctuation"||a.value!=="'s")return e.reset(t),null;e.advance();let n=e.peek();return !n||n.kind!=="selector"&&n.kind!=="identifier"?(e.reset(t),null):(e.advance(),he(Z(r.value),n.value))}tryMatchSelectorPropertyExpression(e){let r=e.peek();if(!r||r.kind!=="selector"||!r.value.startsWith("#"))return null;let t=e.mark();e.advance();let a=e.peek();if(!a||a.kind!=="selector"||!a.value.startsWith("."))return e.reset(t),null;let n=e.peek(1);n&&n.kind,e.advance();let o=a.value.slice(1);return he(Z(r.value),o)}matchGroupToken(e,r,t){let a=e.mark(),n=new Set(t.keys());if(!this.matchTokenSequence(e,r.tokens,t)){e.reset(a);for(let u of t.keys())n.has(u)||t.delete(u);return r.optional||false}return true}getMatchType(e,r){return e.value===r?"exact":e.normalized===r?"normalized":e.stem===r&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===r.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return Z(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let r=(e.normalized||e.value).toLowerCase();return Me(r)?N(r):C(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return N(e.value);let t=e.value.toLowerCase();return Me(t)?N(t):{type:"expression",raw:e.value};case "url":return C(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let a=e.slice(1,-1);return C(a,"string")}if(e==="true")return C(true,"boolean");if(e==="false")return C(false,"boolean");let r=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(r){let a=parseFloat(r[1]);return r[2]?C(e,"duration"):C(a,"number")}let t=parseFloat(e);return isNaN(t)?C(e,"string"):C(t,"number")}applyExtractionRules(e,r){for(let[t,a]of Object.entries(e.extraction))r.has(t)||(a.value!==void 0?r.set(t,{type:"literal",value:a.value}):a.default&&r.set(t,a.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let r=e.peek();if(!r)return;let t=r.value.toLowerCase();if(Q.ENGLISH_NOISE_WORDS.has(t)){let a=e.mark();e.advance();let n=e.peek();if(n&&(n.kind==="selector"||n.kind==="identifier"))return;e.reset(a);}t==="class"&&e.advance();}extractEventModifiers(e){let r={},t=false;for(;!e.isAtEnd();){let a=e.peek();if(!a||a.kind!=="event-modifier")break;let n=a.metadata;if(!n)break;switch(t=true,n.modifierName){case "once":r.once=true;break;case "debounce":typeof n.value=="number"&&(r.debounce=n.value);break;case "throttle":typeof n.value=="number"&&(r.throttle=n.value);break;case "queue":(n.value==="first"||n.value==="last"||n.value==="all"||n.value==="none")&&(r.queue=n.value);break}e.advance();}return t?r:void 0}};le.MAX_PROPERTY_DEPTH=10;le.MAX_METHOD_ARGS=20;le.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ot=le,_=new Ot;function ee(i,e){return tt(i,e)}function ar(){return rt()}var Nt={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 It={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)"}},Lt={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"}},jt={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",targetRole:"source",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},$t={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"},markerVariants:{en:["before","after"]},methodCarrier:"method"}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},Vt={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>"}},qt={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}]},Wt={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}]},Kt={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}]},Ut={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}]},Ht={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"duration",roles:[{role:"duration",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},Gt={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2,markerOverride:{en:"as"}},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},Yt={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"}}]},Jt={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"}}]},Xt={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"}}]},Qt={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"}}]},Zt={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}]},ei={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}]},ri={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}]},ti={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}]},ii={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}]},ai={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}]},ni={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}]},oi={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"}}]},ui={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}]},si={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}]},li={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},ci={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"'},mi={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"}}]},pi={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}]},di={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},yi={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:""}}]},fi={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}]},hi={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"}}]},vi={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}]},Ei={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}]},gi={action:"empty",description:"Remove all children from an element (sets innerHTML to empty)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to empty (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},zi={action:"open",description:"Open a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to open (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2},{role:"style",description:"Open-mode variant (modal / non-modal) for <dialog>",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:{en:"as"}}]},ki={action:"close",description:"Close a dialog, details element, or popover",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to close (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},bi={action:"select",description:"Select the contents of a text field or DOM element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element whose contents to select (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ci={action:"clear",description:"Clear a variable, local, or input element",category:"variable",primaryRole:"patient",roles:[{role:"patient",description:"The variable or element to clear (defaults to me)",required:false,expectedTypes:["selector","reference","expression"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},Ai={action:"reset",description:"Reset a <form> element to its default values",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The form element to reset (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},wi={action:"breakpoint",description:"Drop into the debugger",category:"control-flow",primaryRole:"patient",roles:[]},Di={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}]},xi={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}]},Bi={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}]},Si={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Fi={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:""}}]},Ti={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"}}]},Pi={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Ri={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}]},_i={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}]},Oi={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"}}]},Ni={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"}}]},Mi={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"}}]},Ii={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}]},Li={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},ji={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}]},$i={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Vi={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}]},qi={action:"scroll",description:"Scroll the viewport to a target element",category:"navigation",primaryRole:"destination",argSkipTokens:["of","the","top","bottom","middle","center","nearest","left","right","smoothly","instantly"],roles:[{role:"destination",description:"The element to scroll to",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:1,markerOverride:{en:"to"}}]},nr={en:"url",es:"url",pt:"url",fr:"url",de:"url",it:"url",ja:"url",ko:"url",zh:"url",ar:"url",he:"url",hi:"url",bn:"url",tr:"url",ru:"url",uk:"url",pl:"url",id:"url",vi:"url",th:"url",ms:"url",tl:"url",sw:"url",qu:"url"},Wi={en:"partials in",es:"partials in",pt:"partials in",fr:"partials in",de:"partials in",it:"partials in",ja:"partials in",ko:"partials in",zh:"partials in",ar:"partials in",he:"partials in",hi:"partials in",bn:"partials in",tr:"partials in",ru:"partials in",uk:"partials in",pl:"partials in",id:"partials in",vi:"partials in",th:"partials in",ms:"partials in",tl:"partials in",sw:"partials in",qu:"partials in"},Ki={action:"push",description:"Push a URL onto the browser history",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to push (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:nr}]},Ui={action:"replace",description:"Replace the current browser history entry with a URL",category:"navigation",primaryRole:"patient",roles:[{role:"patient",description:"The URL to replace with (after the `url` keyword)",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,markerOverride:nr}]},Hi={action:"process",description:"Process hx-partial markup in HTML content",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The HTML content (string, element, or response) to process",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:1,markerOverride:Wi}]},Gi={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}]},or={toggle:It,add:Lt,remove:jt,put:$t,set:Vt,show:qt,hide:Wt,on:Kt,trigger:Ut,wait:Ht,fetch:Gt,increment:Yt,decrement:Jt,append:Xt,prepend:Qt,log:Zt,get:ei,take:ri,make:ti,halt:ii,settle:ai,throw:ni,send:oi,if:ui,unless:si,else:li,repeat:ci,for:mi,while:pi,continue:di,go:yi,scroll:qi,push:Ki,replace:Ui,process:Hi,transition:fi,clone:hi,focus:vi,blur:Ei,empty:gi,open:zi,close:ki,select:bi,clear:Ci,reset:Ai,breakpoint:wi,call:Di,return:xi,js:Bi,async:Si,tell:Fi,default:Ti,init:Pi,behavior:Ri,install:_i,measure:Oi,swap:Ni,morph:Mi,beep:Ii,break:Li,copy:ji,exit:$i,pick:Vi,render:Gi,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Yi(){return Object.values(or).filter(i=>i.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Xr(),Je)).then(({validateAllSchemas:i,formatValidationResults:e})=>{let r=i(or);r.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(r)),console.warn(`
|
|
3
|
+
These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(i=>{console.debug("Schema validation skipped:",i);});var We=class extends Error{constructor(i,e,r,t){super(i),this.name="SemanticParseError",this.language=e,this.input=r,this.diagnostics=t;}};function S(i,e,r){return {message:i,severity:e,source:"semantic-parser",...r&&{code:r}}}function se(i,e){return e.length===0?i:{...i,diagnostics:e}}var K=class F{parse(e,r){let{modifiers:t,remainingInput:a}=this.extractStandaloneModifiers(e,r),n=a||e,o=[],u=ee(n,r),s=V(r);if(s.length===0)throw new We(`No patterns available for language: ${r}`,r,n,[S(`No patterns registered for language '${r}'`,"error","no-patterns")]);let l=[...s].sort((h,E)=>E.priority-h.priority),c=l.filter(h=>h.command==="on"),m=_.matchBest(u,c);if(m){o.push(S(`event pattern matched: ${m.pattern.id} (confidence: ${m.confidence.toFixed(2)})`,"info","pattern-match"));let h=this.buildEventHandler(m,u,r),E=t?this.applyModifiers(h,t):h;return se(E,o)}o.push(S(`event patterns: ${c.length} tried, no match`,"info","stage-event"));let p=l.filter(h=>h.command!=="on"),d=_.matchBest(u,p);if(d)return o.push(S(`command pattern matched: ${d.pattern.id} (confidence: ${d.confidence.toFixed(2)})`,"info","pattern-match")),se(this.buildCommand(d,r),o);o.push(S(`command patterns: ${p.length} tried, no match`,"info","stage-command"));let y=this.trySOVEventExtraction(n,r,l);if(y){o.push(S("SOV event extraction succeeded","info","stage-sov"));let h=t?this.applyModifiers(y,t):y;return se(h,o)}o.push(S("SOV event extraction: no event keyword found","info","stage-sov"));let v=this.tryCompoundCommandParsing(u,p,r);if(v)return o.push(S("compound command parsing succeeded","info","stage-compound")),se(v,o);throw o.push(S("compound parsing: no then-keywords or no command matches","info","stage-compound")),o.push(S(`all parse stages exhausted for "${n}"`,"error","parse-failed")),new We(`Could not parse input in ${r}: ${n}`,r,n,o)}canParse(e,r){try{return this.parse(e,r),!0}catch{return false}}supportedLanguages(){return ar()}buildCommand(e,r){if(!e)throw new Error("No match to build command from");let t={};for(let[a,n]of e.captured)t[a]=n;return ue(e.pattern.command,t,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,r,t){if(!e)throw new Error("No match to build event handler from");let a=e.captured.get("event");if(!a)throw new Error("Event handler pattern matched but no event captured");let n=_.extractEventModifiers(r),o=this.extractOrConjunctionEvents(r,t),u=a;o.length>0&&a.type==="literal"&&(u={type:"literal",value:[String(a.value),...o.map(m=>String("value"in m?m.value:""))].join(" or ")});let s,l=e.captured.get("action");if(l&&l.type==="literal"){let c=l.value,m={};for(let[y,v]of e.captured)y!=="event"&&y!=="action"&&y!=="continues"&&(m[y]=v);let p=ue(c,m,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence}),d=e.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then"){let y=V(t).filter(E=>E.command!=="on").sort((E,z)=>z.priority-E.priority),v=V(t).filter(E=>E.id.startsWith("grammar-")&&E.id.includes("-continuation")).sort((E,z)=>z.priority-E.priority),h=this.parseBodyWithGrammarPatterns(r,y,v,t);h.length>0?s=[p,...h]:s=[p];}else s=[p];}else {let c=V(t).filter(m=>m.command!=="on").sort((m,p)=>p.priority-m.priority);s=this.parseBodyWithClauses(r,c,t);}return Ie(u,s,n,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,r,t){let a=[],n=[];for(;!e.isAtEnd();){let o=e.peek();if(!o)break;let u=o.kind==="conjunction"||o.kind==="keyword"&&this.isThenKeyword(o.value,t),s=o.kind==="keyword"&&this.isEndKeyword(o.value,t);if(u){if(n.length>0){let l=this.parseClause(n,r,t);a.push(...l),n.length=0;}e.advance();continue}if(s){if(n.length>0){let l=this.parseClause(n,r,t);a.push(...l);}e.advance();break}n.push(o),e.advance();}if(n.length>0){let o=this.parseClause(n,r,t);a.push(...o);}return a.length>1?[Le(a,"then",{sourceLanguage:t})]:a}parseClause(e,r,t){if(e.length===0)return [];let a=new J(e,t),n=[];for(;!a.isAtEnd();){let o=_.matchBest(a,r);o?n.push(this.buildCommand(o,t)):a.advance();}if(n.length===0){let o=this.parseSOVClauseByVerbAnchoring(e,t);if(o.length>0)return o}return n}static buildVerbLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(t)&&(r.set(a.primary.toLowerCase(),t),a.alternatives))for(let n of a.alternatives)r.set(n.toLowerCase(),t);return r}static buildMarkerToRoleLookup(e){let r=new Map;for(let[t,a]of Object.entries(e.roleMarkers))if(a&&(r.set(a.primary,t),a.alternatives))for(let n of a.alternatives)r.has(n)||r.set(n,t);return r}parseSOVClauseByVerbAnchoring(e,r){let t=I(r);if(!t||t.wordOrder!=="SOV")return [];let a=F.buildVerbLookup(t),n=F.buildMarkerToRoleLookup(t),o=[],u=0;for(;u<e.length;){let s=-1,l="";for(let y=u;y<e.length;y++){let v=e[y],h=a.get(v.value.toLowerCase()),E=v.normalized?a.get(v.normalized.toLowerCase()):void 0,z=h||E;if(z){s=y,l=z;break}}if(s===-1)break;let c=e.slice(u,s),m=e.length;for(let y=s+1;y<e.length;y++){let v=e[y];if(v.kind==="conjunction"||this.isThenKeyword(v.value,r)){m=y;break}if(y>s+1&&(a.get(v.value.toLowerCase())||(v.normalized?a.get(v.normalized.toLowerCase()):void 0))){m=y;break}}let p=e.slice(s+1,m),d=this.extractRolesFromMarkedTokens(c,p,n,l,r);if(o.push(ue(l,d,{sourceLanguage:r,confidence:.7})),u=m,u<e.length){let y=e[u];(y.kind==="conjunction"||this.isThenKeyword(y.value,r))&&u++;}}return o}extractRolesFromMarkedTokens(e,r,t,a,n){let o={},u=s=>{let l=[];for(let c of s){let m=t.get(c.value);if(m&&c.kind==="particle"&&l.length>0){let p=this.tokensToSemanticValue(l);if(p){let d=this.mapRoleForCommand(m,a,o);d&&(o[d]=p);}l=[];}else l.push(c);}if(l.length>0){let c=this.tokensToSemanticValue(l);c&&(o.patient?o.destination||(o.destination=c):o.patient=c);}};return u(e),u(r),o}mapRoleForCommand(e,r,t){return t[e]?e==="patient"&&!t.destination?"destination":e==="destination"&&!t.patient?"patient":e==="source"&&!t.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let r=e.filter(n=>n.kind!=="whitespace");if(r.length===0)return null;if(r.length===1)return this.tokenToSemanticValue(r[0]);let t=r.map(n=>n.value).join(""),a=r[0];return a.kind==="selector"||a.value.startsWith("#")||a.value.startsWith(".")||a.value.startsWith("@")||a.value.startsWith("*")?Z(t):a.kind==="literal"||a.value.startsWith('"')||a.value.startsWith("'")?C(t):a.kind==="reference"?N(t):C(t)}tokenToSemanticValue(e){let r=e.value;if(e.kind==="selector"||r.startsWith("#")||r.startsWith(".")||r.startsWith("@")||r.startsWith("*"))return Z(r);if(r.startsWith('"')||r.startsWith("'"))return C(r);if(/^-?\d+(\.\d+)?$/.test(r))return C(parseFloat(r));if(r==="true"||r==="\u771F"||r==="\uCC38"||r==="do\u011Fru")return C(true);if(r==="false"||r==="\u507D"||r==="\uAC70\uC9D3"||r==="yanl\u0131\u015F")return C(false);let t=e.normalized?.toLowerCase();return t==="me"||t==="it"||t==="you"||t==="result"||t==="body"?N(t):e.kind==="reference"?N(e.normalized||"me"):C(r)}parseBodyWithGrammarPatterns(e,r,t,a){let n=[];for(;!e.isAtEnd();){let o=e.peek();if(o&&this.isThenKeyword(o.value,a)){e.advance();continue}if(o&&this.isEndKeyword(o.value,a)){e.advance();break}let u=false;if(t.length>0){let s=_.matchBest(e,t);if(s){let l=s.pattern.command,c={};for(let[d,y]of s.captured)d!=="event"&&d!=="action"&&d!=="continues"&&(c[d]=y);let m=ue(l,c,{sourceLanguage:a,patternId:s.pattern.id});n.push(m),u=true;let p=s.captured.get("continues");if(p&&p.type==="literal"&&p.value==="then")continue}}if(!u){let s=_.matchBest(e,r);s&&(n.push(this.buildCommand(s,a)),u=true);}u||e.advance();}return n}tryCompoundCommandParsing(e,r,t){let a=e.tokens;if(!a.some(s=>s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,t)))return null;let o=new J(a,t),u=this.parseBodyWithClauses(o,r,t);return u.length===0?null:u.length===1?u[0]:Le(u,"then",{sourceLanguage:t,confidence:.65})}trySOVEventExtraction(e,r,t){let a=F.SOV_EVENT_MARKERS[r];if(!a)return null;let o=ee(e,r).tokens,u=Nt[r],s=new Set;if(u)for(let g of Object.keys(u))s.add(g.toLowerCase());let l=F.SOV_SOURCE_MARKERS[r],c=-1,m="",p="",d=1;for(let g=0;g<o.length;g++){let A=o[g],P=A.value.toLowerCase(),R=P,L="",pe=P.indexOf("[");pe>0&&(R=P.slice(0,pe),L=A.value.slice(pe));let de=A.normalized?.toLowerCase(),we=de&&F.KNOWN_EVENTS.has(de),De=s.has(P)||s.has(R),gr=F.KNOWN_EVENTS.has(R);if(we||De||gr){let U;if(we?U=de:De?U=u?.[P]??u?.[R]??R:U=R,a.size>0){let ie=1,ye=o[g+1];ye&&ye.kind==="selector"&&ye.value.startsWith("[")&&(ie=2);let ae=o[g+ie];if(ae&&(ae.kind==="particle"||ae.kind==="keyword")&&a.has(ae.value)){c=g,m=U,p=L||(ie===2?o[g+1].value:""),d=ie+1;break}}else {c=g,m=U,p=L,d=1;break}}}if(c===-1)return null;let y=new Set;for(let g=c;g<c+d;g++)y.add(g);if(l){let g=c+d;if(g<o.length){let A=o[g];(A.kind==="particle"||A.kind==="keyword")&&l.markers.has(A.value)&&y.add(g);}for(let A=0;A<c;A++){let P=o[A],R=P.value.toLowerCase(),L=P.normalized?.toLowerCase();if(l.windowTokens.has(R)||L&&l.windowTokens.has(L)){y.add(A);break}}}let v=o.filter((g,A)=>!y.has(A));if(v.length===0)return null;let h=t.filter(g=>g.command!=="on"),E=new J(v,r),z=this.parseBodyWithClauses(E,h,r);if(z.length===0)return null;let Ae={sourceLanguage:r,confidence:.75};return p&&(Ae.keyFilter=p),Ie({type:"literal",value:m},z,void 0,Ae)}isThenKeyword(e,r){let t={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 (t[r]||t.en).has(e.toLowerCase())}isEndKeyword(e,r){let t={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 (t[r]||t.en).has(e.toLowerCase())}extractStandaloneModifiers(e,r){let a=ee(e,r).tokens;if(a.length===0)return {modifiers:null,remainingInput:null};let o=a[0].value.toLowerCase(),u=F.STANDALONE_MODIFIERS[o];if(!u)return {modifiers:null,remainingInput:null};let s={},l=1;if(u==="once")s.once=true;else {let d=1;if(d<a.length){let y=a[d];(y.kind==="keyword"||y.kind==="particle")&&(d++,l++);}if(d<a.length){let y=a[d];if(y.kind==="literal"){let v=y.value.match(/^(\d+)(ms|s|m)?$/);if(v){let h=parseInt(v[1],10),E=v[2]||"ms";E==="s"?h*=1e3:E==="m"&&(h*=6e4),s[u]=h,l=d+1;}}}s[u]||(s[u]=u==="debounce"?300:100);}let c=a.slice(l);if(c.length===0)return {modifiers:null,remainingInput:null};let m=c[0].position.start,p=e.slice(m);return {modifiers:s,remainingInput:p}}applyModifiers(e,r){return {...e,eventModifiers:{...e.eventModifiers,...r}}}extractOrConjunctionEvents(e,r){let t=[];for(;;){let a=e.mark(),n=e.peek();if(!n)break;let o=(n.normalized||n.value).toLowerCase();if(!F.OR_KEYWORDS.has(o)){e.reset(a);break}e.advance();let u=e.peek();if(!u){e.reset(a);break}let s=(u.normalized||u.value).toLowerCase();e.advance(),t.push({type:"literal",value:s});}return t}};K.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);K.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};K.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};K.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};K.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Ji=K,Xi=new Ji;function Qi(i,e){return Xi.parse(i,e)}function Zi(i,e){try{let r=ee(i,e),t=V(e);if(t.length===0)return {confidence:0,parseSuccess:!1,error:`No patterns available for language: ${e}`};let a=[...t].sort((l,c)=>c.priority-l.priority),n=a.filter(l=>l.command==="on"),o=_.matchBest(r,n);if(o)return {confidence:o.confidence,parseSuccess:!0,patternId:o.pattern.id,action:o.pattern.command,tokensConsumed:o.consumedTokens};r.reset(r.mark());let u=a.filter(l=>l.command!=="on"),s=_.matchBest(r,u);return s?{confidence:s.confidence,parseSuccess:!0,patternId:s.pattern.id,action:s.pattern.command,tokensConsumed:s.consumedTokens}:{confidence:0,parseSuccess:!1,error:`Could not match any patterns for: ${i}`}}catch(r){return {confidence:0,parseSuccess:false,error:r instanceof Error?r.message:String(r)}}}function ur(i,e){try{let t=Qi(i,e);if(t)return {node:t,confidence:t.metadata?.confidence??.8,error:void 0,tokensConsumed:ee(i,e).tokens.length}}catch{}let r=Zi(i,e);return r.parseSuccess?{node:null,confidence:r.confidence,error:void 0,tokensConsumed:r.tokensConsumed}:{node:null,confidence:0,error:r.error}}function sr(i,e){let r=e==="SOV"?"sovPosition":"svoPosition";return [...i].sort((t,a)=>{let n=t[r]??99,o=a[r]??99;return n-o})}function ea(i,e){let r=i.markerOverride?.[e.code],t=e.roleMarkers[i.role];if(r!==void 0)return {primary:r,position:t?.position??"before",isOverride:true};if(t&&t.primary){let a={primary:t.primary,position:t.position,isOverride:false};return t.alternatives&&(a.alternatives=t.alternatives),a}return null}function ra(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let o=e.roleMarkers.destination;o&&n.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary}]}),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.patient;if(u){let l=u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary};n.push(l);}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${i.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`{event} ${t.primary} {destination?} {patient} ${u?.primary||""} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ta(i,e,r,t,a){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(s);}if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let s=t.primary.split(/\s+/);if(s.length>1)for(let l of s)n.push({type:"literal",value:l});else {let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${i.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`{patient} ${o?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ia(i,e,r,t,a){let n=[];n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}let u=e.roleMarkers.destination;if(u&&(n.push({type:"role",role:"destination",optional:false}),n.push(u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary})),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let l=t.primary.split(/\s+/);if(l.length>1)for(let c of l)n.push({type:"literal",value:c});else {let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(s),{id:`${i.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(a.basePriority??100)+40,template:{format:`{patient} ${o?.primary||""} {destination} ${u?.primary||""} {event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function aa(i,e,r,t,a){let n=[];n.push({type:"role",role:"event",optional:false});let o=t.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];o.length>0&&n.push({type:"literal",value:o[0],alternatives:o.slice(1)});let u=e.roleMarkers.destination;u&&n.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary}]}),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};n.push(c);}let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(l),{id:`${i.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(a.basePriority??100)+52,template:{format:`{event}${o[0]||""} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function na(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let u=t.primary.split(/\s+/);if(u.length>1)for(let s of u)n.push({type:"literal",value:s});else {let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}}let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(o),{id:`${i.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{event} ${t.primary} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function oa(i,e,r,t){let a=e.eventHandler?.temporalMarkers;if(!a||a.length===0)return null;let n=[];n.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&n.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),n.push({type:"literal",value:a[0],alternatives:a.slice(1)}),n.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.patient;if(o?.primary){let s=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(s);}let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};return n.push(u),{id:`${i.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(t.basePriority??100)+49,template:{format:`{event} ${a[0]} {patient} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function ua(i,e,r,t,a){let n=[];if(n.push({type:"role",role:"event",optional:false}),t.position==="after"){let c=t.primary.split(/\s+/);if(c.length>1)for(let m of c)n.push({type:"literal",value:m});else {let m=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(m);}}let u=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.sovPosition??999,d=m.sovPosition??999;return p-d});for(let c of u){n.push({type:"role",role:c.role,optional:false});let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}}let s=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(s);let l=u.map(c=>`{${c.role}}`).join(" ");return {id:`${i.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`{event} ${t.primary} ${l} ${r.primary}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(u.map(c=>[c.role,{fromRole:c.role}]))}}}function sa(i,e,r,t,a){let n=[],u=[...i.roles.filter(y=>y.required)].sort((y,v)=>{let h=y.sovPosition??999,E=v.sovPosition??999;return h-E}),s=u[0];n.push({type:"role",role:s.role,optional:false});let l;if(s.markerOverride&&s.markerOverride[e.code]!==void 0)l=s.markerOverride[e.code];else {let y=e.roleMarkers[s.role];y&&(l=y.primary);}if(l&&n.push({type:"literal",value:l}),n.push({type:"role",role:"event",optional:false}),t.position==="after"){let y=t.primary.split(/\s+/);if(y.length>1)for(let v of y)n.push({type:"literal",value:v});else {let v=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(v);}}let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(c);let m=u[1];n.push({type:"role",role:m.role,optional:false});let p,d;if(m.markerOverride&&m.markerOverride[e.code]!==void 0)p=m.markerOverride[e.code];else {let y=e.roleMarkers[m.role];y&&(p=y.primary,d=y.alternatives);}if(p){let y=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};n.push(y);}return {id:`${i.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`{${s.role}} {event} ${t.primary} ${r.primary} {${m.role}}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},[s.role]:{fromRole:s.role},[m.role]:{fromRole:m.role}}}}function Ke(i,e,r,t,a){let n=[];if(t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;return u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),{id:`${i.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(a.basePriority??100)+50,template:{format:`${t.primary} {event} ${r.primary} {patient} ${u?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function la(i,e,r,t,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o),n.push({type:"role",role:"patient",optional:false});let u=e.roleMarkers.destination;if(u&&n.push({type:"group",optional:true,tokens:[u.alternatives?{type:"literal",value:u.primary,alternatives:u.alternatives}:{type:"literal",value:u.primary},{type:"role",role:"destination",optional:true}]}),t.position==="before"){let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(s);}return n.push({type:"role",role:"event",optional:false}),{id:`${i.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(a.basePriority??100)+45,template:{format:`${r.primary} {patient} ${u?.primary||""} {destination?} ${t.primary} {event}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ca(i,e,r,t,a){let n=[],o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}n.push({type:"role",role:"event",optional:false});let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${i.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${r.primary} ${l} ${t.primary} {event}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function Ue(i,e,r,t,a){let n=[];if(t.position==="before"){let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(c);}n.push({type:"role",role:"event",optional:false});let o=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(o);let s=[...i.roles.filter(c=>c.required)].sort((c,m)=>{let p=c.svoPosition??999,d=m.svoPosition??999;return p-d});for(let c of s){let m,p;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)m=c.markerOverride[e.code];else {let d=e.roleMarkers[c.role];d&&(m=d.primary,p=d.alternatives);}if(m){let d=p?{type:"literal",value:m,alternatives:p}:{type:"literal",value:m};n.push(d);}n.push({type:"role",role:c.role,optional:false});}let l=s.map(c=>`{${c.role}}`).join(" ");return {id:`${i.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(a.basePriority??100)+55,template:{format:`${t.primary} {event} ${r.primary} ${l}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},...Object.fromEntries(s.map(c=>[c.role,{fromRole:c.role}]))}}}function ma(i,e,r,t,a){let n=[],o=e.eventHandler?.negationMarker;if(t.position==="before"){let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};n.push(l);}if(o){let l=o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary};n.push(l);}n.push({type:"role",role:"event",optional:false});let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};n.push(u),n.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&n.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${i.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(a.basePriority??100)+48,template:{format:`${t.primary} ${o?.primary||""} {event} ${r.primary} {patient} ${s?.primary||""} {destination?}`,tokens:n},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function pa(i,e,r,t){let a=[];a.push({type:"literal",value:"and",alternatives:["then"]}),a.push({type:"role",role:"event",optional:false});let n=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};a.push(n),a.push({type:"role",role:"patient",optional:false});let o=e.roleMarkers.destination;return o&&a.push({type:"group",optional:true,tokens:[o.alternatives?{type:"literal",value:o.primary,alternatives:o.alternatives}:{type:"literal",value:o.primary},{type:"role",role:"destination",optional:true}]}),{id:`${i.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(t.basePriority??100)+45,template:{format:`[proclitic?] {event} ${r.primary} {patient} ${o?.primary||""} {destination?}`,tokens:a},extraction:{action:{value:i.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var re={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function lr(i,e,r=re){let t=`${i.action}-${e.code}-generated`,a=r.basePriority??100,n=e.keywords[i.action];if(!n)throw new Error(`No keyword translation for '${i.action}' in ${e.code}`);let o=ha(i,e,n),u=mr(i,e),s=za(i,e,n);return {id:t,language:e.code,command:i.action,priority:a,template:{format:s,tokens:o},extraction:u}}function da(i,e,r=re){if(i.roles.filter(u=>!u.required).length===0)return null;let a=i.roles.filter(u=>u.required),n={...i,roles:a};return {...lr(n,e,r),id:`${i.action}-${e.code}-generated-simple`,priority:(r.basePriority??100)-5,extraction:mr(i,e)}}function ya(i,e,r=re){let t=[];if(t.push(lr(i,e,r)),r.generateSimpleVariants){let a=da(i,e,r);a&&t.push(a);}return t}function cr(i,e=re){let r=[],t=Yi();for(let a of t){if(!i.keywords[a.action])continue;let n=ya(a,i,e);if(r.push(...n),i.eventHandler?.eventMarker){let o=fa(a,i,e);r.push(...o);}}return r}function fa(i,e,r=re){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let t=[],a=e.eventHandler.eventMarker,n=e.keywords[i.action];if(!n)return [];let u=i.roles.filter(s=>s.required).length===2;if(e.wordOrder==="SOV")if(u)t.push(ua(i,e,n,a,r)),t.push(sa(i,e,n,a,r));else {t.push(ra(i,e,n,a,r)),t.push(ta(i,e,n,a,r));let s=e.roleMarkers.destination;s&&s.primary!==a.primary&&t.push(ia(i,e,n,a,r));let l=a.primary.split(/\s+/),c=a.alternatives?.some(p=>!p.includes(" ")&&p.length>1);l.length>1&&c&&t.push(aa(i,e,n,a,r)),t.push(na(i,e,n,a,r));let m=oa(i,e,n,r);m&&t.push(m);}else e.wordOrder==="VSO"?u?(t.push(Ue(i,e,n,a,r)),t.push(ca(i,e,n,a,r))):(t.push(Ke(i,e,n,a,r)),t.push(la(i,e,n,a,r)),e.eventHandler?.negationMarker&&t.push(ma(i,e,n,a,r)),e.tokenization?.prefixes&&t.push(pa(i,e,n,r))):u?t.push(Ue(i,e,n,a,r)):t.push(Ke(i,e,n,a,r));return t}function ha(i,e,r){let t=[],a=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary},n=va(i,e);switch(e.wordOrder){case "SVO":t.push(a),t.push(...n);break;case "SOV":t.push(...n),t.push(a);break;case "VSO":t.push(a),t.push(...n);break;default:t.push(a),t.push(...n);}return t}function va(i,e){let r=[],t=sr(i.roles,e.wordOrder);for(let a of t){let n=Ea(a,e);a.required?r.push(...n):r.push({type:"group",optional:true,tokens:n});}return r}function Ea(i,e){let r=[],t=i.markerOverride?.[e.code],a=e.roleMarkers[i.role],n={type:"role",role:i.role,optional:!i.required,expectedTypes:i.expectedTypes};if(t!==void 0){let o=t?t.split(/\s+/).filter(Boolean):[];if((a?.position??"before")==="before"){for(let s of o)r.push({type:"literal",value:s});r.push(n);}else {r.push(n);for(let s of o)r.push({type:"literal",value:s});}}else if(a)if(a.position==="before"){if(a.primary){let o=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};r.push(o);}r.push(n);}else {r.push(n);let o=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};r.push(o);}else r.push(n);return r}function ga(i,e){let r={};for(let t of i.roles){let a=t.markerOverride?.[e.code],n=e.roleMarkers[t.role];a!==void 0?r[t.role]=a?{marker:a}:{}:n&&n.primary?r[t.role]=n.alternatives?{marker:n.primary,markerAlternatives:n.alternatives}:{marker:n.primary}:r[t.role]={};}return r}function mr(i,e){let r=ga(i,e),t={};for(let a of i.roles){let n=r[a.role]||{};!a.required&&a.default?t[a.role]={...n,default:a.default}:t[a.role]=n;}return t}function za(i,e,r){let t=[],n=sr(i.roles,e.wordOrder).map(o=>{let u=ea(o,e),s="";return u&&u.primary?u.position==="before"?s=`${u.primary} {${o.role}}`:s=`{${o.role}} ${u.primary}`:s=`{${o.role}}`,o.required?s:`[${s}]`});switch(e.wordOrder){case "SVO":case "VSO":t.push(r.primary,...n);break;case "SOV":t.push(...n,r.primary);break;default:t.push(r.primary,...n);}return t.join(" ")}var ka=class{constructor(i={}){this.cache=new Map,this.config={maxSize:i.maxSize??1e3,ttlMs:i.ttlMs??0,enabled:i.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(i,e){return `${e}:${i}`}isExpired(i){return this.config.ttlMs===0?false:Date.now()-i.createdAt>this.config.ttlMs}evictLRU(){let i=this.cache.keys().next().value;i!==void 0&&(this.cache.delete(i),this.stats.evictions++);}get(i,e){if(!this.config.enabled){this.stats.misses++;return}let r=this.makeKey(i,e),t=this.cache.get(r);if(!t){this.stats.misses++;return}if(this.isExpired(t)){this.cache.delete(r),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(r),t.lastAccessed=Date.now(),this.cache.set(r,t),this.stats.hits++,t.result}set(i,e,r){if(!this.config.enabled||r!==null&&typeof r=="object"&&"confidence"in r&&r.confidence===0)return;let t=this.makeKey(i,e),a=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(t,{result:r,createdAt:a,lastAccessed:a});}has(i,e){if(!this.config.enabled)return false;let r=this.makeKey(i,e),t=this.cache.get(r);return t?this.isExpired(t)?(this.cache.delete(r),this.stats.expirations++,false):true:false}delete(i,e){let r=this.makeKey(i,e);return this.cache.delete(r)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let i=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:i>0?this.stats.hits/i:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(i){if(i.maxSize!==void 0)for(this.config.maxSize=i.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();i.ttlMs!==void 0&&(this.config.ttlMs=i.ttlMs),i.enabled!==void 0&&(this.config.enabled=i.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}};new ka;var pr={code:"vi",name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t",direction:"ltr",script:"latin",wordOrder:"SVO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"t\xF4i",it:"n\xF3",you:"b\u1EA1n",result:"k\u1EBFt qu\u1EA3",event:"s\u1EF1 ki\u1EC7n",target:"m\u1EE5c ti\xEAu",body:"body"},possessive:{marker:"c\u1EE7a",markerPosition:"between",specialForms:{me:"c\u1EE7a t\xF4i",it:"c\u1EE7a n\xF3",you:"c\u1EE7a b\u1EA1n"},keywords:{"c\u1EE7a t\xF4i":"me","c\u1EE7a b\u1EA1n":"you","c\u1EE7a anh":"you","c\u1EE7a ch\u1ECB":"you","c\u1EE7a n\xF3":"it"}},roleMarkers:{destination:{primary:"v\xE0o",alternatives:["cho","\u0111\u1EBFn"],position:"before"},source:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],position:"before"},patient:{primary:"",position:"before"},style:{primary:"v\u1EDBi",position:"before"}},keywords:{toggle:{primary:"chuy\u1EC3n \u0111\u1ED5i",alternatives:["b\u1EADt t\u1EAFt","chuy\u1EC3n"],normalized:"toggle"},add:{primary:"th\xEAm",alternatives:["b\u1ED5 sung"],normalized:"add"},remove:{primary:"x\xF3a",alternatives:["g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ECF"],normalized:"remove"},put:{primary:"\u0111\u1EB7t",alternatives:["\u0111\u1EC3","\u0111\u01B0a"],normalized:"put"},append:{primary:"n\u1ED1i",normalized:"append"},prepend:{primary:"th\xEAm v\xE0o \u0111\u1EA7u",normalized:"prepend"},take:{primary:"l\u1EA5y",normalized:"take"},make:{primary:"t\u1EA1o",normalized:"make"},clone:{primary:"nh\xE2n b\u1EA3n",normalized:"clone"},swap:{primary:"ho\xE1n \u0111\u1ED5i",normalized:"swap"},morph:{primary:"bi\u1EBFn \u0111\u1ED5i",normalized:"morph"},set:{primary:"g\xE1n",alternatives:["thi\u1EBFt l\u1EADp"],normalized:"set"},get:{primary:"l\u1EA5y gi\xE1 tr\u1ECB",alternatives:["nh\u1EADn"],normalized:"get"},increment:{primary:"t\u0103ng",alternatives:["t\u0103ng l\xEAn"],normalized:"increment"},decrement:{primary:"gi\u1EA3m",alternatives:["gi\u1EA3m \u0111i"],normalized:"decrement"},log:{primary:"in ra",normalized:"log"},show:{primary:"hi\u1EC3n th\u1ECB",alternatives:["hi\u1EC7n"],normalized:"show"},hide:{primary:"\u1EA9n",alternatives:["che","gi\u1EA5u"],normalized:"hide"},transition:{primary:"chuy\u1EC3n ti\u1EBFp",normalized:"transition"},on:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},trigger:{primary:"k\xEDch ho\u1EA1t",normalized:"trigger"},send:{primary:"g\u1EEDi",normalized:"send"},focus:{primary:"t\u1EADp trung",normalized:"focus"},blur:{primary:"m\u1EA5t t\u1EADp trung",normalized:"blur"},empty:{primary:"l\xE0m-r\u1ED7ng",normalized:"empty"},open:{primary:"m\u1EDF",normalized:"open"},close:{primary:"\u0111\xF3ng",normalized:"close"},select:{primary:"\u0111\xE1nh-d\u1EA5u",normalized:"select"},clear:{primary:"t\u1EA9y",normalized:"clear"},reset:{primary:"\u0111\u1EB7t-l\u1EA1i",normalized:"reset"},breakpoint:{primary:"\u0111i\u1EC3m-d\u1EEBng",normalized:"breakpoint"},click:{primary:"nh\u1EA5p",alternatives:["b\u1EA5m"],normalized:"click"},hover:{primary:"di chu\u1ED9t",alternatives:["r\xEA chu\u1ED9t"],normalized:"hover"},submit:{primary:"n\u1ED9p",alternatives:[],normalized:"submit"},input:{primary:"nh\u1EADp",alternatives:["nh\u1EADp li\u1EC7u"],normalized:"input"},change:{primary:"thay \u0111\u1ED5i",alternatives:["\u0111\u1ED5i"],normalized:"change"},go:{primary:"\u0111i \u0111\u1EBFn",alternatives:["\u0111i"],normalized:"go"},scroll:{primary:"cu\u1ED9n",normalized:"scroll"},push:{primary:"\u0111\u1EA9y",alternatives:["push"],normalized:"push"},replace:{primary:"thay_th\u1EBF",alternatives:["thay_the"],normalized:"replace"},process:{primary:"x\u1EED_l\xFD",alternatives:["xu_ly"],normalized:"process"},wait:{primary:"ch\u1EDD",alternatives:["\u0111\u1EE3i"],normalized:"wait"},fetch:{primary:"t\u1EA3i",normalized:"fetch"},settle:{primary:"\u1ED5n \u0111\u1ECBnh",normalized:"settle"},if:{primary:"n\u1EBFu",normalized:"if"},when:{primary:"l\xFAc",normalized:"when"},where:{primary:"\u1EDF_\u0111\xE2u",normalized:"where"},else:{primary:"kh\xF4ng th\xEC",alternatives:["n\u1EBFu kh\xF4ng"],normalized:"else"},repeat:{primary:"l\u1EB7p l\u1EA1i",normalized:"repeat"},for:{primary:"v\u1EDBi m\u1ED7i",normalized:"for"},while:{primary:"trong khi",normalized:"while"},continue:{primary:"ti\u1EBFp t\u1EE5c",normalized:"continue"},halt:{primary:"d\u1EEBng",alternatives:["d\u1EEBng l\u1EA1i"],normalized:"halt"},throw:{primary:"n\xE9m",normalized:"throw"},call:{primary:"g\u1ECDi",normalized:"call"},return:{primary:"tr\u1EA3 v\u1EC1",normalized:"return"},then:{primary:"r\u1ED3i",alternatives:["sau \u0111\xF3","th\xEC"],normalized:"then"},and:{primary:"v\xE0",normalized:"and"},end:{primary:"k\u1EBFt th\xFAc",normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"b\u1EA5t \u0111\u1ED3ng b\u1ED9",normalized:"async"},tell:{primary:"n\xF3i v\u1EDBi",normalized:"tell"},default:{primary:"m\u1EB7c \u0111\u1ECBnh",normalized:"default"},init:{primary:"kh\u1EDFi t\u1EA1o",normalized:"init"},behavior:{primary:"h\xE0nh vi",normalized:"behavior"},install:{primary:"c\xE0i \u0111\u1EB7t",normalized:"install"},measure:{primary:"\u0111o l\u01B0\u1EDDng",normalized:"measure"},beep:{primary:"beep",normalized:"beep"},break:{primary:"ng\u1EAFt",normalized:"break"},copy:{primary:"sao ch\xE9p",normalized:"copy"},exit:{primary:"tho\xE1t",normalized:"exit"},pick:{primary:"ch\u1ECDn",normalized:"pick"},render:{primary:"k\u1EBFt xu\u1EA5t",normalized:"render"},into:{primary:"v\xE0o",alternatives:["v\xE0o trong"],normalized:"into"},before:{primary:"tr\u01B0\u1EDBc",alternatives:["tr\u01B0\u1EDBc khi"],normalized:"before"},after:{primary:"sau",alternatives:["sau khi"],normalized:"after"},until:{primary:"cho \u0111\u1EBFn khi",normalized:"until"},event:{primary:"s\u1EF1 ki\u1EC7n",normalized:"event"},from:{primary:"t\u1EEB",alternatives:["kh\u1ECFi"],normalized:"from"},connect:{primary:"k\u1EBFt-n\u1ED1i",alternatives:["k\u1EBFt-n\u1ED1i-t\u1EDBi"],normalized:"connect"},stream:{primary:"truy\u1EC1n-ph\xE1t",alternatives:["ph\xE1t","lu\u1ED3ng"],normalized:"stream"},live:{primary:"tr\u1EF1c-ti\u1EBFp",alternatives:["ph\xE1t-tr\u1EF1c-ti\u1EBFp"],normalized:"live"},socket:{primary:"socket",alternatives:["\u1ED5-c\u1EAFm","websocket"],normalized:"socket"}},eventHandler:{keyword:{primary:"khi",alternatives:["tr\xEAn"],normalized:"on"},sourceMarker:{primary:"tr\xEAn",alternatives:["t\u1EA1i"],position:"before"},eventMarker:{primary:"khi",alternatives:["l\xFAc"],position:"before"},temporalMarkers:["khi","l\xFAc"]}};function ba(i){return {isLetter:t=>i.test(t),isIdentifierChar:t=>/[0-9]/.test(t)||i.test(t)}}var{isLetter:Ca,isIdentifierChar:Aa}=ba(/[a-zA-ZàáảãạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹỵđÀÁẢÃẠĂẰẮẲẴẶÂẦẤẨẪẬÈÉẺẼẸÊỀẾỂỄỆÌÍỈĨỊÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢÙÚỦŨỤƯỪỨỬỮỰỲÝỶỸỴĐ]/),wa=new Set(["trong","ngo\xE0i","tr\xEAn","d\u01B0\u1EDBi","v\xE0o","ra","\u0111\u1EBFn","t\u1EEB","v\u1EDBi","cho","b\u1EDFi","qua","tr\u01B0\u1EDBc","sau","gi\u1EEFa","b\xEAn","theo","v\u1EC1","t\u1EDBi","l\xEAn","xu\u1ED1ng"]),Da=class{constructor(){this.name="vietnamese-keyword";}setContext(i){this.context=i;}canExtract(i,e){return Ca(i[e])}extract(i,e){if(!this.context)throw new Error("VietnameseKeywordExtractor: context not set");let r=this.tryMultiWordPhrase(i,e);if(r)return r;let t=e,a="";for(;t<i.length&&Aa(i[t]);)a+=i[t++];if(!a)return null;let n=a.toLowerCase(),o=wa.has(n),u=this.context.lookupKeyword(n),s=u&&u.normalized!==u.native?u.normalized:void 0;return {value:a,length:t-e,metadata:{normalized:s,isPreposition:o}}}tryMultiWordPhrase(i,e){if(!this.context)return null;let r=["chuy\u1EC3n \u0111\u1ED5i","b\u1EADt t\u1EAFt","hi\u1EC3n th\u1ECB","g\u1EE1 b\u1ECF","lo\u1EA1i b\u1ECF","b\u1ED5 sung","th\xEAm v\xE0o \u0111\u1EA7u","ho\xE1n \u0111\u1ED5i","bi\u1EBFn \u0111\u1ED5i","thi\u1EBFt l\u1EADp","l\u1EA5y gi\xE1 tr\u1ECB","t\u0103ng l\xEAn","gi\u1EA3m \u0111i","in ra","chuy\u1EC3n ti\u1EBFp","k\xEDch ho\u1EA1t","t\u1EADp trung","m\u1EA5t t\u1EADp trung","nh\u1EA5p chu\u1ED9t","di chu\u1ED9t","r\xEA chu\u1ED9t","nh\u1EADp li\u1EC7u","thay \u0111\u1ED5i","\u0111i \u0111\u1EBFn","ch\u1EDD \u0111\u1EE3i","\u1ED5n \u0111\u1ECBnh","n\u1EBFu kh\xF4ng","kh\xF4ng th\xEC","l\u1EB7p l\u1EA1i","v\u1EDBi m\u1ED7i","trong khi","ti\u1EBFp t\u1EE5c","d\u1EEBng l\u1EA1i","tr\u1EA3 v\u1EC1","sau \u0111\xF3","k\u1EBFt th\xFAc","b\u1EA5t \u0111\u1ED3ng b\u1ED9","n\xF3i v\u1EDBi","m\u1EB7c \u0111\u1ECBnh","kh\u1EDFi t\u1EA1o","h\xE0nh vi","c\xE0i \u0111\u1EB7t","\u0111o l\u01B0\u1EDDng","sao ch\xE9p","tho\xE1t ra","k\u1EBFt xu\u1EA5t","v\xE0o trong","tr\u01B0\u1EDBc khi","sau khi","cho \u0111\u1EBFn khi","s\u1EF1 ki\u1EC7n","k\u1EBFt qu\u1EA3","m\u1EE5c ti\xEAu","c\u1EE7a t\xF4i","c\u1EE7a n\xF3","c\u1EE7a b\u1EA1n","c\u1EE7a anh","c\u1EE7a ch\u1ECB","kh\xF4ng x\xE1c \u0111\u1ECBnh","\u0111\u1EA7u ti\xEAn","cu\u1ED1i c\xF9ng","ti\u1EBFp theo","tr\u01B0\u1EDBc \u0111\xF3","g\u1EA7n nh\u1EA5t","nh\u1EA5p \u0111\xFAp","g\u1EEDi bi\u1EC3u m\u1EABu","ph\xEDm xu\u1ED1ng","ph\xEDm l\xEAn","chu\u1ED9t v\xE0o","chu\u1ED9t ra","t\u1EA3i trang","mili gi\xE2y","th\xEAm v\xE0o cu\u1ED1i","nh\xE2n b\u1EA3n","t\u1EA1o ra","\u0111\u1EB7t gi\xE1 tr\u1ECB","ghi nh\u1EADt k\xFD","chuy\u1EC3n t\u1EDBi","ng\u01B0\u1EE3c l\u1EA1i"];for(let t of r)if(i.slice(e,e+t.length).toLowerCase()===t.toLowerCase()){let n=e+t.length;if(n>=i.length||!/[a-zA-Zàáảãạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹỵđ]/.test(i[n])){let o=this.context.lookupKeyword(t);return {value:i.slice(e,n),length:t.length,metadata:{normalized:o?.normalized,isPreposition:false}}}}return null}};function xa(){return [new Da]}var Ba=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],Sa=class{constructor(i=Ba){this.name="operator",this.operators=[...i].sort((e,r)=>r.length-e.length);}canExtract(i,e){return this.operators.some(r=>i.startsWith(r,e))}extract(i,e){for(let r of this.operators)if(i.startsWith(r,e))return {value:r,length:r.length};return null}},Fa="()[]{},:;",Ta=class{constructor(i=Fa){this.punctuation=i,this.name="punctuation";}canExtract(i,e){return this.punctuation.includes(i[e])}extract(i,e){let r=i[e];return this.punctuation.includes(r)?{value:r,length:1}:null}};function Pa(i,e){let r=i[e];if(r==="#"){let t=i.slice(e).match(/^#[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="."){let t=i.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return t?t[0]:null}if(r==="["){let t=0,a=e;for(;a<i.length;){if(i[a]==="["&&t++,i[a]==="]"&&(t--,t===0))return i.slice(e,a+1);a++;}return null}if(r==="<"){let t=i.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return t?t[0]:null}return null}var Ra=class{constructor(){this.name="css-selector";}canExtract(i,e){let r=i[e];return r==="#"||r==="."||r==="["||r==="<"}extract(i,e){let r=Pa(i,e);return r?{value:r,length:r.length,metadata:{type:"css-selector"}}:null}},_a=class{constructor(){this.name="event-modifier";}canExtract(i,e){if(i[e]!==".")return false;let r=i.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(r)}extract(i,e){let r=i.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!r)return null;let t=r[0],a=t.slice(1).split("(")[0],n=r[1];return {value:t,length:t.length,metadata:{modifierName:a,value:n?a==="queue"?n:parseInt(n,10):void 0}}}};function Oa(i,e){let r=i.slice(e);if(r.startsWith("http://")||r.startsWith("https://")){let t=r.match(/^https?:\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("//")){let t=r.match(/^\/\/[^\s]*/);return t?t[0]:null}if(r.startsWith("./")||r.startsWith("../")){let t=r.match(/^\.\.?\/[^\s]*/);return t?t[0]:null}if(r.startsWith("/")){let t=r.match(/^\/[^\s]*/);return t?t[0]:null}return null}var Na=class{constructor(){this.name="url";}canExtract(i,e){let r=i.slice(e);return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")}extract(i,e){let r=Oa(i,e);return r?{value:r,length:r.length,metadata:{type:"url"}}:null}},Ma=class{constructor(){this.name="variable-ref";}canExtract(i,e){return i[e]===":"&&e+1<i.length&&/[a-zA-Z_]/.test(i[e+1])}extract(i,e){if(!this.canExtract(i,e))return null;let r=1;for(;e+r<i.length&&/[a-zA-Z0-9_]/.test(i[e+r]);)r++;return {value:i.substring(e,e+r),length:r,metadata:{type:"variable-reference"}}}};function Ia(){return [new Na,new _a,new Ma,new Ra]}var La=[{native:"\u0111\xFAng",normalized:"true"},{native:"sai",normalized:"false"},{native:"null",normalized:"null"},{native:"kh\xF4ng x\xE1c \u0111\u1ECBnh",normalized:"undefined"},{native:"\u0111\u1EA7u ti\xEAn",normalized:"first"},{native:"cu\u1ED1i c\xF9ng",normalized:"last"},{native:"ti\u1EBFp theo",normalized:"next"},{native:"tr\u01B0\u1EDBc \u0111\xF3",normalized:"previous"},{native:"g\u1EA7n nh\u1EA5t",normalized:"closest"},{native:"cha",normalized:"parent"},{native:"nh\u1EA5p",normalized:"click"},{native:"nh\u1EA5p chu\u1ED9t",normalized:"click"},{native:"click",normalized:"click"},{native:"nh\u1EA5p \u0111\xFAp",normalized:"dblclick"},{native:"nh\u1EADp",normalized:"input"},{native:"thay \u0111\u1ED5i",normalized:"change"},{native:"g\u1EEDi bi\u1EC3u m\u1EABu",normalized:"submit"},{native:"ph\xEDm xu\u1ED1ng",normalized:"keydown"},{native:"ph\xEDm l\xEAn",normalized:"keyup"},{native:"chu\u1ED9t v\xE0o",normalized:"mouseover"},{native:"chu\u1ED9t ra",normalized:"mouseout"},{native:"t\u1EA3i trang",normalized:"load"},{native:"cu\u1ED9n",normalized:"scroll"},{native:"c\u1EE7a t\xF4i",normalized:"my"},{native:"c\u1EE7a n\xF3",normalized:"its"},{native:"gi\xE2y",normalized:"s"},{native:"mili gi\xE2y",normalized:"ms"},{native:"ph\xFAt",normalized:"m"},{native:"gi\u1EDD",normalized:"h"},{native:"th\xEAm v\xE0o cu\u1ED1i",normalized:"append"},{native:"nh\xE2n b\u1EA3n",normalized:"clone"},{native:"t\u1EA1o ra",normalized:"make"},{native:"\u0111\u1EB7t gi\xE1 tr\u1ECB",normalized:"set"},{native:"ghi nh\u1EADt k\xFD",normalized:"log"},{native:"chuy\u1EC3n t\u1EDBi",normalized:"go"},{native:"ng\u01B0\u1EE3c l\u1EA1i",normalized:"else"},{native:"l\u1EB7p",normalized:"repeat"},{native:"ho\u1EB7c",normalized:"or"},{native:"kh\xF4ng",normalized:"not"},{native:"l\xE0",normalized:"is"},{native:"t\u1ED3n t\u1EA1i",normalized:"exists"},{native:"r\u1ED7ng",normalized:"empty"},{native:"javascript",normalized:"js"}],ja=class extends _e{constructor(){super(),this.language="vi",this.direction="ltr",this.initializeKeywordsFromProfile(pr,La),this.registerExtractors(Ia()),this.registerExtractor(new Fe),this.registerExtractor(new Te),this.registerExtractors(xa()),this.registerExtractor(new Sa),this.registerExtractor(new Ta);}classifyToken(i){let e=i.toLowerCase();return this.isKeyword(e)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(i)?"event-modifier":i.startsWith("#")||i.startsWith(".")||i.startsWith("[")||i.startsWith("*")||i.startsWith("<")?"selector":i.startsWith('"')||i.startsWith("'")||/^\d/.test(i)?"literal":["==","!=","<=",">=","<",">","&&","||","!"].includes(i)?"operator":"identifier"}},$a=new ja;rr("vi",$a,pr);function ce(i){let e=i.getAttribute("data-lang");if(e)return ke(e);let r=i.getAttribute("data-hyperscript-lang")??i.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(r)return ke(r);let t=typeof document<"u"?document.documentElement?.lang:null;return t&&t!=="en"?ke(t):null}function ke(i){return i.split("-")[0].toLowerCase()}var dr={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],breakpoint:[],call:[["patient",""]],clear:[["patient",""]],clone:[["patient",""],["destination","into"]],close:[["patient",""]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],empty:[["patient",""]],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],open:[["style","as"],["patient",""]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],process:[["patient","partials in"]],push:[["patient","url"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],replace:[["patient","url"]],reset:[["patient",""]],return:[["patient",""]],scroll:[["destination","to"]],select:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["duration",""]],while:[["condition",""]]};function me(i){switch(i.kind){case "event-handler":return Va(i);case "compound":return qa(i);default:return Wa(i)}}function Va(i){let e=["on"],r=i.roles.get("event");r&&e.push(te(r));let t=i.roles.get("source");if(t&&e.push("from",te(t)),i.body&&i.body.length>0){let a=i.body.map(me);e.push(a.join(" then "));}return e.join(" ")}function qa(i){let e=i.chainType==="async"?"async":i.chainType;return i.statements.map(me).join(` ${e} `)}function Wa(i){let e=dr[i.action];if(e){let t=[i.action];for(let[a,n]of e){let o=i.roles.get(a);o&&(a==="destination"&&o.type==="reference"&&o.value==="me"||(n&&t.push(n),t.push(te(o))));}return t.join(" ")}let r=[i.action];for(let[,t]of i.roles)r.push(te(t));return r.join(" ")}function te(i){switch(i.type){case "literal":return typeof i.value=="string"&&i.dataType==="string"?`"${i.value}"`:String(i.value);case "selector":return i.value;case "reference":return i.value;case "property-path":return Ka(i);case "expression":return i.raw;case "flag":return i.enabled?`+${i.name}`:`~${i.name}`}}function Ka(i){let e=te(i.object),r=i.property;if(i.object.type==="reference")switch(i.object.value){case "me":return `my ${r}`;case "it":return `its ${r}`;case "you":return `your ${r}`}return `${e}'s ${r}`}var fr=.5,Ua={confidenceThreshold:fr,strategy:"semantic",fallbackToOriginal:true};function Ha(i,e){return typeof i=="number"?i:i[e]??i["*"]??fr}function be(i,e,r={}){let t={...Ua,...r},a=yr(i,e,t);if(a!==null)return a;let n=Ya(i);if(n){let o=yr(n.commands,e,t);if(o!==null)return n.prefix+o}return i}function yr(i,e,r){if(r.strategy==="semantic"||r.strategy==="auto"){let t=Ha(r.confidenceThreshold,e),a=hr(i,e,t);if(a!==null)return a}if((r.strategy==="auto"||r.strategy==="i18n")&&r.i18nToEnglish){let t=Ja(i,e,r.i18nToEnglish);if(t!==null)return t}return null}var Ga=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Ya(i){let e=i.match(Ga);if(!e)return null;let r=e[1],t=i.slice(r.length);return t?{prefix:r,commands:t}:null}function hr(i,e,r){try{let t=Qa(i,e);if(t.length>1)return Za(t,e,r);if(!ir(e))return null;let a=ur(i,e);return a.confidence<r||!a.node?null:me(a.node)}catch{return null}}function Ja(i,e,r){try{let t=r(i,e);return t!==i?t:null}catch{return null}}function Xa(i){let e=["then"],r=I(i);if(r?.keywords?.then){let t=r.keywords.then;if(t.primary&&t.primary!=="then"&&e.push(t.primary),t.alternatives)for(let a of t.alternatives)e.includes(a)||e.push(a);}return e}function Qa(i,e){let t=Xa(e).map(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a=new RegExp(`\\s+(?:${t.join("|")})\\s+`,"i"),n=i.split(`
|
|
4
|
+
`).map(u=>u.trim()).filter(u=>u.length>0),o=[];for(let u of n){let s=u.split(a);o.push(...s);}return o}function Za(i,e,r){let t=[];for(let a of i){let n=hr(a.trim(),e,r);if(n===null)return null;t.push(n);}return t.join(" then ")}function Ce(i={}){return function(r){let{internals:t}=r,a=t.runtime,n=a.getScript.bind(a);a.getScript=function(o){let u=n(o);if(!u)return null;let s=en(o,i);if(!s||s==="en")return u;let l=be(u,s,i);return i.debug&&l!==u&&console.log(`[hyperscript-i18n] ${s}: "${u}" \u2192 "${l}"`),l};}}function en(i,e){if(e.languageAttribute){let t=i.getAttribute(e.languageAttribute);if(t)return t.split("-")[0].toLowerCase()}let r=ce(i);return r||(e.defaultLanguage??null)}function vr(i,e,r={}){return e==="en"?i:be(i,e,r)}tr(i=>cr(i));function Er(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(Ce()),rn());}function rn(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let r=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(r).forEach(t=>{let a=e.getInternalData(t);a.initialized&&(a.initialized=false);}),e.processNode(document.body);}var bo=["vi"];Er();exports.plugin=Ce;exports.preprocess=vr;exports.resolveLanguage=ce;exports.supportedLanguages=bo;return exports;})({});
|