@lokascript/hyperscript-adapter 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +46 -3
  2. package/dist/hyperscript-i18n-ar.global.js +4 -4
  3. package/dist/hyperscript-i18n-bn.global.js +4 -4
  4. package/dist/hyperscript-i18n-de.global.js +4 -4
  5. package/dist/hyperscript-i18n-east-asian.global.js +4 -4
  6. package/dist/hyperscript-i18n-en.global.js +6 -6
  7. package/dist/hyperscript-i18n-es.global.js +4 -4
  8. package/dist/hyperscript-i18n-fr.global.js +4 -4
  9. package/dist/hyperscript-i18n-he.global.js +4 -4
  10. package/dist/hyperscript-i18n-hi.global.js +4 -4
  11. package/dist/hyperscript-i18n-id.global.js +4 -4
  12. package/dist/hyperscript-i18n-it.global.js +4 -4
  13. package/dist/hyperscript-i18n-ja.global.js +4 -4
  14. package/dist/hyperscript-i18n-ko.global.js +4 -4
  15. package/dist/hyperscript-i18n-ms.global.js +4 -4
  16. package/dist/hyperscript-i18n-pl.global.js +4 -4
  17. package/dist/hyperscript-i18n-pt.global.js +4 -4
  18. package/dist/hyperscript-i18n-qu.global.js +4 -4
  19. package/dist/hyperscript-i18n-ru.global.js +4 -4
  20. package/dist/hyperscript-i18n-slavic.global.js +4 -4
  21. package/dist/hyperscript-i18n-south-asian.global.js +4 -4
  22. package/dist/hyperscript-i18n-southeast-asian.global.js +4 -4
  23. package/dist/hyperscript-i18n-sw.global.js +4 -4
  24. package/dist/hyperscript-i18n-th.global.js +4 -4
  25. package/dist/hyperscript-i18n-tl.global.js +4 -4
  26. package/dist/hyperscript-i18n-tr.global.js +4 -4
  27. package/dist/hyperscript-i18n-uk.global.js +4 -4
  28. package/dist/hyperscript-i18n-vi.global.js +4 -4
  29. package/dist/hyperscript-i18n-western.global.js +4 -4
  30. package/dist/hyperscript-i18n-zh.global.js +4 -4
  31. package/dist/hyperscript-i18n.global.js +73 -7
  32. package/dist/hyperscript-i18n.global.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/hyperscript-renderer.ts +3 -0
@@ -1,4 +1,4 @@
1
- var HyperscriptI18n=(function(exports){'use strict';var nt=new Map,it=new Map,ot=new Map;function st(n,e,t){nt.set(n,e),it.set(n,t),ot.delete(n);}var at=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function E(n,e){return {start:n,end:e}}function T(n,e,t,r){if(typeof r=="string")return {value:n,kind:e,position:t,normalized:r};if(r){let{normalized:i,stem:o,stemConfidence:s}=r;return {value:n,kind:e,position:t,...i!==void 0&&{normalized:i},...o!==void 0&&{stem:o},...s!==void 0&&{stemConfidence:s}}}return {value:n,kind:e,position:t}}function F(n){return /\s/.test(n)}function ge(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function Ee(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function P(n){return /\d/.test(n)}function lt(n){return /[a-zA-Z]/.test(n)}function k(n){return /[a-zA-Z0-9_-]/.test(n)}function ct(n,e){if(e>=n.length)return null;let t=n[e];if(!ge(t))return null;let r=e,i="";if(t==="#"||t==="."){for(i+=n[r++];r<n.length&&k(n[r]);)i+=n[r++];if(i.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let s=r+1;for(;s<n.length&&k(n[s]);)s++;if(s<n.length&&n[s]==="(")return i}}else if(t==="["){let o=1,s=false,a=null,l=false;for(i+=n[r++];r<n.length&&o>0;){let u=n[r];i+=u,l?l=false:u==="\\"?l=true:s?u===a&&(s=false,a=null):u==='"'||u==="'"||u==="`"?(s=true,a=u):u==="["?o++:u==="]"&&o--,r++;}if(o!==0)return null}else if(t==="@"){for(i+=n[r++];r<n.length&&k(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="*"){for(i+=n[r++];r<n.length&&k(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="<"){if(i+=n[r++],r>=n.length||!lt(n[r]))return null;for(;r<n.length&&k(n[r]);)i+=n[r++];for(;r<n.length;){let o=n[r];if(o==="."){if(i+=n[r++],r>=n.length||!k(n[r]))return null;for(;r<n.length&&k(n[r]);)i+=n[r++];}else if(o==="#"){if(i+=n[r++],r>=n.length||!k(n[r]))return null;for(;r<n.length&&k(n[r]);)i+=n[r++];}else if(o==="["){let s=1,a=false,l=null,u=false;for(i+=n[r++];r<n.length&&s>0;){let c=n[r];i+=c,u?u=false:c==="\\"?u=true:a?c===l&&(a=false,l=null):c==='"'||c==="'"||c==="`"?(a=true,l=c):c==="["?s++:c==="]"&&s--,r++;}if(s!==0)return null}else break}for(;r<n.length&&F(n[r]);)i+=n[r++];if(r<n.length&&n[r]==="/")for(i+=n[r++];r<n.length&&F(n[r]);)i+=n[r++];if(r>=n.length||n[r]!==">")return null;i+=n[r++];}return i||null}function ut(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return false;if(e+2>=n.length)return true;let r=n[e+2];return F(r)||r==="*"||!k(r)}function pt(n,e){if(e>=n.length)return null;let t=n[e];if(!Ee(t)||t==="'"&&ut(n,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,s=t,a=false;for(;o<n.length;){let l=n[o];if(s+=l,a)a=false;else if(l==="\\")a=true;else if(l===i)return s;o++;}return s}function Te(n,e){if(e>=n.length)return false;let t=n[e],r=n[e+1]||"",i=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(r==="/"||r==="."&&i==="/"))return true;let o=n.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function dt(n,e){if(!Te(n,e))return null;let t=e,r="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let o=n[t];if(o==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=o,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(i.test(o))r+=o,t++;else break}return r.length<2?null:r}function ft(n,e){if(e>=n.length)return null;let t=n[e];if(!P(t)&&t!=="-"&&t!=="+")return null;let r=e,i="";if((n[r]==="-"||n[r]==="+")&&(i+=n[r++]),r>=n.length||!P(n[r]))return null;for(;r<n.length&&P(n[r]);)i+=n[r++];if(r<n.length&&n[r]===".")for(i+=n[r++];r<n.length&&P(n[r]);)i+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?i+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(i+=n[r])),i}var ke=class be{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map;}tryPropertyAccess(e,t,r){if(e[t]!==".")return false;let i=r[r.length-1],o=i&&i.position.end<t;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return r.push(T(".","operator",E(t,t+1))),true;let l=t+1;for(;l<e.length&&k(e[l]);)l++;return l<e.length&&e[l]==="("?(r.push(T(".","operator",E(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(r.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))r.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))r.has(i)||r.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&r.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:i});}for(let i of t)r.set(i.native,i);this.profileKeywords=Array.from(r.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let r of this.profileKeywords)if(e.slice(t).startsWith(r.native))return T(r.native,"keyword",E(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(i=>r.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,r){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return T(e,"keyword",E(t,r),s)}trySelector(e,t){let r=ct(e,t);return r?T(r,"selector",E(t,t+r.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let r=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let i=r[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=r[1];return {...T(i,"event-modifier",E(t,t+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let r=pt(e,t);return r?T(r,"literal",E(t,t+r.length)):null}tryNumber(e,t){let r=ft(e,t);return r?T(r,"literal",E(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,i=false){let o=t;if(i)for(;o<e.length&&F(e[o]);)o++;let s=e.slice(o);for(let a of r){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let c=s[a.length]||"";if(k(c))continue}return {suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(e,t,r=true){let i=t,o="";if(r&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!P(e[i]))return null;for(;i<e.length&&P(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&P(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,r,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,a=this.parseBaseNumber(e,t,o);if(!a)return null;let{number:l,endPos:u}=a,c=[...r,...be.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,u,c,s);return p&&(l+=p.suffix,u=p.endPos),T(l,"literal",E(t,u))}tryUrl(e,t){let r=dt(e,t);return r?T(r,"url",E(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!k(e[t+1]))return null;let r=t+1;for(;r<e.length&&k(e[r]);)r++;let i=e.slice(t,r);return T(i,"identifier",E(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return T(r,"operator",E(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?T(i,"operator",E(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?T(i,"punctuation",E(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let i of r)if(e.slice(t,t+i.length)===i)return T(i,"particle",E(t,t+i.length));return null}};ke.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 mt=ke,Se={code:"tl",name:"Tagalog",nativeName:"Tagalog",direction:"ltr",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"ako",it:"ito",you:"ikaw",result:"resulta",event:"pangyayari",target:"target",body:"body"},possessive:{marker:"ng",markerPosition:"between",keywords:{ko:"me",akin:"me",aking:"me",mo:"you",iyo:"you",niya:"it",nito:"it",kaniya:"it"}},roleMarkers:{destination:{primary:"sa",position:"before"},source:{primary:"mula_sa",position:"before"},patient:{primary:"",position:"before"},style:{primary:"nang",position:"before"}},keywords:{toggle:{primary:"palitan",alternatives:["itoggle"],normalized:"toggle"},add:{primary:"idagdag",alternatives:["magdagdag"],normalized:"add"},remove:{primary:"alisin",alternatives:["tanggalin"],normalized:"remove"},put:{primary:"ilagay",alternatives:["maglagay"],normalized:"put"},append:{primary:"idagdag_sa_dulo",normalized:"append"},prepend:{primary:"idagdag_sa_simula",normalized:"prepend"},take:{primary:"kumuha",normalized:"take"},make:{primary:"gumawa",alternatives:["lumikha"],normalized:"make"},clone:{primary:"kopyahin",normalized:"clone"},swap:{primary:"palitan_pwesto",alternatives:["magpalit"],normalized:"swap"},morph:{primary:"baguhin",normalized:"morph"},set:{primary:"itakda",alternatives:["magtakda"],normalized:"set"},get:{primary:"kunin",alternatives:["kumuha"],normalized:"get"},increment:{primary:"dagdagan",alternatives:["taasan"],normalized:"increment"},decrement:{primary:"bawasan",alternatives:["ibaba"],normalized:"decrement"},log:{primary:"itala",normalized:"log"},show:{primary:"ipakita",alternatives:["magpakita"],normalized:"show"},hide:{primary:"itago",alternatives:["magtago"],normalized:"hide"},transition:{primary:"baguhin",alternatives:["lumipat"],normalized:"transition"},on:{primary:"kapag",alternatives:["kung","sa"],normalized:"on"},trigger:{primary:"palitawin",alternatives:["magpatugtog"],normalized:"trigger"},send:{primary:"ipadala",alternatives:["magpadala"],normalized:"send"},focus:{primary:"ituon",normalized:"focus"},blur:{primary:"alisin_tuon",normalized:"blur"},go:{primary:"pumunta",alternatives:["punta"],normalized:"go"},wait:{primary:"maghintay",alternatives:["hintay"],normalized:"wait"},fetch:{primary:"kuhanin_mula",alternatives:["kunin_mula"],normalized:"fetch"},settle:{primary:"magpatahimik",normalized:"settle"},if:{primary:"kung",alternatives:["kapag"],normalized:"if"},when:{primary:"kapag",normalized:"when"},where:{primary:"kung_saan",normalized:"where"},else:{primary:"kung_hindi",alternatives:["kundi"],normalized:"else"},repeat:{primary:"ulitin",alternatives:["paulit-ulit"],normalized:"repeat"},for:{primary:"para_sa",normalized:"for"},while:{primary:"habang",normalized:"while"},continue:{primary:"magpatuloy",normalized:"continue"},halt:{primary:"itigil",alternatives:["huminto"],normalized:"halt"},throw:{primary:"ihagis",alternatives:["itapon"],normalized:"throw"},call:{primary:"tawagin",alternatives:["tawagan","tumawag"],normalized:"call"},return:{primary:"ibalik",alternatives:["bumalik"],normalized:"return"},then:{primary:"pagkatapos",alternatives:["saka"],normalized:"then"},and:{primary:"at",normalized:"and"},end:{primary:"wakas",alternatives:["tapos"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"async",normalized:"async"},tell:{primary:"sabihin",alternatives:["magsabi"],normalized:"tell"},default:{primary:"pamantayan",alternatives:["default","unang_halaga"],normalized:"default"},init:{primary:"simulan",alternatives:["magsimula"],normalized:"init"},behavior:{primary:"ugali",alternatives:["kilos"],normalized:"behavior"},install:{primary:"ikabit",alternatives:["mag-install"],normalized:"install"},measure:{primary:"sukatin",normalized:"measure"},beep:{primary:"tunog",normalized:"beep"},break:{primary:"itigil",normalized:"break"},copy:{primary:"kopyahin",normalized:"copy"},exit:{primary:"lumabas",normalized:"exit"},pick:{primary:"pumili",normalized:"pick"},render:{primary:"ipakita",normalized:"render"},into:{primary:"sa",normalized:"into"},before:{primary:"bago",normalized:"before"},after:{primary:"matapos",alternatives:["pagkatapos"],normalized:"after"},until:{primary:"hanggang",normalized:"until"},event:{primary:"pangyayari",normalized:"event"},from:{primary:"mula",alternatives:["galing"],normalized:"from"}},eventHandler:{keyword:{primary:"kapag",normalized:"on"},sourceMarker:{primary:"mula_sa",alternatives:["galing_sa"],position:"before"},eventMarker:{primary:"kapag",alternatives:["kung","sa"],position:"before"}}},ht=[{native:"totoo",normalized:"true"},{native:"mali",normalized:"false"},{native:"wala",normalized:"null"},{native:"hindi_tinukoy",normalized:"undefined"},{native:"una",normalized:"first"},{native:"huli",normalized:"last"},{native:"susunod",normalized:"next"},{native:"nakaraan",normalized:"previous"},{native:"pinakamalapit",normalized:"closest"},{native:"magulang",normalized:"parent"},{native:"pindot",normalized:"click"},{native:"pagbabago",normalized:"change"},{native:"isumite",normalized:"submit"},{native:"input",normalized:"input"},{native:"karga",normalized:"load"},{native:"mag_scroll",normalized:"scroll"}],vt=class extends mt{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(Se,ht);}tokenize(n){let e=[],t=0;for(;t<n.length;){if(F(n[t])){t++;continue}if(ge(n[t])){let r=this.tryEventModifier(n,t);if(r){e.push(r),t=r.position.end;continue}if(this.tryPropertyAccess(n,t,e)){t++;continue}let i=this.trySelector(n,t);if(i){e.push(i),t=i.position.end;continue}}if(Ee(n[t])){let r=this.tryString(n,t);if(r){e.push(r),t=r.position.end;continue}}if(P(n[t])||n[t]==="-"&&t+1<n.length&&P(n[t+1])){let r=this.tryNumber(n,t);if(r){e.push(r),t=r.position.end;continue}}if(Te(n,t)){let r=this.tryUrl(n,t);if(r){e.push(r),t=r.position.end;continue}}if(n[t]===":"){let r=this.tryVariableRef(n,t);if(r){e.push(r),t=r.position.end;continue}}if("()[]{}:,;".includes(n[t])){e.push(T(n[t],"operator",E(t,t+1))),t++;continue}if(k(n[t])){let r=t,i=this.tryProfileKeyword(n,t);if(i){e.push(i),t=i.position.end;continue}let o="";for(;t<n.length&&k(n[t]);)o+=n[t],t++;o&&e.push(T(o,"identifier",E(r,t)));continue}t++;}return new at(e,"tl")}classifyToken(n){return this.isKeyword(n)?"keyword":n.startsWith(".")||n.startsWith("#")||n.startsWith("[")||n.startsWith("*")||n.startsWith("<")?"selector":n.startsWith(":")?"identifier":n.startsWith('"')||n.startsWith("'")||/^-?\d/.test(n)?"literal":"identifier"}},yt=new vt;st("tl",yt,Se);var gt=Object.defineProperty,Et=Object.getOwnPropertyNames,Ne=(n,e)=>function(){return n&&(e=(0, n[Et(n)[0]])(n=0)),e},Tt=(n,e)=>{for(var t in e)gt(n,t,{get:e[t],enumerable:true});};function we(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`))}function A(n,e,t={},r){let i=Ie[n],o=we(i,t),s=Me[n],a=s?we(s,t):void 0;return {code:n,message:o,severity:e,...r&&{role:r},...a&&{suggestion:a}}}var h,Ie,Me,kt=Ne({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION"},Ie={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition."},Me={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition."};}}),Le={};Tt(Le,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Rt,getValidationStats:()=>xt,validateAllSchemas:()=>Pt,validateCommandSchema:()=>De});function bt(n,e){return {action:n,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function De(n){let e=[];for(let r of n.roles)r.expectedTypes.includes("literal")&&r.expectedTypes.includes("selector")&&(r.role==="patient"&&se.has(n.action)?e.push(A(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:r.role,command:n.action},r.role)):e.push(A(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:r.role},r.role))),r.expectedTypes.length>3&&!se.has(n.action)&&e.push(A(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:r.role,count:r.expectedTypes.length},r.role));switch(n.action){case "transition":St(n,e);break;case "on":wt(n,e);break;case "if":case "unless":At(n,e);break;case "repeat":case "for":case "while":Ct(n,e);break}return n.roles.filter(r=>r.required).length===0&&(Be.has(n.action)?e.push(A(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:n.action})):e.push(A(h.NO_REQUIRED_ROLES,"warning",{}))),bt(n.action,e)}function St(n,e){let t=n.roles.find(i=>i.role==="patient"),r=n.roles.find(i=>i.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(A(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!r&&e.push(A(h.TRANSITION_MISSING_GOAL,"error",{}));}function wt(n,e){let t=n.roles.find(r=>r.role==="event");t||e.push(A(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(A(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function At(n,e){let t=n.roles.find(r=>r.role==="condition");t||e.push(A(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(A(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Ct(n,e){n.action==="for"?n.roles.find(r=>r.role==="source")||e.push(A(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):n.action==="while"&&(n.roles.find(r=>r.role==="condition")||e.push(A(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Pt(n,e={}){let t=new Map,{includeNotes:r=false}=e;for(let[i,o]of Object.entries(n)){let s=De(o),a=s.items.some(u=>u.severity==="warning"||u.severity==="error"),l=r&&s.items.some(u=>u.severity==="note");(a||l)&&t.set(i,s);}return t}function Rt(n,e={}){let t=[],{showNotes:r=false,showCodes:i=true}=e;for(let[o,s]of n){let a=s.items.filter(c=>c.severity==="error"),l=s.items.filter(c=>c.severity==="warning"),u=s.items.filter(c=>c.severity==="note");if(a.length>0){t.push(` \u274C ${o}:`);for(let c of a){let p=i?` [${c.code}]`:"";t.push(` ERROR${p}: ${c.message}`),c.suggestion&&t.push(` \u{1F4A1} Suggestion: ${c.suggestion}`);}}if(l.length>0){t.push(` \u26A0\uFE0F ${o}:`);for(let c of l){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`),c.suggestion&&t.push(` \u{1F4A1} ${c.suggestion}`);}}if(r&&u.length>0){t.push(` \u2139\uFE0F ${o}:`);for(let c of u){let p=i?` [${c.code}]`:"";t.push(` ${p?`${c.code}: `:""}${c.message}`);}}}return t.join(`
2
- `)}function xt(n){let e=0,t=0,r=0,i={};for(let o of n.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&r++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:n.size,errors:e,warnings:t,notes:r,byCode:i}}var se,Be,_t=Ne({"src/generators/schema-validator.ts"(){kt(),se=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),Be=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function j(n){let e="complex";return n.startsWith("#")&&!n.includes(" ")?e="id":n.startsWith(".")&&!n.includes(" ")?e="class":n.startsWith("[")&&n.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(n)&&(e="element"),{type:"selector",value:n,selectorKind:e}}function b(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}var Ot=new Set(["me","you","it","result","event","target","body"]);function Ae(n){return Ot.has(n)}function O(n){return {type:"reference",value:n}}function ne(n,e){return {type:"property-path",object:n,property:e}}function X(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function Ce(n,e,t,r,i,o){let s=new Map;s.set("event",n);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),a}function Pe(n,e="then",t){let r={kind:"compound",action:"compound",roles:new Map,statements:n,chainType:e};return t!==void 0&&(r.metadata=t),r}function Re(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Nt(n,e){return n.possessive?.keywords?.[e]}var D=new Map,B=new Map,Q=new Map,ae=null;function ze(n,e){let t={...n};for(let r of Object.keys(e)){let i=e[r],o=n[r];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[r]=ze(o,i):t[r]=i);}return t}function It(n,e){return ze(n,e)}function ce(n){if(!n.extends)return n;let e=B.get(n.extends);if(!e)return console.warn(`[Registry] Profile '${n.code}' extends '${n.extends}' but base is not registered. Make sure to import the base language before the variant.`),n;let t=ce(e);return It(t,n)}function $e(n){ae=n;}var xe=new Map;function z(n){return n.split("-")[0]}function $(n){return n.includes("-")}function Mt(n){let e=D.get(n);if(!e&&$(n)){let t=z(n);e=D.get(t);}if(!e){let t=Array.from(D.keys()).join(", ");throw new Error(`Language '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return e}function Lt(n){let e=B.get(n);if(!e&&$(n)){let t=z(n);e=B.get(t);}if(!e){let t=Array.from(B.keys()).join(", ");throw new Error(`Language profile '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return ce(e)}function Dt(n){let e=D.get(n);return !e&&$(n)&&(e=D.get(z(n))),e}function N(n){let e=B.get(n);return !e&&$(n)&&(e=B.get(z(n))),e?ce(e):void 0}function qe(){return Array.from(D.keys())}function Bt(n,e){return Mt(e).tokenize(n)}function L(n){let e=Q.get(n);if(!e&&$(n)&&(e=Q.get(z(n))),e)return e;let t=xe.get(n);if(!t&&$(n)&&(t=xe.get(z(n))),t)return Q.set(n,t),t;if(!ae)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=Lt(n),i=ae(r);return Q.set(n,i),i}var Z=class W{constructor(){this.stemMatchCount=0,this.totalKeywordMatches=0;}matchPattern(e,t){let r=e.mark(),i=new Map;if(this.currentProfile=N(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(r),null;let s=this.calculateConfidence(t,i);return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-r.position,confidence:s}}matchBest(e,t){let r=[];for(let o of t){let s=e.mark(),a=this.matchPattern(e,o);a&&r.push(a),e.reset(s);}if(r.length===0)return null;r.sort((o,s)=>{let a=s.pattern.priority-o.pattern.priority;return a!==0?a:s.confidence-o.confidence});let i=r[0];return this.matchPattern(e,i.pattern),i}matchTokenSequence(e,t,r){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,r)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(!r)return false;let i=this.getMatchType(r,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Re(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,l),true);let u=this.tryMatchSelectorPropertyExpression(e);if(u)return t.expectedTypes&&t.expectedTypes.length>0&&!Re(u.type,t.expectedTypes)?t.optional||false:(r.set(t.role,u),true);let c=this.tokenToSemanticValue(i);return !c||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(c.type)?t.optional||false:(r.set(t.role,c),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),i=Nt(this.currentProfile,r);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let l=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(l+=u.value,e.advance()),ne(O(i),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 t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<W.MAX_METHOD_ARGS;){let u=e.peek();if(!u)break;if(u.kind==="punctuation"&&u.value===")"){e.advance();break}if(u.kind==="punctuation"&&u.value===","){e.advance();continue}a.push(u.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<W.MAX_PROPERTY_DEPTH;){let u=e.peek();if(!u||u.kind!=="operator"||u.value!==".")break;e.advance();let c=e.peek();if(!c||c.kind!=="identifier")break;e.advance(),s+=`.${c.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let u=[],c=0;for(;!e.isAtEnd()&&u.length<W.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(c===0){e.advance();break}c--;}if(d.kind==="punctuation"&&d.value==="("&&c++,d.kind==="punctuation"&&d.value===","){e.advance();continue}u.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${u.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(r),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(r),null):(e.advance(),ne(j(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(r),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return ne(j(t.value),s)}matchGroupToken(e,t,r){let i=e.mark(),o=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(i);for(let a of r.keys())o.has(a)||r.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return j(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return Ae(t)?O(t):b(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return O(e.value);let r=e.value.toLowerCase();return Ae(r)?O(r):{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 i=e.slice(1,-1);return b(i,"string")}if(e==="true")return b(true,"boolean");if(e==="false")return b(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?b(e,"duration"):b(i,"number")}let r=parseFloat(e);return isNaN(r)?b(e,"string"):b(r,"number")}applyExtractionRules(e,t){for(let[r,i]of Object.entries(e.extraction))t.has(r)||(i.value!==void 0?t.set(r,{type:"literal",value:i.value}):i.default&&t.set(r,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,i=0,o=u=>e.extraction?.[u]?.default!==void 0;for(let u of e.template.tokens)if(u.type==="role")i+=1,t.has(u.role)&&(r+=1);else if(u.type==="group"){for(let c of u.tokens)if(c.type==="role"){let p=o(c.role),d=.8;i+=d,t.has(c.role)?r+=d:p&&(r+=d*.6);}}let s=i>0?r/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let u=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-u);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(r.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of t.entries()){let a=i[o];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let u=l.prepositionValue;a.includes(u)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(W.ENGLISH_NOISE_WORDS.has(r)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(r=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return r?t:void 0}};Z.MAX_PROPERTY_DEPTH=10;Z.MAX_METHOD_ARGS=20;Z.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var Ve=Z,M=new Ve,ie=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function $t(n){return Dt(n)}function oe(n,e){return Bt(n,e)}function Fe(){return qe()}var qt={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 q=class R{parse(e,t){let{modifiers:r,remainingInput:i}=this.extractStandaloneModifiers(e,t),o=i||e,s=oe(o,t),a=L(t);if(a.length===0)throw new Error(`No patterns available for language: ${t}`);let l=[...a].sort((v,S)=>S.priority-v.priority),u=l.filter(v=>v.command==="on"),c=M.matchBest(s,u);if(c){let v=this.buildEventHandler(c,s,t);return r?this.applyModifiers(v,r):v}let p=l.filter(v=>v.command!=="on"),d=M.matchBest(s,p);if(d)return this.buildCommand(d,t);let f=this.trySOVEventExtraction(o,t,l);if(f)return r?this.applyModifiers(f,r):f;let m=this.tryCompoundCommandParsing(s,p,t);if(m)return m;throw new Error(`Could not parse input in ${t}: ${o}`)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return Fe()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[i,o]of e.captured)r[i]=o;return X(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=M.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,r),a=i;s.length>0&&i.type==="literal"&&(a={type:"literal",value:[String(i.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,u=e.captured.get("action");if(u&&u.type==="literal"){let c=u.value,p={};for(let[m,v]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(p[m]=v);let d=X(c,p,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=L(r).filter(g=>g.command!=="on").sort((g,C)=>C.priority-g.priority),v=L(r).filter(g=>g.id.startsWith("grammar-")&&g.id.includes("-continuation")).sort((g,C)=>C.priority-g.priority),S=this.parseBodyWithGrammarPatterns(t,m,v,r);S.length>0?l=[d,...S]:l=[d];}else l=[d];}else {let c=L(r).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);l=this.parseBodyWithClauses(t,c,r);}return Ce(a,l,o,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),l=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(o.length>0){let u=this.parseClause(o,t,r);i.push(...u),o.length=0;}e.advance();continue}if(l){if(o.length>0){let u=this.parseClause(o,t,r);i.push(...u);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,t,r);i.push(...s);}return i.length>1?[Pe(i,"then",{sourceLanguage:r})]:i}parseClause(e,t,r){if(e.length===0)return [];let i=new ie(e,r),o=[];for(;!i.isAtEnd();){let s=M.matchBest(i,t);s?o.push(this.buildCommand(s,r)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,r);if(s.length>0)return s}return o}static buildVerbLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(r)&&(t.set(i.primary.toLowerCase(),r),i.alternatives))for(let o of i.alternatives)t.set(o.toLowerCase(),r);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.roleMarkers))if(i&&(t.set(i.primary,r),i.alternatives))for(let o of i.alternatives)t.has(o)||t.set(o,r);return t}parseSOVClauseByVerbAnchoring(e,t){let r=N(t);if(!r||r.wordOrder!=="SOV")return [];let i=R.buildVerbLookup(r),o=R.buildMarkerToRoleLookup(r),s=[],a=0;for(;a<e.length;){let l=-1,u="";for(let m=a;m<e.length;m++){let v=e[m],S=i.get(v.value.toLowerCase()),g=v.normalized?i.get(v.normalized.toLowerCase()):void 0,C=S||g;if(C){l=m,u=C;break}}if(l===-1)break;let c=e.slice(a,l),p=e.length;for(let m=l+1;m<e.length;m++){let v=e[m];if(v.kind==="conjunction"||this.isThenKeyword(v.value,t)){p=m;break}if(m>l+1&&(i.get(v.value.toLowerCase())||(v.normalized?i.get(v.normalized.toLowerCase()):void 0))){p=m;break}}let d=e.slice(l+1,p),f=this.extractRolesFromMarkedTokens(c,d,o,u,t);if(s.push(X(u,f,{sourceLanguage:t,confidence:.7})),a=p,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,r,i,o){let s={},a=l=>{let u=[];for(let c of l){let p=r.get(c.value);if(p&&c.kind==="particle"&&u.length>0){let d=this.tokensToSemanticValue(u);if(d){let f=this.mapRoleForCommand(p,i,s);f&&(s[f]=d);}u=[];}else u.push(c);}if(u.length>0){let c=this.tokensToSemanticValue(u);c&&(s.patient?s.destination||(s.destination=c):s.patient=c);}};return a(e),a(t),s}mapRoleForCommand(e,t,r){return r[e]?e==="patient"&&!r.destination?"destination":e==="destination"&&!r.patient?"patient":e==="source"&&!r.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let r=t.map(o=>o.value).join(""),i=t[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?j(r):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?b(r):i.kind==="reference"?O(r):b(r)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return j(t);if(t.startsWith('"')||t.startsWith("'"))return b(t);if(/^-?\d+(\.\d+)?$/.test(t))return b(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return b(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return b(false);let r=e.normalized?.toLowerCase();return r==="me"||r==="it"||r==="you"||r==="result"||r==="body"?O(r):e.kind==="reference"?O(e.normalized||"me"):b(t)}parseBodyWithGrammarPatterns(e,t,r,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let a=false;if(r.length>0){let l=M.matchBest(e,r);if(l){let u=l.pattern.command,c={};for(let[f,m]of l.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(c[f]=m);let p=X(u,c,{sourceLanguage:i,patternId:l.pattern.id});o.push(p),a=true;let d=l.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then")continue}}if(!a){let l=M.matchBest(e,t);l&&(o.push(this.buildCommand(l,i)),a=true);}a||e.advance();}return o}tryCompoundCommandParsing(e,t,r){let i=e.tokens;if(!i.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,r)))return null;let s=new ie(i,r),a=this.parseBodyWithClauses(s,t,r);return a.length===0?null:a.length===1?a[0]:Pe(a,"then",{sourceLanguage:r,confidence:.65})}trySOVEventExtraction(e,t,r){let i=R.SOV_EVENT_MARKERS[t];if(!i)return null;let s=oe(e,t).tokens,a=qt[t],l=new Set;if(a)for(let y of Object.keys(a))l.add(y.toLowerCase());let u=R.SOV_SOURCE_MARKERS[t],c=-1,p="",d="",f=1;for(let y=0;y<s.length;y++){let w=s[y],x=w.value.toLowerCase(),_=x,I="",ee=x.indexOf("[");ee>0&&(_=x.slice(0,ee),I=w.value.slice(ee));let te=w.normalized?.toLowerCase(),ve=te&&R.KNOWN_EVENTS.has(te),ye=l.has(x)||l.has(_),rt=R.KNOWN_EVENTS.has(_);if(ve||ye||rt){let V;if(ve?V=te:ye?V=a?.[x]??a?.[_]??_:V=_,i.size>0){let K=1,re=s[y+1];re&&re.kind==="selector"&&re.value.startsWith("[")&&(K=2);let Y=s[y+K];if(Y&&(Y.kind==="particle"||Y.kind==="keyword")&&i.has(Y.value)){c=y,p=V,d=I||(K===2?s[y+1].value:""),f=K+1;break}}else {c=y,p=V,d=I,f=1;break}}}if(c===-1)return null;let m=new Set;for(let y=c;y<c+f;y++)m.add(y);if(u){let y=c+f;if(y<s.length){let w=s[y];(w.kind==="particle"||w.kind==="keyword")&&u.markers.has(w.value)&&m.add(y);}for(let w=0;w<c;w++){let x=s[w],_=x.value.toLowerCase(),I=x.normalized?.toLowerCase();if(u.windowTokens.has(_)||I&&u.windowTokens.has(I)){m.add(w);break}}}let v=s.filter((y,w)=>!m.has(w));if(v.length===0)return null;let S=r.filter(y=>y.command!=="on"),g=new ie(v,t),C=this.parseBodyWithClauses(g,S,t);if(C.length===0)return null;let he={sourceLanguage:t,confidence:.75};return d&&(he.keyFilter=d),Ce({type:"literal",value:p},C,void 0,he)}isThenKeyword(e,t){let r={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (r[t]||r.en).has(e.toLowerCase())}isEndKeyword(e,t){let r={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (r[t]||r.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let i=oe(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),a=R.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let l={},u=1;if(a==="once")l.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,u++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let v=m.value.match(/^(\d+)(ms|s|m)?$/);if(v){let S=parseInt(v[1],10),g=v[2]||"ms";g==="s"?S*=1e3:g==="m"&&(S*=6e4),l[a]=S,u=f+1;}}}l[a]||(l[a]=a==="debounce"?300:100);}let c=i.slice(u);if(c.length===0)return {modifiers:null,remainingInput:null};let p=c[0].position.start,d=e.slice(p);return {modifiers:l,remainingInput:d}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let r=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!R.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let a=e.peek();if(!a){e.reset(i);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),r.push({type:"literal",value:l});}return r}};q.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);q.SOV_EVENT_MARKERS={ja:new Set(["\u3067"]),ko:new Set,tr:new Set(["de","da","te","ta"]),bn:new Set(["\u098F"]),qu:new Set(["pi"])};q.SOV_SOURCE_MARKERS={ja:{markers:new Set(["\u304B\u3089"]),windowTokens:new Set(["\u30A6\u30A3\u30F3\u30C9\u30A6","\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8","window","document"])},ko:{markers:new Set(["\uC5D0\uC11C"]),windowTokens:new Set(["\uCC3D","\uC708\uB3C4\uC6B0","\uBB38\uC11C","window","document"])},tr:{markers:new Set(["den","dan","ten","tan"]),windowTokens:new Set(["pencere","belge","window","document"])},bn:{markers:new Set(["\u09A5\u09C7\u0995\u09C7","\u09AE\u09A7\u09CD\u09AF\u09C7"]),windowTokens:new Set(["\u0989\u0987\u09A8\u09CD\u09A1\u09CB","\u09A1\u0995\u09C1\u09AE\u09C7\u09A8\u09CD\u099F","window","document"])},qu:{markers:new Set(["manta"]),windowTokens:new Set(["k_iri","ventana","window","document"])}};q.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};q.OR_KEYWORDS=new Set(["or","\u0623\u0648","o","ou","oder","atau","atau","\u6216","\u307E\u305F\u306F","\uB610\uB294","veya","\u0985\u09A5\u09AC\u09BE","utaq","au","\u0430\u0431\u043E","\u0438\u043B\u0438","ho\u1EB7c","lub","\u05D0\u05D5","\u0E2B\u0E23\u0E37\u0E2D","o"]);var Ft=q,Wt=new Ft;function ue(n,e){return Wt.parse(n,e)}var le=class{constructor(n={}){this.cache=new Map,this.config={maxSize:n.maxSize??1e3,ttlMs:n.ttlMs??0,enabled:n.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(n,e){return `${e}:${n}`}isExpired(n){return this.config.ttlMs===0?false:Date.now()-n.createdAt>this.config.ttlMs}evictLRU(){let n=this.cache.keys().next().value;n!==void 0&&(this.cache.delete(n),this.stats.evictions++);}get(n,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(n,e),r=this.cache.get(t);if(!r){this.stats.misses++;return}if(this.isExpired(r)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),r.lastAccessed=Date.now(),this.cache.set(t,r),this.stats.hits++,r.result}set(n,e,t){if(!this.config.enabled||t.confidence===0)return;let r=this.makeKey(n,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(r,{result:t,createdAt:i,lastAccessed:i});}has(n,e){if(!this.config.enabled)return false;let t=this.makeKey(n,e),r=this.cache.get(t);return r?this.isExpired(r)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(n,e){let t=this.makeKey(n,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let n=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:n>0?this.stats.hits/n:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(n){if(n.maxSize!==void 0)for(this.config.maxSize=n.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();n.ttlMs!==void 0&&(this.config.ttlMs=n.ttlMs),n.enabled!==void 0&&(this.config.enabled=n.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},jt=new le;var Gt=class{constructor(n={}){this.patternMatcher=new Ve,this.languages=new Set(qe()),n.cache===false?this.cache=new le({enabled:false}):this.cache=n.cache?new le(n.cache):jt;}analyze(n,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(n,e);if(t)return t;let r=this.analyzeUncached(n,e);return this.cache.set(n,e,r),r}analyzeUncached(n,e){try{try{let s=ue(n,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=$t(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let r=t.tokenize(n),i=L(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(r,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(n){return this.languages.has(n)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(n){this.cache.configure(n);}buildSemanticNode(n){return {kind:"command",action:n.pattern.command,roles:n.captured,metadata:{patternId:n.pattern.id}}}};function We(n){return new Gt(n)}var Ut=.5;function je(n,e=Ut){return n.confidence>=e&&n.command!==void 0}var Ht={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"],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)"}},Kt={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"}},Yt={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},Xt={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},Qt={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>"}},Zt={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}]},Jt={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}]},er={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}]},tr={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}]},rr={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},nr={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},ir={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"}}]},or={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"}}]},sr={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"}}]},ar={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"}}]},lr={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}]},cr={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}]},ur={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}]},pr={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}]},dr={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}]},fr={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}]},mr={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}]},hr={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"}}]},vr={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}]},yr={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}]},gr={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Er={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"'},Tr={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"}}]},kr={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}]},br={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Sr={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:""}}]},wr={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}]},Ar={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"}}]},Cr={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}]},Pr={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}]},Rr={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}]},xr={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}]},_r={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}]},Or={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Nr={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:""}}]},Ir={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"}}]},Mr={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},Lr={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}]},Dr={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}]},Br={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"}}]},zr={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"}}]},$r={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"}}]},qr={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}]},Vr={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Fr={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}]},Wr={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},jr={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}]},Gr={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}]},Ge={toggle:Ht,add:Kt,remove:Yt,put:Xt,set:Qt,show:Zt,hide:Jt,on:er,trigger:tr,wait:rr,fetch:nr,increment:ir,decrement:or,append:sr,prepend:ar,log:lr,get:cr,take:ur,make:pr,halt:dr,settle:fr,throw:mr,send:hr,if:vr,unless:yr,else:gr,repeat:Er,for:Tr,while:kr,continue:br,go:Sr,transition:wr,clone:Ar,focus:Cr,blur:Pr,call:Rr,return:xr,js:_r,async:Or,tell:Nr,default:Ir,init:Mr,behavior:Lr,install:Dr,measure:Br,swap:zr,morph:$r,beep:qr,break:Vr,copy:Fr,exit:Wr,pick:jr,render:Gr,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Ur(){return Object.values(Ge).filter(n=>n.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(_t(),Le)).then(({validateAllSchemas:n,formatValidationResults:e})=>{let t=n(Ge);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
- These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(n=>{console.debug("Schema validation skipped:",n);});function Ue(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...n].sort((r,i)=>{let o=r[t]??99,s=i[t]??99;return o-s})}function Hr(n,e){let t=n.markerOverride?.[e.code],r=e.roleMarkers[n.role];if(t!==void 0)return {primary:t,position:r?.position??"before",isOverride:true};if(r&&r.primary){let i={primary:r.primary,position:r.position,isOverride:false};return r.alternatives&&(i.alternatives=r.alternatives),i}return null}function Kr(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let c of u)o.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let u=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(u);}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Yr(n,e,t,r,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let l=r.primary.split(/\s+/);if(l.length>1)for(let u of l)o.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Xr(n,e,t,r,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}let a=e.roleMarkers.destination;if(a&&(o.push({type:"role",role:"destination",optional:false}),o.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let c of u)o.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${n.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function Qr(n,e,t,r,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=r.alternatives?.filter(c=>!c.includes(" ")&&c.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.patient;if(l){let c=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};o.push(c);}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(u),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function Zr(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let l of a)o.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(s),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function Jr(n,e,t,r){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function en(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let p of c)o.push({type:"literal",value:p});else {let p=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(p);}}let a=[...n.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.sovPosition??999,f=p.sovPosition??999;return d-f});for(let c of a){o.push({type:"role",role:c.role,optional:false});let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(l);let u=a.map(c=>`{${c.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${r.primary} ${u} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(a.map(c=>[c.role,{fromRole:c.role}]))}}}function tn(n,e,t,r,i){let o=[],a=[...n.roles.filter(m=>m.required)].sort((m,v)=>{let S=m.sovPosition??999,g=v.sovPosition??999;return S-g}),l=a[0];o.push({type:"role",role:l.role,optional:false});let u;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)u=l.markerOverride[e.code];else {let m=e.roleMarkers[l.role];m&&(u=m.primary);}if(u&&o.push({type:"literal",value:u}),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let m=r.primary.split(/\s+/);if(m.length>1)for(let v of m)o.push({type:"literal",value:v});else {let v=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(v);}}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(c);let p=a[1];o.push({type:"role",role:p.role,optional:false});let d,f;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code];else {let m=e.roleMarkers[p.role];m&&(d=m.primary,f=m.alternatives);}if(d){let m=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};o.push(m);}return {id:`${n.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${l.role}} {event} ${r.primary} ${t.primary} {${p.role}}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},[l.role]:{fromRole:l.role},[p.role]:{fromRole:p.role}}}}function _e(n,e,t,r,i){let o=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${r.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function rn(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}return o.push({type:"role",role:"event",optional:false}),{id:`${n.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function nn(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...n.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of l){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:c.role,optional:false});}if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let u=l.map(c=>`{${c.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${u} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(c=>[c.role,{fromRole:c.role}]))}}}function Oe(n,e,t,r,i){let o=[];if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...n.roles.filter(c=>c.required)].sort((c,p)=>{let d=c.svoPosition??999,f=p.svoPosition??999;return d-f});for(let c of l){let p,d;if(c.markerOverride&&c.markerOverride[e.code]!==void 0)p=c.markerOverride[e.code];else {let f=e.roleMarkers[c.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:c.role,optional:false});}let u=l.map(c=>`{${c.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${u}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(c=>[c.role,{fromRole:c.role}]))}}}function on(n,e,t,r,i){let o=[],s=e.eventHandler?.negationMarker;if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}if(s){let u=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(a),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.destination;return l&&o.push({type:"group",optional:true,tokens:[l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${l?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function sn(n,e,t,r){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var G={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function He(n,e,t=G){let r=`${n.action}-${e.code}-generated`,i=t.basePriority??100,o=e.keywords[n.action];if(!o)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let s=un(n,e,o),a=Ye(n,e),l=mn(n,e,o);return {id:r,language:e.code,command:n.action,priority:i,template:{format:l,tokens:s},extraction:a}}function an(n,e,t=G){if(n.roles.filter(a=>!a.required).length===0)return null;let i=n.roles.filter(a=>a.required),o={...n,roles:i};return {...He(o,e,t),id:`${n.action}-${e.code}-simple`,priority:(t.basePriority??100)-5,extraction:Ye(n,e)}}function ln(n,e,t=G){let r=[];if(r.push(He(n,e,t)),t.generateSimpleVariants){let i=an(n,e,t);i&&r.push(i);}return r}function Ke(n,e=G){let t=[],r=Ur();for(let i of r){if(!n.keywords[i.action])continue;let o=ln(i,n,e);if(t.push(...o),n.eventHandler?.eventMarker){let s=cn(i,n,e);t.push(...s);}}return t}function cn(n,e,t=G){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let r=[],i=e.eventHandler.eventMarker,o=e.keywords[n.action];if(!o)return [];let a=n.roles.filter(l=>l.required).length===2;if(e.wordOrder==="SOV")if(a)r.push(en(n,e,o,i,t)),r.push(tn(n,e,o,i,t));else {r.push(Kr(n,e,o,i,t)),r.push(Yr(n,e,o,i,t));let l=e.roleMarkers.destination;l&&l.primary!==i.primary&&r.push(Xr(n,e,o,i,t));let u=i.primary.split(/\s+/),c=i.alternatives?.some(d=>!d.includes(" ")&&d.length>1);u.length>1&&c&&r.push(Qr(n,e,o,i,t)),r.push(Zr(n,e,o,i,t));let p=Jr(n,e,o,t);p&&r.push(p);}else e.wordOrder==="VSO"?a?(r.push(Oe(n,e,o,i,t)),r.push(nn(n,e,o,i,t))):(r.push(_e(n,e,o,i,t)),r.push(rn(n,e,o,i,t)),e.eventHandler?.negationMarker&&r.push(on(n,e,o,i,t)),e.tokenization?.prefixes&&r.push(sn(n,e,o,t))):a?r.push(Oe(n,e,o,i,t)):r.push(_e(n,e,o,i,t));return r}function un(n,e,t){let r=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},o=pn(n,e);switch(e.wordOrder){case "SVO":r.push(i),r.push(...o);break;case "SOV":r.push(...o),r.push(i);break;case "VSO":r.push(i),r.push(...o);break;default:r.push(i),r.push(...o);}return r}function pn(n,e){let t=[],r=Ue(n.roles,e.wordOrder);for(let i of r){let o=dn(i,e);i.required?t.push(...o):t.push({type:"group",optional:true,tokens:o});}return t}function dn(n,e){let t=[],r=n.markerOverride?.[e.code],i=e.roleMarkers[n.role],o={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(i?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(o)):(t.push(o),r&&t.push({type:"literal",value:r}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}t.push(o);}else {t.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}else t.push(o);return t}function fn(n,e){let t={};for(let r of n.roles){let i=r.markerOverride?.[e.code],o=e.roleMarkers[r.role];i!==void 0?t[r.role]=i?{marker:i}:{}:o&&o.primary?t[r.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:t[r.role]={};}return t}function Ye(n,e){let t=fn(n,e),r={};for(let i of n.roles){let o=t[i.role]||{};!i.required&&i.default?r[i.role]={...o,default:i.default}:r[i.role]=o;}return r}function mn(n,e,t){let r=[],o=Ue(n.roles,e.wordOrder).map(s=>{let a=Hr(s,e),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(e.wordOrder){case "SVO":case "VSO":r.push(t.primary,...o);break;case "SOV":r.push(...o,t.primary);break;default:r.push(t.primary,...o);}return r.join(" ")}function J(n){let e=n.getAttribute("data-lang");if(e)return pe(e);let t=n.getAttribute("data-hyperscript-lang")??n.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return pe(t);let r=typeof document<"u"?document.documentElement?.lang:null;return r&&r!=="en"?pe(r):null}function pe(n){return n.split("-")[0].toLowerCase()}var Xe={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function H(n){switch(n.kind){case "event-handler":return hn(n);case "compound":return vn(n);default:return yn(n)}}function hn(n){let e=["on"],t=n.roles.get("event");t&&e.push(U(t));let r=n.roles.get("source");if(r&&e.push("from",U(r)),n.body&&n.body.length>0){let i=n.body.map(H);e.push(i.join(" then "));}return e.join(" ")}function vn(n){let e=n.chainType==="async"?"async":n.chainType;return n.statements.map(H).join(` ${e} `)}function yn(n){let e=Xe[n.action];if(e){let r=[n.action];for(let[i,o]of e){let s=n.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&r.push(o),r.push(U(s))));}return r.join(" ")}let t=[n.action];for(let[,r]of n.roles)t.push(U(r));return t.join(" ")}function U(n){switch(n.type){case "literal":return typeof n.value=="string"&&n.dataType==="string"?`"${n.value}"`:String(n.value);case "selector":return n.value;case "reference":return n.value;case "property-path":return gn(n);case "expression":return n.raw}}function gn(n){let e=U(n.object),t=n.property;if(n.object.type==="reference")switch(n.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var Ze=.5,En={confidenceThreshold:Ze,strategy:"semantic",fallbackToOriginal:true};function Tn(n,e){return typeof n=="number"?n:n[e]??n["*"]??Ze}var de=null;function kn(){return de||(de=We()),de}function fe(n,e,t={}){let r={...En,...t},i=Qe(n,e,r);if(i!==null)return i;let o=Sn(n);if(o){let s=Qe(o.commands,e,r);if(s!==null)return o.prefix+s}return n}function Qe(n,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let r=Tn(t.confidenceThreshold,e),i=Je(n,e,r);if(i!==null)return i}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let r=wn(n,e,t.i18nToEnglish);if(r!==null)return r}return null}var bn=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Sn(n){let e=n.match(bn);if(!e)return null;let t=e[1],r=n.slice(t.length);return r?{prefix:t,commands:r}:null}function Je(n,e,t){try{let r=Cn(n,e);if(r.length>1)return Pn(r,e,t);let i=kn();if(!i.supportsLanguage(e))return null;let o=i.analyze(n,e);if(!je(o,t))return null;if(o.node)return H(o.node);let s=ue(n,e);return H(s)}catch{return null}}function wn(n,e,t){try{let r=t(n,e);return r!==n?r:null}catch{return null}}function An(n){let e=["then"],t=N(n);if(t?.keywords?.then){let r=t.keywords.then;if(r.primary&&r.primary!=="then"&&e.push(r.primary),r.alternatives)for(let i of r.alternatives)e.includes(i)||e.push(i);}return e}function Cn(n,e){let r=An(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${r.join("|")})\\s+`,"i"),o=n.split(`
4
- `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of o){let l=a.split(i);s.push(...l);}return s}function Pn(n,e,t){let r=[];for(let i of n){let o=Je(i.trim(),e,t);if(o===null)return null;r.push(o);}return r.join(" then ")}function me(n={}){return function(t){let{internals:r}=t,i=r.runtime,o=i.getScript.bind(i);i.getScript=function(s){let a=o(s);if(!a)return null;let l=Rn(s,n);if(!l||l==="en")return a;let u=fe(a,l,n);return n.debug&&u!==a&&console.log(`[hyperscript-i18n] ${l}: "${a}" \u2192 "${u}"`),u};}}function Rn(n,e){if(e.languageAttribute){let r=n.getAttribute(e.languageAttribute);if(r)return r.split("-")[0].toLowerCase()}let t=J(n);return t||(e.defaultLanguage??null)}function et(n,e,t={}){return e==="en"?n:fe(n,e,t)}$e(n=>Ke(n));function tt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(me()),xn());}function xn(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(r=>{let i=e.getInternalData(r);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var ei=["tl"];tt();exports.plugin=me;exports.preprocess=et;exports.resolveLanguage=J;exports.supportedLanguages=ei;return exports;})({});
1
+ var HyperscriptI18n=(function(exports){'use strict';function P(n,e){return e?{type:"literal",value:n,dataType:e}:{type:"literal",value:n}}function de(n,e){return e?{type:"selector",value:n,selectorKind:e}:{type:"selector",value:n}}function ne(n){return {type:"reference",value:n}}function fe(n,e){return {type:"property-path",object:n,property:e}}var Tt=class{constructor(n){this.namespace=n,this.enabled=this.checkEnabled();}checkEnabled(){if(typeof process<"u"&&process.env){let n=process.env.DEBUG||"";return n==="*"||n.includes("framework:*")||n.includes(`framework:${this.namespace}`)}return false}log(n,e,...t){if(!this.enabled)return;let r=`[framework:${this.namespace}]`,i=new Date().toISOString();switch(n){case "debug":console.debug(`${i} ${r} DEBUG:`,e,...t);break;case "info":console.info(`${i} ${r} INFO:`,e,...t);break;case "warn":console.warn(`${i} ${r} WARN:`,e,...t);break;case "error":console.error(`${i} ${r} ERROR:`,e,...t);break}}debug(n,...e){this.log("debug",n,...e);}info(n,...e){this.log("info",n,...e);}warn(n,...e){this.log("warn",n,...e);}error(n,...e){this.log("error",n,...e);}isEnabled(){return this.enabled}enable(){this.enabled=true;}disable(){this.enabled=false;}};function xt(n){return new Tt(n)}function D(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function Ct(n,e){return n?.possessive?.keywords?.[e]}var H=class V{constructor(){this.logger=xt("pattern-matcher"),this.stemMatchCount=0,this.totalKeywordMatches=0;}safeToLowerCase(e){return typeof e=="string"?e.toLowerCase():e==null?"":String(e).toLowerCase()}matchPattern(e,t,r){let i=e.mark(),o=new Map;if(this.logger.debug("========================================"),this.logger.debug("matchPattern ENTRY"),this.logger.debug("Pattern ID:",t.id),this.logger.debug("Pattern command:",t.command),this.logger.debug("Pattern language:",t.language),this.logger.debug("Pattern template:",JSON.stringify(t.template,null,2)),this.logger.isEnabled()){let l=[];for(let c=0;c<10;c++){let u=e.peek(c);if(u)l.push({type:u.type,value:u.value,kind:u.kind});else break}this.logger.debug("Input tokens (first 10):",l),this.logger.debug("Profile code:",r?.code);}this.currentProfile=r,this.stemMatchCount=0,this.totalKeywordMatches=0,this.logger.debug("--- Calling matchTokenSequence ---"),this.logger.debug("Pattern tokens to match:",JSON.stringify(t.template.tokens,null,2));let s=this.matchTokenSequence(e,t.template.tokens,o);if(this.logger.debug("matchTokenSequence returned:",s),this.logger.debug("Captured roles:",Array.from(o.entries()).map(([l,c])=>[l,JSON.stringify(c)])),!s)return this.logger.debug(">>> MATCH FAILED - resetting token position"),e.reset(i),null;let a=this.calculateConfidence(t,o);return this.applyExtractionRules(t,o),{pattern:t,captured:o,consumedTokens:e.position()-i.position,confidence:a}}matchBest(e,t,r){let i=[];for(let s of t){let a=e.mark(),l=this.matchPattern(e,s,r);l&&i.push(l),e.reset(a);}if(i.length===0)return null;i.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;if(l!==0)return l;let c=a.confidence-s.confidence;return Math.abs(c)>.001?c:a.consumedTokens-s.consumedTokens});let o=i[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r,i){let o=t[0],s=o?.type==="literal"&&(o.value==="and"||o.value==="then"||o.alternatives?.includes("and")||o.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!s)for(;e.peek()?.kind==="conjunction";)e.advance();let a=null,l=null;for(let c=0;c<t.length;c++){let u=t[c];this.logger.debug(" >> Matching pattern token:",JSON.stringify(u,null,2));let p=e.peek();if(this.logger.debug(" >> Current input token:",p?JSON.stringify({type:p.type,value:p.value,kind:p.kind}):"EOF"),u.type==="role"&&u.greedy){let y=this.collectStopMarkers(t,c+1);if(i)for(let E of i)y.add(E);let v=[];for(;!e.isAtEnd();){let E=e.peek();if(!E||this.isStopMarker(E,y))break;v.push(E.value),e.advance();}if(v.length>0){r.set(u.role,{type:"expression",raw:v.join(" ")}),a=null,l=null;continue}else {if(u.optional)continue;return false}}if(u.type==="group"){let y=this.collectStopMarkers(t,c+1);if(i)for(let E of i)y.add(E);if(this.matchGroupToken(e,u,r,y)){a=null,l=null;continue}if(this.isOptional(u))continue;return false}let d=u.type==="role"&&u.optional===true,f=d?e.mark():null;if(u.type==="role"&&!d){let y=c+1<t.length?t[c+1]:null;if(y?.type==="literal"){let v=e.peek();if(v&&this.getMatchType(v,y.value)!=="none"){if(this.logger.debug(" >> MARKER-STEAL GUARD: current token matches next literal, skipping role"),this.logger.debug(" >> Token match FAILED"),this.isOptional(u))continue;if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),r.delete(l),a=null,l=null;let E=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Backtrack retry result:",E),E)continue}return false}}}let g=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Match result:",g),g){d?(a=f,l=u.role):(a=null,l=null);continue}if(this.logger.debug(" >> Token match FAILED"),!this.isOptional(u)){if(a&&l){this.logger.debug(" >> BACKTRACKING: undoing optional role",l),e.reset(a),r.delete(l),a=null,l=null;let y=this.matchPatternToken(e,u,r);if(this.logger.debug(" >> Backtrack retry result:",y),y)continue}return false}}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(this.logger.debug(" >>> matchLiteralToken: expecting",t.value),this.logger.debug(" >>> matchLiteralToken: got token",r?JSON.stringify({type:r.type,value:r.value,kind:r.kind}):"null"),!r)return this.logger.debug(" >>> matchLiteralToken: FAIL - no token"),false;let i=this.getMatchType(r,t.value);if(this.logger.debug(" >>> matchType for",r.value,"vs",t.value,":",i),i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.logger.debug(" >>> matchRoleToken ENTRY: capturing role",t.role),this.logger.debug(" >>> matchRoleToken: expected types",t.expectedTypes),this.logger.debug(" >>> matchRoleToken: optional?",t.optional),this.skipNoiseWords(e);let i=e.peek();if(this.logger.debug(" >>> After skipNoiseWords, current token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null"),!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!D(o.type,t.expectedTypes)?t.optional||false:(r.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!D(s.type,t.expectedTypes)?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!D(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!D(l.type,t.expectedTypes)?t.optional||false:(r.set(t.role,l),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!D(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);this.logger.debug(" >>> Trying tokenToSemanticValue for token:",i?JSON.stringify({value:i.value,kind:i.kind}):"null");let u=this.tokenToSemanticValue(i);return this.logger.debug(" >>> tokenToSemanticValue returned:",u?JSON.stringify(u):"null"),u?(this.logger.debug(" >>> Validating type:",u.type,"against expected:",t.expectedTypes),t.expectedTypes&&t.expectedTypes.length>0&&!D(u.type,t.expectedTypes)?(this.logger.debug(" >>> TYPE MISMATCH - returning",t.optional||false),t.optional||false):(this.logger.debug(" >>> Type validation PASSED"),r.set(t.role,u),e.advance(),true)):t.optional||false}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=t.normalized||t.value,i=this.safeToLowerCase(r),o=Ct(this.currentProfile,i);if(!o)return null;let s=e.mark();e.advance();let a=e.peek();if(!a)return e.reset(s),null;if(a.kind==="identifier"||a.kind==="keyword"&&!this.isStructuralKeyword(a.value)||a.kind==="selector"&&a.value.startsWith("*")||a.kind==="selector"&&a.value.startsWith("@")||a.kind==="selector"&&a.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a.value)){e.advance();let l=a.value;a.kind==="selector"&&l.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(l)&&(l=l.substring(1));let c=l;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)c+=e.peek().value,e.advance();let u=e.peek();return u?.kind==="literal"&&u.value.startsWith("(")&&(c+=u.value,e.advance()),fe(ne(o),c)}return e.reset(s),null}isStructuralKeyword(e){return new Set(["into","in","to","from","at","by","with","without","before","after","of","as","on","then","end","else","if","repeat","while","for","toggle","add","remove","put","set","show","hide","increment","decrement","send","trigger","call"]).has(e.toLowerCase())}tryMatchMethodCallExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<V.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<V.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<V.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(u===0){e.advance();break}u--;}if(d.kind==="punctuation"&&d.value==="("&&u++,d.kind==="punctuation"&&d.value===","){e.advance();continue}c.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(r),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(r),null):(e.advance(),fe(de(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||typeof t.value!="string"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(r),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return fe(de(t.value),s)}matchGroupToken(e,t,r,i){let o=e.mark(),s=new Set(r.keys());if(this.matchTokenSequence(e,t.tokens,r,i))return true;e.reset(o);for(let c of r.keys())s.has(c)||r.delete(c);if(!t.optional)return false;let l=this.getGroupLeadingMarker(t);if(l)for(let c=1;c<=V.MAX_MARKER_SCAN;c++){let u=e.peek(c);if(!u)break;if((u.normalized||u.value).toLowerCase()===l){this.logger.debug(" >> MARKER SCAN: found",l,"at offset",c,"- skipping intervening tokens");for(let f=0;f<c;f++)e.advance();if(this.matchTokenSequence(e,t.tokens,r,i))return true;e.reset(o);for(let f of r.keys())s.has(f)||r.delete(f);break}}return true}getGroupLeadingMarker(e){let t=e.tokens[0];return t?.type==="literal"?t.value.toLowerCase():null}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&this.safeToLowerCase(e.value)===t.toLowerCase()?"case-insensitive":"none"}collectStopMarkers(e,t){let r=new Set;for(let i=t;i<e.length;i++){let o=e[i];if(o.type==="literal"){if(r.add(o.value.toLowerCase()),o.alternatives)for(let s of o.alternatives)r.add(s.toLowerCase());break}if(o.type==="group"){for(let s of o.tokens)if(s.type==="literal"){if(r.add(s.value.toLowerCase()),s.alternatives)for(let a of s.alternatives)r.add(a.toLowerCase());break}if(!o.optional)break}}return r}isStopMarker(e,t){return t.size===0?false:!!(t.has(e.value.toLowerCase())||e.normalized&&t.has(e.normalized.toLowerCase()))}tokenToSemanticValue(e){switch(e.kind){case "selector":return de(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=e.normalized||e.value;this.safeToLowerCase(t);return P(e.normalized||e.value);case "identifier":if(typeof e.value=="string"&&e.value.startsWith(":"))return ne(e.value);this.safeToLowerCase(e.value);return {type:"expression",raw:e.value};case "url":return P(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return P(i,"string")}if(e==="true")return P(true,"boolean");if(e==="false")return P(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?P(e,"duration"):P(i,"number")}let r=parseFloat(e);return isNaN(r)?P(e,"string"):P(r,"number")}applyExtractionRules(e,t){for(let[r,i]of Object.entries(e.extraction))t.has(r)||(i.value!==void 0?t.set(r,{type:"literal",value:i.value}):i.default&&t.set(r,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}calculateConfidence(e,t){let r=0,i=0,o=c=>e.extraction?.[c]?.default!==void 0;for(let c of e.template.tokens)if(c.type==="role")i+=1,t.has(c.role)&&(r+=1);else if(c.type==="group"){for(let u of c.tokens)if(u.type==="role"){let p=o(u.role),d=.8;i+=d,t.has(u.role)?r+=d:p&&(r+=d*.6);}}let s=i>0?r/i:1;if(this.stemMatchCount>0&&this.totalKeywordMatches>0){let c=this.stemMatchCount/this.totalKeywordMatches*.15;s=Math.max(.5,s-c);}let a=this.calculateVSOConfidenceBoost(e);s=Math.min(1,s+a);let l=this.arabicPrepositionDisambiguation(e,t);return s=Math.max(0,Math.min(1,s+l)),s}calculateVSOConfidenceBoost(e){if(e.language!=="ar")return 0;let t=e.template.tokens[0];if(!t||t.type!=="literal")return 0;let r=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]);if(r.has(t.value))return .15;if(t.alternatives){for(let i of t.alternatives)if(r.has(i))return .15}return 0}arabicPrepositionDisambiguation(e,t){if(e.language!=="ar")return 0;let r=0,i={patient:["\u0639\u0644\u0649"],destination:["\u0625\u0644\u0649","\u0627\u0644\u0649"],source:["\u0645\u0646"],agent:["\u0645\u0646"],manner:["\u0628"],style:["\u0628"],goal:["\u0625\u0644\u0649","\u0627\u0644\u0649"],method:["\u0628"]};for(let[o,s]of t.entries()){let a=i[o];if(!a||a.length===0)continue;let l="metadata"in s?s.metadata:void 0;if(l&&typeof l.prepositionValue=="string"){let c=l.prepositionValue;a.includes(c)?r+=.1:r-=.1;}}return Math.max(-0.1,Math.min(.1,r))}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=this.safeToLowerCase(t.value);if(V.ENGLISH_NOISE_WORDS.has(r)){let i=e.mark();e.advance();let o=e.peek();if(o&&o.kind==="selector")return;e.reset(i);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(r=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return r?t:void 0}};H.MAX_MARKER_SCAN=3;H.MAX_PROPERTY_DEPTH=10;H.MAX_METHOD_ARGS=20;H.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var At=H;new At;var Ne=class{constructor(){this.name="string-literal";}canExtract(n,e){let t=n[e];return t==='"'||t==="'"||t==="`"||t==="\u201C"||t==="\u2018"}extract(n,e){let t=n[e];if(t==="\u201C"){let o=1;for(;e+o<n.length;){if(n[e+o]==="\u201D")return o++,{value:n.substring(e,e+o),length:o};o++;}return null}if(t==="\u2018"){let o=1;for(;e+o<n.length;){if(n[e+o]==="\u2019")return o++,{value:n.substring(e,e+o),length:o};o++;}return null}let r=1,i=false;for(;e+r<n.length;){let o=n[e+r];if(i){i=false,r++;continue}if(o==="\\"){i=true,r++;continue}if(o===t)return r++,{value:n.substring(e,e+r),length:r};r++;}return null}},Oe=class{constructor(){this.name="number";}canExtract(n,e){return /\d/.test(n[e])}extract(n,e){let t=0,r=false;for(;e+t<n.length;){let s=n[e+t];if(/\d/.test(s))t++;else if(s==="."&&!r)r=true,t++;else break}if(t===0)return null;let i=n.substring(e,e+t),o=e+t;if(o<n.length){let s=n.slice(o),a=[{pattern:"\u6BEB\u79D2",suffix:"ms"},{pattern:"\u5206\u949F",suffix:"m"},{pattern:"\u5C0F\u65F6",suffix:"h"},{pattern:"\u30DF\u30EA\u79D2",suffix:"ms"},{pattern:"\u6642\u9593",suffix:"h"}];for(let c of a)if(s.startsWith(c.pattern))return {value:i+c.suffix,length:t+c.pattern.length,metadata:{hasTimeUnit:true}};if(s.startsWith("ms"))return {value:i+"ms",length:t+2,metadata:{hasTimeUnit:true}};let l=[{pattern:"\u79D2",suffix:"s"},{pattern:"\u5206",suffix:"m"}];for(let c of l)if(s.startsWith(c.pattern))return {value:i+c.suffix,length:t+1,metadata:{hasTimeUnit:true}};if(/^[smh](?![a-zA-Z])/.test(s))return {value:i+s[0],length:t+1,metadata:{hasTimeUnit:true}}}return {value:i,length:t}}};function Rt(n){return "setContext"in n&&typeof n.setContext=="function"}function Pt(n){let e={language:n.language,direction:n.direction,lookupKeyword:n.lookupKeyword.bind(n),isKeyword:n.isKeyword.bind(n),isKeywordStart:n.isKeywordStart.bind(n)};return n.normalizer?{...e,normalizer:n.normalizer}:e}var Nt=new Set(["me","you","it","result","event","target","body"]);function _e(n,e=Nt){return e.has(n)}var Y=class{constructor(n,e){this.pos=0,this.tokens=n,this.language=e;}peek(n=0){let e=this.pos+n;return e<0||e>=this.tokens.length?null:this.tokens[e]}advance(){if(this.isAtEnd())throw new Error("Unexpected end of token stream");return this.tokens[this.pos++]}isAtEnd(){return this.pos>=this.tokens.length}mark(){return {position:this.pos}}reset(n){this.pos=n.position;}position(){return this.pos}remaining(){return this.tokens.slice(this.pos)}takeWhile(n){let e=[];for(;!this.isAtEnd()&&n(this.peek());)e.push(this.advance());return e}skipWhile(n){for(;!this.isAtEnd()&&n(this.peek());)this.advance();}};function S(n,e){return {start:n,end:e}}function w(n,e,t,r){if(typeof n=="object"){let{value:o,kind:s,position:a,normalized:l,stem:c,stemConfidence:u,metadata:p}=n;return {value:o,kind:s,position:a,...l!==void 0&&{normalized:l},...c!==void 0&&{stem:c},...u!==void 0&&{stemConfidence:u},...p!==void 0&&{metadata:p}}}let i=n;if(!e||!t)throw new Error("createToken requires kind and position parameters");if(typeof r=="string")return {value:i,kind:e,position:t,normalized:r};if(r){let{normalized:o,stem:s,stemConfidence:a,metadata:l}=r;return {value:i,kind:e,position:t,...o!==void 0&&{normalized:o},...s!==void 0&&{stem:s},...a!==void 0&&{stemConfidence:a},...l!==void 0&&{metadata:l}}}return {value:i,kind:e,position:t}}function K(n){return /\s/.test(n)}function _t(n){return n==="#"||n==="."||n==="["||n==="@"||n==="*"||n==="<"}function It(n){return n==='"'||n==="'"||n==="`"||n==="\u300C"||n==="\u300D"}function I(n){return /\d/.test(n)}function Mt(n){return /[a-zA-Z]/.test(n)}function x(n){return /[a-zA-Z0-9_-]/.test(n)}function Lt(n,e){if(e>=n.length)return null;let t=n[e];if(!_t(t))return null;let r=e,i="";if(t==="#"||t==="."){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null;if(r<n.length&&n[r]==="."&&t==="#"){let s=r+1;for(;s<n.length&&x(n[s]);)s++;if(s<n.length&&n[s]==="(")return i}}else if(t==="["){let o=1,s=false,a=null,l=false;for(i+=n[r++];r<n.length&&o>0;){let c=n[r];i+=c,l?l=false:c==="\\"?l=true:s?c===a&&(s=false,a=null):c==='"'||c==="'"||c==="`"?(s=true,a=c):c==="["?o++:c==="]"&&o--,r++;}if(o!==0)return null}else if(t==="@"){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="*"){for(i+=n[r++];r<n.length&&x(n[r]);)i+=n[r++];if(i.length<=1)return null}else if(t==="<"){if(i+=n[r++],r>=n.length||!Mt(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];for(;r<n.length;){let o=n[r];if(o==="."){if(i+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];}else if(o==="#"){if(i+=n[r++],r>=n.length||!x(n[r]))return null;for(;r<n.length&&x(n[r]);)i+=n[r++];}else if(o==="["){let s=1,a=false,l=null,c=false;for(i+=n[r++];r<n.length&&s>0;){let u=n[r];i+=u,c?c=false:u==="\\"?c=true:a?u===l&&(a=false,l=null):u==='"'||u==="'"||u==="`"?(a=true,l=u):u==="["?s++:u==="]"&&s--,r++;}if(s!==0)return null}else break}for(;r<n.length&&K(n[r]);)i+=n[r++];if(r<n.length&&n[r]==="/")for(i+=n[r++];r<n.length&&K(n[r]);)i+=n[r++];if(r>=n.length||n[r]!==">")return null;i+=n[r++];}return i||null}function $t(n,e){if(e>=n.length||n[e]!=="'"||e+1>=n.length||n[e+1].toLowerCase()!=="s")return false;if(e+2>=n.length)return true;let r=n[e+2];return K(r)||r==="*"||!x(r)}function Dt(n,e){if(e>=n.length)return null;let t=n[e];if(!It(t)||t==="'"&&$t(n,e))return null;let i={'"':'"',"'":"'","`":"`","\u300C":"\u300D"}[t];if(!i)return null;let o=e+1,s=t,a=false;for(;o<n.length;){let l=n[o];if(s+=l,a)a=false;else if(l==="\\")a=true;else if(l===i)return s;o++;}return s}function Vt(n,e){if(e>=n.length)return false;let t=n[e],r=n[e+1]||"",i=n[e+2]||"";if(t==="/"&&r!=="/"&&/[a-zA-Z0-9._-]/.test(r)||t==="/"&&r==="/"&&/[a-zA-Z]/.test(i)||t==="."&&(r==="/"||r==="."&&i==="/"))return true;let o=n.slice(e,e+8).toLowerCase();return !!(o.startsWith("http://")||o.startsWith("https://"))}function Bt(n,e){if(!Vt(n,e))return null;let t=e,r="",i=/[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;for(;t<n.length;){let o=n[t];if(o==="#"){if(r.length>0&&/[a-zA-Z0-9/.]$/.test(r))for(r+=o,t++;t<n.length&&/[a-zA-Z0-9_-]/.test(n[t]);)r+=n[t++];break}if(i.test(o))r+=o,t++;else break}return r.length<2?null:r}function zt(n,e){if(e>=n.length)return null;let t=n[e];if(!I(t)&&t!=="-"&&t!=="+")return null;let r=e,i="";if((n[r]==="-"||n[r]==="+")&&(i+=n[r++]),r>=n.length||!I(n[r]))return null;for(;r<n.length&&I(n[r]);)i+=n[r++];if(r<n.length&&n[r]===".")for(i+=n[r++];r<n.length&&I(n[r]);)i+=n[r++];return r<n.length&&(n.slice(r,r+2)==="ms"?i+="ms":(n[r]==="s"||n[r]==="m"||n[r]==="h")&&(i+=n[r])),i}var qt=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"];new Set(qt);var Me=class Le{constructor(){this.profileKeywords=[],this.profileKeywordMap=new Map,this.extractors=[];}tokenize(e){if(this.isUsingExtractors())return this.tokenizeWithExtractors(e);throw new Error(`${this.constructor.name}: tokenize() not implemented and no extractors registered. Either register extractors or override tokenize() method.`)}registerExtractor(e){Rt(e)&&e.setContext(Pt(this)),this.extractors.push(e);}registerExtractors(e){for(let t of e)this.registerExtractor(t);}clearExtractors(){this.extractors=[];}isUsingExtractors(){return this.extractors.length>0}tokenizeWithExtractors(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&K(e[r]);)r++;if(r>=e.length)break;let i=false;for(let o of this.extractors)if(o.canExtract(e,r)){let s=o.extract(e,r);if(s){let a=s.metadata?.normalized,l=s.metadata?.stem,c=s.metadata?.stemConfidence,u={};if(s.metadata)for(let[d,f]of Object.entries(s.metadata))d!=="normalized"&&d!=="stem"&&d!=="stemConfidence"&&(u[d]=f);let p={};a&&(p.normalized=a),l&&(p.stem=l),c!==void 0&&(p.stemConfidence=c),Object.keys(u).length>0&&(p.metadata=u),t.push(w(s.value,this.classifyToken(s.value),S(r,r+s.length),Object.keys(p).length>0?p:void 0)),r+=s.length,i=true;break}}if(!i){let o=e[r],s=this.classifyUnknownChar(o);t.push(w(o,s,S(r,r+1))),r++;}}return new Y(t,this.language)}classifyUnknownChar(e){return "()[]{},:;".includes(e)?"punctuation":"+-*/<>=!&|".includes(e)?"operator":"identifier"}tryPropertyAccess(e,t,r){if(e[t]!==".")return false;let i=r[r.length-1],o=i&&i.position.end<t;if(i&&!o&&(i.kind==="identifier"||i.kind==="keyword"||i.kind==="selector"))return r.push(w(".","operator",S(t,t+1))),true;let l=t+1;for(;l<e.length&&x(e[l]);)l++;return l<e.length&&e[l]==="("?(r.push(w(".","operator",S(t,t+1))),true):false}initializeKeywordsFromProfile(e,t=[]){let r=new Map;if(e.keywords){for(let[i,o]of Object.entries(e.keywords))if(r.set(o.primary,{native:o.primary,normalized:o.normalized||i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:o.normalized||i});}if(e.references){for(let[i,o]of Object.entries(e.references))r.set(o,{native:o,normalized:i});for(let i of Object.keys(e.references))r.has(i)||r.set(i,{native:i,normalized:i});}if(e.roleMarkers){for(let[i,o]of Object.entries(e.roleMarkers))if(o.primary&&r.set(o.primary,{native:o.primary,normalized:i}),o.alternatives)for(let s of o.alternatives)r.set(s,{native:s,normalized:i});}if(e.possessive?.keywords)for(let[i,o]of Object.entries(e.possessive.keywords))r.set(i,{native:i,normalized:o});for(let i of t)r.set(i.native,i);this.profileKeywords=Array.from(r.values()).sort((i,o)=>o.native.length-i.native.length),this.profileKeywordMap=new Map;for(let i of this.profileKeywords){this.profileKeywordMap.set(i.native.toLowerCase(),i);let o=this.removeDiacritics(i.native);o!==i.native&&!this.profileKeywordMap.has(o.toLowerCase())&&this.profileKeywordMap.set(o.toLowerCase(),i);}}removeDiacritics(e){return e.replace(/[\u064B-\u0652\u0670]/g,"")}tryProfileKeyword(e,t){for(let r of this.profileKeywords)if(e.slice(t).startsWith(r.native))return w(r.native,"keyword",S(t,t+r.native.length),r.normalized);return null}isKeywordStart(e,t){let r=e.slice(t);return this.profileKeywords.some(i=>r.startsWith(i.native))}lookupKeyword(e){return this.profileKeywordMap.get(e.toLowerCase())}isKeyword(e){return this.profileKeywordMap.has(e.toLowerCase())}setNormalizer(e){this.normalizer=e;}tryNormalize(e){if(!this.normalizer)return null;let t=this.normalizer.normalize(e);return t.stem!==e&&t.confidence>=.7?t:null}tryMorphKeywordMatch(e,t,r){let i=this.tryNormalize(e);if(!i)return null;let o=this.lookupKeyword(i.stem);if(!o)return null;let s={normalized:o.normalized,stem:i.stem,stemConfidence:i.confidence};return w(e,"keyword",S(t,r),s)}trySelector(e,t){let r=Lt(e,t);return r?w(r,"selector",S(t,t+r.length)):null}tryEventModifier(e,t){if(e[t]!==".")return null;let r=e.slice(t).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);if(!r)return null;let i=r[0].replace(/(\s|\.)$/,""),o=i.slice(1).split("(")[0],s=r[1];return {...w(i,"event-modifier",S(t,t+i.length)),metadata:{modifierName:o,value:s?o==="queue"?s:parseInt(s,10):void 0}}}tryString(e,t){let r=Dt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryNumber(e,t){let r=zt(e,t);return r?w(r,"literal",S(t,t+r.length)):null}tryMatchTimeUnit(e,t,r,i=false){let o=t;if(i)for(;o<e.length&&K(e[o]);)o++;let s=e.slice(o);for(let a of r){let l=s.slice(0,a.length);if(a.caseInsensitive?l.toLowerCase()===a.pattern.toLowerCase():l===a.pattern){if(a.notFollowedBy&&(s[a.length]||"")===a.notFollowedBy)continue;if(a.checkBoundary){let u=s[a.length]||"";if(x(u))continue}return {suffix:a.suffix,endPos:o+a.length}}}return null}parseBaseNumber(e,t,r=true){let i=t,o="";if(r&&(e[i]==="-"||e[i]==="+")&&(o+=e[i++]),i>=e.length||!I(e[i]))return null;for(;i<e.length&&I(e[i]);)o+=e[i++];if(i<e.length&&e[i]===".")for(o+=e[i++];i<e.length&&I(e[i]);)o+=e[i++];return !o||o==="-"||o==="+"?null:{number:o,endPos:i}}tryNumberWithTimeUnits(e,t,r,i={}){let{allowSign:o=true,skipWhitespace:s=false}=i,a=this.parseBaseNumber(e,t,o);if(!a)return null;let{number:l,endPos:c}=a,u=[...r,...Le.STANDARD_TIME_UNITS],p=this.tryMatchTimeUnit(e,c,u,s);return p&&(l+=p.suffix,c=p.endPos),w(l,"literal",S(t,c))}tryUrl(e,t){let r=Bt(e,t);return r?w(r,"url",S(t,t+r.length)):null}tryVariableRef(e,t){if(e[t]!==":"||t+1>=e.length||!x(e[t+1]))return null;let r=t+1;for(;r<e.length&&x(e[r]);)r++;let i=e.slice(t,r);return w(i,"identifier",S(t,r))}tryOperator(e,t){let r=e.slice(t,t+2);if(["==","!=","<=",">=","&&","||","->"].includes(r))return w(r,"operator",S(t,t+2));let i=e[t];return ["<",">","!","+","-","*","/","="].includes(i)?w(i,"operator",S(t,t+1)):["(",")","{","}",",",";",":"].includes(i)?w(i,"punctuation",S(t,t+1)):null}tryMultiCharParticle(e,t,r){for(let i of r)if(e.slice(t,t+i.length)===i)return w(i,"particle",S(t,t+i.length));return null}};Me.STANDARD_TIME_UNITS=[{pattern:"ms",suffix:"ms",length:2},{pattern:"s",suffix:"s",length:1,checkBoundary:true},{pattern:"m",suffix:"m",length:1,checkBoundary:true,notFollowedBy:"s"},{pattern:"h",suffix:"h",length:1,checkBoundary:true}];var $e=Me;function De(n){return {stem:n,confidence:1}}function Ve(n,e,t){return t?{stem:n,confidence:e,metadata:t}:{stem:n,confidence:e}}var Wt=new Map,jt=new Map,Ft=new Map;function Ut(n,e,t){Wt.set(n,e),jt.set(n,t),Ft.delete(n);}var Be={code:"tl",name:"Tagalog",nativeName:"Tagalog",direction:"ltr",script:"latin",wordOrder:"VSO",markingStrategy:"preposition",usesSpaces:true,defaultVerbForm:"base",verb:{position:"start",subjectDrop:true},references:{me:"ako",it:"ito",you:"ikaw",result:"resulta",event:"pangyayari",target:"target",body:"body"},possessive:{marker:"ng",markerPosition:"between",keywords:{ko:"me",akin:"me",aking:"me",mo:"you",iyo:"you",niya:"it",nito:"it",kaniya:"it"}},roleMarkers:{destination:{primary:"sa",position:"before"},source:{primary:"mula_sa",position:"before"},patient:{primary:"",position:"before"},style:{primary:"nang",position:"before"}},keywords:{toggle:{primary:"palitan",alternatives:["itoggle"],normalized:"toggle"},add:{primary:"idagdag",alternatives:["magdagdag"],normalized:"add"},remove:{primary:"alisin",alternatives:["tanggalin"],normalized:"remove"},put:{primary:"ilagay",alternatives:["maglagay"],normalized:"put"},append:{primary:"idagdag_sa_dulo",normalized:"append"},prepend:{primary:"idagdag_sa_simula",normalized:"prepend"},take:{primary:"kumuha",normalized:"take"},make:{primary:"gumawa",alternatives:["lumikha"],normalized:"make"},clone:{primary:"i-clone",normalized:"clone"},swap:{primary:"palitan_pwesto",alternatives:["magpalit"],normalized:"swap"},morph:{primary:"baguhin",normalized:"morph"},set:{primary:"itakda",alternatives:["magtakda"],normalized:"set"},get:{primary:"kunin",normalized:"get"},increment:{primary:"dagdagan",alternatives:["taasan"],normalized:"increment"},decrement:{primary:"bawasan",alternatives:["ibaba"],normalized:"decrement"},log:{primary:"itala",normalized:"log"},show:{primary:"ipakita",alternatives:["magpakita"],normalized:"show"},hide:{primary:"itago",alternatives:["magtago"],normalized:"hide"},transition:{primary:"lumipat",normalized:"transition"},on:{primary:"kapag",normalized:"on"},trigger:{primary:"palitawin",alternatives:["magpatugtog"],normalized:"trigger"},send:{primary:"ipadala",alternatives:["magpadala"],normalized:"send"},focus:{primary:"ituon",normalized:"focus"},blur:{primary:"alisin_tuon",normalized:"blur"},go:{primary:"pumunta",alternatives:["punta"],normalized:"go"},wait:{primary:"maghintay",alternatives:["hintay"],normalized:"wait"},fetch:{primary:"kuhanin_mula",alternatives:["kunin_mula"],normalized:"fetch"},settle:{primary:"magpatahimik",normalized:"settle"},if:{primary:"kung",normalized:"if"},when:{primary:"tuwing",normalized:"when"},where:{primary:"kung_saan",normalized:"where"},else:{primary:"kung_hindi",alternatives:["kundi"],normalized:"else"},repeat:{primary:"ulitin",alternatives:["paulit-ulit"],normalized:"repeat"},for:{primary:"para_sa",normalized:"for"},while:{primary:"habang",normalized:"while"},continue:{primary:"magpatuloy",normalized:"continue"},halt:{primary:"itigil",alternatives:["huminto"],normalized:"halt"},throw:{primary:"ihagis",alternatives:["itapon"],normalized:"throw"},call:{primary:"tawagin",alternatives:["tawagan","tumawag"],normalized:"call"},return:{primary:"ibalik",alternatives:["bumalik"],normalized:"return"},then:{primary:"pagkatapos",alternatives:["saka"],normalized:"then"},and:{primary:"at",normalized:"and"},end:{primary:"wakas",alternatives:["tapos"],normalized:"end"},js:{primary:"js",normalized:"js"},async:{primary:"async",normalized:"async"},tell:{primary:"sabihin",alternatives:["magsabi"],normalized:"tell"},default:{primary:"pamantayan",alternatives:["default","unang_halaga"],normalized:"default"},init:{primary:"simulan",alternatives:["magsimula"],normalized:"init"},behavior:{primary:"ugali",alternatives:["kilos"],normalized:"behavior"},install:{primary:"ikabit",alternatives:["mag-install"],normalized:"install"},measure:{primary:"sukatin",normalized:"measure"},beep:{primary:"tunog",normalized:"beep"},break:{primary:"putulin",normalized:"break"},copy:{primary:"kopyahin",normalized:"copy"},exit:{primary:"lumabas",normalized:"exit"},pick:{primary:"pumili",normalized:"pick"},render:{primary:"irender",normalized:"render"},into:{primary:"sa",normalized:"into"},before:{primary:"bago",normalized:"before"},after:{primary:"matapos",normalized:"after"},until:{primary:"hanggang",normalized:"until"},event:{primary:"pangyayari",normalized:"event"},from:{primary:"mula",alternatives:["galing"],normalized:"from"}},eventHandler:{keyword:{primary:"kapag",normalized:"on"},sourceMarker:{primary:"mula_sa",alternatives:["galing_sa"],position:"before"},eventMarker:{primary:"kapag",position:"before"}}};function Gt(n){let e=n.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122?true:n==="\xF1"||n==="\xD1"}function Kt(n){for(let e of n)if(Gt(e))return true;return false}var Ht=[{pattern:"magpapa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"magpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ipag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nagpa",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3}],Yt=[{pattern:"mag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nag",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"mang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"nang",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"ma",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"na",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3},{pattern:"i",confidencePenalty:.15,prefixType:"verb-marker",minRemaining:3},{pattern:"pa",confidencePenalty:.12,prefixType:"verb-marker",minRemaining:3}],Xt=["um","in"],Jt=[{pattern:"hin",confidencePenalty:.18,type:"patient-focus"},{pattern:"in",confidencePenalty:.18,type:"patient-focus"},{pattern:"han",confidencePenalty:.18,type:"locative-focus"},{pattern:"an",confidencePenalty:.18,type:"locative-focus"}];function Qt(n){let e=n.toLowerCase();if(e.length<5)return null;let t=0;for(let r=0;r<e.length;r++){let i=e[r];if(!"aeiou".includes(i))t=r+1;else break}if(t===0)return null;for(let r of Xt){let i=t;if(e.slice(i,i+r.length)===r){let o=e.slice(0,t)+e.slice(i+r.length);if(o.length>=3)return {stem:o,infix:r}}}return null}function Zt(n){let e=n.toLowerCase();if(e.length<4)return {stem:e,reduplicated:false};let t=e[0],r=e[1];if(!"aeiou".includes(t)&&"aeiou".includes(r)){let i=e.slice(2);if(i.length>=2&&i[0]===t)return {stem:i,reduplicated:true}}return {stem:e,reduplicated:false}}var er=class{constructor(){this.language="tl";}isNormalizable(n){return !(!Kt(n)||n.length<2)}normalize(n){let e=n.toLowerCase(),t=1,r=[],i=[],o=[];for(let c of Ht)if(e.startsWith(c.pattern)){let u=e.slice(c.pattern.length),p=c.minRemaining??2;if(u.length>=p){e=u,t-=c.confidencePenalty,r.push(c.pattern),o.push(`prefix:${c.pattern}`);break}}if(r.length===0){for(let c of Yt)if(e.startsWith(c.pattern)){let u=e.slice(c.pattern.length),p=c.minRemaining??2;if(u.length>=p){e=u,t-=c.confidencePenalty,r.push(c.pattern),o.push(`prefix:${c.pattern}`);break}}}let s=Zt(e);s.reduplicated&&s.stem.length>=2&&(e=s.stem,t-=.1,o.push("reduplication:CV"));let a=Qt(e),l=false;if(a&&a.stem.length>=2&&(e=a.stem,t-=.18,o.push(`infix:${a.infix}`),l=true),!l){for(let c of Jt)if(e.endsWith(c.pattern)){let u=e.slice(0,-c.pattern.length);if(u.length>=2){e=u,t-=c.confidencePenalty,i.push(c.pattern),o.push(`suffix:${c.pattern}`);break}}}return t=Math.max(.5,t),r.length===0&&i.length===0&&o.length===0?De(n):Ve(e,t,{removedPrefixes:r,removedSuffixes:i,appliedRules:o})}},tr=new er,rr=["===","!==","->","==","!=","<=",">=","&&","||","**","+=","-=","*=","/=","+","-","*","/","=",">","<","!","&","|","%","^","~"],nr=class{constructor(n=rr){this.name="operator",this.operators=[...n].sort((e,t)=>t.length-e.length);}canExtract(n,e){return this.operators.some(t=>n.startsWith(t,e))}extract(n,e){for(let t of this.operators)if(n.startsWith(t,e))return {value:t,length:t.length};return null}},ir="()[]{},:;",or=class{constructor(n=ir){this.punctuation=n,this.name="punctuation";}canExtract(n,e){return this.punctuation.includes(n[e])}extract(n,e){let t=n[e];return this.punctuation.includes(t)?{value:t,length:1}:null}};function sr(n,e){let t=n[e];if(t==="#"){let r=n.slice(e).match(/^#[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="."){let r=n.slice(e).match(/^\.[a-zA-Z_][\w-]*/);return r?r[0]:null}if(t==="["){let r=0,i=e;for(;i<n.length;){if(n[i]==="["&&r++,n[i]==="]"&&(r--,r===0))return n.slice(e,i+1);i++;}return null}if(t==="<"){let r=n.slice(e).match(/^<[\w-]+(?:[#.][\w-]+|\[[^\]]+\])*\s*\/>/);return r?r[0]:null}return null}var ar=class{constructor(){this.name="css-selector";}canExtract(n,e){let t=n[e];return t==="#"||t==="."||t==="["||t==="<"}extract(n,e){let t=sr(n,e);return t?{value:t,length:t.length,metadata:{type:"css-selector"}}:null}},lr=class{constructor(){this.name="event-modifier";}canExtract(n,e){if(n[e]!==".")return false;let t=n.slice(e);return /^\.(once|prevent|stop|debounce|throttle|queue)/.test(t)}extract(n,e){let t=n.slice(e).match(/^\.(?:once|prevent|stop|debounce|throttle|queue)(?:\(([^)]+)\))?/);if(!t)return null;let r=t[0],i=r.slice(1).split("(")[0],o=t[1];return {value:r,length:r.length,metadata:{modifierName:i,value:o?i==="queue"?o:parseInt(o,10):void 0}}}};function cr(n,e){let t=n.slice(e);if(t.startsWith("http://")||t.startsWith("https://")){let r=t.match(/^https?:\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("//")){let r=t.match(/^\/\/[^\s]*/);return r?r[0]:null}if(t.startsWith("./")||t.startsWith("../")){let r=t.match(/^\.\.?\/[^\s]*/);return r?r[0]:null}if(t.startsWith("/")){let r=t.match(/^\/[^\s]*/);return r?r[0]:null}return null}var ur=class{constructor(){this.name="url";}canExtract(n,e){let t=n.slice(e);return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")}extract(n,e){let t=cr(n,e);return t?{value:t,length:t.length,metadata:{type:"url"}}:null}},pr=class{constructor(){this.name="variable-ref";}canExtract(n,e){return n[e]===":"&&e+1<n.length&&/[a-zA-Z_]/.test(n[e+1])}extract(n,e){if(!this.canExtract(n,e))return null;let t=1;for(;e+t<n.length&&/[a-zA-Z0-9_]/.test(n[e+t]);)t++;return {value:n.substring(e,e+t),length:t,metadata:{type:"variable-reference"}}}};function dr(n){return /[a-zA-Z_]/.test(n)}function fr(n){return /[a-zA-Z0-9_]/.test(n)}var mr=new Set(["sa","ng","para","mula","hanggang","gaya","tulad","kasama","para sa"]),hr=class{constructor(){this.name="tagalog-keyword";}setContext(n){this.context=n;}canExtract(n,e){return dr(n[e])}extract(n,e){if(!this.context)throw new Error("TagalogKeywordExtractor: context not set");let t=e,r="";for(;t<n.length&&fr(n[t]);)r+=n[t++];if(!r)return null;let i=r.toLowerCase(),o=mr.has(i),s=this.context.lookupKeyword(i),a=s&&s.normalized!==s.native?s.normalized:void 0,l;if(!s&&this.context.normalizer){let c=this.context.normalizer.normalize(r);if(c.stem!==r&&c.confidence>=.7){let u=this.context.lookupKeyword(c.stem);u&&(l=u.normalized);}}return {value:r,length:r.length,metadata:{normalized:a||l,isPreposition:o}}}};function yr(){return [new hr]}function gr(){return [new ur,new lr,new pr,new ar]}var vr=[{native:"totoo",normalized:"true"},{native:"mali",normalized:"false"},{native:"wala",normalized:"null"},{native:"hindi_tinukoy",normalized:"undefined"},{native:"una",normalized:"first"},{native:"huli",normalized:"last"},{native:"susunod",normalized:"next"},{native:"nakaraan",normalized:"previous"},{native:"pinakamalapit",normalized:"closest"},{native:"magulang",normalized:"parent"},{native:"pindot",normalized:"click"},{native:"pagbabago",normalized:"change"},{native:"isumite",normalized:"submit"},{native:"input",normalized:"input"},{native:"karga",normalized:"load"},{native:"mag_scroll",normalized:"scroll"}],br=class extends $e{constructor(){super(),this.language="tl",this.direction="ltr",this.initializeKeywordsFromProfile(Be,vr),this.setNormalizer(tr),this.registerExtractors(gr()),this.registerExtractor(new Ne),this.registerExtractor(new Oe),this.registerExtractors(yr()),this.registerExtractor(new nr),this.registerExtractor(new or);}classifyToken(n){return this.isKeyword(n)?"keyword":/^\.(once|prevent|stop|debounce|throttle|queue)(\(.*\))?$/.test(n)?"event-modifier":n.startsWith(".")||n.startsWith("#")||n.startsWith("[")||n.startsWith("*")||n.startsWith("<")?"selector":n.startsWith(":")?"identifier":n.startsWith('"')||n.startsWith("'")||/^-?\d/.test(n)?"literal":"identifier"}},Er=new br;Ut("tl",Er,Be);var Sr=Object.defineProperty,wr=Object.getOwnPropertyNames,Qe=(n,e)=>function(){return n&&(e=(0, n[wr(n)[0]])(n=0)),e},kr=(n,e)=>{for(var t in e)Sr(n,t,{get:e[t],enumerable:true});};function ze(n,e){return n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`))}function C(n,e,t={},r){let i=Ze[n],o=ze(i,t),s=et[n],a=s?ze(s,t):void 0;return {code:n,message:o,severity:e,...r&&{role:r},...a&&{suggestion:a}}}var h,Ze,et,Tr=Qe({"src/generators/schema-error-codes.ts"(){h={AMBIGUOUS_TYPE_LITERAL_SELECTOR:"SCHEMA_AMBIGUOUS_TYPE_LITERAL_SELECTOR",TOO_MANY_EXPECTED_TYPES:"SCHEMA_TOO_MANY_EXPECTED_TYPES",MULTI_TYPE_PATIENT_EXPECTED:"SCHEMA_MULTI_TYPE_PATIENT_EXPECTED",NO_REQUIRED_ROLES:"SCHEMA_NO_REQUIRED_ROLES",NO_REQUIRED_ROLES_EXPECTED:"SCHEMA_NO_REQUIRED_ROLES_EXPECTED",TRANSITION_PATIENT_ACCEPTS_SELECTOR:"SCHEMA_TRANSITION_PATIENT_ACCEPTS_SELECTOR",TRANSITION_MISSING_GOAL:"SCHEMA_TRANSITION_MISSING_GOAL",EVENT_HANDLER_MISSING_EVENT:"SCHEMA_EVENT_HANDLER_MISSING_EVENT",EVENT_HANDLER_EVENT_NOT_REQUIRED:"SCHEMA_EVENT_HANDLER_EVENT_NOT_REQUIRED",CONDITIONAL_MISSING_CONDITION:"SCHEMA_CONDITIONAL_MISSING_CONDITION",CONDITIONAL_CONDITION_NOT_REQUIRED:"SCHEMA_CONDITIONAL_CONDITION_NOT_REQUIRED",FOR_LOOP_MISSING_SOURCE:"SCHEMA_FOR_LOOP_MISSING_SOURCE",WHILE_LOOP_MISSING_CONDITION:"SCHEMA_WHILE_LOOP_MISSING_CONDITION",VALUE_TYPE_MISMATCH:"SCHEMA_VALUE_TYPE_MISMATCH",SELECTOR_KIND_MISMATCH:"SCHEMA_SELECTOR_KIND_MISMATCH",SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE:"SCHEMA_SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE",KEYWORD_COLLISION:"PROFILE_KEYWORD_COLLISION"},Ze={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Role '{role}' accepts both 'literal' and 'selector'. This may cause ambiguous type inference for values starting with special characters (* . # etc.).",[h.TOO_MANY_EXPECTED_TYPES]:"Role '{role}' accepts {count} different types. This may make type inference unreliable.",[h.MULTI_TYPE_PATIENT_EXPECTED]:"Role '{role}' accepts multiple types (expected for {command} command).",[h.NO_REQUIRED_ROLES]:"Command has no required roles. Is this intentional?",[h.NO_REQUIRED_ROLES_EXPECTED]:"Command has no required roles (expected for {command}).",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Transition command 'patient' role (CSS property name) should only accept 'literal', not 'selector'. CSS property names like 'background-color' are strings, not CSS selectors.",[h.TRANSITION_MISSING_GOAL]:"Transition command requires a 'goal' role for the target value (to <value>). Without it, there's no way to specify what value to transition to.",[h.EVENT_HANDLER_MISSING_EVENT]:"Event handler command should have an 'event' role to specify which event to listen for.",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Event role should be required - every event handler needs an event to listen for.",[h.CONDITIONAL_MISSING_CONDITION]:"Conditional command should have a 'condition' role for the boolean expression.",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Condition role should be required - conditionals need a condition to evaluate.",[h.FOR_LOOP_MISSING_SOURCE]:"For-loop should have a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"While-loop should have a 'condition' role for the loop condition.",[h.VALUE_TYPE_MISMATCH]:"Role '{role}' of command '{command}' expects type [{expectedTypes}], got '{actualType}'.",[h.SELECTOR_KIND_MISMATCH]:"Role '{role}' of command '{command}' expects selector kind [{selectorKinds}], got '{actualKind}'.",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Role '{role}' has selectorKinds but expectedTypes does not include 'selector'.",[h.KEYWORD_COLLISION]:"Keyword '{keyword}' is used by multiple commands: {commands}. Only the first-registered command will be reachable."},et={[h.AMBIGUOUS_TYPE_LITERAL_SELECTOR]:"Consider being more specific about which type is expected, or use explicit type markers.",[h.TOO_MANY_EXPECTED_TYPES]:"Consider narrowing the accepted types to improve type inference reliability.",[h.TRANSITION_PATIENT_ACCEPTS_SELECTOR]:"Remove 'selector' from expectedTypes and only accept 'literal'.",[h.TRANSITION_MISSING_GOAL]:"Add a 'goal' role with expectedTypes ['literal', 'variable'].",[h.EVENT_HANDLER_MISSING_EVENT]:"Add an 'event' role with expectedTypes ['literal'].",[h.EVENT_HANDLER_EVENT_NOT_REQUIRED]:"Set required: true on the 'event' role.",[h.CONDITIONAL_MISSING_CONDITION]:"Add a 'condition' role with expectedTypes ['expression'].",[h.CONDITIONAL_CONDITION_NOT_REQUIRED]:"Set required: true on the 'condition' role.",[h.FOR_LOOP_MISSING_SOURCE]:"Add a 'source' role for the collection to iterate over.",[h.WHILE_LOOP_MISSING_CONDITION]:"Add a 'condition' role for the loop continuation condition.",[h.VALUE_TYPE_MISMATCH]:"Ensure the value matches one of the expected types: [{expectedTypes}].",[h.SELECTOR_KIND_MISMATCH]:"Use a selector of the correct kind: [{selectorKinds}].",[h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE]:"Either add 'selector' to expectedTypes or remove selectorKinds.",[h.KEYWORD_COLLISION]:"Give each command a unique keyword. Move the shared keyword to alternatives on one command, or use a more specific translation."};}}),tt={};kr(tt,{SchemaErrorCodes:()=>h,formatValidationResults:()=>Or,getValidationStats:()=>_r,validateAllKeywordCollisions:()=>Mr,validateAllSchemas:()=>Nr,validateCommandSchema:()=>rt,validateKeywordCollisions:()=>nt,validateRoleValues:()=>Ir});function xr(n,e){return {action:n,items:e,get notes(){return e.filter(t=>t.severity==="note").map(t=>t.message)},get warnings(){return e.filter(t=>t.severity==="warning").map(t=>t.message)},get errors(){return e.filter(t=>t.severity==="error").map(t=>t.message)}}}function rt(n){let e=[];for(let r of n.roles)r.expectedTypes.includes("literal")&&r.expectedTypes.includes("selector")&&(r.role==="patient"&&ge.has(n.action)?e.push(C(h.MULTI_TYPE_PATIENT_EXPECTED,"note",{role:r.role,command:n.action},r.role)):e.push(C(h.AMBIGUOUS_TYPE_LITERAL_SELECTOR,"warning",{role:r.role},r.role))),r.expectedTypes.length>3&&!ge.has(n.action)&&e.push(C(h.TOO_MANY_EXPECTED_TYPES,"warning",{role:r.role,count:r.expectedTypes.length},r.role));for(let r of n.roles)r.selectorKinds&&r.selectorKinds.length>0&&(r.expectedTypes.includes("selector")||e.push(C(h.SELECTOR_KINDS_WITHOUT_SELECTOR_TYPE,"warning",{role:r.role},r.role)));switch(n.action){case "transition":Cr(n,e);break;case "on":Ar(n,e);break;case "if":case "unless":Rr(n,e);break;case "repeat":case "for":case "while":Pr(n,e);break}return n.roles.filter(r=>r.required).length===0&&(it.has(n.action)?e.push(C(h.NO_REQUIRED_ROLES_EXPECTED,"note",{command:n.action})):e.push(C(h.NO_REQUIRED_ROLES,"warning",{}))),xr(n.action,e)}function Cr(n,e){let t=n.roles.find(i=>i.role==="patient"),r=n.roles.find(i=>i.role==="goal");t&&t.expectedTypes.includes("selector")&&e.push(C(h.TRANSITION_PATIENT_ACCEPTS_SELECTOR,"warning",{},"patient")),t&&!r&&e.push(C(h.TRANSITION_MISSING_GOAL,"error",{}));}function Ar(n,e){let t=n.roles.find(r=>r.role==="event");t||e.push(C(h.EVENT_HANDLER_MISSING_EVENT,"warning",{})),t&&!t.required&&e.push(C(h.EVENT_HANDLER_EVENT_NOT_REQUIRED,"warning",{}));}function Rr(n,e){let t=n.roles.find(r=>r.role==="condition");t||e.push(C(h.CONDITIONAL_MISSING_CONDITION,"warning",{})),t&&!t.required&&e.push(C(h.CONDITIONAL_CONDITION_NOT_REQUIRED,"warning",{}));}function Pr(n,e){n.action==="for"?n.roles.find(r=>r.role==="source")||e.push(C(h.FOR_LOOP_MISSING_SOURCE,"warning",{})):n.action==="while"&&(n.roles.find(r=>r.role==="condition")||e.push(C(h.WHILE_LOOP_MISSING_CONDITION,"warning",{})));}function Nr(n,e={}){let t=new Map,{includeNotes:r=false}=e;for(let[i,o]of Object.entries(n)){let s=rt(o),a=s.items.some(c=>c.severity==="warning"||c.severity==="error"),l=r&&s.items.some(c=>c.severity==="note");(a||l)&&t.set(i,s);}return t}function Or(n,e={}){let t=[],{showNotes:r=false,showCodes:i=true}=e;for(let[o,s]of n){let a=s.items.filter(u=>u.severity==="error"),l=s.items.filter(u=>u.severity==="warning"),c=s.items.filter(u=>u.severity==="note");if(a.length>0){t.push(` \u274C ${o}:`);for(let u of a){let p=i?` [${u.code}]`:"";t.push(` ERROR${p}: ${u.message}`),u.suggestion&&t.push(` \u{1F4A1} Suggestion: ${u.suggestion}`);}}if(l.length>0){t.push(` \u26A0\uFE0F ${o}:`);for(let u of l){let p=i?` [${u.code}]`:"";t.push(` ${p?`${u.code}: `:""}${u.message}`),u.suggestion&&t.push(` \u{1F4A1} ${u.suggestion}`);}}if(r&&c.length>0){t.push(` \u2139\uFE0F ${o}:`);for(let u of c){let p=i?` [${u.code}]`:"";t.push(` ${p?`${u.code}: `:""}${u.message}`);}}}return t.join(`
2
+ `)}function _r(n){let e=0,t=0,r=0,i={};for(let o of n.values())for(let s of o.items)s.severity==="error"?e++:s.severity==="warning"?t++:s.severity==="note"&&r++,i[s.code]=(i[s.code]||0)+1;return {totalCommands:n.size,errors:e,warnings:t,notes:r,byCode:i}}function Ir(n,e){let t=[];for(let r of e){let i=n.roles.find(o=>o.role===r.role);i&&(i.expectedTypes.length>0&&!i.expectedTypes.includes(r.type)&&(i.expectedTypes.includes("expression")||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects type [${i.expectedTypes.join(", ")}], got '${r.type}'`,code:h.VALUE_TYPE_MISMATCH})),r.type==="selector"&&r.selectorKind&&i.selectorKinds&&i.selectorKinds.length>0&&(i.selectorKinds.includes(r.selectorKind)||t.push({level:"error",role:r.role,message:`${n.action}.${r.role} expects selector kind [${i.selectorKinds.join(", ")}], got '${r.selectorKind}'`,code:h.SELECTOR_KIND_MISMATCH})));}return t}function nt(n){let e=[];if(!n.keywords)return {language:n.code,collisions:e};let t=new Map;for(let[i,o]of Object.entries(n.keywords)){if(!o||!o.primary)continue;let s=t.get(o.primary)||[];if(s.push({command:i,isPrimary:true}),t.set(o.primary,s),o.alternatives)for(let a of o.alternatives){let l=t.get(a)||[];l.push({command:i,isPrimary:false}),t.set(a,l);}}for(let[i,o]of t){let s=[...new Set(o.map(c=>c.command))];if(s.length<=1)continue;let a=o.filter(c=>c.isPrimary).length,l;a>=2?l="primary-primary":a===1?l="primary-alternative":l="alternative-alternative",e.push({keyword:i,commands:s.sort(),type:l});}let r={"primary-primary":0,"primary-alternative":1,"alternative-alternative":2};return e.sort((i,o)=>r[i.type]-r[o.type]),{language:n.code,collisions:e}}function Mr(n){let e=[];for(let[,t]of Object.entries(n)){let r=nt(t);r.collisions.length>0&&e.push(r);}return e.sort((t,r)=>t.language.localeCompare(r.language))}var ge,it,Lr=Qe({"src/generators/schema-validator.ts"(){Tr(),ge=new Set(["put","append","prepend","log","throw","make","measure","return","swap","morph","beep","copy"]),it=new Set(["compound","else","halt","continue","async","init","settle","focus","blur","return","js","measure","break","exit","beep"]);}});function J(n){let e="complex";return n.startsWith("#")&&!n.includes(" ")?e="id":n.startsWith(".")&&!n.includes(" ")?e="class":n.startsWith("[")&&n.endsWith("]")?e="attribute":/^[a-z][a-z0-9]*$/i.test(n)&&(e="element"),{type:"selector",value:n,selectorKind:e}}function k(n,e){let t={type:"literal",value:n};return e!==void 0?{type:"literal",value:n,dataType:e}:t}function qe(n){return _e(n)}function M(n){return {type:"reference",value:n}}function me(n,e){return {type:"property-path",object:n,property:e}}function ie(n,e,t){let r={kind:"command",action:n,roles:new Map(Object.entries(e))};return t!==void 0?{...r,metadata:t}:r}function We(n,e,t,r,i,o){let s=new Map;s.set("event",n);let a={kind:"event-handler",action:"on",roles:s,body:e};return t!==void 0&&(a.eventModifiers=t),r!==void 0&&(a.metadata=r),a}function je(n,e="then",t){let r={kind:"compound",action:"compound",roles:new Map,statements:n,chainType:e};return t!==void 0&&(r.metadata=t),r}function Fe(n,e){return !e||e.length===0||e.includes(n)||e.includes("expression")?true:n==="property-path"?e.some(t=>["selector","reference","expression"].includes(t)):false}function $r(n,e){return n.possessive?.keywords?.[e]}var q=new Map,W=new Map,oe=new Map,ve=null;function ot(n,e){let t={...n};for(let r of Object.keys(e)){let i=e[r],o=n[r];i!==void 0&&(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?t[r]=ot(o,i):t[r]=i);}return t}function Dr(n,e){return ot(n,e)}function Ee(n){if(!n.extends)return n;let e=W.get(n.extends);if(!e)return console.warn(`[Registry] Profile '${n.code}' extends '${n.extends}' but base is not registered. Make sure to import the base language before the variant.`),n;let t=Ee(e);return Dr(t,n)}function st(n){ve=n;}var Ue=new Map;function j(n){return n.split("-")[0]}function F(n){return n.includes("-")}function Vr(n){let e=q.get(n);if(!e&&F(n)){let t=j(n);e=q.get(t);}if(!e){let t=Array.from(q.keys()).join(", ");throw new Error(`Language '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return e}function Br(n){let e=W.get(n);if(!e&&F(n)){let t=j(n);e=W.get(t);}if(!e){let t=Array.from(W.keys()).join(", ");throw new Error(`Language profile '${n}' is not registered. Registered languages: ${t||"none"}. Import the language module first: import '@lokascript/semantic/languages/${n}';`)}return Ee(e)}function zr(n){let e=q.get(n);return !e&&F(n)&&(e=q.get(j(n))),e}function L(n){let e=W.get(n);return !e&&F(n)&&(e=W.get(j(n))),e?Ee(e):void 0}function at(){return Array.from(q.keys())}function qr(n,e){return Vr(e).tokenize(n)}function z(n){let e=oe.get(n);if(!e&&F(n)&&(e=oe.get(j(n))),e)return e;let t=Ue.get(n);if(!t&&F(n)&&(t=Ue.get(j(n))),t)return oe.set(n,t),t;if(!ve)throw new Error(`No patterns registered for language '${n}'. Either import the language module or set a pattern generator.`);let r=Br(n),i=ve(r);return oe.set(n,i),i}var he=.8,jr=.6,Fr=.15,Ur=.5,Ge=.15,Ke=.1,He=new Set(["\u0628\u062F\u0644","\u063A\u064A\u0631","\u0623\u0636\u0641","\u0623\u0632\u0644","\u0636\u0639","\u0627\u062C\u0639\u0644","\u0639\u064A\u0646","\u0632\u062F","\u0627\u0646\u0642\u0635","\u0633\u062C\u0644","\u0623\u0638\u0647\u0631","\u0623\u062E\u0641","\u0634\u063A\u0644","\u0623\u0631\u0633\u0644","\u0631\u0643\u0632","\u0634\u0648\u0634","\u062A\u0648\u0642\u0641","\u0627\u0646\u0633\u062E","\u0627\u062D\u0630\u0641","\u0627\u0635\u0646\u0639","\u0627\u0646\u062A\u0638\u0631","\u0627\u0646\u062A\u0642\u0627\u0644","\u0623\u0648"]),Gr={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"]},Kr=class{calculate(n){return this.calculateWithBreakdown(n).final}calculateWithBreakdown(n){let e=this.scoreRoleCoverage(n),t=this.scoreStemPenalty(n),r=this.scoreLanguageBoost(n),i=this.scoreLanguageAdjustment(n),o=e;return o=Math.max(Ur,o+t),o=Math.min(1,o+r),o=Math.max(0,Math.min(1,o+i)),{roleCoverage:e,stemPenalty:t,languageBoost:r,languageAdjustment:i,final:o}}scoreRoleCoverage(n){let{pattern:e,captured:t}=n,r=0,i=0,o=s=>e.extraction?.[s]?.default!==void 0;for(let s of e.template.tokens)if(s.type==="role")i+=1,t.has(s.role)&&(r+=1);else if(s.type==="group")for(let a of s.tokens)a.type==="role"&&(i+=he,t.has(a.role)?r+=he:o(a.role)&&(r+=he*jr));return i>0?r/i:1}scoreStemPenalty(n){let{stemMatchCount:e,totalKeywordMatches:t}=n;return e<=0||t<=0?0:-(e/t)*Fr}scoreLanguageBoost(n){let{pattern:e}=n;if(e.language!=="ar")return 0;let t=e.template.tokens[0];return !t||t.type!=="literal"?0:He.has(t.value)||t.alternatives?.some(r=>He.has(r))?Ge:0}scoreLanguageAdjustment(n){let{pattern:e,captured:t}=n;if(e.language!=="ar")return 0;let r=0;for(let[i,o]of t.entries()){let s=Gr[i];if(!s||s.length===0)continue;let a="metadata"in o?o.metadata:void 0;a&&typeof a.prepositionValue=="string"&&(s.includes(a.prepositionValue)?r+=.1:r-=.1);}return Math.max(-Ke,Math.min(Ke,r))}},Hr=new Kr,ae=class X{constructor(e){this.matchCache=new Map,this.stemMatchCount=0,this.totalKeywordMatches=0,this.confidenceModel=e??Hr;}matchPattern(e,t){let r=e.mark(),i=new Map;if(this.currentProfile=L(t.language),this.stemMatchCount=0,this.totalKeywordMatches=0,!this.matchTokenSequence(e,t.template.tokens,i))return e.reset(r),null;let s=this.confidenceModel.calculate({pattern:t,captured:i,stemMatchCount:this.stemMatchCount,totalKeywordMatches:this.totalKeywordMatches});return this.applyExtractionRules(t,i),{pattern:t,captured:i,consumedTokens:e.position()-r.position,confidence:s}}matchBest(e,t){this.matchCache.clear();let r=[],i=e.position();for(let s of t){let a=e.mark(),l=`${i}:${s.id}`,c;this.matchCache.has(l)?c=this.matchCache.get(l):(c=this.matchPattern(e,s),this.matchCache.set(l,c)),c&&r.push(c),e.reset(a);}if(r.length===0)return null;r.sort((s,a)=>{let l=a.pattern.priority-s.pattern.priority;return l!==0?l:a.confidence-s.confidence});let o=r[0];return this.matchPattern(e,o.pattern),o}matchTokenSequence(e,t,r){let i=t[0],o=i?.type==="literal"&&(i.value==="and"||i.value==="then"||i.alternatives?.includes("and")||i.alternatives?.includes("then"));if(this.currentProfile?.code==="ar"&&!o)for(;e.peek()?.kind==="conjunction";)e.advance();for(let s of t)if(!this.matchPatternToken(e,s,r)){if(this.isOptional(s))continue;return false}return true}matchPatternToken(e,t,r){switch(t.type){case "literal":return this.matchLiteralToken(e,t);case "role":return this.matchRoleToken(e,t,r);case "group":return this.matchGroupToken(e,t,r);default:return false}}matchLiteralToken(e,t){let r=e.peek();if(!r)return false;let i=this.getMatchType(r,t.value);if(i!=="none")return this.totalKeywordMatches++,i==="stem"&&this.stemMatchCount++,e.advance(),true;if(t.alternatives)for(let o of t.alternatives){let s=this.getMatchType(r,o);if(s!=="none")return this.totalKeywordMatches++,s==="stem"&&this.stemMatchCount++,e.advance(),true}return false}matchRoleToken(e,t,r){this.skipNoiseWords(e);let i=e.peek();if(!i)return t.optional||false;let o=this.tryMatchPossessiveExpression(e);if(o)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(o.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,o),true);let s=this.tryMatchMethodCallExpression(e);if(s)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(s.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,s),true);let a=this.tryMatchPossessiveSelectorExpression(e);if(a)return t.expectedTypes&&t.expectedTypes.length>0&&!Fe(a.type,t.expectedTypes)?t.optional||false:(r.set(t.role,a),true);let l=this.tryMatchPropertyAccessExpression(e);if(l)return t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(l.type)&&!t.expectedTypes.includes("expression")?t.optional||false:(r.set(t.role,l),true);let c=this.tryMatchSelectorPropertyExpression(e);if(c)return t.expectedTypes&&t.expectedTypes.length>0&&!Fe(c.type,t.expectedTypes)?t.optional||false:(r.set(t.role,c),true);let u=this.tokenToSemanticValue(i);return !u||t.expectedTypes&&t.expectedTypes.length>0&&!t.expectedTypes.includes(u.type)?t.optional||false:(r.set(t.role,u),e.advance(),true)}tryMatchPossessiveExpression(e){let t=e.peek();if(!t||!this.currentProfile)return null;let r=(t.normalized||t.value).toLowerCase(),i=$r(this.currentProfile,r);if(!i)return null;let o=e.mark();e.advance();let s=e.peek();if(!s)return e.reset(o),null;if(s.kind==="identifier"||s.kind==="keyword"&&!this.isStructuralKeyword(s.value)||s.kind==="selector"&&s.value.startsWith("*")||s.kind==="selector"&&s.value.startsWith("@")||s.kind==="selector"&&s.value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(s.value)){e.advance();let a=s.value;s.kind==="selector"&&a.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(a)&&(a=a.substring(1));let l=a;for(;e.peek()?.kind==="selector"&&e.peek().value.startsWith(".")&&/^\.[a-zA-Z_]\w*/.test(e.peek().value);)l+=e.peek().value,e.advance();let c=e.peek();return c?.kind==="literal"&&c.value.startsWith("(")&&(l+=c.value,e.advance()),me(M(i),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 t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=e.peek();if(!s||s.kind!=="punctuation"||s.value!=="(")return e.reset(r),null;e.advance();let a=[];for(;!e.isAtEnd()&&a.length<X.MAX_METHOD_ARGS;){let c=e.peek();if(!c)break;if(c.kind==="punctuation"&&c.value===")"){e.advance();break}if(c.kind==="punctuation"&&c.value===","){e.advance();continue}a.push(c.value),e.advance();}return {type:"expression",raw:`${t.value}.${o.value}(${a.join(", ")})`}}tryMatchPropertyAccessExpression(e){let t=e.peek();if(!t||t.kind!=="identifier"&&t.kind!=="keyword")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="operator"||i.value!==".")return e.reset(r),null;e.advance();let o=e.peek();if(!o||o.kind!=="identifier")return e.reset(r),null;e.advance();let s=`${t.value}.${o.value}`,a=1;for(;!e.isAtEnd()&&a<X.MAX_PROPERTY_DEPTH;){let c=e.peek();if(!c||c.kind!=="operator"||c.value!==".")break;e.advance();let u=e.peek();if(!u||u.kind!=="identifier")break;e.advance(),s+=`.${u.value}`,a++;}let l=e.peek();if(l&&l.kind==="punctuation"&&l.value==="("){e.advance();let c=[],u=0;for(;!e.isAtEnd()&&c.length<X.MAX_METHOD_ARGS;){let d=e.peek();if(!d)break;if(d.kind==="punctuation"&&d.value===")"){if(u===0){e.advance();break}u--;}if(d.kind==="punctuation"&&d.value==="("&&u++,d.kind==="punctuation"&&d.value===","){e.advance();continue}c.push(d.value),e.advance();}return {type:"expression",raw:`${s}(${c.join(", ")})`}}return {type:"expression",raw:s}}tryMatchPossessiveSelectorExpression(e){let t=e.peek();if(!t||t.kind!=="selector")return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="punctuation"||i.value!=="'s")return e.reset(r),null;e.advance();let o=e.peek();return !o||o.kind!=="selector"&&o.kind!=="identifier"?(e.reset(r),null):(e.advance(),me(J(t.value),o.value))}tryMatchSelectorPropertyExpression(e){let t=e.peek();if(!t||t.kind!=="selector"||!t.value.startsWith("#"))return null;let r=e.mark();e.advance();let i=e.peek();if(!i||i.kind!=="selector"||!i.value.startsWith("."))return e.reset(r),null;let o=e.peek(1);o&&o.kind,e.advance();let s=i.value.slice(1);return me(J(t.value),s)}matchGroupToken(e,t,r){let i=e.mark(),o=new Set(r.keys());if(!this.matchTokenSequence(e,t.tokens,r)){e.reset(i);for(let a of r.keys())o.has(a)||r.delete(a);return t.optional||false}return true}getMatchType(e,t){return e.value===t?"exact":e.normalized===t?"normalized":e.stem===t&&e.stemConfidence!==void 0&&e.stemConfidence>=.7?"stem":e.kind==="keyword"&&e.value.toLowerCase()===t.toLowerCase()?"case-insensitive":"none"}tokenToSemanticValue(e){switch(e.kind){case "selector":return J(e.value);case "literal":return this.parseLiteralValue(e.value);case "keyword":let t=(e.normalized||e.value).toLowerCase();return qe(t)?M(t):k(e.normalized||e.value);case "identifier":if(e.value.startsWith(":"))return M(e.value);let r=e.value.toLowerCase();return qe(r)?M(r):{type:"expression",raw:e.value};case "url":return k(e.value,"string");default:return null}}parseLiteralValue(e){if(e.startsWith('"')||e.startsWith("'")||e.startsWith("`")||e.startsWith("\u300C")){let i=e.slice(1,-1);return k(i,"string")}if(e==="true")return k(true,"boolean");if(e==="false")return k(false,"boolean");let t=e.match(/^(\d+(?:\.\d+)?)(ms|s|m|h)?$/);if(t){let i=parseFloat(t[1]);return t[2]?k(e,"duration"):k(i,"number")}let r=parseFloat(e);return isNaN(r)?k(e,"string"):k(r,"number")}applyExtractionRules(e,t){for(let[r,i]of Object.entries(e.extraction))t.has(r)||(i.value!==void 0?t.set(r,{type:"literal",value:i.value}):i.default&&t.set(r,i.default));}isOptional(e){return e.type!=="literal"&&e.optional===true}skipNoiseWords(e){let t=e.peek();if(!t)return;let r=t.value.toLowerCase();if(X.ENGLISH_NOISE_WORDS.has(r)){let i=e.mark();e.advance();let o=e.peek();if(o&&(o.kind==="selector"||o.kind==="identifier"))return;e.reset(i);}r==="class"&&e.advance();}extractEventModifiers(e){let t={},r=false;for(;!e.isAtEnd();){let i=e.peek();if(!i||i.kind!=="event-modifier")break;let o=i.metadata;if(!o)break;switch(r=true,o.modifierName){case "once":t.once=true;break;case "debounce":typeof o.value=="number"&&(t.debounce=o.value);break;case "throttle":typeof o.value=="number"&&(t.throttle=o.value);break;case "queue":(o.value==="first"||o.value==="last"||o.value==="all"||o.value==="none")&&(t.queue=o.value);break}e.advance();}return r?t:void 0}};ae.MAX_PROPERTY_DEPTH=10;ae.MAX_METHOD_ARGS=20;ae.ENGLISH_NOISE_WORDS=new Set(["the","a","an"]);var lt=ae,B=new lt;function Yr(n){return zr(n)}function ye(n,e){return qr(n,e)}function ct(){return at()}var Xr={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 Qr={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)"}},Zr={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"}},en={action:"remove",description:"Remove a class or attribute from an element",category:"dom-class",primaryRole:"patient",roles:[{role:"patient",description:"The class or attribute to remove",required:true,expectedTypes:["selector"],svoPosition:1,sovPosition:2},{role:"source",description:"The element to remove from (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}],errorCodes:["MISSING_ARGUMENT","NO_VALID_CLASS_NAMES"],preconditions:[{condition:"Command has at least one argument",errorCode:"MISSING_ARGUMENT",message:"remove command requires an argument"}],recoveryHints:{MISSING_ARGUMENT:"Add a class selector (.classname) or attribute to remove",NO_VALID_CLASS_NAMES:"Ensure class names start with a dot (.) and are valid CSS identifiers"}},tn={action:"put",description:"Put content into a target element or variable",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The content to put",required:true,expectedTypes:["literal","selector","reference","expression"],svoPosition:1,sovPosition:1},{role:"destination",description:"Where to put the content",required:true,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:2,markerOverride:{en:"into"}}],errorCodes:["MISSING_ARGUMENTS","MISSING_CONTENT","MISSING_POSITION","INVALID_POSITION","NO_TARGET","NO_ELEMENTS"],preconditions:[{condition:"Command has content and position arguments",errorCode:"MISSING_ARGUMENTS",message:"put requires arguments"},{condition:"Content to put is specified",errorCode:"MISSING_CONTENT",message:"put requires content"},{condition:"Position keyword is specified (into, before, after, etc.)",errorCode:"MISSING_POSITION",message:"put requires position keyword"}],recoveryHints:{MISSING_ARGUMENTS:"Use syntax: put <content> into/before/after <target>",MISSING_CONTENT:"Add content to put (string, element, or expression)",MISSING_POSITION:"Add position keyword: into, before, after, at start of, at end of",INVALID_POSITION:"Valid positions: into, before, after, at start of, at end of",NO_TARGET:'Ensure target element exists or use "me" reference',NO_ELEMENTS:"Check that the selector matches existing elements"}},rn={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>"}},nn={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}]},on={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}]},sn={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}]},an={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}]},ln={action:"wait",description:"Wait for a duration or event",category:"async",primaryRole:"patient",roles:[{role:"patient",description:"Duration or event to wait for",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1}]},cn={action:"fetch",description:"Fetch data from a URL",category:"async",primaryRole:"source",roles:[{role:"source",description:"The URL to fetch from",required:true,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1,renderOverride:{en:""}},{role:"responseType",description:"Response format (json, text, html, blob, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:2,sovPosition:2},{role:"method",description:"HTTP method (GET, POST, etc.)",required:false,expectedTypes:["literal"],svoPosition:3,sovPosition:3},{role:"destination",description:"Where to store the result",required:false,expectedTypes:["selector","reference"],svoPosition:4,sovPosition:4}]},un={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"}}]},pn={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"}}]},dn={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"}}]},fn={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"}}]},mn={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}]},hn={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}]},yn={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}]},gn={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}]},vn={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}]},bn={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}]},En={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}]},Sn={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"}}]},wn={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}]},kn={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}]},Tn={action:"else",description:"Else branch of conditional",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},xn={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"'},Cn={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"}}]},An={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}]},Rn={action:"continue",description:"Continue to next loop iteration",category:"control-flow",primaryRole:"patient",roles:[]},Pn={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:""}}]},Nn={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}]},On={action:"clone",description:"Clone an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to clone",required:true,expectedTypes:["selector","reference"],svoPosition:1,sovPosition:2},{role:"destination",description:"Where to put the clone",required:false,expectedTypes:["selector","reference"],svoPosition:2,sovPosition:1,markerOverride:{en:"into"}}]},_n={action:"focus",description:"Focus an element",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The element to focus (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:1,sovPosition:1}]},In={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}]},Mn={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}]},Ln={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}]},$n={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}]},Dn={action:"async",description:"Execute commands asynchronously",category:"async",primaryRole:"patient",hasBody:true,roles:[]},Vn={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:""}}]},Bn={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"}}]},zn={action:"init",description:"Initialization block that runs once",category:"control-flow",primaryRole:"patient",hasBody:true,roles:[]},qn={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}]},Wn={action:"install",description:"Install a behavior on an element",category:"control-flow",primaryRole:"patient",roles:[{role:"patient",description:"The behavior name to install",required:true,expectedTypes:["literal","reference","expression"],svoPosition:1,sovPosition:2},{role:"destination",description:"Element to install on (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:1}]},jn={action:"measure",description:"Measure element dimensions (x, y, width, height, etc.)",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"Property to measure (x, y, width, height, top, left, etc.)",required:false,expectedTypes:["literal","expression"],svoPosition:1,sovPosition:1},{role:"source",description:"Element to measure (defaults to me)",required:false,expectedTypes:["selector","reference"],default:{type:"reference",value:"me"},svoPosition:2,sovPosition:2,markerOverride:{en:"of"}}]},Fn={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"}}]},Un={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"}}]},Gn={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}]},Kn={action:"break",description:"Exit from the current loop",category:"control-flow",primaryRole:"patient",roles:[]},Hn={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}]},Yn={action:"exit",description:"Exit from the current event handler",category:"control-flow",primaryRole:"patient",roles:[]},Xn={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}]},Jn={action:"render",description:"Render a template with optional variables",category:"dom-content",primaryRole:"patient",roles:[{role:"patient",description:"The template to render",required:true,expectedTypes:["selector","reference","expression"],svoPosition:1,sovPosition:2},{role:"style",description:"Variables to pass to the template (with keyword)",required:false,expectedTypes:["expression","reference"],svoPosition:2,sovPosition:1}]},ut={toggle:Qr,add:Zr,remove:en,put:tn,set:rn,show:nn,hide:on,on:sn,trigger:an,wait:ln,fetch:cn,increment:un,decrement:pn,append:dn,prepend:fn,log:mn,get:hn,take:yn,make:gn,halt:vn,settle:bn,throw:En,send:Sn,if:wn,unless:kn,else:Tn,repeat:xn,for:Cn,while:An,continue:Rn,go:Pn,transition:Nn,clone:On,focus:_n,blur:In,call:Mn,return:Ln,js:$n,async:Dn,tell:Vn,default:Bn,init:zn,behavior:qn,install:Wn,measure:jn,swap:Fn,morph:Un,beep:Gn,break:Kn,copy:Hn,exit:Yn,pick:Xn,render:Jn,compound:{action:"compound",description:"A compound node representing chained statements",primaryRole:"patient",category:"control-flow",hasBody:true,roles:[]}};function Qn(){return Object.values(ut).filter(n=>n.roles.length>0)}typeof process<"u"&&process.env.NODE_ENV!=="production"&&Promise.resolve().then(()=>(Lr(),tt)).then(({validateAllSchemas:n,formatValidationResults:e})=>{let t=n(ut);t.size>0&&(console.warn("[SCHEMA VALIDATION] Found issues in command schemas:"),console.warn(e(t)),console.warn(`
3
+ These warnings help identify potential schema design issues.`),console.warn("Fix them to improve type inference and avoid runtime bugs."));}).catch(n=>{console.debug("Schema validation skipped:",n);});var Ye=class extends Error{constructor(n,e,t,r){super(n),this.name="SemanticParseError",this.language=e,this.input=t,this.diagnostics=r;}};function R(n,e,t){return {message:n,severity:e,source:"semantic-parser",...t&&{code:t}}}function se(n,e){return e.length===0?n:{...n,diagnostics:e}}var U=class N{parse(e,t){let{modifiers:r,remainingInput:i}=this.extractStandaloneModifiers(e,t),o=i||e,s=[],a=ye(o,t),l=z(t);if(l.length===0)throw new Ye(`No patterns available for language: ${t}`,t,o,[R(`No patterns registered for language '${t}'`,"error","no-patterns")]);let c=[...l].sort((y,v)=>v.priority-y.priority),u=c.filter(y=>y.command==="on"),p=B.matchBest(a,u);if(p){s.push(R(`event pattern matched: ${p.pattern.id} (confidence: ${p.confidence.toFixed(2)})`,"info","pattern-match"));let y=this.buildEventHandler(p,a,t),v=r?this.applyModifiers(y,r):y;return se(v,s)}s.push(R(`event patterns: ${u.length} tried, no match`,"info","stage-event"));let d=c.filter(y=>y.command!=="on"),f=B.matchBest(a,d);if(f)return s.push(R(`command pattern matched: ${f.pattern.id} (confidence: ${f.confidence.toFixed(2)})`,"info","pattern-match")),se(this.buildCommand(f,t),s);s.push(R(`command patterns: ${d.length} tried, no match`,"info","stage-command"));let m=this.trySOVEventExtraction(o,t,c);if(m){s.push(R("SOV event extraction succeeded","info","stage-sov"));let y=r?this.applyModifiers(m,r):m;return se(y,s)}s.push(R("SOV event extraction: no event keyword found","info","stage-sov"));let g=this.tryCompoundCommandParsing(a,d,t);if(g)return s.push(R("compound command parsing succeeded","info","stage-compound")),se(g,s);throw s.push(R("compound parsing: no then-keywords or no command matches","info","stage-compound")),s.push(R(`all parse stages exhausted for "${o}"`,"error","parse-failed")),new Ye(`Could not parse input in ${t}: ${o}`,t,o,s)}canParse(e,t){try{return this.parse(e,t),!0}catch{return false}}supportedLanguages(){return ct()}buildCommand(e,t){if(!e)throw new Error("No match to build command from");let r={};for(let[i,o]of e.captured)r[i]=o;return ie(e.pattern.command,r,{sourceLanguage:t,patternId:e.pattern.id,confidence:e.confidence})}buildEventHandler(e,t,r){if(!e)throw new Error("No match to build event handler from");let i=e.captured.get("event");if(!i)throw new Error("Event handler pattern matched but no event captured");let o=B.extractEventModifiers(t),s=this.extractOrConjunctionEvents(t,r),a=i;s.length>0&&i.type==="literal"&&(a={type:"literal",value:[String(i.value),...s.map(p=>String("value"in p?p.value:""))].join(" or ")});let l,c=e.captured.get("action");if(c&&c.type==="literal"){let u=c.value,p={};for(let[m,g]of e.captured)m!=="event"&&m!=="action"&&m!=="continues"&&(p[m]=g);let d=ie(u,p,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence}),f=e.captured.get("continues");if(f&&f.type==="literal"&&f.value==="then"){let m=z(r).filter(v=>v.command!=="on").sort((v,E)=>E.priority-v.priority),g=z(r).filter(v=>v.id.startsWith("grammar-")&&v.id.includes("-continuation")).sort((v,E)=>E.priority-v.priority),y=this.parseBodyWithGrammarPatterns(t,m,g,r);y.length>0?l=[d,...y]:l=[d];}else l=[d];}else {let u=z(r).filter(p=>p.command!=="on").sort((p,d)=>d.priority-p.priority);l=this.parseBodyWithClauses(t,u,r);}return We(a,l,o,{sourceLanguage:r,patternId:e.pattern.id,confidence:e.confidence})}parseBodyWithClauses(e,t,r){let i=[],o=[];for(;!e.isAtEnd();){let s=e.peek();if(!s)break;let a=s.kind==="conjunction"||s.kind==="keyword"&&this.isThenKeyword(s.value,r),l=s.kind==="keyword"&&this.isEndKeyword(s.value,r);if(a){if(o.length>0){let c=this.parseClause(o,t,r);i.push(...c),o.length=0;}e.advance();continue}if(l){if(o.length>0){let c=this.parseClause(o,t,r);i.push(...c);}e.advance();break}o.push(s),e.advance();}if(o.length>0){let s=this.parseClause(o,t,r);i.push(...s);}return i.length>1?[je(i,"then",{sourceLanguage:r})]:i}parseClause(e,t,r){if(e.length===0)return [];let i=new Y(e,r),o=[];for(;!i.isAtEnd();){let s=B.matchBest(i,t);s?o.push(this.buildCommand(s,r)):i.advance();}if(o.length===0){let s=this.parseSOVClauseByVerbAnchoring(e,r);if(s.length>0)return s}return o}static buildVerbLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.keywords))if(!["on","if","else","when","where","while","for","end","then","and"].includes(r)&&(t.set(i.primary.toLowerCase(),r),i.alternatives))for(let o of i.alternatives)t.set(o.toLowerCase(),r);return t}static buildMarkerToRoleLookup(e){let t=new Map;for(let[r,i]of Object.entries(e.roleMarkers))if(i&&(t.set(i.primary,r),i.alternatives))for(let o of i.alternatives)t.has(o)||t.set(o,r);return t}parseSOVClauseByVerbAnchoring(e,t){let r=L(t);if(!r||r.wordOrder!=="SOV")return [];let i=N.buildVerbLookup(r),o=N.buildMarkerToRoleLookup(r),s=[],a=0;for(;a<e.length;){let l=-1,c="";for(let m=a;m<e.length;m++){let g=e[m],y=i.get(g.value.toLowerCase()),v=g.normalized?i.get(g.normalized.toLowerCase()):void 0,E=y||v;if(E){l=m,c=E;break}}if(l===-1)break;let u=e.slice(a,l),p=e.length;for(let m=l+1;m<e.length;m++){let g=e[m];if(g.kind==="conjunction"||this.isThenKeyword(g.value,t)){p=m;break}if(m>l+1&&(i.get(g.value.toLowerCase())||(g.normalized?i.get(g.normalized.toLowerCase()):void 0))){p=m;break}}let d=e.slice(l+1,p),f=this.extractRolesFromMarkedTokens(u,d,o,c,t);if(s.push(ie(c,f,{sourceLanguage:t,confidence:.7})),a=p,a<e.length){let m=e[a];(m.kind==="conjunction"||this.isThenKeyword(m.value,t))&&a++;}}return s}extractRolesFromMarkedTokens(e,t,r,i,o){let s={},a=l=>{let c=[];for(let u of l){let p=r.get(u.value);if(p&&u.kind==="particle"&&c.length>0){let d=this.tokensToSemanticValue(c);if(d){let f=this.mapRoleForCommand(p,i,s);f&&(s[f]=d);}c=[];}else c.push(u);}if(c.length>0){let u=this.tokensToSemanticValue(c);u&&(s.patient?s.destination||(s.destination=u):s.patient=u);}};return a(e),a(t),s}mapRoleForCommand(e,t,r){return r[e]?e==="patient"&&!r.destination?"destination":e==="destination"&&!r.patient?"patient":e==="source"&&!r.source?"source":null:e}tokensToSemanticValue(e){if(e.length===0)return null;let t=e.filter(o=>o.kind!=="whitespace");if(t.length===0)return null;if(t.length===1)return this.tokenToSemanticValue(t[0]);let r=t.map(o=>o.value).join(""),i=t[0];return i.kind==="selector"||i.value.startsWith("#")||i.value.startsWith(".")||i.value.startsWith("@")||i.value.startsWith("*")?J(r):i.kind==="literal"||i.value.startsWith('"')||i.value.startsWith("'")?k(r):i.kind==="reference"?M(r):k(r)}tokenToSemanticValue(e){let t=e.value;if(e.kind==="selector"||t.startsWith("#")||t.startsWith(".")||t.startsWith("@")||t.startsWith("*"))return J(t);if(t.startsWith('"')||t.startsWith("'"))return k(t);if(/^-?\d+(\.\d+)?$/.test(t))return k(parseFloat(t));if(t==="true"||t==="\u771F"||t==="\uCC38"||t==="do\u011Fru")return k(true);if(t==="false"||t==="\u507D"||t==="\uAC70\uC9D3"||t==="yanl\u0131\u015F")return k(false);let r=e.normalized?.toLowerCase();return r==="me"||r==="it"||r==="you"||r==="result"||r==="body"?M(r):e.kind==="reference"?M(e.normalized||"me"):k(t)}parseBodyWithGrammarPatterns(e,t,r,i){let o=[];for(;!e.isAtEnd();){let s=e.peek();if(s&&this.isThenKeyword(s.value,i)){e.advance();continue}if(s&&this.isEndKeyword(s.value,i)){e.advance();break}let a=false;if(r.length>0){let l=B.matchBest(e,r);if(l){let c=l.pattern.command,u={};for(let[f,m]of l.captured)f!=="event"&&f!=="action"&&f!=="continues"&&(u[f]=m);let p=ie(c,u,{sourceLanguage:i,patternId:l.pattern.id});o.push(p),a=true;let d=l.captured.get("continues");if(d&&d.type==="literal"&&d.value==="then")continue}}if(!a){let l=B.matchBest(e,t);l&&(o.push(this.buildCommand(l,i)),a=true);}a||e.advance();}return o}tryCompoundCommandParsing(e,t,r){let i=e.tokens;if(!i.some(l=>l.kind==="conjunction"||l.kind==="keyword"&&this.isThenKeyword(l.value,r)))return null;let s=new Y(i,r),a=this.parseBodyWithClauses(s,t,r);return a.length===0?null:a.length===1?a[0]:je(a,"then",{sourceLanguage:r,confidence:.65})}trySOVEventExtraction(e,t,r){let i=N.SOV_EVENT_MARKERS[t];if(!i)return null;let s=ye(e,t).tokens,a=Xr[t],l=new Set;if(a)for(let b of Object.keys(a))l.add(b.toLowerCase());let c=N.SOV_SOURCE_MARKERS[t],u=-1,p="",d="",f=1;for(let b=0;b<s.length;b++){let T=s[b],O=T.value.toLowerCase(),_=O,$="",ce=O.indexOf("[");ce>0&&(_=O.slice(0,ce),$=T.value.slice(ce));let ue=T.normalized?.toLowerCase(),Ae=ue&&N.KNOWN_EVENTS.has(ue),Re=l.has(O)||l.has(_),kt=N.KNOWN_EVENTS.has(_);if(Ae||Re||kt){let G;if(Ae?G=ue:Re?G=a?.[O]??a?.[_]??_:G=_,i.size>0){let te=1,pe=s[b+1];pe&&pe.kind==="selector"&&pe.value.startsWith("[")&&(te=2);let re=s[b+te];if(re&&(re.kind==="particle"||re.kind==="keyword")&&i.has(re.value)){u=b,p=G,d=$||(te===2?s[b+1].value:""),f=te+1;break}}else {u=b,p=G,d=$,f=1;break}}}if(u===-1)return null;let m=new Set;for(let b=u;b<u+f;b++)m.add(b);if(c){let b=u+f;if(b<s.length){let T=s[b];(T.kind==="particle"||T.kind==="keyword")&&c.markers.has(T.value)&&m.add(b);}for(let T=0;T<u;T++){let O=s[T],_=O.value.toLowerCase(),$=O.normalized?.toLowerCase();if(c.windowTokens.has(_)||$&&c.windowTokens.has($)){m.add(T);break}}}let g=s.filter((b,T)=>!m.has(T));if(g.length===0)return null;let y=r.filter(b=>b.command!=="on"),v=new Y(g,t),E=this.parseBodyWithClauses(v,y,t);if(E.length===0)return null;let Ce={sourceLanguage:t,confidence:.75};return d&&(Ce.keyFilter=d),We({type:"literal",value:p},E,void 0,Ce)}isThenKeyword(e,t){let r={en:new Set(["then"]),ja:new Set(["\u305D\u308C\u304B\u3089","\u6B21\u306B","\u305D\u3057\u3066"]),ar:new Set(["\u062B\u0645","\u0628\u0639\u062F\u0647\u0627","\u062B\u0645\u0651"]),es:new Set(["entonces","luego","despu\xE9s"]),ko:new Set(["\uADF8\uB2E4\uC74C","\uADF8\uB9AC\uACE0","\uADF8\uB7F0\uD6C4","\uADF8\uB7EC\uBA74"]),zh:new Set(["\u7136\u540E","\u63A5\u7740","\u4E4B\u540E"]),tr:new Set(["sonra","ard\u0131ndan","daha sonra"]),pt:new Set(["ent\xE3o","depois","logo"]),fr:new Set(["puis","ensuite","alors"]),de:new Set(["dann","danach","anschlie\xDFend"]),id:new Set(["lalu","kemudian","setelah itu"]),tl:new Set(["pagkatapos","tapos"]),bn:new Set(["\u09A4\u09BE\u09B0\u09AA\u09B0","\u09AA\u09B0\u09C7"]),qu:new Set(["chaymantataq","hinaspa","chaymanta","chayqa"]),sw:new Set(["kisha","halafu","baadaye"])};return (r[t]||r.en).has(e.toLowerCase())}isEndKeyword(e,t){let r={en:new Set(["end"]),ja:new Set(["\u7D42\u308F\u308A","\u7D42\u4E86","\u304A\u308F\u308A"]),ar:new Set(["\u0646\u0647\u0627\u064A\u0629","\u0627\u0646\u062A\u0647\u0649","\u0622\u062E\u0631"]),es:new Set(["fin","final","terminar"]),ko:new Set(["\uB05D","\uC885\uB8CC","\uB9C8\uCE68"]),zh:new Set(["\u7ED3\u675F","\u7EC8\u6B62","\u5B8C"]),tr:new Set(["son","biti\u015F","bitti"]),pt:new Set(["fim","final","t\xE9rmino"]),fr:new Set(["fin","terminer","finir"]),de:new Set(["ende","beenden","fertig"]),id:new Set(["selesai","akhir","tamat"]),tl:new Set(["wakas","tapos"]),bn:new Set(["\u09B8\u09AE\u09BE\u09AA\u09CD\u09A4"]),qu:new Set(["tukukuy","tukuy","puchukay"]),sw:new Set(["mwisho","maliza","tamati"])};return (r[t]||r.en).has(e.toLowerCase())}extractStandaloneModifiers(e,t){let i=ye(e,t).tokens;if(i.length===0)return {modifiers:null,remainingInput:null};let s=i[0].value.toLowerCase(),a=N.STANDALONE_MODIFIERS[s];if(!a)return {modifiers:null,remainingInput:null};let l={},c=1;if(a==="once")l.once=true;else {let f=1;if(f<i.length){let m=i[f];(m.kind==="keyword"||m.kind==="particle")&&(f++,c++);}if(f<i.length){let m=i[f];if(m.kind==="literal"){let g=m.value.match(/^(\d+)(ms|s|m)?$/);if(g){let y=parseInt(g[1],10),v=g[2]||"ms";v==="s"?y*=1e3:v==="m"&&(y*=6e4),l[a]=y,c=f+1;}}}l[a]||(l[a]=a==="debounce"?300:100);}let u=i.slice(c);if(u.length===0)return {modifiers:null,remainingInput:null};let p=u[0].position.start,d=e.slice(p);return {modifiers:l,remainingInput:d}}applyModifiers(e,t){return {...e,eventModifiers:{...e.eventModifiers,...t}}}extractOrConjunctionEvents(e,t){let r=[];for(;;){let i=e.mark(),o=e.peek();if(!o)break;let s=(o.normalized||o.value).toLowerCase();if(!N.OR_KEYWORDS.has(s)){e.reset(i);break}e.advance();let a=e.peek();if(!a){e.reset(i);break}let l=(a.normalized||a.value).toLowerCase();e.advance(),r.push({type:"literal",value:l});}return r}};U.KNOWN_EVENTS=new Set(["click","dblclick","input","change","submit","keydown","keyup","keypress","mouseover","mouseout","mousedown","mouseup","focus","blur","load","scroll","resize","contextmenu"]);U.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"])};U.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"])}};U.STANDALONE_MODIFIERS={once:"once",debounced:"debounce",debounce:"debounce",throttled:"throttle",throttle:"throttle"};U.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 Zn=U,ei=new Zn;function Se(n,e){return ei.parse(n,e)}var be=class{constructor(n={}){this.cache=new Map,this.config={maxSize:n.maxSize??1e3,ttlMs:n.ttlMs??0,enabled:n.enabled??true},this.stats={hits:0,misses:0,evictions:0,expirations:0};}makeKey(n,e){return `${e}:${n}`}isExpired(n){return this.config.ttlMs===0?false:Date.now()-n.createdAt>this.config.ttlMs}evictLRU(){let n=this.cache.keys().next().value;n!==void 0&&(this.cache.delete(n),this.stats.evictions++);}get(n,e){if(!this.config.enabled){this.stats.misses++;return}let t=this.makeKey(n,e),r=this.cache.get(t);if(!r){this.stats.misses++;return}if(this.isExpired(r)){this.cache.delete(t),this.stats.expirations++,this.stats.misses++;return}return this.cache.delete(t),r.lastAccessed=Date.now(),this.cache.set(t,r),this.stats.hits++,r.result}set(n,e,t){if(!this.config.enabled||t.confidence===0)return;let r=this.makeKey(n,e),i=Date.now();for(;this.cache.size>=this.config.maxSize;)this.evictLRU();this.cache.set(r,{result:t,createdAt:i,lastAccessed:i});}has(n,e){if(!this.config.enabled)return false;let t=this.makeKey(n,e),r=this.cache.get(t);return r?this.isExpired(r)?(this.cache.delete(t),this.stats.expirations++,false):true:false}delete(n,e){let t=this.makeKey(n,e);return this.cache.delete(t)}clear(){this.cache.clear();}resetStats(){this.stats={hits:0,misses:0,evictions:0,expirations:0};}getStats(){let n=this.stats.hits+this.stats.misses;return {hits:this.stats.hits,misses:this.stats.misses,size:this.cache.size,maxSize:this.config.maxSize,hitRate:n>0?this.stats.hits/n:0,evictions:this.stats.evictions,expirations:this.stats.expirations,enabled:this.config.enabled}}configure(n){if(n.maxSize!==void 0)for(this.config.maxSize=n.maxSize;this.cache.size>this.config.maxSize;)this.evictLRU();n.ttlMs!==void 0&&(this.config.ttlMs=n.ttlMs),n.enabled!==void 0&&(this.config.enabled=n.enabled);}enable(){this.config.enabled=true;}disable(){this.config.enabled=false;}getConfig(){return {...this.config}}},ti=new be;var ri=class{constructor(n={}){this.patternMatcher=new lt,this.languages=new Set(at()),n.cache===false?this.cache=new be({enabled:false}):this.cache=n.cache?new be(n.cache):ti;}analyze(n,e){if(!this.supportsLanguage(e))return {confidence:0,errors:[`Language '${e}' is not supported for semantic parsing`]};let t=this.cache.get(n,e);if(t)return t;let r=this.analyzeUncached(n,e);return this.cache.set(n,e,r),r}analyzeUncached(n,e){try{try{let s=Se(n,e),a={confidence:s.metadata?.confidence??.8,node:s};return s.kind==="command"?{...a,command:{name:s.action,roles:s.roles}}:a}catch{}let t=Yr(e);if(!t)return {confidence:0,errors:[`No tokenizer available for language '${e}'`]};let r=t.tokenize(n),i=z(e);if(i.length===0)return {confidence:0,errors:[`No patterns available for language '${e}'`]};let o=this.patternMatcher.matchBest(r,i);if(o){let s=this.buildSemanticNode(o);return {confidence:o.confidence,command:{name:o.pattern.command,roles:o.captured},node:s,tokensConsumed:o.consumedTokens}}return {confidence:0,errors:["No pattern matched the input"]}}catch(t){return {confidence:0,errors:[t instanceof Error?t.message:String(t)]}}}supportsLanguage(n){return this.languages.has(n)}supportedLanguages(){return Array.from(this.languages)}getCacheStats(){return this.cache.getStats()}clearCache(){this.cache.clear();}configureCache(n){this.cache.configure(n);}buildSemanticNode(n){return {kind:"command",action:n.pattern.command,roles:n.captured,metadata:{patternId:n.pattern.id}}}};function pt(n){return new ri(n)}var ni=.5;function dt(n,e=ni){return n.confidence>=e&&n.command!==void 0}function ft(n,e){let t=e==="SOV"?"sovPosition":"svoPosition";return [...n].sort((r,i)=>{let o=r[t]??99,s=i[t]??99;return o-s})}function ii(n,e){let t=n.markerOverride?.[e.code],r=e.roleMarkers[n.role];if(t!==void 0)return {primary:t,position:r?.position??"before",isOverride:true};if(r&&r.primary){let i={primary:r.primary,position:r.position,isOverride:false};return r.alternatives&&(i.alternatives=r.alternatives),i}return null}function oi(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)o.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}}let s=e.roleMarkers.destination;s&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary}]}),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.patient;if(a){let c=a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary};o.push(c);}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${n.action}-event-${e.code}-sov`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`{event} ${r.primary} {destination?} {patient} ${a?.primary||""} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function si(n,e,t,r,i){let o=[];o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let l=r.primary.split(/\s+/);if(l.length>1)for(let c of l)o.push({type:"literal",value:c});else {let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-patient-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`{patient} ${s?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ai(n,e,t,r,i){let o=[];o.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};o.push(c);}let a=e.roleMarkers.destination;if(a&&(o.push({type:"role",role:"destination",optional:false}),o.push(a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary})),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let c=r.primary.split(/\s+/);if(c.length>1)for(let u of c)o.push({type:"literal",value:u});else {let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(l),{id:`${n.action}-event-${e.code}-sov-patient-first-dest`,language:e.code,command:"on",priority:(i.basePriority??100)+40,template:{format:`{patient} ${s?.primary||""} {destination} ${a?.primary||""} {event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination"}}}}function li(n,e,t,r,i){let o=[];o.push({type:"role",role:"event",optional:false});let s=r.alternatives?.filter(u=>!u.includes(" ")&&u.length>1)||[];s.length>0&&o.push({type:"literal",value:s[0],alternatives:s.slice(1)});let a=e.roleMarkers.destination;a&&o.push({type:"group",optional:true,tokens:[{type:"role",role:"destination",optional:true},a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary}]}),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.patient;if(l){let u=l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary};o.push(u);}let c=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(c),{id:`${n.action}-event-${e.code}-sov-compact`,language:e.code,command:"on",priority:(i.basePriority??100)+52,template:{format:`{event}${s[0]||""} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function ci(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let a=r.primary.split(/\s+/);if(a.length>1)for(let l of a)o.push({type:"literal",value:l});else {let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}}let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(s),{id:`${n.action}-event-${e.code}-sov-simple`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{event} ${r.primary} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{default:{type:"reference",value:"me"}}}}}function ui(n,e,t,r){let i=e.eventHandler?.temporalMarkers;if(!i||i.length===0)return null;let o=[];o.push({type:"role",role:"event",optional:false}),e.possessive?.marker&&o.push({type:"group",optional:true,tokens:[{type:"literal",value:e.possessive.marker}]}),o.push({type:"literal",value:i[0],alternatives:i.slice(1)}),o.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.patient;if(s?.primary){let l=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(l);}let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};return o.push(a),{id:`${n.action}-event-${e.code}-sov-temporal`,language:e.code,command:"on",priority:(r.basePriority??100)+49,template:{format:`{event} ${i[0]} {patient} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"}}}}function pi(n,e,t,r,i){let o=[];if(o.push({type:"role",role:"event",optional:false}),r.position==="after"){let u=r.primary.split(/\s+/);if(u.length>1)for(let p of u)o.push({type:"literal",value:p});else {let p=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(p);}}let a=[...n.roles.filter(u=>u.required)].sort((u,p)=>{let d=u.sovPosition??999,f=p.sovPosition??999;return d-f});for(let u of a){o.push({type:"role",role:u.role,optional:false});let p,d;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)p=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}}let l=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(l);let c=a.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-sov-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`{event} ${r.primary} ${c} ${t.primary}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(a.map(u=>[u.role,{fromRole:u.role}]))}}}function di(n,e,t,r,i){let o=[],a=[...n.roles.filter(m=>m.required)].sort((m,g)=>{let y=m.sovPosition??999,v=g.sovPosition??999;return y-v}),l=a[0];o.push({type:"role",role:l.role,optional:false});let c;if(l.markerOverride&&l.markerOverride[e.code]!==void 0)c=l.markerOverride[e.code];else {let m=e.roleMarkers[l.role];m&&(c=m.primary);}if(c&&o.push({type:"literal",value:c}),o.push({type:"role",role:"event",optional:false}),r.position==="after"){let m=r.primary.split(/\s+/);if(m.length>1)for(let g of m)o.push({type:"literal",value:g});else {let g=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(g);}}let u=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(u);let p=a[1];o.push({type:"role",role:p.role,optional:false});let d,f;if(p.markerOverride&&p.markerOverride[e.code]!==void 0)d=p.markerOverride[e.code];else {let m=e.roleMarkers[p.role];m&&(d=m.primary,f=m.alternatives);}if(d){let m=f?{type:"literal",value:d,alternatives:f}:{type:"literal",value:d};o.push(m);}return {id:`${n.action}-event-${e.code}-sov-2role-dest-first`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`{${l.role}} {event} ${r.primary} ${t.primary} {${p.role}}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},[l.role]:{fromRole:l.role},[p.role]:{fromRole:p.role}}}}function Xe(n,e,t,r,i){let o=[];if(r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;return a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso`,language:e.code,command:"on",priority:(i.basePriority??100)+50,template:{format:`${r.primary} {event} ${t.primary} {patient} ${a?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function fi(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s),o.push({type:"role",role:"patient",optional:false});let a=e.roleMarkers.destination;if(a&&o.push({type:"group",optional:true,tokens:[a.alternatives?{type:"literal",value:a.primary,alternatives:a.alternatives}:{type:"literal",value:a.primary},{type:"role",role:"destination",optional:true}]}),r.position==="before"){let l=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(l);}return o.push({type:"role",role:"event",optional:false}),{id:`${n.action}-event-${e.code}-vso-verb-first`,language:e.code,command:"on",priority:(i.basePriority??100)+45,template:{format:`${t.primary} {patient} ${a?.primary||""} {destination?} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function mi(n,e,t,r,i){let o=[],s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...n.roles.filter(u=>u.required)].sort((u,p)=>{let d=u.svoPosition??999,f=p.svoPosition??999;return d-f});for(let u of l){let p,d;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)p=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:u.role,optional:false});}if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let c=l.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-verb-first-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${t.primary} ${c} ${r.primary} {event}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(u=>[u.role,{fromRole:u.role}]))}}}function Je(n,e,t,r,i){let o=[];if(r.position==="before"){let u=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(u);}o.push({type:"role",role:"event",optional:false});let s=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(s);let l=[...n.roles.filter(u=>u.required)].sort((u,p)=>{let d=u.svoPosition??999,f=p.svoPosition??999;return d-f});for(let u of l){let p,d;if(u.markerOverride&&u.markerOverride[e.code]!==void 0)p=u.markerOverride[e.code];else {let f=e.roleMarkers[u.role];f&&(p=f.primary,d=f.alternatives);}if(p){let f=d?{type:"literal",value:p,alternatives:d}:{type:"literal",value:p};o.push(f);}o.push({type:"role",role:u.role,optional:false});}let c=l.map(u=>`{${u.role}}`).join(" ");return {id:`${n.action}-event-${e.code}-vso-2role`,language:e.code,command:"on",priority:(i.basePriority??100)+55,template:{format:`${r.primary} {event} ${t.primary} ${c}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},...Object.fromEntries(l.map(u=>[u.role,{fromRole:u.role}]))}}}function hi(n,e,t,r,i){let o=[],s=e.eventHandler?.negationMarker;if(r.position==="before"){let c=r.alternatives?{type:"literal",value:r.primary,alternatives:r.alternatives}:{type:"literal",value:r.primary};o.push(c);}if(s){let c=s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary};o.push(c);}o.push({type:"role",role:"event",optional:false});let a=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};o.push(a),o.push({type:"role",role:"patient",optional:false});let l=e.roleMarkers.destination;return l&&o.push({type:"group",optional:true,tokens:[l.alternatives?{type:"literal",value:l.primary,alternatives:l.alternatives}:{type:"literal",value:l.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-negated`,language:e.code,command:"on",priority:(i.basePriority??100)+48,template:{format:`${r.primary} ${s?.primary||""} {event} ${t.primary} {patient} ${l?.primary||""} {destination?}`,tokens:o},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}function yi(n,e,t,r){let i=[];i.push({type:"literal",value:"and",alternatives:["then"]}),i.push({type:"role",role:"event",optional:false});let o=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary};i.push(o),i.push({type:"role",role:"patient",optional:false});let s=e.roleMarkers.destination;return s&&i.push({type:"group",optional:true,tokens:[s.alternatives?{type:"literal",value:s.primary,alternatives:s.alternatives}:{type:"literal",value:s.primary},{type:"role",role:"destination",optional:true}]}),{id:`${n.action}-event-${e.code}-vso-proclitic`,language:e.code,command:"on",priority:(r.basePriority??100)+45,template:{format:`[proclitic?] {event} ${t.primary} {patient} ${s?.primary||""} {destination?}`,tokens:i},extraction:{action:{value:n.action},event:{fromRole:"event"},patient:{fromRole:"patient"},destination:{fromRole:"destination",default:{type:"reference",value:"me"}}}}}var Q={basePriority:100,generateSimpleVariants:true,generateAlternatives:true};function mt(n,e,t=Q){let r=`${n.action}-${e.code}-generated`,i=t.basePriority??100,o=e.keywords[n.action];if(!o)throw new Error(`No keyword translation for '${n.action}' in ${e.code}`);let s=Ei(n,e,o),a=yt(n,e),l=Ti(n,e,o);return {id:r,language:e.code,command:n.action,priority:i,template:{format:l,tokens:s},extraction:a}}function gi(n,e,t=Q){if(n.roles.filter(a=>!a.required).length===0)return null;let i=n.roles.filter(a=>a.required),o={...n,roles:i};return {...mt(o,e,t),id:`${n.action}-${e.code}-generated-simple`,priority:(t.basePriority??100)-5,extraction:yt(n,e)}}function vi(n,e,t=Q){let r=[];if(r.push(mt(n,e,t)),t.generateSimpleVariants){let i=gi(n,e,t);i&&r.push(i);}return r}function ht(n,e=Q){let t=[],r=Qn();for(let i of r){if(!n.keywords[i.action])continue;let o=vi(i,n,e);if(t.push(...o),n.eventHandler?.eventMarker){let s=bi(i,n,e);t.push(...s);}}return t}function bi(n,e,t=Q){if(!e.eventHandler||!e.eventHandler.eventMarker)return [];let r=[],i=e.eventHandler.eventMarker,o=e.keywords[n.action];if(!o)return [];let a=n.roles.filter(l=>l.required).length===2;if(e.wordOrder==="SOV")if(a)r.push(pi(n,e,o,i,t)),r.push(di(n,e,o,i,t));else {r.push(oi(n,e,o,i,t)),r.push(si(n,e,o,i,t));let l=e.roleMarkers.destination;l&&l.primary!==i.primary&&r.push(ai(n,e,o,i,t));let c=i.primary.split(/\s+/),u=i.alternatives?.some(d=>!d.includes(" ")&&d.length>1);c.length>1&&u&&r.push(li(n,e,o,i,t)),r.push(ci(n,e,o,i,t));let p=ui(n,e,o,t);p&&r.push(p);}else e.wordOrder==="VSO"?a?(r.push(Je(n,e,o,i,t)),r.push(mi(n,e,o,i,t))):(r.push(Xe(n,e,o,i,t)),r.push(fi(n,e,o,i,t)),e.eventHandler?.negationMarker&&r.push(hi(n,e,o,i,t)),e.tokenization?.prefixes&&r.push(yi(n,e,o,t))):a?r.push(Je(n,e,o,i,t)):r.push(Xe(n,e,o,i,t));return r}function Ei(n,e,t){let r=[],i=t.alternatives?{type:"literal",value:t.primary,alternatives:t.alternatives}:{type:"literal",value:t.primary},o=Si(n,e);switch(e.wordOrder){case "SVO":r.push(i),r.push(...o);break;case "SOV":r.push(...o),r.push(i);break;case "VSO":r.push(i),r.push(...o);break;default:r.push(i),r.push(...o);}return r}function Si(n,e){let t=[],r=ft(n.roles,e.wordOrder);for(let i of r){let o=wi(i,e);i.required?t.push(...o):t.push({type:"group",optional:true,tokens:o});}return t}function wi(n,e){let t=[],r=n.markerOverride?.[e.code],i=e.roleMarkers[n.role],o={type:"role",role:n.role,optional:!n.required,expectedTypes:n.expectedTypes};if(r!==void 0)(i?.position??"before")==="before"?(r&&t.push({type:"literal",value:r}),t.push(o)):(t.push(o),r&&t.push({type:"literal",value:r}));else if(i)if(i.position==="before"){if(i.primary){let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}t.push(o);}else {t.push(o);let s=i.alternatives?{type:"literal",value:i.primary,alternatives:i.alternatives}:{type:"literal",value:i.primary};t.push(s);}else t.push(o);return t}function ki(n,e){let t={};for(let r of n.roles){let i=r.markerOverride?.[e.code],o=e.roleMarkers[r.role];i!==void 0?t[r.role]=i?{marker:i}:{}:o&&o.primary?t[r.role]=o.alternatives?{marker:o.primary,markerAlternatives:o.alternatives}:{marker:o.primary}:t[r.role]={};}return t}function yt(n,e){let t=ki(n,e),r={};for(let i of n.roles){let o=t[i.role]||{};!i.required&&i.default?r[i.role]={...o,default:i.default}:r[i.role]=o;}return r}function Ti(n,e,t){let r=[],o=ft(n.roles,e.wordOrder).map(s=>{let a=ii(s,e),l="";return a&&a.primary?a.position==="before"?l=`${a.primary} {${s.role}}`:l=`{${s.role}} ${a.primary}`:l=`{${s.role}}`,s.required?l:`[${l}]`});switch(e.wordOrder){case "SVO":case "VSO":r.push(t.primary,...o);break;case "SOV":r.push(...o,t.primary);break;default:r.push(t.primary,...o);}return r.join(" ")}function le(n){let e=n.getAttribute("data-lang");if(e)return we(e);let t=n.getAttribute("data-hyperscript-lang")??n.closest?.("[data-hyperscript-lang]")?.getAttribute("data-hyperscript-lang");if(t)return we(t);let r=typeof document<"u"?document.documentElement?.lang:null;return r&&r!=="en"?we(r):null}function we(n){return n.split("-")[0].toLowerCase()}var gt={add:[["patient",""],["destination","to"]],append:[["patient",""],["destination","to"]],async:[],beep:[["patient",""]],behavior:[["patient",""]],blur:[["patient",""]],break:[],call:[["patient",""]],clone:[["patient",""],["destination","into"]],compound:[],continue:[],copy:[["patient",""]],decrement:[["patient",""],["quantity","by"]],default:[["destination",""],["patient","to"]],else:[],exit:[],fetch:[["source",""],["responseType","as"],["method","via"],["destination","on"]],focus:[["patient",""]],for:[["patient",""],["source","in"]],get:[["source",""],["destination","on"]],go:[["destination",""]],halt:[["patient",""]],hide:[["patient",""],["style","with"]],if:[["condition",""]],increment:[["patient",""],["quantity","by"]],init:[],install:[["patient",""],["destination","on"]],js:[["patient",""]],log:[["patient",""]],make:[["patient",""]],measure:[["patient",""],["source","of"]],morph:[["destination",""],["patient","to"]],on:[["event",""],["source","from"]],pick:[["patient",""],["source","from"]],prepend:[["patient",""],["destination","to"]],put:[["patient",""],["destination","into"]],remove:[["patient",""],["source","from"]],render:[["patient",""],["style","with"]],repeat:[["quantity",""],["condition","until"]],return:[["patient",""]],send:[["event",""],["destination","to"]],set:[["destination",""],["patient","to"]],settle:[["patient",""]],show:[["patient",""],["style","with"]],swap:[["method",""],["destination","of"],["patient","with"]],take:[["patient",""],["source","from"]],tell:[["destination",""]],throw:[["patient",""]],toggle:[["patient",""],["destination","on"]],transition:[["patient",""],["goal","to"],["destination","on"],["duration","over"],["style","with"]],trigger:[["event",""],["destination","on"]],unless:[["condition",""]],wait:[["patient",""]],while:[["condition",""]]};function ee(n){switch(n.kind){case "event-handler":return xi(n);case "compound":return Ci(n);default:return Ai(n)}}function xi(n){let e=["on"],t=n.roles.get("event");t&&e.push(Z(t));let r=n.roles.get("source");if(r&&e.push("from",Z(r)),n.body&&n.body.length>0){let i=n.body.map(ee);e.push(i.join(" then "));}return e.join(" ")}function Ci(n){let e=n.chainType==="async"?"async":n.chainType;return n.statements.map(ee).join(` ${e} `)}function Ai(n){let e=gt[n.action];if(e){let r=[n.action];for(let[i,o]of e){let s=n.roles.get(i);s&&(i==="destination"&&s.type==="reference"&&s.value==="me"||(o&&r.push(o),r.push(Z(s))));}return r.join(" ")}let t=[n.action];for(let[,r]of n.roles)t.push(Z(r));return t.join(" ")}function Z(n){switch(n.type){case "literal":return typeof n.value=="string"&&n.dataType==="string"?`"${n.value}"`:String(n.value);case "selector":return n.value;case "reference":return n.value;case "property-path":return Ri(n);case "expression":return n.raw;case "flag":return n.enabled?`+${n.name}`:`~${n.name}`}}function Ri(n){let e=Z(n.object),t=n.property;if(n.object.type==="reference")switch(n.object.value){case "me":return `my ${t}`;case "it":return `its ${t}`;case "you":return `your ${t}`}return `${e}'s ${t}`}var bt=.5,Pi={confidenceThreshold:bt,strategy:"semantic",fallbackToOriginal:true};function Ni(n,e){return typeof n=="number"?n:n[e]??n["*"]??bt}var ke=null;function Oi(){return ke||(ke=pt()),ke}function Te(n,e,t={}){let r={...Pi,...t},i=vt(n,e,r);if(i!==null)return i;let o=Ii(n);if(o){let s=vt(o.commands,e,r);if(s!==null)return o.prefix+s}return n}function vt(n,e,t){if(t.strategy==="semantic"||t.strategy==="auto"){let r=Ni(t.confidenceThreshold,e),i=Et(n,e,r);if(i!==null)return i}if((t.strategy==="auto"||t.strategy==="i18n")&&t.i18nToEnglish){let r=Mi(n,e,t.i18nToEnglish);if(r!==null)return r}return null}var _i=/^(on\s+(?:every\s+)?[\w-]+(?:\[.*?\])?(?:\.[\w-]+(?:\([^)]*\))?)*(?:\s+from\s+\S+)?(?:\s+queue\s+\w+)?\s+)/;function Ii(n){let e=n.match(_i);if(!e)return null;let t=e[1],r=n.slice(t.length);return r?{prefix:t,commands:r}:null}function Et(n,e,t){try{let r=$i(n,e);if(r.length>1)return Di(r,e,t);let i=Oi();if(!i.supportsLanguage(e))return null;let o=i.analyze(n,e);if(!dt(o,t))return null;if(o.node)return ee(o.node);let s=Se(n,e);return ee(s)}catch{return null}}function Mi(n,e,t){try{let r=t(n,e);return r!==n?r:null}catch{return null}}function Li(n){let e=["then"],t=L(n);if(t?.keywords?.then){let r=t.keywords.then;if(r.primary&&r.primary!=="then"&&e.push(r.primary),r.alternatives)for(let i of r.alternatives)e.includes(i)||e.push(i);}return e}function $i(n,e){let r=Li(e).map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`\\s+(?:${r.join("|")})\\s+`,"i"),o=n.split(`
4
+ `).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of o){let l=a.split(i);s.push(...l);}return s}function Di(n,e,t){let r=[];for(let i of n){let o=Et(i.trim(),e,t);if(o===null)return null;r.push(o);}return r.join(" then ")}function xe(n={}){return function(t){let{internals:r}=t,i=r.runtime,o=i.getScript.bind(i);i.getScript=function(s){let a=o(s);if(!a)return null;let l=Vi(s,n);if(!l||l==="en")return a;let c=Te(a,l,n);return n.debug&&c!==a&&console.log(`[hyperscript-i18n] ${l}: "${a}" \u2192 "${c}"`),c};}}function Vi(n,e){if(e.languageAttribute){let r=n.getAttribute(e.languageAttribute);if(r)return r.split("-")[0].toLowerCase()}let t=le(n);return t||(e.defaultLanguage??null)}function St(n,e,t={}){return e==="en"?n:Te(n,e,t)}st(n=>ht(n));function wt(){typeof _hyperscript<"u"&&_hyperscript.use&&(_hyperscript.use(xe()),Bi());}function Bi(){if(typeof document>"u")return;let e=_hyperscript?.internals?.runtime;if(!e?.processNode||!e?.getInternalData)return;let t=e.getScriptSelector?.()??"[_], [script], [data-script]";document.querySelectorAll(t).forEach(r=>{let i=e.getInternalData(r);i.initialized&&(i.initialized=false);}),e.processNode(document.body);}var Wo=["tl"];wt();exports.plugin=xe;exports.preprocess=St;exports.resolveLanguage=le;exports.supportedLanguages=Wo;return exports;})({});