@malloy-publisher/app 0.0.219 → 0.0.221

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 (27) hide show
  1. package/dist/api-doc.yaml +291 -20
  2. package/dist/assets/{EnvironmentPage-gehnjfC6.js → EnvironmentPage-D6G5n6mY.js} +1 -1
  3. package/dist/assets/{HomePage-8LQBytE4.js → HomePage-DgZluD8u.js} +1 -1
  4. package/dist/assets/LightMode-w9v0pEbg.js +1 -0
  5. package/dist/assets/MainPage-Bi_Tukvr.js +2 -0
  6. package/dist/assets/{MaterializationsPage-D7P1Kp6O.js → MaterializationsPage-BVERjnmG.js} +1 -1
  7. package/dist/assets/ModelPage-2OjS259-.js +1 -0
  8. package/dist/assets/{PackagePage-Cz9fVwSG.js → PackagePage-C8L2On4z.js} +1 -1
  9. package/dist/assets/{RouteError-UONCloyN.js → RouteError-DJoNC_Vl.js} +1 -1
  10. package/dist/assets/ThemeEditorPage-B-hJ1zgd.js +1 -0
  11. package/dist/assets/{WorkbookPage-Bhzqvbq_.js → WorkbookPage-CTbDgGeJ.js} +1 -1
  12. package/dist/assets/{core-BiGj7BML.es-kMHAa8tP.js → core-D9Hl0IDY.es-CmgzHn4c.js} +1 -1
  13. package/dist/assets/github-dark-DenFmJkN.es-DHJKELXO.js +1 -0
  14. package/dist/assets/index-8E2uLeV9.js +2541 -0
  15. package/dist/assets/index-BEjJCJjX.js +1761 -0
  16. package/dist/assets/index-BF8PkFm8.js +1 -0
  17. package/dist/assets/index-Cr-asgoV.js +527 -0
  18. package/dist/assets/index-DcCw_qxr.js +18 -0
  19. package/dist/assets/index-w_0OQJgZ.js +23 -0
  20. package/dist/index.html +1 -1
  21. package/package.json +3 -2
  22. package/dist/assets/MainPage-DDaZLJw-.js +0 -2
  23. package/dist/assets/ModelPage-Do_vhxOc.js +0 -1
  24. package/dist/assets/index-VzRbxcF7.js +0 -455
  25. package/dist/assets/index-ddq4-5hu.js +0 -1760
  26. package/dist/assets/index-qOQF9CXq.js +0 -40
  27. package/dist/assets/index.umd-B2kmxDh7.js +0 -2467
@@ -1,40 +0,0 @@
1
- import{an as Ni}from"./index-VzRbxcF7.js";function Mi(u,Q){for(var B=0;B<Q.length;B++){const V=Q[B];if(typeof V!="string"&&!Array.isArray(V)){for(const g in V)if(g!=="default"&&!(g in u)){const l=Object.getOwnPropertyDescriptor(V,g);l&&Object.defineProperty(u,g,l.get?l:{enumerable:!0,get:()=>V[g]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var Ft={},ct={},Mr;function Nt(){if(Mr)return ct;Mr=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.isChainOp=u,ct.isStringCondition=Q,ct.isStringFilter=B,ct.isBooleanFilter=V,ct.isNumberFilter=g,ct.isTemporalFilter=l,ct.isFilterExpression=f,ct.isFilterable=c;function u(s){return["and","or",","].includes(s)}function Q(s){return["starts","ends","contains","="].includes(s.operator)}function B(s){return typeof s=="object"&&s!==null&&"operator"in s&&typeof s.operator=="string"&&["starts","ends","contains","=","~","null","empty","and","or",",","()"].includes(s.operator)}function V(s){return typeof s=="object"&&s!==null&&"operator"in s&&typeof s.operator=="string"&&["null","true","false","=false","=true"].includes(s.operator)}function g(s){return typeof s=="object"&&s!==null&&"operator"in s&&typeof s.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null"].includes(s.operator)}function l(s){return typeof s=="object"&&s!==null&&"operator"in s&&typeof s.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null"].includes(s.operator)}function f(s){return typeof s=="object"&&s!==null&&"operator"in s}function c(s){return["string","number","boolean","timestamp","timestamptz","date"].includes(s)}return ct}var zt={},jr;function ji(){return jr||(jr=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.BooleanFilterExpression=void 0,zt.BooleanFilterExpression={parse(u){var Q;if(u.match(/^\s*$/))return{parsed:null,log:[]};const B={parsed:null,log:[]};let V=u.toLowerCase().trim().replace(/\s\s+/," "),g=!1;if(V.startsWith("not ")&&(g=!0,V=V.slice(4)),V==="true")B.parsed={operator:"true"};else if(V==="=true")B.parsed={operator:"=true"};else if(V==="false")B.parsed={operator:"false"};else if(V==="=false")B.parsed={operator:"=false"};else if(V==="null")B.parsed={operator:"null"};else{const l=u.match(/[^\s]/),f=l&&(Q=l.index)!==null&&Q!==void 0?Q:0;B.log=[{message:`Illegal boolean filter '${V}'. Must be one of true,=true,false,=false,null`,severity:"error",startIndex:f,endIndex:f+u.length-1}]}return g&&B.parsed&&(B.parsed.not=!0),B},unparse(u){return u===null?"":(u.not?"not ":"")+u.operator}}),zt}var Sr={},nt={},Ur;function lr(){if(Ur)return nt;Ur=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.maybeNot=Q,nt.unescape=B,nt.escape=V,nt.matchOp=l,nt.conjoin=c,nt.joinNumbers=s,nt.mkRange=d,nt.mkValues=e,nt.numNot=y,nt.temporalNot=k,nt.joinTemporal=x,nt.timeLiteral=H,nt.mkUnits=ae;const u=Nt();function Q(q){const[E,C]=q;return E&&C&&(0,u.isStringFilter)(C)?{...C,not:!0}:C}function B(q){return q.replace(/\\(.)/g,"$1")}function V(q){const E=q.toLowerCase();return E==="null"||E==="empty"?"\\"+q:q.replace(/([,; |()\\%_-])/g,"\\$1")}function g(q){let E=!1,C=!1,j=0,he=!1;const $e=q.length;for(let Se=0;Se<$e;Se+=1){const Re=q[Se];if(Re===" "||Re===" "){j+=1;continue}j=0,Re==="%"?(he=!0,Se===0&&(E=!0),C=!0):(C=!1,Re==="\\"?Se+=1:Re==="_"&&(he=!0))}return{hasLike:he,percentEnd:C&&$e>1,percentStart:E&&$e>1,endSpace:j}}function l(q){let E=q.trimStart();const{hasLike:C,percentEnd:j,percentStart:he,endSpace:$e}=g(E);if($e>0&&(E=E.slice(0,-$e)),C){if(he&&j){const Se=E.slice(1,-1);if(!g(Se).hasLike&&Se.length>0)return{operator:"contains",values:[B(Se)]}}else if(j){const Se=E.slice(0,-1);if(!g(Se).hasLike)return{operator:"starts",values:[B(Se)]}}else if(he){const Se=E.slice(1);if(!g(Se).hasLike)return{operator:"ends",values:[B(Se)]}}return{operator:"~",escaped_values:[E]}}return E.toLowerCase()==="null"?{operator:"null"}:E.toLowerCase()==="empty"?{operator:"empty"}:{operator:"=",values:[B(E)]}}function f(q,E){var C,j;return q.operator===E.operator&&((C=q.not)!==null&&C!==void 0?C:!1)===((j=E.not)!==null&&j!==void 0?j:!1)}function c(q,E,C){if(E=E.toLowerCase(),(0,u.isStringFilter)(q)&&(0,u.isStringFilter)(C)){if(E===","){if(q.operator==="~"&&f(q,C))return{...q,escaped_values:[...q.escaped_values,...C.escaped_values]};if((0,u.isStringCondition)(q)&&f(q,C))return{...q,values:[...q.values,...C.values]}}const j=E===","?",":E==="|"?"or":E===";"?"and":void 0;if(j)return q.operator===j?{...q,members:[...q.members,C]}:{operator:j,members:[q,C]}}return null}function s(q,E,C){if(E=E.toLowerCase(),(0,u.isNumberFilter)(q)&&(0,u.isNumberFilter)(C)){if(E==="or"&&q.operator==="="&&f(q,C)){const j={operator:"=",values:[...q.values,...C.values]};return q.not&&(j.not=!0),j}if(E==="and"||E==="or")return q.operator===E?{...q,members:[...q.members,C]}:{operator:E,members:[q,C]}}return null}function d(q,E,C,j){return{operator:"range",startValue:E,startOperator:q==="("?">":">=",endValue:C,endOperator:j===")"?"<":"<="}}function e(q,E){return{values:[q,...E]}}function y(q,E){return(0,u.isNumberFilter)(q)&&E?q.operator==="="?{operator:"!=",values:q.values}:q.operator==="!="?{operator:"=",values:q.values}:{...q,not:!0}:q}function k(q,E){if((0,u.isTemporalFilter)(q)&&E){if("not"in q){const C={...q};return q.not?delete C.not:C.not=!0,C}return{...q,not:!0}}return q}function x(q,E,C){return E=E.toLowerCase(),(0,u.isTemporalFilter)(q)&&(0,u.isTemporalFilter)(C)&&(E==="and"||E==="or")?q.operator===E?{...q,members:[...q.members,C]}:{operator:E,members:[q,C]}:null}function H(q,E){const C={moment:"literal",literal:q};return E&&(C.units=E),C}function ae(q){switch(q.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return nt}var kr,Qr;function Ui(){if(Qr)return kr;Qr=1;const{numNot:u,mkRange:Q,joinNumbers:B,mkValues:V}=lr();function g(s,d){function e(){this.constructor=s}e.prototype=d.prototype,s.prototype=new e}function l(s,d,e,y){var k=Error.call(this,s);return Object.setPrototypeOf&&Object.setPrototypeOf(k,l.prototype),k.expected=d,k.found=e,k.location=y,k.name="SyntaxError",k}g(l,Error);function f(s,d,e){return e=e||" ",s.length>d?s:(d-=s.length,e+=e.repeat(d),s+e.slice(0,d))}l.prototype.format=function(s){var d="Error: "+this.message;if(this.location){var e=null,y;for(y=0;y<s.length;y++)if(s[y].source===this.location.source){e=s[y].text.split(/\r\n|\n|\r/g);break}var k=this.location.start,x=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(k):k,H=this.location.source+":"+x.line+":"+x.column;if(e){var ae=this.location.end,q=f("",x.line.toString().length," "),E=e[k.line-1],C=k.line===ae.line?ae.column:E.length+1,j=C-k.column||1;d+=`
2
- --> `+H+`
3
- `+q+` |
4
- `+x.line+" | "+E+`
5
- `+q+" | "+f("",k.column-1," ")+f("",j,"^")}else d+=`
6
- at `+H}return d},l.buildMessage=function(s,d){var e={literal:function(E){return'"'+k(E.text)+'"'},class:function(E){var C=E.parts.map(function(j){return Array.isArray(j)?x(j[0])+"-"+x(j[1]):x(j)});return"["+(E.inverted?"^":"")+C.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(E){return E.description}};function y(E){return E.charCodeAt(0).toString(16).toUpperCase()}function k(E){return E.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(C){return"\\x0"+y(C)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(C){return"\\x"+y(C)})}function x(E){return E.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(C){return"\\x0"+y(C)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(C){return"\\x"+y(C)})}function H(E){return e[E.type](E)}function ae(E){var C=E.map(H),j,he;if(C.sort(),C.length>0){for(j=1,he=1;j<C.length;j++)C[j-1]!==C[j]&&(C[he]=C[j],he++);C.length=he}switch(C.length){case 1:return C[0];case 2:return C[0]+" or "+C[1];default:return C.slice(0,-1).join(", ")+", or "+C[C.length-1]}}function q(E){return E?'"'+k(E)+'"':"end of input"}return"Expected "+ae(s)+" but "+q(d)+" found."};function c(s,d){d=d!==void 0?d:{};var e={},y=d.grammarSource,k={numberFilter:jt},x=jt,H="(",ae=")",q="!=",E=",",C="=",j="<=",he=">=",$e="[",Se="]",Re="-",ke=".",me="not",P="null",W="and",z="or",U="to",G=/^[<>]/,ee=/^[0-9]/,ne=/^[Ee]/,te=/^[+\-]/,ce=/^[a-zA-Z]/,be=/^[ \t]/,ye=Ye("(",!1),le=Ye(")",!1),ve=Ye("!=",!1),_=Ye(",",!1),I=Ye("=",!1),D=Ye("<=",!1),N=Ye(">=",!1),A=_t(["<",">"],!1,!1),h=Ye("[",!1),w=Ye("]",!1),F=Ye("-",!1),T=_t([["0","9"]],!1,!1),M=Ye(".",!1),Y=_t(["E","e"],!1,!1),we=_t(["+","-"],!1,!1),Le=Ye("not",!0),Qe=Ye("null",!0),J=Ye("and",!0),Be=Ye("or",!0),Xe=Ye("to",!0),Ie=_t([["a","z"],["A","Z"]],!1,!1),et=ur("whitespace"),Me=_t([" "," "],!1,!1),wt=function(S,O){return O.reduce((Z,[,se,,_e])=>B(Z,se,_e),S)},it=function(S,O){return u(O,S)},at=function(S){return S},st=function(){return{operator:"null"}},tt=function(S){return{operator:"()",expr:S}},R=function(S,O,Z,se){return Q(S,O,Z,se)},re=function(S,O){return{operator:"!=",...V(S,O.map(Z=>Z[3]))}},Oe=function(S,O){return{operator:"=",...V(S,O.map(Z=>Z[3]))}},pe=function(S,O){return{operator:S,values:[O]}},Ve=function(S,O){return{operator:"=",...V(S,O.map(Z=>Z[3]))}},ze=function(){return"["},ft=function(){return"("},ot=function(){return"]"},kt=function(){return")"},$=function(S){return S},t=function(){return"or"},a=function(){return"and"},m=function(){return"not"},p=d.peg$currPos|0,K=[{line:1,column:1}],de=p,Pe=d.peg$maxFailExpected||[],X=d.peg$silentFails|0,De;if(d.startRule){if(!(d.startRule in k))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');x=k[d.startRule]}function Ye(S,O){return{type:"literal",text:S,ignoreCase:O}}function _t(S,O,Z){return{type:"class",parts:S,inverted:O,ignoreCase:Z}}function fr(){return{type:"end"}}function ur(S){return{type:"other",description:S}}function Xt(S){var O=K[S],Z;if(O)return O;if(S>=K.length)Z=K.length-1;else for(Z=S;!K[--Z];);for(O=K[Z],O={line:O.line,column:O.column};Z<S;)s.charCodeAt(Z)===10?(O.line++,O.column=1):O.column++,Z++;return K[S]=O,O}function Zt(S,O,Z){var se=Xt(S),_e=Xt(O),ie={source:y,start:{offset:S,line:se.line,column:se.column},end:{offset:O,line:_e.line,column:_e.column}};return ie}function Te(S){p<de||(p>de&&(de=p,Pe=[]),Pe.push(S))}function cr(S,O,Z){return new l(l.buildMessage(S,O),S,O,Z)}function jt(){var S,O,Z,se,_e,ie,fe,ge;if(S=p,O=Ut(),O!==e){for(Z=[],se=p,_e=Ne(),ie=tr(),ie!==e?(fe=Ne(),ge=Ut(),ge!==e?(_e=[_e,ie,fe,ge],se=_e):(p=se,se=e)):(p=se,se=e);se!==e;)Z.push(se),se=p,_e=Ne(),ie=tr(),ie!==e?(fe=Ne(),ge=Ut(),ge!==e?(_e=[_e,ie,fe,ge],se=_e):(p=se,se=e)):(p=se,se=e);S=wt(O,Z)}else p=S,S=e;return S}function Ut(){var S,O,Z;return S=p,O=hr(),O!==e?(Ne(),Z=er(),Z!==e?S=it(O,Z):(p=S,S=e)):(p=S,S=e),S===e&&(S=p,O=er(),O!==e&&(O=at(O)),S=O),S}function er(){var S,O,Z,se,_e,ie,fe,ge,xe,je;if(S=p,O=gr(),O!==e&&(O=st()),S=O,S===e&&(S=p,s.charCodeAt(p)===40?(O=H,p++):(O=e,X===0&&Te(ye)),O!==e?(Z=Ne(),se=jt(),se!==e?(_e=Ne(),s.charCodeAt(p)===41?(ie=ae,p++):(ie=e,X===0&&Te(le)),ie!==e?S=tt(se):(p=S,S=e)):(p=S,S=e)):(p=S,S=e),S===e&&(S=p,O=pr(),O!==e?(Z=Ne(),se=lt(),se!==e?(_e=Ne(),ie=vr(),ie!==e?(fe=Ne(),ge=lt(),ge!==e?(xe=Ne(),je=dr(),je!==e?S=R(O,se,ge,je):(p=S,S=e)):(p=S,S=e)):(p=S,S=e)):(p=S,S=e)):(p=S,S=e),S===e))){if(S=p,s.substr(p,2)===q?(O=q,p+=2):(O=e,X===0&&Te(ve)),O!==e)if(Z=Ne(),se=lt(),se!==e){for(_e=[],ie=p,fe=Ne(),s.charCodeAt(p)===44?(ge=E,p++):(ge=e,X===0&&Te(_)),ge!==e?(xe=Ne(),je=lt(),je!==e?(fe=[fe,ge,xe,je],ie=fe):(p=ie,ie=e)):(p=ie,ie=e);ie!==e;)_e.push(ie),ie=p,fe=Ne(),s.charCodeAt(p)===44?(ge=E,p++):(ge=e,X===0&&Te(_)),ge!==e?(xe=Ne(),je=lt(),je!==e?(fe=[fe,ge,xe,je],ie=fe):(p=ie,ie=e)):(p=ie,ie=e);S=re(se,_e)}else p=S,S=e;else p=S,S=e;if(S===e){if(S=p,s.charCodeAt(p)===61?(O=C,p++):(O=e,X===0&&Te(I)),O!==e)if(Z=Ne(),se=lt(),se!==e){for(_e=[],ie=p,fe=Ne(),s.charCodeAt(p)===44?(ge=E,p++):(ge=e,X===0&&Te(_)),ge!==e?(xe=Ne(),je=lt(),je!==e?(fe=[fe,ge,xe,je],ie=fe):(p=ie,ie=e)):(p=ie,ie=e);ie!==e;)_e.push(ie),ie=p,fe=Ne(),s.charCodeAt(p)===44?(ge=E,p++):(ge=e,X===0&&Te(_)),ge!==e?(xe=Ne(),je=lt(),je!==e?(fe=[fe,ge,xe,je],ie=fe):(p=ie,ie=e)):(p=ie,ie=e);S=Oe(se,_e)}else p=S,S=e;else p=S,S=e;if(S===e&&(S=p,O=p,s.substr(p,2)===j?(Z=j,p+=2):(Z=e,X===0&&Te(D)),Z===e&&(s.substr(p,2)===he?(Z=he,p+=2):(Z=e,X===0&&Te(N)),Z===e&&(Z=s.charAt(p),G.test(Z)?p++:(Z=e,X===0&&Te(A)))),Z!==e?O=s.substring(O,p):O=Z,O!==e?(Z=Ne(),se=lt(),se!==e?S=pe(O,se):(p=S,S=e)):(p=S,S=e),S===e))if(S=p,O=lt(),O!==e){for(Z=[],se=p,_e=Ne(),s.charCodeAt(p)===44?(ie=E,p++):(ie=e,X===0&&Te(_)),ie!==e?(fe=Ne(),ge=lt(),ge!==e?(_e=[_e,ie,fe,ge],se=_e):(p=se,se=e)):(p=se,se=e);se!==e;)Z.push(se),se=p,_e=Ne(),s.charCodeAt(p)===44?(ie=E,p++):(ie=e,X===0&&Te(_)),ie!==e?(fe=Ne(),ge=lt(),ge!==e?(_e=[_e,ie,fe,ge],se=_e):(p=se,se=e)):(p=se,se=e);S=Ve(O,Z)}else p=S,S=e}}return S}function pr(){var S,O;return S=p,s.charCodeAt(p)===91?(O=$e,p++):(O=e,X===0&&Te(h)),O!==e&&(O=ze()),S=O,S===e&&(S=p,s.charCodeAt(p)===40?(O=H,p++):(O=e,X===0&&Te(ye)),O!==e&&(O=ft()),S=O),S}function dr(){var S,O;return S=p,s.charCodeAt(p)===93?(O=Se,p++):(O=e,X===0&&Te(w)),O!==e&&(O=ot()),S=O,S===e&&(S=p,s.charCodeAt(p)===41?(O=ae,p++):(O=e,X===0&&Te(le)),O!==e&&(O=kt()),S=O),S}function lt(){var S,O,Z,se,_e,ie,fe,ge,xe,je;if(S=p,O=p,Z=p,s.charCodeAt(p)===45?(se=Re,p++):(se=e,X===0&&Te(F)),se===e&&(se=null),_e=p,ie=[],fe=s.charAt(p),ee.test(fe)?p++:(fe=e,X===0&&Te(T)),fe!==e)for(;fe!==e;)ie.push(fe),fe=s.charAt(p),ee.test(fe)?p++:(fe=e,X===0&&Te(T));else ie=e;if(ie!==e){for(s.charCodeAt(p)===46?(fe=ke,p++):(fe=e,X===0&&Te(M)),fe===e&&(fe=null),ge=[],xe=s.charAt(p),ee.test(xe)?p++:(xe=e,X===0&&Te(T));xe!==e;)ge.push(xe),xe=s.charAt(p),ee.test(xe)?p++:(xe=e,X===0&&Te(T));ie=[ie,fe,ge],_e=ie}else p=_e,_e=e;if(_e===e){for(_e=p,ie=[],fe=s.charAt(p),ee.test(fe)?p++:(fe=e,X===0&&Te(T));fe!==e;)ie.push(fe),fe=s.charAt(p),ee.test(fe)?p++:(fe=e,X===0&&Te(T));if(s.charCodeAt(p)===46?(fe=ke,p++):(fe=e,X===0&&Te(M)),fe!==e){if(ge=[],xe=s.charAt(p),ee.test(xe)?p++:(xe=e,X===0&&Te(T)),xe!==e)for(;xe!==e;)ge.push(xe),xe=s.charAt(p),ee.test(xe)?p++:(xe=e,X===0&&Te(T));else ge=e;ge!==e?(ie=[ie,fe,ge],_e=ie):(p=_e,_e=e)}else p=_e,_e=e}if(_e!==e){if(ie=p,fe=s.charAt(p),ne.test(fe)?p++:(fe=e,X===0&&Te(Y)),fe!==e){if(ge=s.charAt(p),te.test(ge)?p++:(ge=e,X===0&&Te(we)),ge===e&&(ge=null),xe=[],je=s.charAt(p),ee.test(je)?p++:(je=e,X===0&&Te(T)),je!==e)for(;je!==e;)xe.push(je),je=s.charAt(p),ee.test(je)?p++:(je=e,X===0&&Te(T));else xe=e;xe!==e?(fe=[fe,ge,xe],ie=fe):(p=ie,ie=e)}else p=ie,ie=e;ie===e&&(ie=null),se=[se,_e,ie],Z=se}else p=Z,Z=e;return Z!==e?O=s.substring(O,p):O=Z,O!==e&&(O=$(O)),S=O,S}function tr(){var S,O;return S=p,O=yr(),O!==e&&(O=t()),S=O,S===e&&(S=p,O=mr(),O!==e&&(O=a()),S=O),S}function hr(){var S,O,Z,se;return S=p,O=s.substr(p,3),O.toLowerCase()===me?p+=3:(O=e,X===0&&Te(Le)),O!==e?(Z=p,X++,se=Et(),X--,se===e?Z=void 0:(p=Z,Z=e),Z!==e?S=m():(p=S,S=e)):(p=S,S=e),S}function gr(){var S,O,Z,se;return S=p,O=s.substr(p,4),O.toLowerCase()===P?p+=4:(O=e,X===0&&Te(Qe)),O!==e?(Z=p,X++,se=Et(),X--,se===e?Z=void 0:(p=Z,Z=e),Z!==e?(O=[O,Z],S=O):(p=S,S=e)):(p=S,S=e),S}function mr(){var S,O,Z,se;return S=p,O=s.substr(p,3),O.toLowerCase()===W?p+=3:(O=e,X===0&&Te(J)),O!==e?(Z=p,X++,se=Et(),X--,se===e?Z=void 0:(p=Z,Z=e),Z!==e?(O=[O,Z],S=O):(p=S,S=e)):(p=S,S=e),S}function yr(){var S,O,Z,se;return S=p,O=s.substr(p,2),O.toLowerCase()===z?p+=2:(O=e,X===0&&Te(Be)),O!==e?(Z=p,X++,se=Et(),X--,se===e?Z=void 0:(p=Z,Z=e),Z!==e?(O=[O,Z],S=O):(p=S,S=e)):(p=S,S=e),S}function vr(){var S,O,Z,se;return S=p,O=s.substr(p,2),O.toLowerCase()===U?p+=2:(O=e,X===0&&Te(Xe)),O!==e?(Z=p,X++,se=Et(),X--,se===e?Z=void 0:(p=Z,Z=e),Z!==e?(O=[O,Z],S=O):(p=S,S=e)):(p=S,S=e),S}function Et(){var S;return S=s.charAt(p),ce.test(S)?p++:(S=e,X===0&&Te(Ie)),S}function Ne(){var S,O;for(X++,S=[],O=s.charAt(p),be.test(O)?p++:(O=e,X===0&&Te(Me));O!==e;)S.push(O),O=s.charAt(p),be.test(O)?p++:(O=e,X===0&&Te(Me));return X--,O=e,X===0&&Te(et),S}if(De=x(),d.peg$library)return{peg$result:De,peg$currPos:p,peg$FAILED:e,peg$maxFailExpected:Pe,peg$maxFailPos:de};if(De!==e&&p===s.length)return De;throw De!==e&&p<s.length&&Te(fr()),cr(Pe,de<s.length?s.charAt(de):null,de<s.length?Zt(de,de+1):Zt(de,de))}return kr={StartRules:["numberFilter"],SyntaxError:l,parse:c},kr}var ir={},Br;function Cr(){if(Br)return ir;Br=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.run_parser=B;const u=Nt();function Q(V){return V instanceof Error&&"location"in V}function B(V,g){try{const l=g(V);return(0,u.isFilterExpression)(l)?{parsed:l,log:[]}:{parsed:null,log:[]}}catch(l){if(Q(l)){const f=l.location,c=f?f.start.offset:0,s=f?f.end.offset-1:V.length-1;return{parsed:null,log:[{message:l.message,startIndex:c,endIndex:Math.max(c,s),severity:"error"}]}}throw l}}return ir}var Wr;function Qi(){return Wr||(Wr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.NumberFilterExpression=void 0;const Q=Nt(),B=Ui(),V=Cr();u.NumberFilterExpression={parse(g){if(g.match(/^\s*$/))return{parsed:null,log:[]};const l=(0,V.run_parser)(g,B.parse);return l.parsed&&(0,Q.isNumberFilter)(l.parsed)?{parsed:l.parsed,log:[]}:{parsed:null,log:l.log}},unparse(g){if(g===null)return"";switch(g.operator){case"=":return g.values.join(", ");case"!=":return"!= "+g.values.join(", ");case">":case"<":case"<=":case">=":return g.not?g.values.map(l=>g.operator==="="?`not ${l}`:`not ${g.operator} ${l}`).join(", "):g.values.map(l=>`${g.operator} ${l}`).join(", ");case"range":{const l=g.startOperator===">"?"(":"[",f=g.endOperator==="<"?")":"]",c=`${l}${g.startValue} to ${g.endValue}${f}`;return g.not?`not ${c}`:c}case"null":return g.not?"not null":"null";case"and":case"or":return g.members.map(l=>u.NumberFilterExpression.unparse(l)).join(` ${g.operator} `);case"()":{const l="("+u.NumberFilterExpression.unparse(g.expr)+")";return g.not?"not "+l:l}}return`no unparse for ${JSON.stringify(g)}`}}})(Sr)),Sr}var Er={},Or,Gr;function Bi(){if(Gr)return Or;Gr=1;const{conjoin:u,maybeNot:Q,matchOp:B}=lr();function V(c,s){function d(){this.constructor=c}d.prototype=s.prototype,c.prototype=new d}function g(c,s,d,e){var y=Error.call(this,c);return Object.setPrototypeOf&&Object.setPrototypeOf(y,g.prototype),y.expected=s,y.found=d,y.location=e,y.name="SyntaxError",y}V(g,Error);function l(c,s,d){return d=d||" ",c.length>s?c:(s-=c.length,d+=d.repeat(s),c+d.slice(0,s))}g.prototype.format=function(c){var s="Error: "+this.message;if(this.location){var d=null,e;for(e=0;e<c.length;e++)if(c[e].source===this.location.source){d=c[e].text.split(/\r\n|\n|\r/g);break}var y=this.location.start,k=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(y):y,x=this.location.source+":"+k.line+":"+k.column;if(d){var H=this.location.end,ae=l("",k.line.toString().length," "),q=d[y.line-1],E=y.line===H.line?H.column:q.length+1,C=E-y.column||1;s+=`
7
- --> `+x+`
8
- `+ae+` |
9
- `+k.line+" | "+q+`
10
- `+ae+" | "+l("",y.column-1," ")+l("",C,"^")}else s+=`
11
- at `+x}return s},g.buildMessage=function(c,s){var d={literal:function(q){return'"'+y(q.text)+'"'},class:function(q){var E=q.parts.map(function(C){return Array.isArray(C)?k(C[0])+"-"+k(C[1]):k(C)});return"["+(q.inverted?"^":"")+E.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(q){return q.description}};function e(q){return q.charCodeAt(0).toString(16).toUpperCase()}function y(q){return q.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(E){return"\\x0"+e(E)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(E){return"\\x"+e(E)})}function k(q){return q.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(E){return"\\x0"+e(E)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(E){return"\\x"+e(E)})}function x(q){return d[q.type](q)}function H(q){var E=q.map(x),C,j;if(E.sort(),E.length>0){for(C=1,j=1;C<E.length;C++)E[C-1]!==E[C]&&(E[j]=E[C],j++);E.length=j}switch(E.length){case 1:return E[0];case 2:return E[0]+" or "+E[1];default:return E.slice(0,-1).join(", ")+", or "+E[E.length-1]}}function ae(q){return q?'"'+y(q)+'"':"end of input"}return"Expected "+H(c)+" but "+ae(s)+" found."};function f(c,s){s=s!==void 0?s:{};var d={},e=s.grammarSource,y={stringFilter:Me},k=Me,x="-",H="(",ae=")",q="\\",E=",",C=";",j="|",he=/^[^\n,;()|]/,$e=/^[ \t]/,Se=Y("-",!1),Re=Y("(",!1),ke=Y(")",!1),me=J("match string"),P=Y("\\",!1),W=Le(),z=we([`
12
- `,",",";","(",")","|"],!0,!1),U=Y(",",!1),G=Y(";",!1),ee=Y("|",!1),ne=J("whitespace"),te=we([" "," "],!1,!1),ce=function(R,re){return re.reduce((Oe,[,pe,,Ve])=>u(Oe,pe,Ve),R)},be=function(R){return Q([!0,R])},ye=function(R){return R},le=function(R){return{operator:"()",expr:R}},ve=function(R){return B(R)},_=function(R){return R},I=function(){return","},D=function(){return";"},N=function(){return"|"},A=s.peg$currPos|0,h=[{line:1,column:1}],w=A,F=s.peg$maxFailExpected||[],T=s.peg$silentFails|0,M;if(s.startRule){if(!(s.startRule in y))throw new Error(`Can't start parsing from rule "`+s.startRule+'".');k=y[s.startRule]}function Y(R,re){return{type:"literal",text:R,ignoreCase:re}}function we(R,re,Oe){return{type:"class",parts:R,inverted:re,ignoreCase:Oe}}function Le(){return{type:"any"}}function Qe(){return{type:"end"}}function J(R){return{type:"other",description:R}}function Be(R){var re=h[R],Oe;if(re)return re;if(R>=h.length)Oe=h.length-1;else for(Oe=R;!h[--Oe];);for(re=h[Oe],re={line:re.line,column:re.column};Oe<R;)c.charCodeAt(Oe)===10?(re.line++,re.column=1):re.column++,Oe++;return h[R]=re,re}function Xe(R,re,Oe){var pe=Be(R),Ve=Be(re),ze={source:e,start:{offset:R,line:pe.line,column:pe.column},end:{offset:re,line:Ve.line,column:Ve.column}};return ze}function Ie(R){A<w||(A>w&&(w=A,F=[]),F.push(R))}function et(R,re,Oe){return new g(g.buildMessage(R,re),R,re,Oe)}function Me(){var R,re,Oe,pe,Ve,ze,ft,ot;if(R=A,tt(),re=wt(),re!==d){for(Oe=[],pe=A,Ve=tt(),ze=st(),ze!==d?(ft=tt(),ot=wt(),ot!==d?(Ve=[Ve,ze,ft,ot],pe=Ve):(A=pe,pe=d)):(A=pe,pe=d);pe!==d;)Oe.push(pe),pe=A,Ve=tt(),ze=st(),ze!==d?(ft=tt(),ot=wt(),ot!==d?(Ve=[Ve,ze,ft,ot],pe=Ve):(A=pe,pe=d)):(A=pe,pe=d);R=ce(re,Oe)}else A=R,R=d;return R}function wt(){var R,re,Oe;return R=A,c.charCodeAt(A)===45?(re=x,A++):(re=d,T===0&&Ie(Se)),re!==d?(tt(),Oe=it(),Oe!==d?R=be(Oe):(A=R,R=d)):(A=R,R=d),R===d&&(R=A,re=it(),re!==d&&(re=ye(re)),R=re),R}function it(){var R,re,Oe,pe;return R=A,c.charCodeAt(A)===40?(re=H,A++):(re=d,T===0&&Ie(Re)),re!==d?(tt(),Oe=Me(),Oe!==d?(tt(),c.charCodeAt(A)===41?(pe=ae,A++):(pe=d,T===0&&Ie(ke)),pe!==d?R=le(Oe):(A=R,R=d)):(A=R,R=d)):(A=R,R=d),R===d&&(R=A,re=at(),re!==d&&(re=ve(re)),R=re),R}function at(){var R,re,Oe,pe,Ve,ze;if(T++,R=A,re=A,Oe=[],pe=A,c.charCodeAt(A)===92?(Ve=q,A++):(Ve=d,T===0&&Ie(P)),Ve!==d?(c.length>A?(ze=c.charAt(A),A++):(ze=d,T===0&&Ie(W)),ze!==d?(Ve=[Ve,ze],pe=Ve):(A=pe,pe=d)):(A=pe,pe=d),pe===d&&(pe=c.charAt(A),he.test(pe)?A++:(pe=d,T===0&&Ie(z))),pe!==d)for(;pe!==d;)Oe.push(pe),pe=A,c.charCodeAt(A)===92?(Ve=q,A++):(Ve=d,T===0&&Ie(P)),Ve!==d?(c.length>A?(ze=c.charAt(A),A++):(ze=d,T===0&&Ie(W)),ze!==d?(Ve=[Ve,ze],pe=Ve):(A=pe,pe=d)):(A=pe,pe=d),pe===d&&(pe=c.charAt(A),he.test(pe)?A++:(pe=d,T===0&&Ie(z)));else Oe=d;return Oe!==d?re=c.substring(re,A):re=Oe,re!==d&&(re=_(re)),R=re,T--,R===d&&(re=d,T===0&&Ie(me)),R}function st(){var R,re;return R=A,c.charCodeAt(A)===44?(re=E,A++):(re=d,T===0&&Ie(U)),re!==d&&(re=I()),R=re,R===d&&(R=A,c.charCodeAt(A)===59?(re=C,A++):(re=d,T===0&&Ie(G)),re!==d&&(re=D()),R=re,R===d&&(R=A,c.charCodeAt(A)===124?(re=j,A++):(re=d,T===0&&Ie(ee)),re!==d&&(re=N()),R=re)),R}function tt(){var R,re;for(T++,R=[],re=c.charAt(A),$e.test(re)?A++:(re=d,T===0&&Ie(te));re!==d;)R.push(re),re=c.charAt(A),$e.test(re)?A++:(re=d,T===0&&Ie(te));return T--,re=d,T===0&&Ie(ne),R}if(M=k(),s.peg$library)return{peg$result:M,peg$currPos:A,peg$FAILED:d,peg$maxFailExpected:F,peg$maxFailPos:w};if(M!==d&&A===c.length)return M;throw M!==d&&A<c.length&&Ie(Qe()),et(F,w<c.length?c.charAt(w):null,w<c.length?Xe(w,w+1):Xe(w,w))}return Or={StartRules:["stringFilter"],SyntaxError:g,parse:f},Or}var zr;function Wi(){return zr||(zr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringFilterExpression=void 0;const Q=Nt(),B=Bi(),V=lr(),g=Cr();u.StringFilterExpression={parse(l){if(l.match(/^\s*$/))return{parsed:null,log:[]};const f=(0,g.run_parser)(l,B.parse);return f.parsed&&(0,Q.isStringFilter)(f.parsed)?{parsed:f.parsed,log:[]}:{parsed:null,log:f.log}},unparse(l){if(l===null)return"";switch(l.operator){case"=":return l.not?l.values.map(f=>"-"+(0,V.escape)(f)).join(", "):l.values.map(f=>(0,V.escape)(f)).join(", ");case"~":return l.not?l.escaped_values.map(f=>"-"+f).join(", "):l.escaped_values.join(", ");case"starts":return l.not?l.values.map(f=>"-"+(0,V.escape)(f)+"%").join(", "):l.values.map(f=>(0,V.escape)(f)+"%").join(", ");case"ends":return l.not?l.values.map(f=>"-%"+(0,V.escape)(f)).join(", "):l.values.map(f=>"%"+(0,V.escape)(f)).join(", ");case"contains":return l.not?l.values.map(f=>"-%"+(0,V.escape)(f)+"%").join(", "):l.values.map(f=>"%"+(0,V.escape)(f)+"%").join(", ");case"or":return l.members.map(f=>u.StringFilterExpression.unparse(f)).join(" | ");case"and":return l.members.map(f=>u.StringFilterExpression.unparse(f)).join("; ");case",":return l.members.map(f=>u.StringFilterExpression.unparse(f)).join(", ");case"()":{const f="("+u.StringFilterExpression.unparse(l.expr)+")";return l.not?"-"+f:f}case"null":return l.not?"-null":"null";case"empty":return l.not?"-empty":"empty"}}}})(Er)),Er}var Rr={},Fr,Yr;function Gi(){if(Yr)return Fr;Yr=1;const{temporalNot:u,joinTemporal:Q,timeLiteral:B,mkUnits:V}=lr();function g(s,d){function e(){this.constructor=s}e.prototype=d.prototype,s.prototype=new e}function l(s,d,e,y){var k=Error.call(this,s);return Object.setPrototypeOf&&Object.setPrototypeOf(k,l.prototype),k.expected=d,k.found=e,k.location=y,k.name="SyntaxError",k}g(l,Error);function f(s,d,e){return e=e||" ",s.length>d?s:(d-=s.length,e+=e.repeat(d),s+e.slice(0,d))}l.prototype.format=function(s){var d="Error: "+this.message;if(this.location){var e=null,y;for(y=0;y<s.length;y++)if(s[y].source===this.location.source){e=s[y].text.split(/\r\n|\n|\r/g);break}var k=this.location.start,x=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(k):k,H=this.location.source+":"+x.line+":"+x.column;if(e){var ae=this.location.end,q=f("",x.line.toString().length," "),E=e[k.line-1],C=k.line===ae.line?ae.column:E.length+1,j=C-k.column||1;d+=`
13
- --> `+H+`
14
- `+q+` |
15
- `+x.line+" | "+E+`
16
- `+q+" | "+f("",k.column-1," ")+f("",j,"^")}else d+=`
17
- at `+H}return d},l.buildMessage=function(s,d){var e={literal:function(E){return'"'+k(E.text)+'"'},class:function(E){var C=E.parts.map(function(j){return Array.isArray(j)?x(j[0])+"-"+x(j[1]):x(j)});return"["+(E.inverted?"^":"")+C.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(E){return E.description}};function y(E){return E.charCodeAt(0).toString(16).toUpperCase()}function k(E){return E.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(C){return"\\x0"+y(C)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(C){return"\\x"+y(C)})}function x(E){return E.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(C){return"\\x0"+y(C)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(C){return"\\x"+y(C)})}function H(E){return e[E.type](E)}function ae(E){var C=E.map(H),j,he;if(C.sort(),C.length>0){for(j=1,he=1;j<C.length;j++)C[j-1]!==C[j]&&(C[he]=C[j],he++);C.length=he}switch(C.length){case 1:return C[0];case 2:return C[0]+" or "+C[1];default:return C.slice(0,-1).join(", ")+", or "+C[C.length-1]}}function q(E){return E?'"'+k(E)+'"':"end of input"}return"Expected "+ae(s)+" but "+q(d)+" found."};function c(s,d){d=d!==void 0?d:{};var e={},y=d.grammarSource,k={temporalFilter:wr},x=wr,H="(",ae=")",q="second",E="minute",C="hour",j="day",he="week",$e="month",Se="quarter",Re="year",ke="s",me="-",P=":",W="not",z="null",U="to",G="now",ee="last",ne="this",te="next",ce="ago",be="from",ye="before",le="after",ve="through",_="starting",I="for",D="today",N="yesterday",A="tomorrow",h="and",w="or",F="monday",T="tuesday",M="wednesday",Y="thursday",we="friday",Le="saturday",Qe="sunday",J=/^[0-9]/,Be=/^[ Tt]/,Xe=/^[.,]/,Ie=/^[Ww]/,et=/^[Kk]/,Me=/^[Qq]/,wt=/^[1234]/,it=/^[a-zA-Z]/,at=/^[ \t]/,st=Ee("(",!1),tt=Ee(")",!1),R=gt([["0","9"]],!1,!1),re=Ee("second",!0),Oe=Ee("minute",!0),pe=Ee("hour",!0),Ve=Ee("day",!0),ze=Ee("week",!0),ft=Ee("month",!0),ot=Ee("quarter",!0),kt=Ee("year",!0),$=Ee("s",!0),t=Ee("-",!1),a=gt([" ","T","t"],!1,!1),m=Ee(":",!1),p=gt([".",","],!1,!1),K=gt(["W","w"],!1,!1),de=gt(["K","k"],!1,!1),Pe=gt(["Q","q"],!1,!1),X=gt(["1","2","3","4"],!1,!1),De=Ee("not",!0),Ye=Ee("null",!0),_t=Ee("to",!0),fr=Ee("now",!0),ur=Ee("last",!0),Xt=Ee("this",!0),Zt=Ee("next",!0),Te=Ee("ago",!0),cr=Ee("from",!0),jt=Ee("before",!0),Ut=Ee("after",!0),er=Ee("through",!0),pr=Ee("starting",!0),dr=Ee("for",!0),lt=Ee("today",!0),tr=Ee("yesterday",!0),hr=Ee("tomorrow",!0),gr=Ee("and",!0),mr=Ee("or",!0),yr=Ee("monday",!0),vr=Ee("tuesday",!0),Et=Ee("wednesday",!0),Ne=Ee("thursday",!0),S=Ee("friday",!0),O=Ee("saturday",!0),Z=Ee("sunday",!0),se=gt([["a","z"],["A","Z"]],!1,!1),_e=xr("optional whitespace"),ie=gt([" "," "],!1,!1),fe=xr("whitespace"),ge=function(n,o){return o.reduce((i,[,v,,oe])=>Q(i,v,oe),n)},xe=function(n){return u(n,!0)},je=function(n){return n},Tn=function(){return{operator:"null"}},$n=function(n){return{operator:"()",expr:n}},Sn=function(n){return{operator:"before",before:n}},kn=function(n){return{operator:"before",before:n,not:!0}},En=function(n){return{operator:"after",after:n}},On=function(n){return{operator:"after",after:n,not:!0}},Rn=function(n,o){return{operator:n,...o}},Fn=function(n,o){return{operator:"to",fromMoment:n,toMoment:o}},qn=function(n,o){return{...o,operator:"for",begin:n}},Cn=function(n){return{operator:"in",in:n}},xn=function(n){return{operator:"in_last",...n}},Pn=function(){return"last"},Vn=function(){return"next"},In=function(n,o){return{units:o,n}},Ln=function(n){return n},Dn=function(n){return V(n)},Nn=function(){return{moment:"now"}},Mn=function(){return{moment:"today"}},jn=function(){return{moment:"yesterday"}},Un=function(){return{moment:"tomorrow"}},Qn=function(n){return{moment:"ago",...n}},Bn=function(n){return{moment:"from_now",...n}},Wn=function(n){return{moment:n.toLowerCase(),which:"next"}},Gn=function(n){return{moment:n.toLowerCase(),which:"last"}},zn=function(n,o){return{moment:n,units:o}},Yn=function(n){return{moment:n.toLowerCase(),which:"last"}},Hn=function(n){return n},Kn=function(){return"this"},Jn=function(){return"next"},Xn=function(){return"last"},Zn=function(n){return B(n)},ei=function(n){return B(n,"week")},ti=function(n){return B(n,"quarter")},ri=function(n){return B(n,"minute")},ni=function(n){return B(n,"hour")},ii=function(n){return B(n,"day")},si=function(n){return B(n,"month")},ai=function(n){return B(n,"year")},oi=function(n){return n},li=function(){return"or"},fi=function(){return"and"},r=d.peg$currPos|0,Lt=[{line:1,column:1}],ut=r,rr=d.peg$maxFailExpected||[],b=d.peg$silentFails|0,Qt;if(d.startRule){if(!(d.startRule in k))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');x=k[d.startRule]}function Ee(n,o){return{type:"literal",text:n,ignoreCase:o}}function gt(n,o,i){return{type:"class",parts:n,inverted:o,ignoreCase:i}}function ui(){return{type:"end"}}function xr(n){return{type:"other",description:n}}function Pr(n){var o=Lt[n],i;if(o)return o;if(n>=Lt.length)i=Lt.length-1;else for(i=n;!Lt[--i];);for(o=Lt[i],o={line:o.line,column:o.column};i<n;)s.charCodeAt(i)===10?(o.line++,o.column=1):o.column++,i++;return Lt[n]=o,o}function Vr(n,o,i){var v=Pr(n),oe=Pr(o),ue={source:y,start:{offset:n,line:v.line,column:v.column},end:{offset:o,line:oe.line,column:oe.column}};return ue}function L(n){r<ut||(r>ut&&(ut=r,rr=[]),rr.push(n))}function ci(n,o,i){return new l(l.buildMessage(n,o),n,o,i)}function wr(){var n,o,i,v,oe,ue,Ae,Fe;if(n=r,o=_r(),o!==e){for(i=[],v=r,oe=Dt(),ue=Dr(),ue!==e?(Ae=Dt(),Fe=_r(),Fe!==e?(oe=[oe,ue,Ae,Fe],v=oe):(r=v,v=e)):(r=v,v=e);v!==e;)i.push(v),v=r,oe=Dt(),ue=Dr(),ue!==e?(Ae=Dt(),Fe=_r(),Fe!==e?(oe=[oe,ue,Ae,Fe],v=oe):(r=v,v=e)):(r=v,v=e);n=ge(o,i)}else r=n,n=e;return n}function _r(){var n,o,i,v;return n=r,o=mi(),o!==e?(i=rt(),i!==e?(v=Ir(),v!==e?n=xe(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Ir(),o!==e&&(o=je(o)),n=o),n}function Ir(){var n,o,i,v,oe,ue;return n=r,o=yi(),o!==e&&(o=Tn()),n=o,n===e&&(n=r,s.charCodeAt(r)===40?(o=H,r++):(o=e,b===0&&L(st)),o!==e?(i=Dt(),v=wr(),v!==e?(oe=Dt(),s.charCodeAt(r)===41?(ue=ae,r++):(ue=e,b===0&&L(tt)),ue!==e?n=$n(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=bi(),o!==e?(i=rt(),i!==e?(v=At(),v!==e?n=Sn(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Si(),o!==e?(i=rt(),i!==e?(v=At(),v!==e?n=kn(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Ti(),o!==e?(i=rt(),i!==e?(v=At(),v!==e?n=En(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=$i(),o!==e?(i=rt(),i!==e?(v=At(),v!==e?n=On(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=pi(),o!==e?(i=rt(),i!==e?(v=Bt(),v!==e?n=Rn(o,v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=At(),o!==e?(i=rt(),i!==e?(v=vi(),v!==e?(oe=rt(),oe!==e?(ue=At(),ue!==e?n=Fn(o,ue):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=At(),o!==e?(i=rt(),i!==e?(v=ki(),v!==e?(oe=rt(),oe!==e?(ue=Bt(),ue!==e?n=qn(o,ue):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=At(),o!==e&&(o=Cn(o)),n=o,n===e&&(n=r,o=Bt(),o!==e&&(o=xn(o)),n=o)))))))))),n}function pi(){var n,o;return n=r,o=br(),o!==e&&(o=Pn()),n=o,n===e&&(n=r,o=Tr(),o!==e&&(o=Vn()),n=o),n}function Bt(){var n,o,i,v;return n=r,o=di(),o!==e?(i=rt(),i!==e?(v=Lr(),v!==e?n=In(o,v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n}function di(){var n,o,i,v;if(n=r,o=r,i=[],v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e)for(;v!==e;)i.push(v),v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R));else i=e;return i!==e?o=s.substring(o,r):o=i,o!==e&&(o=Ln(o)),n=o,n}function Lr(){var n,o,i,v,oe;return n=r,o=r,i=s.substr(r,6),i.toLowerCase()===q?r+=6:(i=e,b===0&&L(re)),i===e&&(i=s.substr(r,6),i.toLowerCase()===E?r+=6:(i=e,b===0&&L(Oe)),i===e&&(i=s.substr(r,4),i.toLowerCase()===C?r+=4:(i=e,b===0&&L(pe)),i===e&&(i=s.substr(r,3),i.toLowerCase()===j?r+=3:(i=e,b===0&&L(Ve)),i===e&&(i=s.substr(r,4),i.toLowerCase()===he?r+=4:(i=e,b===0&&L(ze)),i===e&&(i=s.substr(r,5),i.toLowerCase()===$e?r+=5:(i=e,b===0&&L(ft)),i===e&&(i=s.substr(r,7),i.toLowerCase()===Se?r+=7:(i=e,b===0&&L(ot)),i===e&&(i=s.substr(r,4),i.toLowerCase()===Re?r+=4:(i=e,b===0&&L(kt))))))))),i!==e?o=s.substring(o,r):o=i,o!==e?(i=s.charAt(r),i.toLowerCase()===ke?r++:(i=e,b===0&&L($)),i===e&&(i=null),v=r,b++,oe=Ue(),b--,oe===e?v=void 0:(r=v,v=e),v!==e?n=Dn(o):(r=n,n=e)):(r=n,n=e),n}function At(){var n,o,i,v,oe,ue;return n=r,o=Nr(),o!==e&&(o=Nn()),n=o,n===e&&(n=r,o=Ei(),o!==e&&(o=Mn()),n=o,n===e&&(n=r,o=Oi(),o!==e&&(o=jn()),n=o,n===e&&(n=r,o=Ri(),o!==e&&(o=Un()),n=o,n===e&&(n=r,o=Bt(),o!==e?(i=rt(),i!==e?(v=_i(),v!==e?n=Qn(o):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Bt(),o!==e?(i=rt(),i!==e?(v=Ai(),v!==e?(oe=rt(),oe!==e?(ue=Nr(),ue!==e?n=Bn(o):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Tr(),o!==e?(i=rt(),i!==e?(v=Ar(),v!==e?n=Wn(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=br(),o!==e?(i=rt(),i!==e?(v=Ar(),v!==e?n=Gn(v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=hi(),o!==e?(i=rt(),i!==e?(v=Lr(),v!==e?n=zn(o,v):(r=n,n=e)):(r=n,n=e)):(r=n,n=e),n===e&&(n=r,o=Ar(),o!==e&&(o=Yn(o)),n=o,n===e&&(n=r,o=gi(),o!==e&&(o=Hn(o)),n=o)))))))))),n}function hi(){var n,o;return n=r,o=wi(),o!==e&&(o=Kn()),n=o,n===e&&(n=r,o=Tr(),o!==e&&(o=Jn()),n=o,n===e&&(n=r,o=br(),o!==e&&(o=Xn()),n=o)),n}function gi(){var n,o,i,v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge,Ze,Ke,Je,bt,dt,ht,nr,Wt,Gt,Ot,Rt,$r,Tt;if(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e)if(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e)if(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e)if(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e)if(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e)if(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e)if(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e)if(s.charCodeAt(r)===45?(He=me,r++):(He=e,b===0&&L(t)),He!==e)if(We=s.charAt(r),J.test(We)?r++:(We=e,b===0&&L(R)),We!==e)if(Ge=s.charAt(r),J.test(Ge)?r++:(Ge=e,b===0&&L(R)),Ge!==e)if(Ze=s.charAt(r),Be.test(Ze)?r++:(Ze=e,b===0&&L(a)),Ze!==e)if(Ke=s.charAt(r),J.test(Ke)?r++:(Ke=e,b===0&&L(R)),Ke!==e)if(Je=s.charAt(r),J.test(Je)?r++:(Je=e,b===0&&L(R)),Je!==e)if(s.charCodeAt(r)===58?(bt=P,r++):(bt=e,b===0&&L(m)),bt!==e)if(dt=s.charAt(r),J.test(dt)?r++:(dt=e,b===0&&L(R)),dt!==e)if(ht=s.charAt(r),J.test(ht)?r++:(ht=e,b===0&&L(R)),ht!==e)if(s.charCodeAt(r)===58?(nr=P,r++):(nr=e,b===0&&L(m)),nr!==e)if(Wt=s.charAt(r),J.test(Wt)?r++:(Wt=e,b===0&&L(R)),Wt!==e)if(Gt=s.charAt(r),J.test(Gt)?r++:(Gt=e,b===0&&L(R)),Gt!==e){if(Ot=r,Rt=s.charAt(r),Xe.test(Rt)?r++:(Rt=e,b===0&&L(p)),Rt!==e){for($r=[],Tt=s.charAt(r),J.test(Tt)?r++:(Tt=e,b===0&&L(R));Tt!==e;)$r.push(Tt),Tt=s.charAt(r),J.test(Tt)?r++:(Tt=e,b===0&&L(R));Rt=[Rt,$r],Ot=Rt}else r=Ot,Ot=e;Ot===e&&(Ot=null),v=[v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge,Ze,Ke,Je,bt,dt,ht,nr,Wt,Gt,Ot],i=v}else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;else r=i,i=e;return i!==e?o=s.substring(o,r):o=i,o!==e&&(o=Zn(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e?(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e?(s.charCodeAt(r)===45?(He=me,r++):(He=e,b===0&&L(t)),He!==e?(We=s.charAt(r),J.test(We)?r++:(We=e,b===0&&L(R)),We!==e?(Ge=s.charAt(r),J.test(Ge)?r++:(Ge=e,b===0&&L(R)),Ge!==e?(s.charCodeAt(r)===45?(Ze=me,r++):(Ze=e,b===0&&L(t)),Ze!==e?(Ke=s.charAt(r),Ie.test(Ke)?r++:(Ke=e,b===0&&L(K)),Ke!==e?(Je=s.charAt(r),et.test(Je)?r++:(Je=e,b===0&&L(de)),Je!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge,Ze,Ke,Je],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ei(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),Me.test(qe)?r++:(qe=e,b===0&&L(Pe)),qe!==e?(Ce=s.charAt(r),wt.test(Ce)?r++:(Ce=e,b===0&&L(X)),Ce!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ti(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e?(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e?(s.charCodeAt(r)===45?(He=me,r++):(He=e,b===0&&L(t)),He!==e?(We=s.charAt(r),J.test(We)?r++:(We=e,b===0&&L(R)),We!==e?(Ge=s.charAt(r),J.test(Ge)?r++:(Ge=e,b===0&&L(R)),Ge!==e?(Ze=s.charAt(r),Be.test(Ze)?r++:(Ze=e,b===0&&L(a)),Ze!==e?(Ke=s.charAt(r),J.test(Ke)?r++:(Ke=e,b===0&&L(R)),Ke!==e?(Je=s.charAt(r),J.test(Je)?r++:(Je=e,b===0&&L(R)),Je!==e?(s.charCodeAt(r)===58?(bt=P,r++):(bt=e,b===0&&L(m)),bt!==e?(dt=s.charAt(r),J.test(dt)?r++:(dt=e,b===0&&L(R)),dt!==e?(ht=s.charAt(r),J.test(ht)?r++:(ht=e,b===0&&L(R)),ht!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge,Ze,Ke,Je,bt,dt,ht],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ri(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e?(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e?(s.charCodeAt(r)===45?(He=me,r++):(He=e,b===0&&L(t)),He!==e?(We=s.charAt(r),J.test(We)?r++:(We=e,b===0&&L(R)),We!==e?(Ge=s.charAt(r),J.test(Ge)?r++:(Ge=e,b===0&&L(R)),Ge!==e?(Ze=s.charAt(r),Be.test(Ze)?r++:(Ze=e,b===0&&L(a)),Ze!==e?(Ke=s.charAt(r),J.test(Ke)?r++:(Ke=e,b===0&&L(R)),Ke!==e?(Je=s.charAt(r),J.test(Je)?r++:(Je=e,b===0&&L(R)),Je!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge,Ze,Ke,Je],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ni(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e?(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e?(s.charCodeAt(r)===45?(He=me,r++):(He=e,b===0&&L(t)),He!==e?(We=s.charAt(r),J.test(We)?r++:(We=e,b===0&&L(R)),We!==e?(Ge=s.charAt(r),J.test(Ge)?r++:(Ge=e,b===0&&L(R)),Ge!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce,He,We,Ge],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ii(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(s.charCodeAt(r)===45?(Fe=me,r++):(Fe=e,b===0&&L(t)),Fe!==e?(qe=s.charAt(r),J.test(qe)?r++:(qe=e,b===0&&L(R)),qe!==e?(Ce=s.charAt(r),J.test(Ce)?r++:(Ce=e,b===0&&L(R)),Ce!==e?(v=[v,oe,ue,Ae,Fe,qe,Ce],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=si(o)),n=o,n===e&&(n=r,o=r,i=r,v=s.charAt(r),J.test(v)?r++:(v=e,b===0&&L(R)),v!==e?(oe=s.charAt(r),J.test(oe)?r++:(oe=e,b===0&&L(R)),oe!==e?(ue=s.charAt(r),J.test(ue)?r++:(ue=e,b===0&&L(R)),ue!==e?(Ae=s.charAt(r),J.test(Ae)?r++:(Ae=e,b===0&&L(R)),Ae!==e?(v=[v,oe,ue,Ae],i=v):(r=i,i=e)):(r=i,i=e)):(r=i,i=e)):(r=i,i=e),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=ai(o)),n=o))))))),n}function Ar(){var n,o,i;return n=r,o=r,i=Ci(),i===e&&(i=xi(),i===e&&(i=Pi(),i===e&&(i=Vi(),i===e&&(i=Ii(),i===e&&(i=Li(),i===e&&(i=Di())))))),i!==e?o=s.substring(o,r):o=i,o!==e&&(o=oi(o)),n=o,n}function Dr(){var n,o;return n=r,o=qi(),o!==e&&(o=li()),n=o,n===e&&(n=r,o=Fi(),o!==e&&(o=fi()),n=o),n}function mi(){var n,o,i,v;return n=r,o=s.substr(r,3),o.toLowerCase()===W?r+=3:(o=e,b===0&&L(De)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function yi(){var n,o,i,v;return n=r,o=s.substr(r,4),o.toLowerCase()===z?r+=4:(o=e,b===0&&L(Ye)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function vi(){var n,o,i,v;return n=r,o=s.substr(r,2),o.toLowerCase()===U?r+=2:(o=e,b===0&&L(_t)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Nr(){var n,o,i,v;return n=r,o=s.substr(r,3),o.toLowerCase()===G?r+=3:(o=e,b===0&&L(fr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function br(){var n,o,i,v;return n=r,o=s.substr(r,4),o.toLowerCase()===ee?r+=4:(o=e,b===0&&L(ur)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function wi(){var n,o,i,v;return n=r,o=s.substr(r,4),o.toLowerCase()===ne?r+=4:(o=e,b===0&&L(Xt)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Tr(){var n,o,i,v;return n=r,o=s.substr(r,4),o.toLowerCase()===te?r+=4:(o=e,b===0&&L(Zt)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function _i(){var n,o,i,v;return n=r,o=s.substr(r,3),o.toLowerCase()===ce?r+=3:(o=e,b===0&&L(Te)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ai(){var n,o,i,v;return n=r,o=s.substr(r,4),o.toLowerCase()===be?r+=4:(o=e,b===0&&L(cr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function bi(){var n,o,i,v;return n=r,o=s.substr(r,6),o.toLowerCase()===ye?r+=6:(o=e,b===0&&L(jt)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ti(){var n,o,i,v;return n=r,o=s.substr(r,5),o.toLowerCase()===le?r+=5:(o=e,b===0&&L(Ut)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function $i(){var n,o,i,v;return n=r,o=s.substr(r,7),o.toLowerCase()===ve?r+=7:(o=e,b===0&&L(er)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Si(){var n,o,i,v;return n=r,o=s.substr(r,8),o.toLowerCase()===_?r+=8:(o=e,b===0&&L(pr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function ki(){var n,o,i,v;return n=r,o=s.substr(r,3),o.toLowerCase()===I?r+=3:(o=e,b===0&&L(dr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ei(){var n,o,i,v;return n=r,o=s.substr(r,5),o.toLowerCase()===D?r+=5:(o=e,b===0&&L(lt)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Oi(){var n,o,i,v;return n=r,o=s.substr(r,9),o.toLowerCase()===N?r+=9:(o=e,b===0&&L(tr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ri(){var n,o,i,v;return n=r,o=s.substr(r,8),o.toLowerCase()===A?r+=8:(o=e,b===0&&L(hr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Fi(){var n,o,i,v;return n=r,o=s.substr(r,3),o.toLowerCase()===h?r+=3:(o=e,b===0&&L(gr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function qi(){var n,o,i,v;return n=r,o=s.substr(r,2),o.toLowerCase()===w?r+=2:(o=e,b===0&&L(mr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ci(){var n,o,i,v;return n=r,o=s.substr(r,6),o.toLowerCase()===F?r+=6:(o=e,b===0&&L(yr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function xi(){var n,o,i,v;return n=r,o=s.substr(r,7),o.toLowerCase()===T?r+=7:(o=e,b===0&&L(vr)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Pi(){var n,o,i,v;return n=r,o=s.substr(r,9),o.toLowerCase()===M?r+=9:(o=e,b===0&&L(Et)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Vi(){var n,o,i,v;return n=r,o=s.substr(r,8),o.toLowerCase()===Y?r+=8:(o=e,b===0&&L(Ne)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ii(){var n,o,i,v;return n=r,o=s.substr(r,6),o.toLowerCase()===we?r+=6:(o=e,b===0&&L(S)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Li(){var n,o,i,v;return n=r,o=s.substr(r,8),o.toLowerCase()===Le?r+=8:(o=e,b===0&&L(O)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Di(){var n,o,i,v;return n=r,o=s.substr(r,6),o.toLowerCase()===Qe?r+=6:(o=e,b===0&&L(Z)),o!==e?(i=r,b++,v=Ue(),b--,v===e?i=void 0:(r=i,i=e),i!==e?(o=[o,i],n=o):(r=n,n=e)):(r=n,n=e),n}function Ue(){var n;return n=s.charAt(r),it.test(n)?r++:(n=e,b===0&&L(se)),n}function Dt(){var n,o;for(b++,n=[],o=s.charAt(r),at.test(o)?r++:(o=e,b===0&&L(ie));o!==e;)n.push(o),o=s.charAt(r),at.test(o)?r++:(o=e,b===0&&L(ie));return b--,o=e,b===0&&L(_e),n}function rt(){var n,o;if(b++,n=[],o=s.charAt(r),at.test(o)?r++:(o=e,b===0&&L(ie)),o!==e)for(;o!==e;)n.push(o),o=s.charAt(r),at.test(o)?r++:(o=e,b===0&&L(ie));else n=e;return b--,n===e&&(o=e,b===0&&L(fe)),n}if(Qt=x(),d.peg$library)return{peg$result:Qt,peg$currPos:r,peg$FAILED:e,peg$maxFailExpected:rr,peg$maxFailPos:ut};if(Qt!==e&&r===s.length)return Qt;throw Qt!==e&&r<s.length&&L(ui()),ci(rr,ut<s.length?s.charAt(ut):null,ut<s.length?Vr(ut,ut+1):Vr(ut,ut))}return Fr={StartRules:["temporalFilter"],SyntaxError:l,parse:c},Fr}var Hr;function zi(){return Hr||(Hr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=void 0;const Q=Nt(),B=Gi(),V=Cr();u.TemporalFilterExpression={parse(c){if(c.match(/^\s*$/))return{parsed:null,log:[]};const s=(0,V.run_parser)(c,B.parse);return s.parsed&&(0,Q.isTemporalFilter)(s.parsed)?{parsed:s.parsed,log:[]}:{parsed:null,log:s.log}},unparse(c){if(c===null)return"";switch(c.operator){case"null":return g(c,"null");case"in":return g(c,f(c.in));case"()":return"("+u.TemporalFilterExpression.unparse(c.expr)+")";case"in_last":return g(c,l(c));case"last":case"next":return g(c,`${c.operator} ${l(c)}`);case"before":return`${c.not?"starting":"before"} ${f(c.before)}`;case"after":return`${c.not?"through":"after"} ${f(c.after)}`;case"to":return g(c,`${f(c.fromMoment)} to ${f(c.toMoment)}`);case"for":return g(c,`${f(c.begin)} for ${l(c)}`);case"or":return c.members.map(s=>u.TemporalFilterExpression.unparse(s)).join(" or ");case"and":return c.members.map(s=>u.TemporalFilterExpression.unparse(s)).join(" and ")}}};function g(c,s){return"not"in c&&c.not?"not "+s:s}function l(c){return c.n==="1"?`1 ${c.units}`:`${c.n} ${c.units}s`}function f(c){switch(c.moment){case"literal":return c.literal;case"now":case"today":case"yesterday":case"tomorrow":return c.moment;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return c.which==="next"?"next "+c.moment:c.moment;case"this":case"next":case"last":return`${c.moment} ${c.units}`;case"ago":return`${l(c)} ago`;case"from_now":return`${l(c)} from now`}}})(Rr)),Rr}var Kr;function Yi(){return Kr||(Kr=1,(function(u){var Q=Ft&&Ft.__createBinding||(Object.create?(function(c,s,d,e){e===void 0&&(e=d);var y=Object.getOwnPropertyDescriptor(s,d);(!y||("get"in y?!s.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return s[d]}}),Object.defineProperty(c,e,y)}):(function(c,s,d,e){e===void 0&&(e=d),c[e]=s[d]})),B=Ft&&Ft.__exportStar||function(c,s){for(var d in c)d!=="default"&&!Object.prototype.hasOwnProperty.call(s,d)&&Q(s,c,d)};Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=u.StringFilterExpression=u.NumberFilterExpression=u.BooleanFilterExpression=void 0,B(Nt(),u);var V=ji();Object.defineProperty(u,"BooleanFilterExpression",{enumerable:!0,get:function(){return V.BooleanFilterExpression}});var g=Qi();Object.defineProperty(u,"NumberFilterExpression",{enumerable:!0,get:function(){return g.NumberFilterExpression}});var l=Wi();Object.defineProperty(u,"StringFilterExpression",{enumerable:!0,get:function(){return l.StringFilterExpression}});var f=zi();Object.defineProperty(u,"TemporalFilterExpression",{enumerable:!0,get:function(){return f.TemporalFilterExpression}})})(Ft)),Ft}var pt={},qt={},Jr;function vn(){if(Jr)return qt;Jr=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.Tag=void 0,qt.interfaceFromTag=Q,qt.interfaceFromDict=B;class u{get parent(){return this._parent}get root(){let g=this;for(;g._parent!==void 0;)g=g._parent;return g}static id(g){let l=u.ids.get(g);return l===void 0&&(l=u.nextTagId,u.ids.set(g,l),u.nextTagId+=1),l}peek(g=0){const l=" ".repeat(g);let f=`#${u.id(this)}`;if(this.properties===void 0&&this.eq&&typeof this.eq=="string")return f+`=${this.eq}`;if(f+=" {",this.eq!==void 0&&(Array.isArray(this.eq)?f+=`
18
- ${l} =: [
19
- ${l} ${this.eq.map(c=>c.peek(g+4)).join(`
20
- ${l} `)}
21
- ${l} ]`:f+=`
22
- ${l} =: ${this.eq}`),this.properties)for(const c in this.properties)f+=`
23
- ${l} ${c}: ${this.properties[c].peek(g+2)}`;return f+=`
24
- ${l}}`,f}constructor(g={},l){if(this._read=!1,l!==void 0&&(this._parent=l),g.eq!==void 0&&(Array.isArray(g.eq)?this.eq=g.eq.map(f=>f instanceof u?f:new u(f,this)):this.eq=g.eq),g.properties){this.properties={};for(const[f,c]of Object.entries(g.properties))this.properties[f]=c instanceof u?c:new u(c,this)}g.deleted&&(this.deleted=g.deleted),g.prefix&&(this.prefix=g.prefix)}static withPrefix(g){return new u({prefix:g})}tag(...g){return this.find(g)}text(...g){var l;const f=(l=this.find(g))===null||l===void 0?void 0:l.getEq();if(!(f===void 0||Array.isArray(f)))return f instanceof Date?f.toISOString():String(f)}scalarType(...g){var l;const f=g.length>0?(l=this.find(g))===null||l===void 0?void 0:l.getEq():this.getEq();if(!(f===void 0||Array.isArray(f)))return f instanceof Date?"date":typeof f}numeric(...g){var l;const f=(l=this.find(g))===null||l===void 0?void 0:l.getEq();if(typeof f=="number")return f;if(typeof f=="string"){const c=Number.parseFloat(f);if(!Number.isNaN(c))return c}}boolean(...g){var l;const f=(l=this.find(g))===null||l===void 0?void 0:l.getEq();if(typeof f=="boolean")return f}isTrue(...g){var l;return((l=this.find(g))===null||l===void 0?void 0:l.getEq())===!0}isFalse(...g){var l;return((l=this.find(g))===null||l===void 0?void 0:l.getEq())===!1}date(...g){var l;const f=(l=this.find(g))===null||l===void 0?void 0:l.getEq();if(f instanceof Date)return f}bare(...g){const l=this.find(g);if(l!==void 0)return!l.hasProperties()}getEq(){return this.eq}getProperty(g){var l;return(l=this.properties)===null||l===void 0?void 0:l[g]}getArrayElement(g){if(Array.isArray(this.eq)&&g<this.eq.length)return this.eq[g]}get dict(){var g;return(g=this.properties)!==null&&g!==void 0?g:{}}*entries(){if(this.properties)for(const g in this.properties)yield[g,this.properties[g]]}*keys(){if(this.properties)for(const g in this.properties)yield g}hasProperties(){return this.properties!==void 0&&Object.keys(this.properties).length>0}array(...g){const l=this.find(g);if(l===void 0)return;const f=l.getEq();if(Array.isArray(f))return f.map((c,s)=>l.getArrayElement(s))}textArray(...g){const l=this.find(g);if(l===void 0)return;const f=l.getEq();if(Array.isArray(f))return f.reduce((c,s,d)=>{const e=l.getArrayElement(d),y=e?.getEq();return y===void 0||Array.isArray(y)?c:y instanceof Date?c.concat(y.toISOString()):c.concat(String(y))},[])}numericArray(...g){const l=this.find(g);if(l===void 0)return;const f=l.getEq();if(Array.isArray(f))return f.reduce((c,s,d)=>{const e=l.getArrayElement(d),y=e?.getEq();if(typeof y=="number")return c.concat(y);if(typeof y=="string"){const k=Number.parseFloat(y);if(!Number.isNaN(k))return c.concat(k)}return c},[])}getProperties(){return this.properties===void 0&&(this.properties={}),this.properties}clone(g){this._read=!0;const l=new u({},g);if(l.prefix=this.prefix,l.deleted=this.deleted,l.location=this.location,l._clonedFrom=this,this.eq!==void 0&&(Array.isArray(this.eq)?l.eq=this.eq.map(f=>f.clone(l)):l.eq=this.eq instanceof Date?new Date(this.eq):this.eq),this.properties){l.properties={};for(const[f,c]of Object.entries(this.properties))l.properties[f]=c.clone(l)}return l}toJSON(){const g={};if(this.eq!==void 0&&(Array.isArray(this.eq)?g.eq=this.eq.map(l=>l.toJSON()):g.eq=this.eq),this.properties!==void 0){g.properties={};for(const[l,f]of Object.entries(this.properties))g.properties[l]=f.toJSON()}return this.deleted&&(g.deleted=!0),this.prefix&&(g.prefix=this.prefix),this.location&&(g.location=this.location),g}validateReferences(){const g=[];return this.collectReferenceErrors(g,[]),g}collectReferenceErrors(g,l){if(this.properties)for(const[f,c]of Object.entries(this.properties))c.deleted||c.collectReferenceErrors(g,[...l,f]);Array.isArray(this.eq)&&this.eq.forEach((f,c)=>{f.collectReferenceErrors(g,[...l,`[${c}]`])})}static escapeString(g){return g.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}static escapeProp(g){return g.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static quoteAndEscape(g,l=!1){return g.match(/^[0-9A-Za-z_]+$/)?g:l?`\`${u.escapeProp(g)}\``:`"${u.escapeString(g)}"`}static serializeScalar(g){return typeof g=="boolean"?g?"@true":"@false":g instanceof Date?`@${g.toISOString()}`:typeof g=="number"?String(g):u.quoteAndEscape(g)}toString(){var g;let l=(g=this.prefix)!==null&&g!==void 0?g:"# ";function f(d){var e;const y=Object.keys((e=d.properties)!==null&&e!==void 0?e:{});for(let k=0;k<y.length;k++)s(y[k],d.properties[y[k]]),k<y.length-1&&(l+=" ")}function c(d,e=!1){if(d.eq!==void 0)if(e||(l+=" = "),Array.isArray(d.eq)){l+="[";for(let y=0;y<d.eq.length;y++)c(d.eq[y],!0),y!==d.eq.length-1&&(l+=", ");l+="]"}else l+=u.serializeScalar(d.eq);if(d.properties){const y=Object.keys(d.properties);!e&&y.length===1&&!y.some(k=>{var x;return((x=d.properties)!==null&&x!==void 0?x:{})[k].deleted})&&d.eq===void 0?(l+=".",f(d)):((!e||d.eq!==void 0)&&(l+=" "),l+="{ ",f(d),l+=" }")}}function s(d,e){if(e.deleted){l+=`-${u.quoteAndEscape(d,!0)}`;return}l+=u.quoteAndEscape(d,!0),c(e)}return f(this),l+=`
25
- `,l}find(g){let l=this;for(const f of g){let c;if(typeof f=="number"?c=l.getArrayElement(f):c=l.getProperty(f),c===void 0)return;c.markRead(),l=c}return l.deleted?void 0:l}markRead(){this._read=!0,this._clonedFrom&&(this._clonedFrom._read=!0)}get wasRead(){return this._read}*walk(g=[]){if(this.properties)for(const[l,f]of Object.entries(this.properties)){if(f.deleted)continue;const c=[...g,l];yield{path:c,tag:f},yield*f.walk(c)}if(Array.isArray(this.eq))for(let l=0;l<this.eq.length;l++){const f=[...g,l.toString()];yield{path:f,tag:this.eq[l]},yield*this.eq[l].walk(f)}}resetReadTracking(){this._read=!1;for(const{tag:g}of this.walk())g._read=!1}getUnreadProperties(g=[]){const l=[];if(this.properties)for(const[f,c]of Object.entries(this.properties)){if(c.deleted)continue;const s=[...g,f];c._read?l.push(...c.getUnreadProperties(s)):l.push(s)}return l}has(...g){return this.find(g)!==void 0}set(g,l=null){let f=this,c,s;for(const d of g)if(c=f,s=d,typeof d=="number"){if(f.eq===void 0||!Array.isArray(f.eq))f.eq=Array.from({length:d+1}).map(()=>new u({},f));else if(f.eq.length<=d){const e=f.eq,y=Array.from({length:d+1}).map((k,x)=>x<e.length?e[x]:new u({},f));f.eq=y}f=f.eq[d]}else{const e=f.properties;e===void 0?(f.properties={[d]:new u({},f)},f=f.properties[d]):d in e?(f=e[d],f.deleted&&(f.deleted=!1)):(e[d]=new u({},f),f=e[d])}if(l===null)f.eq=void 0;else if(l instanceof u){const d=l.clone(c);c&&s!==void 0&&(typeof s=="number"&&Array.isArray(c.eq)?c.eq[s]=d:typeof s=="string"&&c.properties&&(c.properties[s]=d))}else typeof l=="string"||typeof l=="number"||typeof l=="boolean"||l instanceof Date?f.eq=l:Array.isArray(l)&&(f.eq=l.map(d=>new u({eq:d},f)));return this}delete(...g){return this.remove(g,!1)}unset(...g){return this.remove(g,!0)}remove(g,l=!1){var f;let c=this;for(const d of g.slice(0,g.length-1))if(typeof d=="number"){if(c.eq===void 0||!Array.isArray(c.eq)){if(!l)return this;c.eq=Array.from({length:d}).map(()=>new u({},c))}else if(c.eq.length<=d){if(!l)return this;const e=c.eq,y=Array.from({length:d}).map((k,x)=>x<e.length?e[x]:new u({},c));c.eq=y}c=c.eq[d]}else{const e=c.properties;if(e===void 0){if(!l)return this;c.properties={[d]:new u({},c)},c=c.properties[d]}else if(d in e)c=e[d];else{if(!l)return this;e[d]=new u({},c),c=e[d]}}const s=g[g.length-1];return typeof s=="string"?c.properties&&s in c.properties?delete c.properties[s]:l&&((f=c.properties)!==null&&f!==void 0||(c.properties={}),c.properties[s]=new u({deleted:!0},c)):Array.isArray(c.eq)&&c.eq.splice(s,1),this}}qt.Tag=u,u.ids=new Map,u.nextTagId=1e3;function Q(V){const g={};return V.eq!==void 0&&(Array.isArray(V.eq)?g.eq=V.eq.map(l=>Q(l)):g.eq=V.eq),V.properties!==void 0&&(g.properties=B(V.properties)),V.deleted&&(g.deleted=!0),g}function B(V){const g={};for(const[l,f]of Object.entries(V))g[l]=Q(f);return g}return qt}var Ct={},qr={},$t={},Xr;function Mt(){if(Xr)return $t;Xr=1,Object.defineProperty($t,"__esModule",{value:!0}),$t.formatRef=u,$t.isRef=Q,$t.isDataNode=B,$t.isEnvRef=V,$t.isMotlyError=g;function u(l){let f="$";for(let s=0;s<l.linkUps;s++)f+="^";let c=!0;for(const s of l.linkTo)typeof s=="string"?((!c||l.linkUps>0)&&(f+="."),f+=s,c=!1):f+=`[${s}]`;return f}function Q(l){return typeof l=="object"&&l!==null&&"linkTo"in l&&"linkUps"in l&&!Array.isArray(l)&&!(l instanceof Date)}function B(l){return typeof l=="object"&&l!==null&&!Q(l)}function V(l){return typeof l=="object"&&l!==null&&"env"in l&&!Array.isArray(l)&&!(l instanceof Date)}function g(l){return typeof l=="object"&&l!==null&&"code"in l&&"message"in l&&"begin"in l&&"end"in l}return $t}var St={},Zr;function wn(){if(Zr)return St;Zr=1,Object.defineProperty(St,"__esModule",{value:!0}),St.MotValue=St.Mot=void 0,St.buildMot=d;const u=Mt();class Q{text(...y){return this.get(...y)._text()}numeric(...y){return this.get(...y)._numeric()}boolean(...y){return this.get(...y)._boolean()}date(...y){return this.get(...y)._date()}valueType(...y){return this.get(...y)._valueType()}values(...y){return this.get(...y)._values()}texts(...y){const k=this.get(...y)._values();if(!k)return;const x=[];for(const H of k){const ae=H._text();if(ae===void 0)return;x.push(ae)}return x}numerics(...y){const k=this.get(...y)._values();if(!k)return;const x=[];for(const H of k){const ae=H._numeric();if(ae===void 0)return;x.push(ae)}return x}booleans(...y){const k=this.get(...y)._values();if(!k)return;const x=[];for(const H of k){const ae=H._boolean();if(ae===void 0)return;x.push(ae)}return x}dates(...y){const k=this.get(...y)._values();if(!k)return;const x=[];for(const H of k){const ae=H._date();if(ae===void 0)return;x.push(ae)}return x}has(...y){return this.get(...y).exists}}St.Mot=Q;class B extends Q{constructor(y,k,x=!0){super(),this.isRef=!1,this._val=y,this._props=k,this.exists=x}_text(){return this._val?.type==="string"?this._val.value:void 0}_numeric(){return this._val?.type==="number"?this._val.value:void 0}_boolean(){return this._val?.type==="boolean"?this._val.value:void 0}_date(){return this._val?.type==="date"?this._val.value:void 0}_values(){return this._val?.type==="array"?this._val.value:void 0}_valueType(){return this._val?.type}get keys(){return this._props.keys()}get entries(){return this._props.entries()}get(...y){let k=this;for(const x of y){if(typeof x=="number"){const H=k.values();if(!H||!Number.isInteger(x)||x<0||x>=H.length)return f;k=H[x]}else k===this?k=this._props.get(x)??f:k=k.get(x);if(!k.exists)return f}return k}}St.MotValue=B;class V extends Q{constructor(y,k){super(),this.exists=!0,this.isRef=!0,this._target=k}_text(){return this._target.text()}_numeric(){return this._target.numeric()}_boolean(){return this._target.boolean()}_date(){return this._target.date()}_values(){return this._target.values()}_valueType(){return this._target.valueType()}get keys(){return this._target.keys}get entries(){return this._target.entries}get(...y){return this._target.get(...y)}}const g={[Symbol.iterator]:()=>({next:()=>({done:!0,value:void 0})})};class l extends Q{constructor(){super(...arguments),this.exists=!1,this.isRef=!1}_text(){}_numeric(){}_boolean(){}_date(){}_values(){}_valueType(){}get keys(){return g}get entries(){return g}get(...y){return this}}const f=new l,c={createMot(e,y){return new B(e,y)},createRefMot(e,y){return new V(e,y)},undefinedMot:f};function s(e,y,k,x){let H,ae;if(e.linkUps===0)H=y,ae=[];else{const j=k.length-e.linkUps;if(j<0||j>=k.length)return;H=k[j],ae=k.slice(0,j)}let q=H,E=ae,C=H;for(let j=0;j<e.linkTo.length;j++){if((0,u.isRef)(q)){if(x.has(q))return;x.add(q);const Se=s(q,y,E,x);if(x.delete(q),!Se)return;q=Se.target,E=Se.ancestors,C=q,j--;continue}const he=q,$e=e.linkTo[j];if(typeof $e=="string"){if(!he.properties||!($e in he.properties))return;j>0&&(E=[...E,C]),C=he,q=he.properties[$e]}else{if(!he.eq||!Array.isArray(he.eq)||$e>=he.eq.length)return;j>0&&(E=[...E,C]),C=he,q=he.eq[$e]}}if((0,u.isRef)(q)){if(x.has(q))return;x.add(q);const j=s(q,y,E,x);return x.delete(q),j}return{target:q,ancestors:E}}function d(e,y){const k=y?.env,x=y?.factory??c,H=x.undefinedMot,ae=new Map;function q(j,he,$e){if(j.deleted)return H;if(ae.has(j))return ae.get(j);const Se=new Map,Re=C(j.eq,he,$e,j),ke=x.createMot(Re,Se);if(ae.set(j,ke),j.properties)for(const[me,P]of Object.entries(j.properties)){const W=E(P,he,$e,j);W.exists&&Se.set(me,W)}return ke}function E(j,he,$e,Se){if((0,u.isRef)(j)){const ke=new Set;ke.add(j);const me=s(j,he,$e,ke);if(!me||me.target.deleted)return H;const P=q(me.target,he,me.ancestors);return x.createRefMot(j,P)}const Re=j;return Re.deleted?H:q(Re,he,[...$e,Se])}function C(j,he,$e,Se){if(j!==void 0){if((0,u.isEnvRef)(j)){const Re=k?k[j.env]:void 0;return Re===void 0?void 0:{type:"string",value:Re}}if(Array.isArray(j)){const Re=[...$e,Se],ke=[];for(const me of j)ke.push(E(me,he,Re,Se));return{type:"array",value:ke}}if(typeof j=="string")return{type:"string",value:j};if(typeof j=="number")return{type:"number",value:j};if(typeof j=="boolean")return{type:"boolean",value:j};if(j instanceof Date)return{type:"date",value:j}}}return q(e,e,[e])}return St}var mt={},sr={},en;function Hi(){if(en)return sr;en=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.parse=V;class u{constructor(l){this.input=l,this.pos=0}peekChar(){return this.pos<this.input.length?this.input[this.pos]:void 0}advance(l){this.pos+=l}startsWith(l){return this.input.startsWith(l,this.pos)}eatChar(l){return this.peekChar()===l?(this.advance(1),!0):!1}expectChar(l){if(!this.eatChar(l)){const f=this.peekChar();throw this.errorPoint(`Expected '${l}', found ${f===void 0?"end of input":`'${f}'`}`)}}position(){const l=this.input.substring(0,this.pos),f=(l.match(/\n/g)||[]).length,c=l.lastIndexOf(`
26
- `),s=this.pos-(c===-1?0:c+1);return{line:f,column:s,offset:this.pos}}errorPoint(l){const f=this.position();return{code:"tag-parse-syntax-error",message:l,begin:f,end:f}}errorSpan(l,f){return{code:"tag-parse-syntax-error",message:l,begin:f,end:this.position()}}skipWs(){for(;;){for(;this.pos<this.input.length;){const l=this.input[this.pos];if(l===" "||l===" "||l==="\r"||l===`
27
- `)this.pos++;else break}if(this.peekChar()==="#")for(;this.pos<this.input.length;){const l=this.input[this.pos];if(l==="\r"||l===`
28
- `)break;this.pos++}else break}}skipWsAndCommas(){for(this.skipWs();this.peekChar()===",";)this.advance(1),this.skipWs()}parseStatements(){const l=[];for(this.skipWsAndCommas();this.pos<this.input.length;)l.push(this.parseStatement()),this.skipWsAndCommas();return l}parseStatement(){const l=this.position();if(this.startsWith("-..."))return this.advance(4),{kind:"clearAll",span:{begin:l,end:this.position()}};if(this.peekChar()==="-")return this.advance(1),{kind:"define",path:this.parsePropName(),deleted:!0,span:{begin:l,end:this.position()}};const f=this.parsePropName();this.skipWs();const c=this.peekChar();if(c===":"&&this.startsWith(":=")){this.advance(2),this.skipWs();const s=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{kind:"assignBoth",path:f,value:s,properties:d,span:{begin:l,end:this.position()}}}return{kind:"assignBoth",path:f,value:s,properties:null,span:{begin:l,end:this.position()}}}if(c==="="){if(this.advance(1),this.skipWs(),this.peekChar()==="{")throw this.errorPoint("'=' requires a value; use ': { ... }' to replace properties");const s=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{kind:"setEq",path:f,value:s,properties:d,span:{begin:l,end:this.position()}}}return{kind:"setEq",path:f,value:s,properties:null,span:{begin:l,end:this.position()}}}if(c===":"){this.advance(1),this.skipWs();const s=this.parsePropertiesBlock();return{kind:"replaceProperties",path:f,properties:s,span:{begin:l,end:this.position()}}}if(c==="{"){const s=this.parsePropertiesBlock();return{kind:"updateProperties",path:f,properties:s,span:{begin:l,end:this.position()}}}return{kind:"define",path:f,deleted:!1,span:{begin:l,end:this.position()}}}parsePropName(){const f=[this.parseIdentifier()];for(;this.peekChar()===".";)this.advance(1),f.push(this.parseIdentifier());return f}parseIdentifier(){return this.peekChar()==="`"?this.parseBacktickString():this.parseBareString()}parseEqValue(l=!0){const f=this.peekChar();if(l&&f==="[")return{kind:"array",elements:this.parseArray()};if(this.startsWith("<<<"))return{kind:"scalar",value:{kind:"string",value:this.parseHeredoc()}};if(f==="@")return{kind:"scalar",value:this.parseAtValue()};if(f==="$")return{kind:"scalar",value:this.parseReference()};if(f==='"')return this.startsWith('"""')?{kind:"scalar",value:{kind:"string",value:this.parseTripleString()}}:{kind:"scalar",value:{kind:"string",value:this.parseDoubleQuotedString()}};if(f==="'")return this.startsWith("'''")?{kind:"scalar",value:{kind:"string",value:this.parseTripleSingleQuotedString()}}:{kind:"scalar",value:{kind:"string",value:this.parseSingleQuotedString()}};if(f!==void 0&&(f==="-"||f>="0"&&f<="9"||f==="."))return this.parseNumberOrString();if(f!==void 0&&Q(f))return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}};throw this.errorPoint("Expected a value")}parseAtValue(){const l=this.position();if(this.expectChar("@"),this.startsWith("true")&&!this.isBareCharAt(4))return this.advance(4),{kind:"boolean",value:!0};if(this.startsWith("false")&&!this.isBareCharAt(5))return this.advance(5),{kind:"boolean",value:!1};if(this.startsWith("none")&&!this.isBareCharAt(4))return this.advance(4),{kind:"none"};if(this.startsWith("env."))return this.advance(4),{kind:"env",name:this.parseIdentifier()};const f=this.peekChar();if(f!==void 0&&f>="0"&&f<="9")return this.parseDate(l);const c=this.pos;for(;this.pos<this.input.length&&Q(this.input[this.pos]);)this.pos++;const s=this.pos>c?this.input.substring(c,this.pos):"";throw this.errorSpan(`Illegal constant @${s}; expected @true, @false, @none, @env.NAME, or @date`,l)}isBareCharAt(l){const f=this.pos+l;return f<this.input.length&&Q(this.input[f])}parseDate(l){const f=this.pos;if(this.consumeDigits(4,l),this.expectChar("-"),this.consumeDigits(2,l),this.expectChar("-"),this.consumeDigits(2,l),this.peekChar()==="T"){if(this.advance(1),this.consumeDigits(2,l),this.expectChar(":"),this.consumeDigits(2,l),this.peekChar()===":"&&(this.advance(1),this.consumeDigits(2,l),this.peekChar()===".")){this.advance(1);const d=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===d)throw this.errorSpan("Expected fractional digits in date",l)}const s=this.peekChar();s==="Z"?this.advance(1):(s==="+"||s==="-")&&(this.advance(1),this.consumeDigits(2,l),this.peekChar()===":"&&this.advance(1),this.consumeDigits(2,l))}return{kind:"date",value:this.input.substring(f,this.pos)}}consumeDigits(l,f){for(let c=0;c<l;c++){const s=this.peekChar();if(s===void 0||s<"0"||s>"9")throw this.errorSpan("Expected digit",f);this.advance(1)}}parseOptionalExponent(l){const f=this.peekChar();if(f!=="e"&&f!=="E")return;this.advance(1);const c=this.peekChar();(c==="+"||c==="-")&&this.advance(1);const s=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===s)throw this.errorSpan("Expected exponent digits",l)}parseNumberOrString(){const l=this.pos,f=this.position(),c=this.peekChar()==="-";c&&this.advance(1);let s=!1,d=!1;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)s=!0,this.advance(1);if(this.peekChar()==="."){d=!0,this.advance(1);const x=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===x)return this.pos=l,this.parseIntegerOrBare(l,c)}if(!s&&!d){if(this.pos=l,c)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(f);const e=this.peekChar();if(e!==void 0&&Q(e)&&!(e>="0"&&e<="9")){if(this.pos=l,c)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}const y=this.input.substring(l,this.pos),k=parseFloat(y);if(isNaN(k))throw this.errorSpan(`Invalid number: ${y}`,f);return{kind:"scalar",value:{kind:"number",value:k}}}parseIntegerOrBare(l,f){this.pos=l;const c=this.position();f&&this.advance(1);const s=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===s){if(this.pos=l,f)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}if(!f){const y=this.peekChar();if(y!==void 0&&Q(y)&&!(y>="0"&&y<="9"))return this.pos=l,{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(c);const d=this.input.substring(l,this.pos),e=parseFloat(d);if(isNaN(e))throw this.errorSpan(`Invalid number: ${d}`,c);return{kind:"scalar",value:{kind:"number",value:e}}}parseBareString(){const l=this.pos;for(;this.pos<this.input.length&&Q(this.input[this.pos]);)this.pos++;if(this.pos===l)throw this.errorPoint("Expected an identifier");return this.input.substring(l,this.pos)}parseDoubleQuotedString(){const l=this.position();this.expectChar('"');let f="";for(;;){const c=this.peekChar();if(c===void 0||c==="\r"||c===`
29
- `)throw this.errorSpan("Unterminated string",l);if(c==='"')return this.advance(1),f;c==="\\"?(this.advance(1),f+=this.parseEscapeChar()):(this.advance(1),f+=c)}}parseSingleQuotedString(){const l=this.position();this.expectChar("'");let f="";for(;;){const c=this.peekChar();if(c===void 0||c==="\r"||c===`
30
- `)throw this.errorSpan("Unterminated string",l);if(c==="'")return this.advance(1),f;if(c==="\\"){this.advance(1),f+="\\";const s=this.peekChar();if(s===void 0||s==="\r"||s===`
31
- `)throw this.errorSpan("Unterminated string",l);this.advance(1),f+=s}else this.advance(1),f+=c}}parseTripleSingleQuotedString(){const l=this.position();if(!this.startsWith("'''"))throw this.errorPoint("Expected triple-single-quoted string");this.advance(3);let f="";for(;;){if(this.startsWith("'''"))return this.advance(3),f;const c=this.peekChar();if(c===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",l);if(c==="\\"){this.advance(1),f+="\\";const s=this.peekChar();if(s===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",l);this.advance(1),f+=s}else this.advance(1),f+=c}}parseBacktickString(){const l=this.position();this.expectChar("`");let f="";for(;;){const c=this.peekChar();if(c===void 0||c==="\r"||c===`
32
- `)throw this.errorSpan("Unterminated backtick string",l);if(c==="`")return this.advance(1),f;c==="\\"?(this.advance(1),f+=this.parseEscapeChar()):(this.advance(1),f+=c)}}parseTripleString(){const l=this.position();if(!this.startsWith('"""'))throw this.errorPoint("Expected triple-quoted string");this.advance(3);let f="";for(;;){if(this.startsWith('"""'))return this.advance(3),f;const c=this.peekChar();if(c===void 0)throw this.errorSpan("Unterminated triple-quoted string",l);c==="\\"?(this.advance(1),f+=this.parseEscapeChar()):(this.advance(1),f+=c)}}parseEscapeChar(){const l=this.peekChar();if(l===void 0)throw this.errorPoint("Unterminated escape sequence");switch(l){case"b":return this.advance(1),"\b";case"f":return this.advance(1),"\f";case"n":return this.advance(1),`
33
- `;case"r":return this.advance(1),"\r";case"t":return this.advance(1)," ";case"u":{const f=this.position();this.advance(1);const c=this.pos;for(let e=0;e<4;e++){const y=this.peekChar();if(y===void 0||!B(y))throw this.errorSpan("Expected 4 hex digits in \\uXXXX",f);this.advance(1)}const s=this.input.substring(c,this.pos),d=parseInt(s,16);return String.fromCharCode(d)}default:return this.advance(1),l}}parseHeredoc(){const l=this.position();for(this.advance(3);this.pos<this.input.length;){const e=this.input[this.pos];if(e===" "||e===" ")this.pos++;else break}if(this.pos<this.input.length&&this.input[this.pos]==="\r"&&this.advance(1),this.pos>=this.input.length||this.input[this.pos]!==`
34
- `)throw this.errorSpan("Expected newline after <<<",l);this.advance(1);const f=[];let c=!1;for(;this.pos<this.input.length;){const e=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]!==`
35
- `;)this.pos++;let y=this.input.substring(e,this.pos);if(y.endsWith("\r")&&(y=y.substring(0,y.length-1)),this.pos<this.input.length&&this.input[this.pos]===`
36
- `&&this.advance(1),y.trim()===">>>"){c=!0;break}f.push(y)}if(!c)throw this.errorSpan("Unterminated heredoc (expected >>>)",l);if(f.length===0)return"";let s=0;for(const e of f){const y=e.trimStart();if(y.length>0){s=e.length-y.length;break}}return f.map(e=>e.trimStart().length===0?"":s<=e.length?e.substring(s):e).join(`
37
- `)+`
38
- `}parseArray(){const l=this.position();if(this.expectChar("["),this.skipWs(),this.eatChar("]"))return[];const f=[];for(f.push(this.parseArrayElement());;){if(this.skipWs(),this.eatChar("]"))return f;if(this.eatChar(",")){if(this.skipWs(),this.peekChar()==="]")return this.advance(1),f;f.push(this.parseArrayElement())}else throw this.pos>=this.input.length?this.errorSpan("Unclosed '['",l):this.errorPoint("Expected ',' or ']' in array")}}parseArrayElement(){this.skipWs();const l=this.position(),f=this.peekChar();if(f==="{")return{value:null,properties:this.parsePropertiesBlock(),span:{begin:l,end:this.position()}};if(f==="["){const s=this.parseArray();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{value:{kind:"array",elements:s},properties:d,span:{begin:l,end:this.position()}}}return{value:{kind:"array",elements:s},properties:null,span:{begin:l,end:this.position()}}}const c=this.parseEqValue(!1);if(this.skipWs(),this.peekChar()==="{"){const s=this.parsePropertiesBlock();return{value:c,properties:s,span:{begin:l,end:this.position()}}}return{value:c,properties:null,span:{begin:l,end:this.position()}}}parsePropertiesBlock(){const l=this.position();this.expectChar("{");const f=[];for(;;){if(this.skipWsAndCommas(),this.eatChar("}"))return f;if(this.pos>=this.input.length)throw this.errorSpan("Unclosed '{'",l);f.push(this.parseStatement())}}parseReference(){this.expectChar("$");let l=0;for(;this.peekChar()==="^";)this.advance(1),l++;if(l>0){if(this.peekChar()!==".")return{kind:"reference",ups:l,path:[]};this.advance(1)}const f=[],c=this.parseIdentifier();if(f.push({kind:"name",name:c}),this.peekChar()==="["){this.advance(1),this.skipWs();const s=this.parseRefIndex();f.push({kind:"index",index:s}),this.skipWs(),this.expectChar("]")}for(;this.peekChar()===".";){this.advance(1);const s=this.parseIdentifier();if(f.push({kind:"name",name:s}),this.peekChar()==="["){this.advance(1),this.skipWs();const d=this.parseRefIndex();f.push({kind:"index",index:d}),this.skipWs(),this.expectChar("]")}}return{kind:"reference",ups:l,path:f}}parseRefIndex(){const l=this.position(),f=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===f)throw this.errorPoint("Expected array index");const c=parseInt(this.input.substring(f,this.pos),10);if(isNaN(c))throw this.errorSpan("Invalid array index",l);return c}}function Q(g){const l=g.charCodeAt(0);return l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||l===95||l>=192&&l<=591||l>=7680&&l<=7935}function B(g){const l=g.charCodeAt(0);return l>=48&&l<=57||l>=65&&l<=70||l>=97&&l<=102}function V(g){return new u(g).parseStatements()}return sr}var xt={},yt={},tn;function _n(){if(tn)return yt;tn=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.clonePropertyValue=yt.cloneValue=void 0,yt.cloneNode=Q,yt.cloneMotlyNode=B;const u=Mt();function Q(V){const g={};if(V.deleted&&(g.deleted=!0),V.eq!==void 0&&(V.eq instanceof Date?g.eq=new Date(V.eq.getTime()):Array.isArray(V.eq)?g.eq=V.eq.map(B):(0,u.isEnvRef)(V.eq)?g.eq={env:V.eq.env}:g.eq=V.eq),V.properties){const l={};for(const f of Object.keys(V.properties))l[f]=B(V.properties[f]);g.properties=l}return V.location&&(g.location={parseId:V.location.parseId,begin:{...V.location.begin},end:{...V.location.end}}),g}function B(V){return(0,u.isRef)(V)?{linkTo:[...V.linkTo],linkUps:V.linkUps}:Q(V)}return yt.cloneValue=Q,yt.clonePropertyValue=B,yt}var rn;function Ki(){if(rn)return xt;rn=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.flatten=B,xt.chunk=l,xt.topoSort=y,xt.executeChunked=k;const u=Mt(),Q=_n();function B(_,I){const D=[];return V(_,[],I.parseId,D),D}function V(_,I,D,N){for(const A of _)g(A,I,D,N)}function g(_,I,D,N){switch(_.kind){case"setEq":{const A=[...I,..._.path];if(_.value.kind==="scalar"&&_.value.value.kind==="reference"){const h=_.value.value;N.push({path:A,op:{kind:"link",ups:h.ups,refPath:h.path},span:_.span,parseId:D})}else N.push({path:A,op:{kind:"setValue",value:_.value},span:_.span,parseId:D}),_.properties!==null&&V(_.properties,A,D,N);break}case"assignBoth":{const A=[...I,..._.path];if(_.value.kind==="scalar"&&_.value.value.kind==="reference"){const h=_.value.value;N.push({path:A,op:{kind:"clone",ups:h.ups,refPath:h.path},span:_.span,parseId:D}),_.properties!==null&&(N.push({path:A,op:{kind:"clearProperties"},span:_.span,parseId:D}),V(_.properties,A,D,N))}else N.push({path:A,op:{kind:"assignValue",value:_.value},span:_.span,parseId:D}),_.properties!==null&&V(_.properties,A,D,N);break}case"replaceProperties":{const A=[...I,..._.path];N.push({path:A,op:{kind:"clearProperties"},span:_.span,parseId:D}),V(_.properties,A,D,N);break}case"updateProperties":{const A=[...I,..._.path];N.push({path:A,op:{kind:"define"},span:_.span,parseId:D}),V(_.properties,A,D,N);break}case"define":{const A=[...I,..._.path];N.push({path:A,op:{kind:_.deleted?"delete":"define"},span:_.span,parseId:D});break}case"clearAll":{N.push({path:[...I],op:{kind:"clearAll"},span:_.span,parseId:D});break}}}function l(_){const I=_.length;if(I===0)return{splits:[0],deps:[]};const D=new Map;for(let Y=0;Y<I;Y++)D.set(f(_[Y].path),Y);const N=new Set([0,I]),A=new Set,h=[];for(let Y=0;Y<I;Y++){const we=_[Y],Le=f(we.path);if(we.op.kind==="link"||we.op.kind==="clone"){const Qe=d(we.path,we.op.ups,we.op.refPath);if(!c(A,Qe)){h.push({refIdx:Y,targetKey:Qe}),N.add(Y),N.add(Y+1);const J=s(D,Qe);J>Y&&N.add(J)}}A.add(Le)}const w=Array.from(N).sort((Y,we)=>Y-we),F=w.length-1,T=Array.from({length:F},()=>new Set);for(const{refIdx:Y,targetKey:we}of h){const Le=e(w,Y),Qe=s(D,we);if(Qe!==-1){const Be=e(w,Qe);Be!==Le&&T[Le].add(Be)}const J=f(_[Y].path);for(let Be=Y+1;Be<I;Be++){const Xe=f(_[Be].path);if(Xe===J||Xe.startsWith(J+"\0")){const Ie=e(w,Be);Ie!==Le&&T[Ie].add(Le)}}}const M=T.map(Y=>Array.from(Y));return{splits:w,deps:M}}function f(_){return _.join("\0")}function c(_,I){for(const D of _)if(D===I||D.startsWith(I+"\0"))return!0;return!1}function s(_,I){let D=-1;for(const[N,A]of _)(N===I||N.startsWith(I+"\0")||I.startsWith(N+"\0"))&&(D=Math.max(D,A));return D}function d(_,I,D){const N=[];if(I>0){const A=Math.max(0,_.length-1-I);for(let h=0;h<A;h++)N.push(_[h])}for(const A of D)A.kind==="name"?N.push(A.name):N.push(`[${A.index}]`);return N.join("\0")}function e(_,I){let D=0,N=_.length-2;for(;D<N;){const A=D+N+1>>1;_[A]<=I?D=A:N=A-1}return D}function y(_){const I=_.length,D=new Array(I).fill(0),N=Array.from({length:I},()=>[]);for(let T=0;T<I;T++)for(const M of _[T])N[M].push(T),D[T]++;const A=[];for(let T=0;T<I;T++)D[T]===0&&A.push(T);const h=[];let w=0;for(;w<A.length;){const T=A[w++];h.push(T);for(const M of N[T])--D[M]===0&&A.push(M)}const F=[];if(h.length<I){const T=new Set(h);for(let M=0;M<I;M++)T.has(M)||F.push(M)}return{order:h,cycles:F}}function k(_,I,D,N,A){const h=[],w=[];for(const F of D){const T=I[F],M=I[F+1];for(let Y=T;Y<M;Y++)H(_[Y],N,A,h,w)}return x(h,w),h}function x(_,I){if(I.length<2)return;const D=new Map;for(const w of I)D.set(w.sourcePath,w);const N=new Set,A=new Set;for(const w of I){if(A.has(w.sourcePath))continue;const F=[],T=new Set;let M=w;for(;M&&!T.has(M.sourcePath)&&!A.has(M.sourcePath);)F.push(M),T.add(M.sourcePath),M=D.get(M.targetPath);if(M&&T.has(M.sourcePath)){const Y=M.sourcePath,we=[];let Le=!1;for(const Me of F)Me.sourcePath===Y&&(Le=!0),Le&&we.push(Me);const Qe=Me=>Me.replace(/\0/g,"."),J=we.map(Me=>Qe(Me.sourcePath)),Be=we.map(Me=>`$${Qe(Me.targetPath)}`);let Xe=J[0];for(let Me=0;Me<Be.length;Me++)Xe+=` clones ${Be[Me]}`,Me<Be.length-1&&(Xe+=`, ${J[Me+1]}`);for(const Me of we)N.add(Me.errorIndex);const Ie=we[0].errorIndex,et={line:0,column:0,offset:0};_[Ie]={code:"circular-reference",message:`Circular clone dependency: ${Xe}`,begin:et,end:et}}for(const Y of F)A.add(Y.sourcePath)}const h=Array.from(N).sort((w,F)=>F-w);for(const w of h)_[w].code!=="circular-reference"&&_.splice(w,1)}function H(_,I,D,N,A){const h={parseId:_.parseId,options:D};switch(_.op.kind){case"setValue":ae(_.path,_.op.value,I,h,_.span,N);break;case"assignValue":q(_.path,_.op.value,I,h,_.span,N);break;case"clearProperties":E(_.path,I,h,_.span,N);break;case"clearAll":C(_.path,I,h,_.span,N);break;case"define":j(_.path,I,h,_.span,N);break;case"delete":he(_.path,I,h,_.span,N);break;case"link":$e(_.path,_.op.ups,_.op.refPath,I,h,_.span,N);break;case"clone":Se(_.path,_.op.ups,_.op.refPath,I,h,_.span,N,A);break}}function ae(_,I,D,N,A,h){if(_.length===0){P(D,I,N,h);return}const w=me(D,_,N,A,h);if(!w)return;const[F,T]=w,M=le(T);M[F]===void 0&&(M[F]={});const Y=ve(M,F);ke(Y,N,A),P(Y,I,N,h)}function q(_,I,D,N,A,h){if(_.length===0){delete D.properties,D.location=Re(N,A),P(D,I,N,h);return}const w=me(D,_,N,A,h);if(!w)return;const[F,T]=w,M={};M.location=Re(N,A),P(M,I,N,h),le(T)[F]=M}function E(_,I,D,N,A){if(_.length===0){delete I.properties;return}const h=me(I,_,D,N,A);if(!h)return;const[w,F]=h,T=le(F),M=T[w];if(M!==void 0&&!(0,u.isRef)(M))delete M.properties;else{const Y={};Y.location=Re(D,N),T[w]=Y}}function C(_,I,D,N,A){if(_.length===0){delete I.eq,I.properties={};return}const h=me(I,_,D,N,A);if(!h)return;const[w,F]=h,T=le(F),M=T[w];M!==void 0&&!(0,u.isRef)(M)?(delete M.eq,M.properties={}):T[w]={}}function j(_,I,D,N,A){const h=me(I,_,D,N,A);if(!h)return;const[w,F]=h,T=le(F);if(T[w]===void 0){const M={};M.location=Re(D,N),T[w]=M}}function he(_,I,D,N,A){const h=me(I,_,D,N,A);if(!h)return;const[w,F]=h,T={deleted:!0};T.location=Re(D,N),le(F)[w]=T}function $e(_,I,D,N,A,h,w){A.options.disableReferences&&w.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:h.begin,end:h.end});const F=me(N,_,A,h,w);if(!F)return;const[T,M]=F;le(M)[T]=U(I,D)}function Se(_,I,D,N,A,h,w,F){const T=me(N,_,A,h,w);if(!T)return;const[M,Y]=T;let we;try{we=ee(N,_,I,D)}catch(Le){if((0,u.isMotlyError)(Le)){const Qe=w.length;w.push(Le),F.push({sourcePath:f(_),targetPath:d(_,I,D),errorIndex:Qe})}return}ce(we,0,w),we.location=Re(A,h),le(Y)[M]=we}function Re(_,I){return{parseId:_.parseId,begin:I.begin,end:I.end}}function ke(_,I,D){_.location||(_.location=Re(I,D))}function me(_,I,D,N,A){let h=_;for(let w=0;w<I.length-1;w++){const F=I[w],T=le(h);if(T[F]!==void 0&&(0,u.isRef)(T[F]))return A.push({code:"write-through-link",message:`Cannot write through link reference "${F}"`,begin:N.begin,end:N.end}),null;if(T[F]===void 0){const M={};M.location=Re(D,N),T[F]=M}h=ve(T,F),ke(h,D,N)}return[I[I.length-1],h]}function P(_,I,D,N){if(I.kind==="array")_.eq=W(I.elements,N,D);else{const A=I.value;switch(A.kind){case"string":_.eq=A.value;break;case"number":_.eq=A.value;break;case"boolean":_.eq=A.value;break;case"date":_.eq=new Date(A.value);break;case"reference":throw new Error("References should be handled before calling setEqSlot");case"env":_.eq={env:A.name};break;case"none":delete _.eq;break}}}function W(_,I,D){return _.map(N=>z(N,I,D))}function z(_,I,D){if(_.value!==null&&_.value.kind==="scalar"&&_.value.value.kind==="reference"){if(D.options.disableReferences&&I.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:_.span.begin,end:_.span.end}),_.properties!==null){const A={line:0,column:0,offset:0};I.push({code:"ref-with-properties",message:"Cannot add properties to a reference. Did you mean := (clone)?",begin:A,end:A})}return U(_.value.value.ups,_.value.value.path)}const N={};if(N.location=Re(D,_.span),_.value!==null&&P(N,_.value,D,I),_.properties!==null){const A=B(_.properties,D),{splits:h,deps:w}=l(A),{order:F}=y(w);I.push(...k(A,h,F,N,D.options))}return N}function U(_,I){return{linkTo:I.map(D=>D.kind==="name"?D.name:D.index),linkUps:_}}function G(_,I){let D="$";for(let A=0;A<_;A++)D+="^";let N=!0;for(const A of I)A.kind==="name"?((!N||_>0)&&(D+="."),D+=A.name,N=!1):D+=`[${A.index}]`;return D}function ee(_,I,D,N){const A=G(D,N);let h;if(D===0)h=_;else{const F=I.length-1-D;if(F<0)throw ne(`Clone reference ${A} goes ${D} level(s) up but only ${I.length-1} ancestor(s) available`);h=_;for(let T=0;T<F;T++){if(!h.properties)throw ne(`Clone reference ${A} could not be resolved: path segment "${I[T]}" not found`);const M=h.properties[I[T]];if(M===void 0)throw ne(`Clone reference ${A} could not be resolved: path segment "${I[T]}" not found`);if((0,u.isRef)(M)){const Y=te(_,M);if(!Y)throw ne(`Clone reference ${A} could not be resolved: path segment "${I[T]}" is an unresolvable link reference`);h=Y;continue}h=M}}let w=h;for(const F of N)if(F.kind==="name"){if(!w.properties)throw ne(`Clone reference ${A} could not be resolved: property "${F.name}" not found`);const T=w.properties[F.name];if(T===void 0)throw ne(`Clone reference ${A} could not be resolved: property "${F.name}" not found`);if((0,u.isRef)(T)){const M=te(_,T);if(!M)throw ne(`Clone reference ${A} could not be resolved: property "${F.name}" is an unresolvable link reference`);w=M;continue}w=T}else{if(!w.eq||!Array.isArray(w.eq))throw ne(`Clone reference ${A} could not be resolved: index [${F.index}] used on non-array`);if(F.index>=w.eq.length)throw ne(`Clone reference ${A} could not be resolved: index [${F.index}] out of bounds (array length ${w.eq.length})`);const T=w.eq[F.index];if((0,u.isRef)(T)){const M=te(_,T);if(!M)throw ne(`Clone reference ${A} could not be resolved: index [${F.index}] is an unresolvable link reference`);w=M;continue}w=T}return(0,Q.cloneNode)(w)}function ne(_){const I={line:0,column:0,offset:0};return{code:"unresolved-clone-reference",message:_,begin:I,end:I}}function te(_,I,D){D||(D=new Set);const N=(0,u.formatRef)(I);if(D.has(N)||(D.add(N),I.linkUps>0))return null;let A=_;for(const h of I.linkTo){if(A===void 0)return null;if((0,u.isRef)(A)){const F=te(_,A,D);if(!F)return null;A=F}if(!(0,u.isDataNode)(A))return null;const w=A;if(typeof h=="string"){if(!w.properties||!(h in w.properties))return null;A=w.properties[h]}else{if(!w.eq||!Array.isArray(w.eq)||h>=w.eq.length)return null;A=w.eq[h]}}return A!==void 0&&(0,u.isRef)(A)?te(_,A,D):A??null}function ce(_,I,D){if(_.eq!==void 0&&Array.isArray(_.eq))for(let N=0;N<_.eq.length;N++)be(_.eq,N,I+1,D);if(_.properties)for(const N of Object.keys(_.properties))ye(_.properties,N,I+1,D)}function be(_,I,D,N){const A=_[I];if((0,u.isRef)(A)){if(A.linkUps>0&&A.linkUps>D){const h={line:0,column:0,offset:0};N.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,u.formatRef)(A)}" escapes the clone boundary (${A.linkUps} level(s) up from depth ${D})`,begin:h,end:h}),_[I]={}}}else ce(A,D,N)}function ye(_,I,D,N){const A=_[I];if((0,u.isRef)(A)){if(A.linkUps>0&&A.linkUps>D){const h={line:0,column:0,offset:0};N.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,u.formatRef)(A)}" escapes the clone boundary (${A.linkUps} level(s) up from depth ${D})`,begin:h,end:h}),_[I]={}}}else ce(A,D,N)}function le(_){return _.properties||(_.properties={}),_.properties}function ve(_,I){const D=_[I];if((0,u.isRef)(D)){const N={};return _[I]=N,N}return D}return xt}var Yt={},nn;function Ji(){if(nn)return Yt;nn=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.validateReferences=B,Yt.validateSchema=d;const u=Mt();function Q(P,W,z,U,G){const ee={code:W,message:z,path:U};G?.location&&(ee.location=G.location),P.push(ee)}function B(P){const W=[];return V(P,[],[P],P,W),W}function V(P,W,z,U,G){if(P.eq!==void 0&&Array.isArray(P.eq)&&g(P.eq,W,z,P,U,G),P.properties)for(const ee of Object.keys(P.properties)){const ne=P.properties[ee];if(W.push(ee),(0,u.isRef)(ne)){const te=l(ne,z,U);if(te!==null){const ce={message:te,path:[...W],code:"unresolved-reference"};P.location&&(ce.location=P.location),G.push(ce)}}else z.push(P),V(ne,W,z,U,G),z.pop();W.pop()}}function g(P,W,z,U,G,ee){for(let ne=0;ne<P.length;ne++){const te=P[ne],ce=`[${ne}]`;if(W.push(ce),(0,u.isRef)(te)){const be=l(te,z,G);be!==null&&ee.push({message:be,path:[...W],code:"unresolved-reference"})}else z.push(U),V(te,W,z,G,ee),z.pop();W.pop()}}function l(P,W,z){const U=(0,u.formatRef)(P);let G;if(P.linkUps===0)G=z;else{const ee=W.length-P.linkUps;if(ee<0||ee>=W.length)return`Reference "${U}" goes ${P.linkUps} level(s) up but only ${W.length} ancestor(s) available`;G=W[ee]}return f(G,P.linkTo,U)}function f(P,W,z){let U=P;for(const G of W){if(U==="terminal")return`Reference "${z}" could not be resolved: cannot follow path through a link`;if(typeof G=="string"){if(!U.properties)return`Reference "${z}" could not be resolved: property "${G}" not found (node has no properties)`;const ee=U.properties[G];if(ee===void 0)return`Reference "${z}" could not be resolved: property "${G}" not found`;(0,u.isRef)(ee)?U="terminal":U=ee}else{if(U.eq===void 0||!Array.isArray(U.eq))return`Reference "${z}" could not be resolved: index [${G}] used on non-array`;if(G>=U.eq.length)return`Reference "${z}" could not be resolved: index [${G}] out of bounds (array length ${U.eq.length})`;const ee=U.eq[G];(0,u.isRef)(ee)?U="terminal":U=ee}}return null}const c=64,s={string:{properties:{VALUE:{eq:"string"}}},number:{properties:{VALUE:{eq:"number"}}},integer:{properties:{VALUE:{eq:"integer"}}},boolean:{properties:{VALUE:{eq:"boolean"}}},date:{properties:{VALUE:{eq:"date"}}},flag:{properties:{ADDITIONAL:{eq:"reject"}}},tag:{properties:{ADDITIONAL:{eq:"accept"}}},any:{properties:{ADDITIONAL:{eq:"accept"}}}};function d(P,W){const z=[],U=e(W,z);return k(P,W,U,[],z,0),z}function e(P,W){const z={...s},U=y(P,"TYPES");if(U?.properties){for(const[G,ee]of Object.entries(U.properties))if(!(0,u.isRef)(ee)){if(G in s){W.push({message:`Type "${G}" cannot shadow pre-loaded type`,path:["TYPES",G],code:"invalid-schema"});continue}z[G]=ee}}return z}function y(P,W){if(!P.properties)return;const z=P.properties[W];if(!(z===void 0||(0,u.isRef)(z)))return z}function k(P,W,z,U,G,ee){if(ee>c){Q(G,"invalid-schema","Maximum validation depth exceeded (possible recursive type cycle)",[...U],P);return}const ne=y(W,"ONEOF");if(ne&&Array.isArray(ne.eq)){Re(P,ne.eq,z,U,G,ee);return}const te=y(W,"VALUE");te&&x(P,te,z,U,G),j(P,W,z,U,G,ee)}function x(P,W,z,U,G,ee){const ne=typeof W.eq=="string"?W.eq:void 0;if(!ne)return;const te=P.eq;switch(ne){case"string":if(typeof te!="string"){Q(G,"wrong-type",`Expected string, got ${H(te)}`,[...U],P);return}ae(te,W,U,G,P);break;case"number":if(typeof te!="number"){Q(G,"wrong-type",`Expected number, got ${H(te)}`,[...U],P);return}q(te,W,U,G,P);break;case"integer":if(typeof te!="number"||!Number.isInteger(te)){Q(G,"wrong-type",`Expected integer, got ${H(te)}`,[...U],P);return}q(te,W,U,G,P);break;case"boolean":if(typeof te!="boolean"){Q(G,"wrong-type",`Expected boolean, got ${H(te)}`,[...U],P);return}E(te,W,U,G,P);break;case"date":if(!(te instanceof Date)){Q(G,"wrong-type",`Expected date, got ${H(te)}`,[...U],P);return}E(te,W,U,G,P);break;default:{const ce=z[ne];if(!ce){Q(G,"invalid-schema",`Unknown VALUE type "${ne}"`,[...U],P);return}const be=y(ce,"VALUE");if(!be){Q(G,"invalid-schema",`Type "${ne}" cannot be used as a VALUE type (no VALUE constraint)`,[...U],P);return}x(P,be,z,U,G)}}}function H(P){return P===void 0?"no value":P instanceof Date?`date ${P.toISOString()}`:Array.isArray(P)?"array":typeof P=="string"?`string ${JSON.stringify(P)}`:typeof P=="number"||typeof P=="boolean"?`${typeof P} ${P}`:typeof P}function ae(P,W,z,U,G){E(P,W,z,U,G);const ee=y(W,"MATCHES");if(ee&&typeof ee.eq=="string")try{new RegExp(ee.eq).test(P)||Q(U,"pattern-mismatch",`Value "${P}" does not match pattern "${ee.eq}"`,[...z],G)}catch(ce){Q(U,"invalid-schema",`Invalid regex pattern "${ee.eq}": ${ce}`,[...z],G)}const ne=y(W,"MIN_LENGTH");ne&&typeof ne.eq=="number"&&P.length<ne.eq&&Q(U,"length-violation",`String length ${P.length} is less than minimum ${ne.eq}`,[...z],G);const te=y(W,"MAX_LENGTH");te&&typeof te.eq=="number"&&P.length>te.eq&&Q(U,"length-violation",`String length ${P.length} exceeds maximum ${te.eq}`,[...z],G)}function q(P,W,z,U,G){E(P,W,z,U,G);const ee=y(W,"MIN");ee&&typeof ee.eq=="number"&&P<ee.eq&&Q(U,"out-of-range",`Value ${P} is less than minimum ${ee.eq}`,[...z],G);const ne=y(W,"MAX");ne&&typeof ne.eq=="number"&&P>ne.eq&&Q(U,"out-of-range",`Value ${P} exceeds maximum ${ne.eq}`,[...z],G)}function E(P,W,z,U,G){const ee=y(W,"ENUM");if(!ee||!Array.isArray(ee.eq))return;if(!ee.eq.some(te=>{if((0,u.isRef)(te))return!1;const ce=te.eq;return ce instanceof Date&&P instanceof Date?ce.getTime()===P.getTime():ce===P})){const te=ee.eq.filter(ce=>!(0,u.isRef)(ce)).map(ce=>String(ce.eq));Q(U,"invalid-enum-value",`${H(P)} is not one of: [${te.join(", ")}]`,[...z],G)}}function C(P){if(!P.properties)return{kind:"reject"};const W=P.properties.ADDITIONAL;return W===void 0?{kind:"reject"}:(0,u.isRef)(W)?{kind:"reject"}:typeof W.eq=="string"?W.eq==="reject"?{kind:"reject"}:W.eq==="accept"?{kind:"accept"}:{kind:"type",typeName:W.eq}:W.properties&&Object.keys(W.properties).some(U=>U==="VALUE"||U==="REQUIRED"||U==="OPTIONAL"||U==="ADDITIONAL"||U==="ONEOF")?{kind:"inline",constraint:W}:{kind:"accept"}}function j(P,W,z,U,G,ee){const ne=y(W,"REQUIRED")?.properties,te=y(W,"OPTIONAL")?.properties,ce=C(W),be=P.properties;if(ne)for(const[ye,le]of Object.entries(ne)){if((0,u.isRef)(le))continue;const ve=[...U,ye],_=be?.[ye];_===void 0?Q(G,"missing-required",`Missing required property "${ye}"`,ve,P):he(_,le,z,ve,G,ee)}if(te&&be)for(const[ye,le]of Object.entries(te)){if((0,u.isRef)(le))continue;const ve=be[ye];ve!==void 0&&he(ve,le,z,[...U,ye],G,ee)}if(be){const ye=new Set;if(ne)for(const le of Object.keys(ne))ye.add(le);if(te)for(const le of Object.keys(te))ye.add(le);for(const le of Object.keys(be)){if(ye.has(le))continue;const ve=[...U,le];switch(ce.kind){case"reject":{const _=be[le];Q(G,"unknown-property",`Unknown property "${le}"`,ve,(0,u.isRef)(_)?void 0:_);break}case"accept":break;case"type":he(be[le],{eq:ce.typeName},z,ve,G,ee);break;case"inline":{const _=be[le];(0,u.isRef)(_)?Q(G,"wrong-type",`Expected a value but found a link ${(0,u.formatRef)(_)}`,ve):k(_,ce.constraint,z,ve,G,ee+1);break}}}}ke(ne,te,be,U,G),me(ne,te,be,U,G)}function he(P,W,z,U,G,ee){if((0,u.isRef)(P)){Q(G,"wrong-type",`Expected a value but found a link ${(0,u.formatRef)(P)}`,[...U]);return}const ne=typeof W.eq=="string"?W.eq:void 0;if(ne){$e(P,ne,z,U,G,ee);return}k(P,W,z,U,G,ee+1)}function $e(P,W,z,U,G,ee){if(W.endsWith("[]")){Se(P,W.slice(0,-2),z,U,G,ee);return}const ne=z[W];if(!ne){Q(G,"invalid-schema",`Unknown type "${W}" in schema`,[...U],P);return}if(Array.isArray(ne.eq)){Re(P,ne.eq,z,U,G,ee);return}k(P,ne,z,U,G,ee+1)}function Se(P,W,z,U,G,ee){if(!Array.isArray(P.eq)){Q(G,"wrong-type",`Expected ${W}[], got ${H(P.eq)}`,[...U],P);return}for(let ne=0;ne<P.eq.length;ne++){const te=[...U,`[${ne}]`],ce=P.eq[ne];(0,u.isRef)(ce)?Q(G,"wrong-type",`Expected ${W}, got link ${(0,u.formatRef)(ce)}`,te):$e(ce,W,z,te,G,ee)}}function Re(P,W,z,U,G,ee){const ne=[];let te,ce;for(const ye of W){if((0,u.isRef)(ye))continue;const le=typeof ye.eq=="string"?ye.eq:void 0;if(!le)continue;ne.push(le);const ve=[];if($e(P,le,z,U,ve,ee),ve.length===0)return;(!te||ve.length<te.length)&&(te=ve,ce=le)}let be=`Value does not match any type in oneOf: [${ne.join(", ")}]`;if(te&&te.length>0&&ne.length>1){const ye=te.map(le=>le.message).join("; ");be+=`. Closest match "${ce}": ${ye}`}Q(G,"wrong-type",be,[...U],P)}function ke(P,W,z,U,G){if(!z)return;const ee={};function ne(te){if(te)for(const[ce,be]of Object.entries(te)){if((0,u.isRef)(be))continue;const ye=y(be,"EXCLUSIVE");if(!ye)continue;let le;if(typeof ye.eq=="string")le=[ye.eq];else if(Array.isArray(ye.eq))le=ye.eq.filter(ve=>!(0,u.isRef)(ve)).map(ve=>String(ve.eq));else continue;for(const ve of le)ee[ve]||(ee[ve]=[]),ee[ve].push(ce)}}ne(P),ne(W);for(const[te,ce]of Object.entries(ee)){const be=ce.filter(ye=>z[ye]!==void 0);be.length>1&&Q(G,"exclusive-violation",`Properties [${be.join(", ")}] are mutually exclusive (group "${te}")`,[...U])}}function me(P,W,z,U,G){if(!z)return;function ee(ne){if(ne)for(const[te,ce]of Object.entries(ne)){if((0,u.isRef)(ce)||z[te]===void 0)continue;const be=y(ce,"REQUIRES");if(!(!be||!Array.isArray(be.eq)))for(const ye of be.eq){if((0,u.isRef)(ye))continue;const le=typeof ye.eq=="string"?ye.eq:void 0;le&&z[le]===void 0&&Q(G,"requires-violation",`Property "${te}" requires "${le}" to be present`,[...U,te])}}}ee(P),ee(W)}return Yt}var sn;function Xi(){if(sn)return mt;sn=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.MOTLYSchema=mt.MOTLYResult=mt.MOTLYSession=void 0;const u=Mt(),Q=Hi(),B=Ki(),V=Ji(),g=_n(),l=wn();class f{constructor(e){this.accumulated=[],this.nextParseId=0,this.finished=!1,this.disposed=!1,this.options=e??{}}parse(e){if(this.ensureAlive(),this.finished)throw new Error("MOTLYSession is spent after finish() — create a new session");const y=this.nextParseId++;try{const k=(0,Q.parse)(e);return this.accumulated.push({stmts:k,parseId:y}),{parseId:y,errors:[]}}catch(k){if((0,u.isMotlyError)(k))return{parseId:y,errors:[k]};throw k}}finish(){if(this.ensureAlive(),this.finished)throw new Error("finish() has already been called on this session");this.finished=!0;const e=[],y={},k=[];for(const{stmts:E,parseId:C}of this.accumulated){const j={parseId:C,options:{disableReferences:this.options.disableReferences}};k.push(...(0,B.flatten)(E,j))}const{splits:x,deps:H}=(0,B.chunk)(k),{order:ae}=(0,B.topoSort)(H),q=(0,B.executeChunked)(k,x,ae,y,this.options);if(e.push(...q),!this.options.disableReferences){const E=(0,V.validateReferences)(y);for(const C of E)e.push({code:C.code,message:C.message,begin:{line:0,column:0,offset:0},end:{line:0,column:0,offset:0}})}return new c(y,e)}dispose(){this.disposed=!0}ensureAlive(){if(this.disposed)throw new Error("MOTLYSession has been disposed")}}mt.MOTLYSession=f;class c{constructor(e,y){this.value=e,this.errors=y}getValue(){return(0,g.cloneNode)(this.value)}getMot(e){return(0,l.buildMot)(this.value,e)}}mt.MOTLYResult=c;class s{constructor(e){this.tree=e}static parse(e){const y={disableReferences:!0},k={parseId:0,options:y};try{const x=(0,Q.parse)(e),H={},ae=(0,B.flatten)(x,k),{splits:q,deps:E}=(0,B.chunk)(ae),{order:C}=(0,B.topoSort)(E),j=(0,B.executeChunked)(ae,q,C,H,y);return{schema:new s(H),errors:j}}catch(x){if((0,u.isMotlyError)(x))return{schema:new s({}),errors:[x]};throw x}}validate(e){return(0,V.validateSchema)(e,this.tree)}}return mt.MOTLYSchema=s,mt}var an;function Zi(){return an||(an=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.MOTLYSchema=u.MOTLYResult=u.MOTLYSession=u.MotValue=u.Mot=u.formatRef=u.isMotlyError=u.isEnvRef=u.isDataNode=u.isRef=void 0;var Q=Mt();Object.defineProperty(u,"isRef",{enumerable:!0,get:function(){return Q.isRef}}),Object.defineProperty(u,"isDataNode",{enumerable:!0,get:function(){return Q.isDataNode}}),Object.defineProperty(u,"isEnvRef",{enumerable:!0,get:function(){return Q.isEnvRef}}),Object.defineProperty(u,"isMotlyError",{enumerable:!0,get:function(){return Q.isMotlyError}}),Object.defineProperty(u,"formatRef",{enumerable:!0,get:function(){return Q.formatRef}});var B=wn();Object.defineProperty(u,"Mot",{enumerable:!0,get:function(){return B.Mot}}),Object.defineProperty(u,"MotValue",{enumerable:!0,get:function(){return B.MotValue}});var V=Xi();Object.defineProperty(u,"MOTLYSession",{enumerable:!0,get:function(){return V.MOTLYSession}}),Object.defineProperty(u,"MOTLYResult",{enumerable:!0,get:function(){return V.MOTLYResult}}),Object.defineProperty(u,"MOTLYSchema",{enumerable:!0,get:function(){return V.MOTLYSchema}})})(qr)),qr}var on;function es(){if(on)return Ct;on=1;var u={};Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.TagParser=void 0,Ct.parseTag=s,Ct.parseAnnotation=d;const Q=Zi(),B=vn();function V(e){const y=e.search(/[ \t\r\n]/);return y>0?e.slice(y):""}function g(e){return{code:e.code,message:e.message,line:e.begin.line,offset:e.begin.column}}function l(e,y){const k=y.get(e.parseId);if(k)return{url:k.url,range:{start:{line:k.startLine+e.begin.line,character:e.begin.line===0?k.startColumn+e.begin.column:e.begin.column},end:{line:k.startLine+e.end.line,character:e.end.line===0?k.startColumn+e.end.column:e.end.column}}}}function f(e,y,k){if((0,Q.isRef)(e))return new B.Tag({deleted:!0},y);const x=new B.Tag({},y);if(e.location&&k&&(x.location=l(e.location,k)),e.eq!==void 0)if(Array.isArray(e.eq))x.eq=e.eq.map(H=>f(H,x,k));else if((0,Q.isEnvRef)(e.eq)){const H=u[e.eq.env];H!==void 0&&(x.eq=H)}else e.eq instanceof Date?x.eq=new Date(e.eq):x.eq=e.eq;if(e.properties!==void 0){x.properties={};for(const[H,ae]of Object.entries(e.properties))x.properties[H]=f(ae,x,k)}return e.deleted&&(x.deleted=!0),x}class c{constructor(){this.origins=new Map,this.session=new Q.MOTLYSession}parse(y,k){return this.parseSource(y,0,k)}parseAnnotation(y,k){const x=V(y),H=y.length-x.length;return this.parseSource(x,H,k)}parseSource(y,k,x){const{parseId:H,errors:ae}=this.session.parse(y);x&&this.origins.set(H,{url:x.url,startLine:x.startLine,startColumn:x.startColumn+k});const q=ae.map(g);return{tag:new B.Tag,log:q}}finish(){const k=this.session.finish().getValue();return this.session.dispose(),f(k,void 0,this.origins)}}Ct.TagParser=c;function s(e){const y=new c;if(typeof e=="string"){const{log:x}=y.parse(e);return{tag:y.finish(),log:x}}const k=[];for(let x=0;x<e.length;x++){const H=y.parse(e[x]);for(const ae of H.log)k.push({...ae,line:x+ae.line})}return{tag:y.finish(),log:k}}function d(e){const y=new c;if(typeof e=="string"){const{log:x}=y.parseAnnotation(e);return{tag:y.finish(),log:x}}const k=[];for(let x=0;x<e.length;x++){const H=y.parseAnnotation(e[x]);for(const ae of H.log)k.push({...ae,line:x+ae.line})}return{tag:y.finish(),log:k}}return Ct}var ar={},ln;function ts(){if(ln)return ar;ln=1,Object.defineProperty(ar,"__esModule",{value:!0}),ar.parseString=Q;var u;(function(B){B[B.Normal=0]="Normal",B[B.ReverseVirgule=1]="ReverseVirgule",B[B.Unicode=2]="Unicode"})(u||(u={}));function Q(B,V=""){let g=B.slice(V.length),l=u.Normal;V.length&&(g=g.slice(0,-V.length));let f="",c="";for(const s of g)switch(l){case u.Normal:{s==="\\"?l=u.ReverseVirgule:f+=s;break}case u.ReverseVirgule:{let d=s;if(s==="u"){l=u.Unicode,c="";continue}s==="b"?d="\b":s==="f"?d="\f":s==="n"?d=`
39
- `:s==="r"?d="\r":s==="t"&&(d=" "),f+=d,l=u.Normal;break}case u.Unicode:"ABCDEFabcdef0123456789".includes(s)?(c+=s,c.length===4&&(f+=String.fromCharCode(parseInt(c,16)),l=u.Normal)):l=u.Normal}return f}return ar}var fn;function rs(){return fn||(fn=1,(function(u){var Q=pt&&pt.__createBinding||(Object.create?(function(f,c,s,d){d===void 0&&(d=s);var e=Object.getOwnPropertyDescriptor(c,s);(!e||("get"in e?!c.__esModule:e.writable||e.configurable))&&(e={enumerable:!0,get:function(){return c[s]}}),Object.defineProperty(f,d,e)}):(function(f,c,s,d){d===void 0&&(d=s),f[d]=c[s]})),B=pt&&pt.__setModuleDefault||(Object.create?(function(f,c){Object.defineProperty(f,"default",{enumerable:!0,value:c})}):function(f,c){f.default=c}),V=pt&&pt.__exportStar||function(f,c){for(var s in f)s!=="default"&&!Object.prototype.hasOwnProperty.call(c,s)&&Q(c,f,s)},g=pt&&pt.__importStar||(function(){var f=function(c){return f=Object.getOwnPropertyNames||function(s){var d=[];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(d[d.length]=e);return d},f(c)};return function(c){if(c&&c.__esModule)return c;var s={};if(c!=null)for(var d=f(c),e=0;e<d.length;e++)d[e]!=="default"&&Q(s,c,d[e]);return B(s,c),s}})();Object.defineProperty(u,"__esModule",{value:!0}),u.ParseUtil=u.TagParser=u.parseAnnotation=u.parseTag=void 0,V(vn(),u);var l=es();Object.defineProperty(u,"parseTag",{enumerable:!0,get:function(){return l.parseTag}}),Object.defineProperty(u,"parseAnnotation",{enumerable:!0,get:function(){return l.parseAnnotation}}),Object.defineProperty(u,"TagParser",{enumerable:!0,get:function(){return l.TagParser}}),u.ParseUtil=g(ts())})(pt)),pt}var Pt={},Ht={},un;function An(){return un||(un=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.MALLOY_INTERFACE_TYPES=void 0,Ht.MALLOY_INTERFACE_TYPES={Aggregate:{type:"struct",name:"Aggregate",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},Annotation:{type:"struct",name:"Annotation",fields:{value:{type:"string",optional:!1,array:!1}}},AnonymousQueryInfo:{type:"struct",name:"AnonymousQueryInfo",fields:{schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},ArrayCell:{type:"struct",name:"ArrayCell",fields:{array_value:{type:"Cell",array:!0,optional:!1}}},ArrayType:{type:"struct",name:"ArrayType",fields:{element_type:{type:"AtomicType",optional:!1,array:!1}}},AtomicType:{type:"union",name:"AtomicType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",timestamptz_type:"TimestamptzType"}},BooleanCell:{type:"struct",name:"BooleanCell",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanLiteral:{type:"struct",name:"BooleanLiteral",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanType:{type:"struct",name:"BooleanType",fields:{}},CalculateInfo:{type:"struct",name:"CalculateInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},CalculateOperation:{type:"struct",name:"CalculateOperation",fields:{name:{type:"string",optional:!1,array:!1},field:{type:"Field",optional:!1,array:!1}}},Cell:{type:"union",name:"Cell",options:{string_cell:"StringCell",boolean_cell:"BooleanCell",date_cell:"DateCell",timestamp_cell:"TimestampCell",number_cell:"NumberCell",json_cell:"JSONCell",record_cell:"RecordCell",array_cell:"ArrayCell",null_cell:"NullCell",sql_native_cell:"SQLNativeCell"}},CompileModelRequest:{type:"struct",name:"CompileModelRequest",fields:{model_url:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileModelResponse:{type:"struct",name:"CompileModelResponse",fields:{model:{type:"ModelInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileQueryRequest:{type:"struct",name:"CompileQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileQueryResponse:{type:"struct",name:"CompileQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileSourceRequest:{type:"struct",name:"CompileSourceRequest",fields:{model_url:{type:"string",optional:!1,array:!1},name:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileSourceResponse:{type:"struct",name:"CompileSourceResponse",fields:{source:{type:"SourceInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompilerNeeds:{type:"struct",name:"CompilerNeeds",fields:{table_schemas:{type:"SQLTable",array:!0,optional:!0},sql_schemas:{type:"SQLQuery",array:!0,optional:!0},files:{type:"File",array:!0,optional:!0},connections:{type:"Connection",array:!0,optional:!0},translations:{type:"Translation",array:!0,optional:!0}}},Connection:{type:"struct",name:"Connection",fields:{name:{type:"string",optional:!1,array:!1},dialect:{type:"string",optional:!0,array:!1}}},Data:{type:"union",name:"Data",options:{record_cell:"RecordCell",array_cell:"ArrayCell"}},DateCell:{type:"struct",name:"DateCell",fields:{date_value:{type:"string",optional:!1,array:!1}}},DateLiteral:{type:"struct",name:"DateLiteral",fields:{date_value:{type:"string",optional:!1,array:!1},granularity:{type:"DateTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},DateTimeframe:{type:"enum",name:"DateTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5}},DateType:{type:"struct",name:"DateType",fields:{timeframe:{type:"DateTimeframe",optional:!0,array:!1}}},DimensionInfo:{type:"struct",name:"DimensionInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},DocumentPosition:{type:"struct",name:"DocumentPosition",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},DocumentRange:{type:"struct",name:"DocumentRange",fields:{start:{type:"DocumentPosition",optional:!1,array:!1},end:{type:"DocumentPosition",optional:!1,array:!1}}},DrillOperation:{type:"struct",name:"DrillOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},Expression:{type:"union",name:"Expression",options:{field_reference:"Reference",time_truncation:"TimeTruncationFieldReference",filtered_field:"FilteredField",literal_value:"LiteralValueExpression",moving_average:"MovingAverage"}},Field:{type:"struct",name:"Field",fields:{expression:{type:"Expression",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},FieldInfo:{type:"union",name:"FieldInfo",options:{dimension:"DimensionInfo",measure:"MeasureInfo",join:"JoinInfo",view:"ViewInfo",calculate:"CalculateInfo"}},File:{type:"struct",name:"File",fields:{url:{type:"string",optional:!1,array:!1},contents:{type:"string",optional:!0,array:!1},invalidation_key:{type:"string",optional:!0,array:!1}}},Filter:{type:"union",name:"Filter",options:{filter_string:"FilterStringApplication",literal_equality:"LiteralEqualityComparison"}},FilterExpressionLiteral:{type:"struct",name:"FilterExpressionLiteral",fields:{filter_expression_value:{type:"string",optional:!1,array:!1}}},FilterExpressionType:{type:"struct",name:"FilterExpressionType",fields:{filter_type:{type:"FilterableType",optional:!1,array:!1}}},FilterOperation:{type:"struct",name:"FilterOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},FilterStringApplication:{type:"struct",name:"FilterStringApplication",fields:{expression:{type:"Expression",optional:!1,array:!1},filter:{type:"string",optional:!1,array:!1}}},FilterableType:{type:"union",name:"FilterableType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",date_type:"DateType",timestamp_type:"TimestampType",timestamptz_type:"TimestamptzType"}},FilteredField:{type:"struct",name:"FilteredField",fields:{field_reference:{type:"Reference",optional:!1,array:!1},where:{type:"FilterOperation",array:!0,optional:!1}}},GroupBy:{type:"struct",name:"GroupBy",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},JSONCell:{type:"struct",name:"JSONCell",fields:{json_value:{type:"string",optional:!1,array:!1}}},JSONType:{type:"struct",name:"JSONType",fields:{}},JoinInfo:{type:"struct",name:"JoinInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},relationship:{type:"Relationship",optional:!1,array:!1}}},Limit:{type:"struct",name:"Limit",fields:{limit:{type:"number",optional:!1,array:!1}}},LiteralEqualityComparison:{type:"struct",name:"LiteralEqualityComparison",fields:{expression:{type:"Expression",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},LiteralValue:{type:"union",name:"LiteralValue",options:{string_literal:"StringLiteral",number_literal:"NumberLiteral",date_literal:"DateLiteral",timestamp_literal:"TimestampLiteral",boolean_literal:"BooleanLiteral",null_literal:"NullLiteral",filter_expression_literal:"FilterExpressionLiteral"}},LiteralValueExpression:{type:"struct",name:"LiteralValueExpression",fields:{literal_value:{type:"LiteralValue",optional:!1,array:!1}}},Location:{type:"struct",name:"Location",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"Range",optional:!1,array:!1}}},LogMessage:{type:"struct",name:"LogMessage",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"DocumentRange",optional:!1,array:!1},severity:{type:"LogSeverity",optional:!1,array:!1},message:{type:"string",optional:!1,array:!1}}},LogSeverity:{type:"enum",name:"LogSeverity",values:{debug:1,info:2,warn:3,error:4}},MeasureInfo:{type:"struct",name:"MeasureInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ModelEntryValue:{type:"union",name:"ModelEntryValue",options:{source:"SourceInfo",query:"QueryInfo"}},ModelInfo:{type:"struct",name:"ModelInfo",fields:{entries:{type:"ModelEntryValue",array:!0,optional:!1},annotations:{type:"Annotation",array:!0,optional:!0},anonymous_queries:{type:"AnonymousQueryInfo",array:!0,optional:!1}}},MovingAverage:{type:"struct",name:"MovingAverage",fields:{field_reference:{type:"Reference",optional:!1,array:!1},rows_preceding:{type:"number",optional:!0,array:!1},rows_following:{type:"number",optional:!0,array:!1},partition_fields:{type:"Reference",array:!0,optional:!0}}},Nest:{type:"struct",name:"Nest",fields:{name:{type:"string",optional:!0,array:!1},view:{type:"View",optional:!1,array:!1}}},NullCell:{type:"struct",name:"NullCell",fields:{}},NullLiteral:{type:"struct",name:"NullLiteral",fields:{}},NumberCell:{type:"struct",name:"NumberCell",fields:{number_value:{type:"number",optional:!1,array:!1},subtype:{type:"NumberSubtype",optional:!0,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberLiteral:{type:"struct",name:"NumberLiteral",fields:{number_value:{type:"number",optional:!1,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberSubtype:{type:"enum",name:"NumberSubtype",values:{integer:1,decimal:2,bigint:3}},NumberType:{type:"struct",name:"NumberType",fields:{subtype:{type:"NumberSubtype",optional:!0,array:!1}}},OrderBy:{type:"struct",name:"OrderBy",fields:{field_reference:{type:"Reference",optional:!1,array:!1},direction:{type:"OrderByDirection",optional:!0,array:!1}}},OrderByDirection:{type:"enum",name:"OrderByDirection",values:{asc:1,desc:2}},ParameterInfo:{type:"struct",name:"ParameterInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"ParameterType",optional:!1,array:!1},default_value:{type:"LiteralValue",optional:!0,array:!1}}},ParameterType:{type:"union",name:"ParameterType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",filter_expression_type:"FilterExpressionType",timestamptz_type:"TimestamptzType"}},ParameterValue:{type:"struct",name:"ParameterValue",fields:{name:{type:"string",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},Position:{type:"struct",name:"Position",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},Query:{type:"struct",name:"Query",fields:{definition:{type:"QueryDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},QueryArrow:{type:"struct",name:"QueryArrow",fields:{source:{type:"QueryArrowSource",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},QueryArrowSource:{type:"union",name:"QueryArrowSource",options:{refinement:"QueryRefinement",source_reference:"Reference"}},QueryDefinition:{type:"union",name:"QueryDefinition",options:{arrow:"QueryArrow",query_reference:"Reference",refinement:"QueryRefinement"}},QueryInfo:{type:"struct",name:"QueryInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},QueryRefinement:{type:"struct",name:"QueryRefinement",fields:{base:{type:"QueryDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},Range:{type:"struct",name:"Range",fields:{start:{type:"Position",optional:!1,array:!1},end:{type:"Position",optional:!1,array:!1}}},RecordCell:{type:"struct",name:"RecordCell",fields:{record_value:{type:"Cell",array:!0,optional:!1}}},RecordType:{type:"struct",name:"RecordType",fields:{fields:{type:"DimensionInfo",array:!0,optional:!1}}},Reference:{type:"struct",name:"Reference",fields:{name:{type:"string",optional:!1,array:!1},path:{type:"string",array:!0,optional:!0},parameters:{type:"ParameterValue",array:!0,optional:!0}}},Relationship:{type:"enum",name:"Relationship",values:{one:1,many:2,cross:3}},Result:{type:"struct",name:"Result",fields:{data:{type:"Data",optional:!0,array:!1},schema:{type:"Schema",optional:!1,array:!1},sql:{type:"string",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},model_annotations:{type:"Annotation",array:!0,optional:!0},query_timezone:{type:"string",optional:!0,array:!1},source_annotations:{type:"Annotation",array:!0,optional:!0}}},RunIndexQueryRequest:{type:"struct",name:"RunIndexQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},source_name:{type:"string",optional:!1,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunIndexQueryResponse:{type:"struct",name:"RunIndexQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},RunQueryRequest:{type:"struct",name:"RunQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunQueryResponse:{type:"struct",name:"RunQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},SQLNativeCell:{type:"struct",name:"SQLNativeCell",fields:{sql_native_value:{type:"string",optional:!1,array:!1}}},SQLNativeType:{type:"struct",name:"SQLNativeType",fields:{sql_type:{type:"string",optional:!0,array:!1}}},SQLQuery:{type:"struct",name:"SQLQuery",fields:{sql:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},SQLTable:{type:"struct",name:"SQLTable",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},Schema:{type:"struct",name:"Schema",fields:{fields:{type:"FieldInfo",array:!0,optional:!1}}},SourceInfo:{type:"struct",name:"SourceInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},parameters:{type:"ParameterInfo",array:!0,optional:!0}}},StringCell:{type:"struct",name:"StringCell",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringLiteral:{type:"struct",name:"StringLiteral",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringType:{type:"struct",name:"StringType",fields:{}},TimeTruncationFieldReference:{type:"struct",name:"TimeTruncationFieldReference",fields:{field_reference:{type:"Reference",optional:!1,array:!1},truncation:{type:"TimestampTimeframe",optional:!1,array:!1}}},TimestampCell:{type:"struct",name:"TimestampCell",fields:{timestamp_value:{type:"string",optional:!1,array:!1}}},TimestampLiteral:{type:"struct",name:"TimestampLiteral",fields:{timestamp_value:{type:"string",optional:!1,array:!1},granularity:{type:"TimestampTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},TimestampTimeframe:{type:"enum",name:"TimestampTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5,hour:6,minute:7,second:8}},TimestampType:{type:"struct",name:"TimestampType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimestamptzType:{type:"struct",name:"TimestamptzType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimingInfo:{type:"struct",name:"TimingInfo",fields:{name:{type:"string",optional:!1,array:!1},duration_ms:{type:"number",optional:!1,array:!1},detailed_timing:{type:"TimingInfo",array:!0,optional:!0}}},Translation:{type:"struct",name:"Translation",fields:{url:{type:"string",optional:!1,array:!1},compiled_model_json:{type:"string",optional:!0,array:!1}}},View:{type:"struct",name:"View",fields:{definition:{type:"ViewDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ViewArrow:{type:"struct",name:"ViewArrow",fields:{source:{type:"ViewDefinition",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},ViewDefinition:{type:"union",name:"ViewDefinition",options:{arrow:"ViewArrow",view_reference:"Reference",refinement:"ViewRefinement",segment:"ViewSegment"}},ViewInfo:{type:"struct",name:"ViewInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"View",optional:!0,array:!1}}},ViewOperation:{type:"union",name:"ViewOperation",options:{group_by:"GroupBy",aggregate:"Aggregate",order_by:"OrderBy",limit:"Limit",where:"FilterOperation",nest:"Nest",having:"FilterOperation",drill:"DrillOperation",calculate:"CalculateOperation"}},ViewRefinement:{type:"struct",name:"ViewRefinement",fields:{base:{type:"ViewDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},ViewSegment:{type:"struct",name:"ViewSegment",fields:{operations:{type:"ViewOperation",array:!0,optional:!1}}}}),Ht}var Kt={},or={},Jt={},cn;function ns(){return cn||(cn=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.RESERVED_WORDS=void 0,Jt.RESERVED_WORDS=["all","and","as","asc","avg","boolean","by","case","cast","compose","count","date","day","days","desc","distinct","else","end","exclude","export","extend","false","filter","for","from","full","has","hour","hours","import","in","include","inner","internal","is","json","left","like","max","min","minute","minutes","month","months","not","now","null","number","on","or","pick","private","public","quarter","quarters","right","second","seconds","source","sql","string","sum","table","then","this","timestamp","timestamptz","to","true","virtual","week","weeks","when","with","year","years"]),Jt}var pn;function is(){if(pn)return or;pn=1,Object.defineProperty(or,"__esModule",{value:!0}),or.maybeQuoteIdentifier=B;const u=ns();function Q(V){const g=!V.match(/^[A-Za-z_][A-Za-z_0-9]*$/),l=u.RESERVED_WORDS.includes(V.toLowerCase());return g||l}function B(V){return Q(V)?`\`${V}\``:V}return or}var dn;function ss(){if(dn)return Kt;dn=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.queryToMalloy=Q,Kt.filterToMalloy=B;const u=is();function Q(h,{tabWidth:w}={tabWidth:2}){const F=ae(h);return c(F,{tabWidth:w})}function B(h,{tabWidth:w}={tabWidth:2}){const F=I(h);return c(F,{tabWidth:w})}const V=Symbol("indent"),g=Symbol("newline"),l=Symbol("outdent"),f=Symbol("optional_newline_indent");function c(h,{tabWidth:w}={tabWidth:2}){let F="",T=0,M=!0;for(const Y of h)if(Y===g)F+=`
40
- `,M=!0;else if(Y===l)T--;else if(Y===V)T++;else{if(Y===f)continue;M&&(F+=" ".repeat(T*w),M=!1),F+=Y}return F}function s(h,w,F,T){var M;if(w.includes(g))return[h,g,V,...w,g,l,F];const we=((M=T?.spaces)!==null&&M!==void 0?M:!0)?" ":"";return[h,we,...w,we,F]}function d(h){return{contents:h,quoteCharacter:'"'}}function e(h,w){const F=[];for(let T=0;T<h.length;T++){const M=h[T];F.push(M),T<h.length-1&&F.push(w)}return F}function y(h){var w,F;switch(h.kind){case"filter_expression_literal":return[ve(h.filter_expression_value)];case"boolean_literal":return[h.boolean_value.toString()];case"string_literal":{const{contents:T,quoteCharacter:M}=d(h.string_value);return[M,T,M]}case"number_literal":return[h.number_value.toString()];case"null_literal":return["null"];case"date_literal":return[x(k(h.date_value),(w=h.granularity)!==null&&w!==void 0?w:"day",h.timezone)];case"timestamp_literal":return[x(k(h.timestamp_value),(F=h.granularity)!==null&&F!==void 0?F:"second",h.timezone)]}}function k(h){let w;if(w=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/.exec(h)){const[F,T,M,Y,we,Le,Qe]=w;return[T,M,Y,we,Le,Qe]}else if(w=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/.exec(h)){const[F,T,M,Y,we,Le]=w;return[T,M,Y,we,Le,"00"]}else if(w=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d)(?:00)?/.exec(h)){const[F,T,M,Y,we]=w;return[T,M,Y,we,"00","00"]}else if(w=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(h)){const[F,T,M,Y]=w;return[T,M,Y,"00","00","00"]}else if(w=/(\d\d\d\d)-(\d\d)/.exec(h)){const[F,T,M]=w;return[T,M,"01","00","00","00"]}else if(w=/(\d\d\d\d)/.exec(h)){const[F,T]=w;return[T,"01","01","00","00","00"]}return["1970","01","01","00","00","00"]}function x([h,w,F,T,M,Y],we,Le){switch(we){case"year":return`@${h}`;case"quarter":{const Qe=Math.floor(+w/3)+1;return`@${h}-Q${Qe}`}case"month":return`@${h}-${w}`;case"week":return`@${h}-${w}-${F}-WK`;case"day":return`@${h}-${w}-${F}`;case"hour":return`@${h}-${w}-${F} ${T}`;case"minute":return`@${h}-${w}-${F} ${T}:${M}`;case"second":return Le!==void 0?`@${h}-${w}-${F} ${T}:${M}:${Y}[${Le}]`:`@${h}-${w}-${F} ${T}:${M}:${Y}`;default:throw new Error("Unknown timeframe.")}}function H(h){var w;const F=[];for(const T of(w=h.path)!==null&&w!==void 0?w:[])F.push((0,u.maybeQuoteIdentifier)(T)),F.push(".");if(F.push((0,u.maybeQuoteIdentifier)(h.name)),h.parameters){const T=[];for(let M=0;M<h.parameters.length;M++){const Y=h.parameters[M];T.push((0,u.maybeQuoteIdentifier)(Y.name)),T.push(" is "),T.push(...y(Y.value)),M<h.parameters.length-1&&T.push(",",g)}F.push(...s("(",T,")",{spaces:!1}))}return F}function ae(h){const w=[];return w.push(...N(h.annotations)),w.push("run: "),w.push(...E(h.definition)),w}function q(h){const w=[];switch(h.kind){case"source_reference":{w.push(...H(h));break}case"refinement":w.push(...E(h));break}return w}function E(h){const w=[];switch(h.kind){case"arrow":{w.push(...q(h.source)),w.push(" -> "),w.push(...C(h.view));break}case"query_reference":{w.push(...H(h));break}case"refinement":{const F=E(h.base);h.base.kind==="arrow"?w.push(...s("(",F,")",{spaces:!1})):w.push(...F),w.push(" + "),w.push(...C(h.refinement));break}}return w}function C(h){const w=[];switch(h.kind){case"arrow":{w.push(...C(h.source)),w.push(" -> "),w.push(...C(h.view));break}case"view_reference":{w.push(...H(h));break}case"refinement":{w.push(...C(h.base)),w.push(" + "),w.push(...C(h.refinement));break}case"segment":{w.push(...j(h));break}}return w}function j(h){if(h.operations.length===0)return["{ }"];const w=h.operations.length>1,F=[];for(let T=0;T<h.operations.length;T++){const M=h.operations[T],Y=[M];for(;T<h.operations.length-1;){const we=h.operations[T+1];if(we.kind===M.kind)Y.push(we),T++;else break}F.push(...he(Y)),w&&T<h.operations.length-1&&F.push(g)}return s("{",F,"}")}function he(h){switch(h[0].kind){case"aggregate":return P(h,"aggregate");case"group_by":return P(h,"group_by");case"order_by":return W(h);case"nest":return U(h);case"limit":return te(h);case"where":return ce(h);case"having":return ye(h);case"drill":return be(h);case"calculate":return P(h,"calculate")}}function $e(h,w,F=""){const T=[];T.push(`${h}:`);const M=w.length>1||w.some(Y=>Y.includes(g));M?T.push(g,V):T.push(" ");for(let Y=0;Y<w.length;Y++){const we=w[Y];T.push(...we),w.length>1&&Y<w.length-1&&T.push(F),M&&Y<w.length-1&&T.push(g)}return M&&T.push(l),T}function Se(h){const w=[];return w.push(...ke(h.expression)),w}function Re(h){return h}function ke(h){var w;switch(h.kind){case"field_reference":return H(h);case"time_truncation":return[...H(h.field_reference),".",h.truncation];case"filtered_field":return[...H(h.field_reference),...s(" {",ce(h.where),"}")];case"literal_value":return y(h.literal_value);case"moving_average":{const F=["avg_moving",...s("(",[...H(h.field_reference),h.rows_preceding!==void 0?`, ${h.rows_preceding}`:", 0",h.rows_following!==void 0?`, ${h.rows_following}`:""],")",{spaces:!1})];return!((w=h.partition_fields)===null||w===void 0)&&w.length&&F.push(...s(" {",["partition_by",": ",...e(h.partition_fields.flatMap(T=>H(T)),", ")],"}")),F}}}function me(h,w=!1){const F=[];return w||F.push(...N(h.field.annotations)),h.name&&(F.push((0,u.maybeQuoteIdentifier)(h.name)),F.push(" is ")),F.push(...Se(h.field)),F}function P(h,w){const F=[],T=h.length===1;return T&&F.push(...N(h[0].field.annotations)),F.push(...$e(w,h.map(M=>me(M,T)))),F}function W(h){return $e("order_by",h.map(z),",")}function z(h){const w=[];return w.push(...H(h.field_reference)),h.direction&&(w.push(" "),w.push(h.direction)),w}function U(h){const w=[],F=h.length===1;return F&&w.push(...N(h[0].view.annotations)),w.push(...$e("nest",h.map(T=>G(T,F)))),w}function G(h,w=!1){const F=[];return w||F.push(...N(h.view.annotations)),h.name&&(F.push((0,u.maybeQuoteIdentifier)(h.name)),F.push(" is ")),F.push(...ee(h.view)),F}function ee(h){return C(h.definition)}function ne(h){return[`limit: ${h.limit}`]}function te(h){const w=[];for(let F=0;F<h.length;F++)F!==0&&w.push(g),w.push(...ne(h[F]));return w}function ce(h){return $e("where",h.map(D),",")}function be(h){return $e("drill",h.map(D),",")}function ye(h){return $e("having",h.map(D),",")}const le=["`","'",'"'];function ve(h){let w,F;for(const T of le){const M=_(h,T);if(M===h)return`f${T}${h}${T}`;(F===void 0||M.length<F.length)&&(w=T,F=M)}return`f${w}${F}${w}`}function _(h,w){let F="";for(let T=0;T<h.length;T++)h.slice(T).startsWith(w)?(F+="\\"+w,T+=w.length):(F+=h[T],h[T]==="\\"&&(F+=h[++T]));return F}function I(h){switch(h.kind){case"filter_string":return[...ke(h.expression)," ~ ",ve(h.filter)];case"literal_equality":return[...ke(h.expression)," = ",...y(h.value)]}}function D(h){return I(h.filter)}function N(h){return h?h.flatMap(A):[]}function A(h){return[h.value.trim(),g]}return Kt}var Vt={},hn;function as(){if(hn)return Vt;hn=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.nestUnions=Q,Vt.unnestUnions=B,Vt.convertFromThrift=V,Vt.convertToThrift=l;const u=An();function Q(f){if(f==null)return f;if(typeof f=="string"||typeof f=="number"||typeof f=="boolean")return f;if(Array.isArray(f))return f.map(Q);{const c={};let s;for(const d in f)d==="kind"?s=f[d]:c[d]=Q(f[d]);return s===void 0?c:{[s]:c}}}function B(f,c){if(f==null)return f;if(typeof f=="string"||typeof f=="number"||typeof f=="boolean")return f;if(Array.isArray(f))return f.map(s=>B(s,c));{const s=g(c);if(s.type==="union"){for(const d in s.options)if(f[d]!==void 0){const e=B(f[d],s.options[d]);if(typeof e=="object")return{kind:d,...e}}}else if(s.type==="struct"){const d={};for(const e in f){const y=s.fields[e];if(y===void 0)throw new Error(`Unknown field ${e} in ${c}`);d[e]=B(f[e],y.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${c}`)}}function V(f,c){if(f==null)return f;if(typeof f=="string"||typeof f=="boolean")return f;if(typeof f=="number"){if(c==="number")return f;const s=g(c);if(s.type!=="enum")throw new Error(`Found a number where a ${c} was expected`);const d=Object.entries(s.values).find(([,e])=>e===f);if(d===void 0)throw new Error(`${f} is not a valid enum value for ${c}`);return d[0]}else{if(Array.isArray(f))return f.map(s=>V(s,c));{const s=g(c);if(s.type==="union"){for(const d in s.options)if(f[d]!==void 0&&f[d]!==null){const e=V(f[d],s.options[d]);if(typeof e=="object")return{kind:d,...e}}}else if(s.type==="struct"){const d={};for(const e in f){const y=s.fields[e];if(y===void 0)throw new Error(`Unknown field ${e} in ${c}`);d[e]=V(f[e],y.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${c}`)}}}function g(f){const c=u.MALLOY_INTERFACE_TYPES[f];if(c===void 0)throw new Error(`Unknown Malloy interface type ${f}`);return c}function l(f,c){if(f==null)return f;if(typeof f=="number"||typeof f=="boolean")return f;if(typeof f=="string"){if(c==="string")return f;const s=g(c);if(s.type==="enum"){const d=s.values[f];if(d===void 0)throw new Error(`${f} is not a valid enum value for ${c}`);return d}}else{if(Array.isArray(f))return f.map(s=>l(s,c));{const s=g(c);if(s.type==="union"){const d=f.kind,e=s.options[d];if(e===void 0)throw new Error(`${d} is not a valid union of ${c}`);const y=g(e);if(y.type!=="struct")throw new Error("Union fields must be structs");const k={};for(const x in f){if(x==="kind")continue;const H=y.fields[x];k[x]=l(f[x],H.type)}return{[d]:k}}else if(s.type==="struct"){const d={};for(const e in f){const y=s.fields[e];if(y===void 0)throw new Error(`Unknown field ${e} in ${c}`);d[e]=l(f[e],y.type)}return d}}}}return Vt}var gn;function os(){return gn||(gn=1,(function(u){var Q=Pt&&Pt.__createBinding||(Object.create?(function(l,f,c,s){s===void 0&&(s=c);var d=Object.getOwnPropertyDescriptor(f,c);(!d||("get"in d?!f.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return f[c]}}),Object.defineProperty(l,s,d)}):(function(l,f,c,s){s===void 0&&(s=c),l[s]=f[c]})),B=Pt&&Pt.__exportStar||function(l,f){for(var c in l)c!=="default"&&!Object.prototype.hasOwnProperty.call(f,c)&&Q(f,l,c)};Object.defineProperty(u,"__esModule",{value:!0}),u.thingy4sddfdfsd=u.thingy4sdfsd=u.thingy4dfdsfs=u.thingy4asdfas=u.thingy4asdfasdf=u.thingy3dfdf=u.thingy3=u.thingy2asdf=u.thingyssdfg=u.thingy123r=u.thingy1=u.res=u.test=u.convertToThrift=u.convertFromThrift=u.unnestUnions=u.nestUnions=u.filterToMalloy=u.queryToMalloy=void 0,B(An(),u);var V=ss();Object.defineProperty(u,"queryToMalloy",{enumerable:!0,get:function(){return V.queryToMalloy}}),Object.defineProperty(u,"filterToMalloy",{enumerable:!0,get:function(){return V.filterToMalloy}});var g=as();Object.defineProperty(u,"nestUnions",{enumerable:!0,get:function(){return g.nestUnions}}),Object.defineProperty(u,"unnestUnions",{enumerable:!0,get:function(){return g.unnestUnions}}),Object.defineProperty(u,"convertFromThrift",{enumerable:!0,get:function(){return g.convertFromThrift}}),Object.defineProperty(u,"convertToThrift",{enumerable:!0,get:function(){return g.convertToThrift}}),u.test={entries:[{kind:"source",name:"flights",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"boolean_type"},annotations:[{value:"# foo=1"}]},{kind:"dimension",name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}},{kind:"dimension",name:"arr_rec",type:{kind:"array_type",element_type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}}},{kind:"dimension",name:"rec",type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}},{kind:"join",name:"carriers",relationship:"one",schema:{fields:[{kind:"dimension",name:"code",type:{kind:"string_type"}}]}},{kind:"view",name:"by_carrier",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]}}]},parameters:[{name:"param",type:{kind:"number_type"},default_value:{kind:"number_literal",number_value:7}}]}],anonymous_queries:[]},u.res={connection_name:"foo",data:{kind:"array_cell",array_value:[{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"UA"},{kind:"number_cell",number_value:12341234}]},{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"AA"},{kind:"number_cell",number_value:2343}]}]},schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]},sql:"SELECT * ..."},u.thingy1={definition:{kind:"query_reference",name:"flights_by_carrier"}},u.thingy123r={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.thingyssdfg={definition:{kind:"refinement",base:{kind:"query_reference",name:"flights"},refinement:{kind:"view_reference",name:"by_carrier"}}},u.thingy2asdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:"carrier"},filter:"WN"}}]}}}},u.thingy3={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}}},u.thingy3dfdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"view_reference",name:"top10"}}}},u.thingy4asdfasdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}},u.thingy4asdfas={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.thingy4dfdsfs={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"limit",limit:10}]}}}},u.thingy4sdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"limit",limit:10}]}}},u.thingy4sddfdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[]}}}})(Pt)),Pt}var It={},vt={},mn;function ls(){return mn||(mn=1,(function(u){var Q=vt&&vt.__createBinding||(Object.create?(function($,t,a,m){m===void 0&&(m=a);var p=Object.getOwnPropertyDescriptor(t,a);(!p||("get"in p?!t.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty($,m,p)}):(function($,t,a,m){m===void 0&&(m=a),$[m]=t[a]})),B=vt&&vt.__setModuleDefault||(Object.create?(function($,t){Object.defineProperty($,"default",{enumerable:!0,value:t})}):function($,t){$.default=t}),V=vt&&vt.__importStar||(function(){var $=function(t){return $=Object.getOwnPropertyNames||function(a){var m=[];for(var p in a)Object.prototype.hasOwnProperty.call(a,p)&&(m[m.length]=p);return m},$(t)};return function(t){if(t&&t.__esModule)return t;var a={};if(t!=null)for(var m=$(t),p=0;p<m.length;p++)m[p]!=="default"&&Q(a,t,m[p]);return B(a,t),a}})();Object.defineProperty(u,"__esModule",{value:!0}),u.ASTAnnotationList=u.ASTLimitViewOperation=u.ASTView=u.ASTFilterWithLiteralEquality=u.ASTFilterWithFilterString=u.ASTFilter=u.ASTCalculateViewOperation=u.ASTHavingViewOperation=u.ASTDrillViewOperation=u.ASTWhereViewOperation=u.ASTNestViewOperation=u.ASTFilteredFieldExpression=u.ASTFilterOperationList=u.ASTFilterOperation=u.ASTMovingAverageExpression=u.ASTFieldReferenceList=u.ASTLiteralValueExpression=u.ASTTimeTruncationExpression=u.ASTReferenceExpression=u.ASTExpression=u.ASTField=u.ASTAggregateViewOperation=u.ASTGroupByViewOperation=u.ASTOrderByViewOperation=u.ASTViewOperation=u.ASTViewOperationList=u.ASTSegmentViewDefinition=u.ASTRefinementViewDefinition=u.ASTArrowViewDefinition=u.ASTReferenceViewDefinition=u.ASTReferenceQueryArrowSource=u.ASTReferenceQueryDefinition=u.ASTRefinementQueryDefinition=u.ASTArrowQueryDefinition=u.ASTQueryDefinition=u.ASTQueryArrowSource=u.ASTUnimplemented=u.ASTFilterExpressionLiteralValue=u.ASTTimestampLiteralValue=u.ASTDateLiteralValue=u.ASTBooleanLiteralValue=u.ASTNumberLiteralValue=u.ASTNullLiteralValue=u.ASTStringLiteralValue=u.ASTLiteralValue=u.ASTParameterValue=u.ASTParameterValueList=u.ASTFieldReference=u.ASTReference=u.ASTQuery=void 0,u.ASTAnnotation=void 0;const g=V(os()),l=rs(),f=V(Yi());class c{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const t=this;return{Query(){if(t instanceof y)return t;throw new Error("Not an ASTQuery")},Reference(){if(t instanceof k)return t;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(t instanceof W)return t;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(t instanceof H)return t;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(t instanceof w)return t;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(t instanceof F)return t;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(t instanceof ae)return t;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(t instanceof q)return t;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(t instanceof C)return t;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(t instanceof be)return t;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(t instanceof le)return t;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(t instanceof ve)return t;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(t instanceof ye)return t;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(t instanceof _)return t;throw new Error("Not an ASTField")},ReferenceExpression(){if(t instanceof I)return t;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(t instanceof ee)return t;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(t instanceof ke)return t;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(t instanceof ne)return t;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(t instanceof te)return t;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(t instanceof D)return t;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(t instanceof T)return t;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(t instanceof Y)return t;throw new Error("Not an ASTNestViewOperation")},View(){if(t instanceof Ie)return t;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(t instanceof ce)return t;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(t instanceof et)return t;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(t instanceof it)return t;throw new Error("Not an ASTAnnotationList")},Annotation(){if(t instanceof at)return t;throw new Error("Not an ASTAnnotation")}}}get find(){const t=this;return{Query(a){return t.findAny(a).as.Query()},Reference(a){return t.findAny(a).as.Reference()},ReferenceQueryArrowSource(a){return t.findAny(a).as.ReferenceQueryArrowSource()},ParameterValueList(a){return t.findAny(a).as.ParameterValueList()},FilterOperation(a){return t.findAny(a).as.FilterOperation()},FilterOperationList(a){return t.findAny(a).as.FilterOperationList()},ParameterValue(a){return t.findAny(a).as.ParameterValue()},StringLiteralValue(a){return t.findAny(a).as.StringLiteralValue()},NumberLiteralValue(a){return t.findAny(a).as.NumberLiteralValue()},ViewOperationList(a){return t.findAny(a).as.ViewOperationList()},GroupByViewOperation(a){return t.findAny(a).as.GroupByViewOperation()},AggregateViewOperation(a){return t.findAny(a).as.AggregateViewOperation()},OrderByViewOperation(a){return t.findAny(a).as.OrderByViewOperation()},Field(a){return t.findAny(a).as.Field()},ReferenceExpression(a){return t.findAny(a).as.ReferenceExpression()},ReferenceViewDefinition(a){return t.findAny(a).as.ReferenceViewDefinition()},ArrowQueryDefinition(a){return t.findAny(a).as.ArrowQueryDefinition()},ArrowViewDefinition(a){return t.findAny(a).as.ArrowViewDefinition()},RefinementViewDefinition(a){return t.findAny(a).as.RefinementViewDefinition()},TimeTruncationExpression(a){return t.findAny(a).as.TimeTruncationExpression()},FilteredFieldExpression(a){return t.findAny(a).as.FilteredFieldExpression()},NestViewOperation(a){return t.findAny(a).as.NestViewOperation()},View(a){return t.findAny(a).as.View()},SegmentViewDefinition(a){return t.findAny(a).as.SegmentViewDefinition()},LimitViewOperation(a){return t.findAny(a).as.LimitViewOperation()},AnnotationList(a){return t.findAny(a).as.AnnotationList()},Annotation(a){return t.findAny(a).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(t){this._parent=t}static schemaTryGet(t,a,m){return c._schemaTryGet(t,a,m,!1)}static schemaTryGetDrillField(t,a,m){return c._schemaTryGet(t,a,m,!0)}static _schemaTryGet(t,a,m,p){let K=t.fields;for(const Pe of m??[]){const X=K.find(De=>De.name===Pe);if(X===void 0)throw new Error(`${Pe} not found`);if(X.kind==="join"||p&&X.kind==="view"){K=X.schema.fields;continue}if(X.kind==="dimension"||X.kind==="measure"){if(X.type.kind==="record_type"){K=X.type.fields.map(De=>({kind:X.kind,...De}));continue}else if(X.type.kind==="array_type"&&X.type.element_type.kind==="record_type"){K=X.type.element_type.fields.map(De=>({kind:X.kind,...De}));continue}}throw new Error(`${Pe} is not a join, record, or repeated record`)}return K.find(Pe=>Pe.name===a)}static schemaGet(t,a,m){const p=c.schemaTryGet(t,a,m);if(p===void 0)throw new Error(`${a} not found`);return p}static schemaGetDrillField(t,a,m){const p=c.schemaTryGetDrillField(t,a,m);if(p===void 0)throw new Error(`${a} not found`);return p}static schemaMerge(t,a){return{fields:[...t.fields,...a.fields]}}static tagFor(t,a="# "){var m,p;const K=(p=(m=t.annotations)===null||m===void 0?void 0:m.map(Pe=>Pe.value))===null||p===void 0?void 0:p.filter(Pe=>Pe.startsWith(a)),de=new l.TagParser;for(const Pe of K??[])de.parseAnnotation(Pe);return de.finish()}static fieldWasCalculation(t){if(t.kind!=="dimension")throw new Error(`${t.name} could not be an output field, because it is a ${t.kind}, and only dimensions can appear in output schemas`);return c.tagFor(t,"#(malloy) ").has("calculation")}}function s($){return Array.isArray($)||typeof $=="string"||typeof $=="number"||typeof $=="boolean"}class d extends c{constructor(t,a){super(),this.node=t,this.children=a,this.originalChildren=[...a],a.forEach(m=>m.parent=this)}*iter(){for(let t=0;t<this.length;t++)yield this.index(t)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(t){return this.children[t]}insert(t,a){this.edit(),this.children.splice(a,0,t),t.parent=this}add(t){this.edit(),this.children.push(t),t.parent=this}remove(t){const a=this.children.findIndex(m=>m===t);if(a===-1)return this;this.edit(),this.children.splice(a,1)}build(){if(!this.edited)return this.node;const t=this.children.map(a=>a.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=t,t}findAny(t){if(t.length===0)return this;const[a,...m]=t;if(typeof a!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);return this.children[a].findAny(m)}findIndex(t){return this.children.findIndex(t)}indexOf(t){return this.children.indexOf(t)}}class e extends c{constructor(t,a){super(),this.node=t,this.children=a;for(const m in a){const p=a[m];p&&!s(p)&&(p.parent=this)}}build(){if(!this.edited)return this.node;let t=this.node;for(const a in this.children){const m=this.children[a];m===void 0?t={...t,[a]:void 0}:s(m)?this.edited&&(t={...t,[a]:m}):t={...t,[a]:m.build()}}return this.node=t,this.edited=!1,t}findAny(t){if(t.length===0)return this;const[a,...m]=t;if(typeof a!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);const p=this.children[a];if(s(p))throw new Error(`${this.constructor.name}.${a} refers to a basic type, not an ASTNode`);return p._find(m)}}class y extends e{constructor(t){var a,m;let p=t.source;if(p===void 0){if(t.model===void 0)throw new Error("Need a model or source");if(t.query){const X=t.query.definition;if(X.kind==="arrow"&&X.source.kind==="source_reference"){const De=X.source.name;if(p=t.model.entries.find(Ye=>Ye.name===De),p===void 0)throw new Error(`Model does not contain source or query named ${De}`)}}if(p===void 0&&(p=t.model.entries[0]),p===void 0)throw new Error("Model does not contain any sources or queries")}const K=re(p),de=(a=t.query)!==null&&a!==void 0?a:{definition:{kind:"arrow",source:{kind:"source_reference",name:K.name},view:{kind:"segment",operations:[]}}},Pe=(m=t.model)!==null&&m!==void 0?m:{entries:[K],anonymous_queries:[]};super(de,{definition:u.ASTQueryDefinition.from(de.definition),annotations:de.annotations&&new it(de.annotations)}),this.model=Pe,t.source&&this.setSource(t.source.name)}get definition(){return this.children.definition}set definition(t){this.edit(),this.children.definition=t,t.parent=this}get annotations(){return this.children.annotations}reorderFields(t){this.definition.reorderFields(t)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new it([]);return this.children.annotations=t,t.parent=this,t}getInheritedTag(t="# "){return st(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}setViewToEmptySegment(){if(!(this.definition instanceof ke))throw new Error("Must set source before setting view");return this.definition=new ke({kind:"arrow",source:this.definition.source.build(),view:{kind:"segment",operations:[]}}),this.definition.view.as.SegmentViewDefinition()}isRunnable(){return this.definition.isRunnable()}isEmpty(){return this.definition instanceof ke&&this.definition.view instanceof ce&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(t){if(this.definition instanceof ke&&this.definition.source instanceof W&&this.definition.source.name===t)return;if(this.model.entries.find(m=>m.name===t)===void 0)throw new Error(`Source ${t} is not defined in model`);this.definition=new ke({kind:"arrow",source:{kind:"source_reference",name:t},view:this.definition instanceof ke?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(t){const a=this.model.entries.find(m=>m.name===t);if(a===void 0||a.kind!=="query")throw new Error(`No query named ${t} in the model`);this.definition=new P({kind:"query_reference",name:t})}getQueryInfo(t){const a=this.model.entries.find(m=>m.name===t);if(a===void 0)throw new Error(`Query ${t} is not defined in model`);if(a.kind!=="query")throw new Error(`Model entry ${t} is not a query`);return a}toMalloy(){return g.queryToMalloy(this.build())}build(){return super.build()}setView(t){if(!(this.definition instanceof ke))throw new Error("Must set source before setting view");return this.definition=new ke({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:t}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(t){var a;return t instanceof P?(a=this.getQueryInfo(t.name).annotations)!==null&&a!==void 0?a:[]:t instanceof me?this._getInheritedAnnotations(t.base):t instanceof ke?t.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}u.ASTQuery=y;class k extends e{constructor(t){super(t,{name:t.name,path:t.path,parameters:t.parameters&&new H(t.parameters)}),this.reference=t}get name(){return this.children.name}set name(t){this.edit(),this.children.name=t}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}static getOrAddParameters(t){if(t.parameters)return t.parameters;t.edit();const a=new H([]);return t.parameters=a,a}static setParameter(t,a,m){const p=k.tryGetParameter(t,a);if(p!==void 0){p.value=u.ASTLiteralValue.from(u.ASTLiteralValue.makeLiteral(m));return}return t.getOrAddParameters().addParameter(a,m)}static tryGetParameter(t,a){if(t.parameters!==void 0){for(const m of t.parameters.iter())if(m.name===a)return m}}getOrAddParameters(){return k.getOrAddParameters(this)}setParameter(t,a){return k.setParameter(this,t,a)}tryGetParameter(t){return k.tryGetParameter(this,t)}}u.ASTReference=k;class x extends k{get segment(){const t=this.parent;return t instanceof T||t instanceof D?t.field.segment:t instanceof Be||t instanceof Xe?t.segment:t.list.segment}getReferenceSchema(){return this.parent instanceof ye?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const t=this.getReferenceSchema();return c.schemaGet(t,this.name,this.path)}}u.ASTFieldReference=x;class H extends d{constructor(t){super(t,t.map(a=>new ae(a)))}get parameters(){return this.children}addParameter(t,a){this.add(new ae({name:t,value:u.ASTLiteralValue.makeLiteral(a)}))}}u.ASTParameterValueList=H;class ae extends e{constructor(t){super(t,{name:t.name,value:u.ASTLiteralValue.from(t.value)}),this.parameter=t}get name(){return this.children.name}get value(){return this.children.value}set value(t){this.edit(),this.children.value=t}}u.ASTParameterValue=ae,u.ASTLiteralValue={from($){switch($.kind){case"string_literal":return new q($);case"number_literal":return new C($);case"boolean_literal":return new j($);case"date_literal":return new he($);case"timestamp_literal":return new $e($);case"null_literal":return new E($);case"filter_expression_literal":return new Se($)}},makeLiteral($){if($!==null&&typeof $=="object"&&"kind"in $)return $;if(typeof $=="string")return{kind:"string_literal",string_value:$};if(typeof $=="boolean")return{kind:"boolean_literal",boolean_value:$};if(typeof $=="number")return{kind:"number_literal",number_value:$};if($===null)return{kind:"null_literal"};if("date"in $){const t=$.granularity,a=Ve($.date);return Oe(t)?{kind:"date_literal",date_value:a,granularity:t}:{kind:"timestamp_literal",timestamp_value:a,granularity:t}}throw new Error("Unknown literal type")}};class q extends e{constructor(t){super(t,{kind:t.kind,string_value:t.string_value}),this.node=t,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}u.ASTStringLiteralValue=q;class E extends e{constructor(t){super(t,{kind:t.kind}),this.node=t,this.kind="null_literal"}get fieldType(){}}u.ASTNullLiteralValue=E;class C extends e{constructor(t){super(t,{kind:t.kind,number_value:t.number_value}),this.node=t,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}u.ASTNumberLiteralValue=C;class j extends e{constructor(t){super(t,{kind:t.kind,boolean_value:t.boolean_value}),this.node=t,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}u.ASTBooleanLiteralValue=j;class he extends e{constructor(t){super(t,{kind:t.kind,date_value:t.date_value,granularity:t.granularity}),this.node=t,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}u.ASTDateLiteralValue=he;class $e extends e{constructor(t){super(t,{kind:t.kind,timestamp_value:t.timestamp_value,granularity:t.granularity}),this.node=t,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}u.ASTTimestampLiteralValue=$e;class Se extends e{constructor(t){super(t,{kind:t.kind,filter_expression_value:t.filter_expression_value}),this.node=t,this.kind="filter_expression_literal"}get fieldType(){}}u.ASTFilterExpressionLiteralValue=Se;class Re extends c{constructor(t){super(),this.node=t}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}u.ASTUnimplemented=Re,u.ASTQueryArrowSource={from($){switch($.kind){case"refinement":return new me($);case"source_reference":return new W($)}}},u.ASTQueryDefinition={from($){switch($.kind){case"arrow":return new ke($);case"query_reference":return new P($);case"refinement":return new me($)}}};class ke extends e{constructor(t){super(t,{kind:"arrow",source:u.ASTQueryArrowSource.from(t.source),view:z.from(t.view)}),this.node=t}get view(){return this.children.view}set view(t){this.edit(),this.children.view=t,t.parent=this}get source(){return this.children.source}set source(t){this.edit(),this.children.source=t}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}getSourceInfo(){return this.source.getSourceInfo()}getOutputSchema(){return this.view.getRefinementSchema()}isRunnable(){return this.view.isRunnable()&&this.source.isRunnable()}get query(){return this.parent.as.Query()}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.view),this.view.propagateDown(t)}reorderFields(t){this.view instanceof ce?this.view.reorderFields(t):this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}}u.ASTArrowQueryDefinition=ke;class me extends e{constructor(t){super(t,{kind:"refinement",base:u.ASTQueryDefinition.from(t.base),refinement:z.from(t.refinement)}),this.node=t}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(t){this.edit(),this.children.refinement=t,t.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const t=this.base.getOutputSchema(),a=this.refinement.getRefinementSchema();return y.schemaMerge(t,a)}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.refinement),this.refinement.propagateDown(t)}reorderFields(t){this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}getSourceInfo(){return this.base.getSourceInfo()}}u.ASTRefinementQueryDefinition=me;class P extends e{constructor(t){super(t,{kind:"query_reference",name:t.name,path:t.path,parameters:t.parameters&&new H(t.parameters)}),this.node=t}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}getOrAddDefaultSegment(){const t=new me({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=t,t.refinement.as.SegmentViewDefinition()}propagateUp(t){}propagateDown(t){}reorderFields(t){this.query.getOrAddAnnotations().setTagProperty(["field_order"],t)}getOrAddParameters(){return k.getOrAddParameters(this)}setParameter(t,a){return k.setParameter(this,t,a)}tryGetParameter(t){return k.tryGetParameter(this,t)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const a=this.query.model.entries.find(m=>m.name===this.name);if(a===void 0)throw new Error(`Query not found with name ${this.name}`);return a}}u.ASTReferenceQueryDefinition=P;class W extends e{constructor(t){super(t,{kind:"source_reference",name:t.name,path:t.path,parameters:t.parameters&&new H(t.parameters)}),this.node=t}isRunnable(){return this.areRequiredParametersSet()}get name(){return this.children.name}get arrow(){return this.parent.as.ArrowQueryDefinition()}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get path(){return this.children.path}getSourceInfo(){const t=this.arrow.query.model.entries.find(a=>a.name===this.name);if(t===void 0)throw new Error(`No query or source named ${this.name}`);return t}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const a=new me({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=a,a.refinement.as.SegmentViewDefinition()}propagateUp(t){}propagateDown(t){}getOrAddParameters(){return k.getOrAddParameters(this)}setParameter(t,a){return k.setParameter(this,t,a)}tryGetParameter(t){return k.tryGetParameter(this,t)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var t;const a=this.getSourceInfo();return a.kind==="query"?[]:(t=a.parameters)!==null&&t!==void 0?t:[]}areRequiredParametersSet(){const t=this.getSourceParameters();for(const a of t){if(a.default_value!==void 0)continue;if(this.tryGetParameter(a.name)===void 0)return!1}return!0}}u.ASTReferenceQueryArrowSource=W;const z={from($){switch($.kind){case"arrow":return new ne($);case"view_reference":return new ee($);case"segment":return new ce($);case"refinement":return new te($)}}};function U($,t){const a=$.parent;a instanceof ke?a.view=t:a instanceof me?a.refinement=t:a instanceof Ie?a.definition=t:a instanceof ne?a.source===$?a.source=t:a.view=t:a.base===$?a.base=t:a.refinement=t}function G($,t,a=[]){const m=$.getInputSchema(),p=y.schemaGet(m,t,a);if(p===void 0)return{isValidViewRefinement:!1,error:`${t} is not defined`};if(p.kind!=="view")return{isValidViewRefinement:!1,error:`${t} is not a view`};const K=$.getOutputSchema();for(const de of p.schema.fields)if(y.schemaTryGet(K,de.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${t} because stage already has an output field named ${de.name}`};return{isValidViewRefinement:!0}}class ee extends e{constructor(t){super(t,{kind:"view_reference",name:t.name,path:t.path,parameters:t.parameters&&new H(t.parameters)}),this.node=t}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const t=te.segmentRefinementOf(this.build());return U(this,t),t.refinement.as.SegmentViewDefinition()}addViewRefinement(t,a){const{error:m}=this.isValidViewRefinement(t,a);if(m)throw new Error(m);const p=te.viewRefinementOf(this.build(),t,a);return U(this,p),p.refinement.as.ReferenceViewDefinition()}convertToNest(t){const a=z.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});U(this,a)}isValidViewRefinement(t,a){return G(this,t,a)}getInputSchema(){return kt(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const t=this.getInputSchema(),a=c.schemaGet(t,this.name,this.path);if(a.kind!=="view")throw new Error("Not a view");return a}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){}getInheritedAnnotations(){var t;return(t=this.getViewInfo().annotations)!==null&&t!==void 0?t:[]}getOrAddParameters(){return k.getOrAddParameters(this)}setParameter(t,a){return k.setParameter(this,t,a)}tryGetParameter(t){return k.tryGetParameter(this,t)}}u.ASTReferenceViewDefinition=ee;class ne extends e{constructor(t){super(t,{kind:"arrow",source:z.from(t.source),view:z.from(t.view)}),this.node=t}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(t){this.edit(),this.children.source=t}get view(){return this.children.view}set view(t){this.edit(),this.children.view=t,t.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(t,a){return this.view.addViewRefinement(t,a)}convertToNest(t){const a=z.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});U(this,a)}getInputSchema(){return this.source.getOutputSchema()}getOutputSchema(){return this.view.getRefinementSchema()}getImplicitName(){return this.view.getImplicitName()}getRefinementSchema(){throw new Error("An arrow is not a valid refinement")}isValidViewRefinement(t,a){return G(this,t,a)}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.view),this.view.propagateDown(t)}getInheritedAnnotations(){return[]}}u.ASTArrowViewDefinition=ne;class te extends e{constructor(t){super(t,{kind:"refinement",base:z.from(t.base),refinement:z.from(t.refinement)}),this.node=t}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(t){this.edit(),this.children.refinement=t,t.parent=this}get base(){return this.children.base}set base(t){this.edit(),this.children.base=t}convertToNest(t){const a=z.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});U(this,a)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(t,a){return this.refinement.addViewRefinement(t,a)}getInputSchema(){return kt(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return c.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(t,a){return G(this,t,a)}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){t(this.base),t(this.refinement),this.base.propagateDown(t),this.refinement.propagateDown(t)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(t,a,m){return new te({kind:"refinement",base:t,refinement:{kind:"view_reference",name:a,path:m}})}static segmentRefinementOf(t){return new te({kind:"refinement",base:t,refinement:{kind:"segment",operations:[]}})}}u.ASTRefinementViewDefinition=te;class ce extends e{constructor(t){super(t,{kind:"segment",operations:new be(t.operations)}),this.node=t,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let t=!1;for(const a of this.operations.iter()){if(a instanceof ve||a instanceof le)return!0;if(a instanceof Y){if(!a.view.definition.isRunnable())return!1;t=!0}}return t}get operations(){return this.children.operations}convertToNest(t){const a=z.from({kind:"segment",operations:[{kind:"nest",name:t,view:{definition:this.build()}}]});U(this,a)}renameOrderBys(t,a){for(const m of this.operations.iter())m instanceof ye&&m.name===t&&m.setField(a)}propagateUp(t){this.parent.propagateUp(t)}propagateDown(t){}removeOrderBys(t){for(const a of this.operations.iter())a instanceof ye&&a.name===t&&a.delete()}reorderFields(t){const a=[],m=[],p={};let K=!1;for(const X of this.operations.iter()){if((X instanceof ve||X instanceof le||X instanceof Y)&&t.includes(X.name)){p[X.name]=X,K=!0;continue}K?m.push(X):a.push(X)}const de=[];for(const X of t){const De=p[X];if(De===void 0)throw new Error(`No field named ${X}`);de.push(De)}const Pe=[...a,...de,...m];this.operations.items=Pe}renameField(t,a){if(t.name===a)return;const m=this.getOutputSchema();if(c.schemaTryGet(m,a,[]))throw new Error(`Output already has a field named ${a}`);const p=t.name;t.name=a,this.propagateUp(K=>{K instanceof ce&&K.renameOrderBys(p,a)})}addOrderBy(t,a){const m=this.getOutputSchema();try{c.schemaGet(m,t,[])}catch{throw new Error(`No such field ${t} in stage output`)}for(const K of this.operations.iter())if(K instanceof ye&&K.name===t)return K.direction=a,K;const p=new ye({kind:"order_by",field_reference:{name:t},direction:a});return this.addOperation(p),p}addEmptyNest(t){const a=new Y({kind:"nest",name:t,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(a),a}firstIndexOfOperationType(t){return this.operations.findIndex(a=>a.kind===t)}findInsertionPoint(t){const a=this.firstIndexOfOperationType(t);if(a>-1){let K=a;for(;this.operations.index(K)&&this.operations.index(K).kind===t;)K++;return K}const m=this.DEFAULT_INSERTION_ORDER.indexOf(t);if(m===-1)throw new Error(`Operation ${t} is not supported for \`findInsertionPoint\``);const p=this.DEFAULT_INSERTION_ORDER.slice(m+1);for(const K of p){const de=this.firstIndexOfOperationType(K);if(de>-1)return de}return this.operations.length}getFieldNamed(t){const a=this.tryGetFieldNamed(t);if(a===void 0)throw new Error("No such field");return a}hasFieldNamed(t){return this.tryGetFieldNamed(t)!==void 0}hasField(t,a){return this.tryGetField(t,a)!==void 0}getField(t,a){const m=this.tryGetField(t,a);if(m===void 0)throw new Error("No such field");return m}tryGetField(t,a){for(const m of this.operations.iter())if(m instanceof le||m instanceof ve){const p=m.field.getReference();if(p&&p.name===t&&ze(p.path,a))return m}else if(m instanceof Y){if(m.view instanceof ee)return m}else if(m instanceof J){const p=m.expression.field.getReference();if(p&&p.name===t&&ze(p.path,a))return m}}tryGetFieldNamed(t){for(const a of this.operations.iter())if((a instanceof le||a instanceof ve||a instanceof Y||a instanceof J)&&a.name===t)return a}getGroupBy(t){for(const a of this.operations.iter())if(a instanceof le&&a.name===t)return a}removeGroupBy(t){var a;return(a=this.getGroupBy(t))===null||a===void 0||a.delete(),this}addGroupBy(t,a=[],m){const p=this.makeField(t,a,m,"dimension");return this.addOperation(p),p}addDrill(t){const a=new Le({kind:"drill",...t});return this.addOperation(a),a}addWhere(t,a,m){const p=Array.isArray(a)?a:[],K=m===void 0?a:m,de=typeof K=="string"?K:tt(K),Pe=this.getInputSchema(),X=y.schemaGet(Pe,t,p);ot(X,K);const De=new we({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:p},filter:de}});return this.addOperation(De),De}addHaving(t,a,m){const p=Array.isArray(a)?a:[],K=m===void 0?a:m,de=typeof K=="string"?K:tt(K),Pe=this.getInputSchema(),X=y.schemaGet(Pe,t,p);ot(X,K);const De=new Qe({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:p},filter:de}});return this.addOperation(De),De}addCalculateMovingAverage(t,a,m,p,K){const de=new J({kind:"calculate",name:t,field:{expression:{kind:"moving_average",field_reference:{name:a,path:m},rows_preceding:p,rows_following:K}}});return this.addOperation(de),de}addTimeGroupBy(t,a,m,p){const K=this.getInputSchema(),de=c.schemaGet(K,t,a);if(de===void 0)throw new Error(`No such field ${t}`);if(de.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${t}`);if(de.type.kind!==p)throw new Error(`${t} is not a ${p}`);const Pe=new le({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:t,path:a},truncation:m}}});return this.addOperation(Pe),Pe}addDateGroupBy(t,a,m){const p=m===void 0?a:m,K=m===void 0?[]:a;return this.addTimeGroupBy(t,K,p,"date_type")}addTimestampGroupBy(t,a,m){const p=m===void 0?a:m,K=m===void 0?[]:a;return this.addTimeGroupBy(t,K,p,"timestamp_type")}addTimestamptzGroupBy(t,a,m){const p=m===void 0?a:m,K=m===void 0?[]:a;return this.addTimeGroupBy(t,K,p,"timestamptz_type")}addAggregate(t,a=[],m){const p=this.makeField(t,a,m,"measure");return this.addOperation(p),p}addNest(t,a){const m=this.makeField(t,[],a,"view");return this.addOperation(m),m}makeField(t,a,m,p){const K=this.getInputSchema(),de=c.schemaGet(K,t,a);if(de===void 0)throw new Error(`No such field ${t}`);if(de.kind!==p){const Pe=Me(p),X=p;throw new Error(`Cannot ${Pe} non-${X} ${t}`)}return p==="dimension"?le.fromReference(t,a,m):p==="measure"?ve.fromReference(t,a,m):Y.fromReference(t,a,m)}addOperation(t){if((t instanceof le||t instanceof ve||t instanceof Y||t instanceof J)&&this.hasFieldNamed(t.name))throw new Error(`Query already has a field named ${t.name}`);const a=this.findInsertionPoint(t.kind);return this.operations.insert(t,a),t}getRefinementSchema(){const t=[];for(const a of this.operations.iter())(a instanceof le||a instanceof ve||a instanceof Y||a instanceof J)&&t.push(a.getFieldInfo());return{fields:t}}setLimit(t){et.validateLimit(t);const a=[...this.operations.iter()].find(u.ASTViewOperation.isLimit);a?a.limit=t:this.operations.add(new et({kind:"limit",limit:t}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const t=te.segmentRefinementOf(this.build());return U(this,t),t.refinement.as.SegmentViewDefinition()}addViewRefinement(t,a){const{error:m}=this.isValidViewRefinement(t,a);if(m)throw new Error(m);const p=te.viewRefinementOf(this.build(),t,a);return U(this,p),p.refinement.as.ReferenceViewDefinition()}getInputSchema(){return kt(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(t,a){return G(this,t,a)}getInheritedAnnotations(){return[]}}u.ASTSegmentViewDefinition=ce;class be extends d{constructor(t){super(t,t.map(a=>u.ASTViewOperation.from(a)))}get items(){return this.children}set items(t){this.edit(),this.children=t}get segment(){return this.parent.as.SegmentViewDefinition()}}u.ASTViewOperationList=be,u.ASTViewOperation={from($){switch($.kind){case"group_by":return new le($);case"aggregate":return new ve($);case"order_by":return new ye($);case"nest":return new Y($);case"limit":return new et($);case"where":return new we($);case"drill":return new Le($);case"having":return new Qe($);case"calculate":return new J($)}},isLimit($){return $ instanceof et}};class ye extends e{constructor(t){super(t,{kind:"order_by",field_reference:new x(t.field_reference),direction:t.direction}),this.node=t,this.kind="order_by"}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get direction(){return this.children.direction}set direction(t){this.direction!==t&&(this.edit(),this.children.direction=t)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(t){const a=this.list.segment.getOutputSchema();c.schemaGet(a,t,[]),this.edit(),this.children.field_reference=new x({name:t})}setDirection(t){this.direction=t}}u.ASTOrderByViewOperation=ye;class le extends e{constructor(t){super(t,{kind:"group_by",name:t.name,field:new _(t.field)}),this.node=t,this.kind="group_by"}get field(){return this.children.field}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.field.name;if(a===void 0)throw new Error("Group by does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.field.name===t?this.children.name=void 0:this.children.name=t)}get list(){return this.parent.as.ViewOperationList()}rename(t){this.list.segment.renameField(this,t)}delete(){this.list.remove(this),this.list.segment.propagateUp(t=>{t instanceof ce&&t.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(t){this.edit(),this.field.annotations=t}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(t="# "){return st(t,this.field.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}static fromReference(t,a,m){return new le({kind:"group_by",name:m,field:{expression:{kind:"field_reference",name:t,path:a}}})}}u.ASTGroupByViewOperation=le;class ve extends e{constructor(t){super(t,{kind:"aggregate",name:t.name,field:new _(t.field)}),this.node=t,this.kind="aggregate"}get field(){return this.children.field}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.field.name;if(a===void 0)throw new Error("Aggregate does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.field.name===t?this.children.name=void 0:this.children.name=t)}get annotations(){return this.field.annotations}rename(t){this.list.segment.renameField(this,t)}convertToCalculateMovingAverage(t,a,m=0,p=[]){if(!(this.field.expression instanceof I))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const K=new J({kind:"calculate",name:t,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:a,rows_following:m,partition_fields:p.map(de=>({name:de}))}}});return this.list.add(K),K}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(t=>{t instanceof ce&&t.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:l.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(t="# "){return st(t,this.field.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}addWhere(t,a,m){const p=Array.isArray(a)?a:[],K=m===void 0?a:m,de=typeof K=="string"?K:tt(K),Pe=this.list.segment.getInputSchema(),X=y.schemaGet(Pe,t,p);ot(X,K);const De={filter:{kind:"filter_string",expression:{kind:"field_reference",name:t,path:p},filter:de}};if(this.field.expression instanceof T)return this.field.expression.where.add(new w(De)),this.field.expression;if(this.field.expression instanceof I){const Ye=this.field.expression.build();return this.field.expression=new T({kind:"filtered_field",field_reference:{name:Ye.name,path:Ye.path,parameters:Ye.parameters},where:[De]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(t,a,m){return new ve({kind:"aggregate",name:m,field:{expression:{kind:"field_reference",name:t,path:a}}})}}u.ASTAggregateViewOperation=ve;class _ extends e{constructor(t){super(t,{expression:u.ASTExpression.from(t.expression),annotations:t.annotations&&new it(t.annotations)}),this.node=t}get expression(){return this.children.expression}set expression(t){this.edit(),this.children.expression=t,t.parent=this}get name(){return this.expression.name}get type(){const t=this.expression.fieldType;if(t===void 0)throw new Error("Field expression does not have a type");return t}get annotations(){return this.children.annotations}set annotations(t){this.edit(),this.children.annotations=t}getReference(){if(!(this.expression instanceof N))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new it([]);return this.children.annotations=t,t.parent=this,t}getInheritedTag(t="# "){return st(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}u.ASTField=_,u.ASTExpression={from($){switch($.kind){case"field_reference":return new I($);case"filtered_field":return new T($);case"time_truncation":return new D($);case"literal_value":return new N($);case"moving_average":return new h($)}}};class I extends e{constructor(t){super(t,{kind:t.kind,name:t.name,path:t.path,parameters:t.parameters&&new H(t.parameters)}),this.node=t,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(t){this.edit(),this.children.parameters=t}get segment(){const t=this.parent;if(t instanceof _)return t.segment;if(t instanceof Be||t instanceof Xe)return t.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const t=this.segment.getInputSchema(),m=this.parent instanceof Xe&&this.parent.parent instanceof Le?c.schemaGetDrillField(t,this.name,this.path):c.schemaGet(t,this.name,this.path);if(m.kind!=="dimension"&&m.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return m}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}getOrAddParameters(){return k.getOrAddParameters(this)}setParameter(t,a){return k.setParameter(this,t,a)}tryGetParameter(t){return k.tryGetParameter(this,t)}}u.ASTReferenceExpression=I;class D extends e{constructor(t){super(t,{kind:t.kind,field_reference:new x(t.field_reference),truncation:t.truncation}),this.node=t,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(t){this.edit(),this.children.truncation=t}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=c.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){const t=this.getFieldInfo();if(t.type.kind==="date_type")return{...t.type,timeframe:M(this.truncation)};if(t.type.kind==="timestamp_type"||t.type.kind==="timestamptz_type")return{...t.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}u.ASTTimeTruncationExpression=D;class N extends e{constructor(t){super(t,{kind:t.kind,literal_value:u.ASTLiteralValue.from(t.literal_value)}),this.node=t,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}u.ASTLiteralValueExpression=N;class A extends d{constructor(t){super(t,t.map(a=>new x(a)))}}u.ASTFieldReferenceList=A;class h extends e{constructor(t){super(t,{kind:t.kind,field_reference:new x(t.field_reference),rows_preceding:t.rows_preceding,rows_following:t.rows_following,partition_fields:new A(t.partition_fields||[])}),this.node=t,this.kind="moving_average"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get rowsPreceding(){return this.children.rows_preceding}set rowsPreceding(t){this.edit(),this.children.rows_preceding=t}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(t){this.edit(),this.children.rows_following=t}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(t){this.children.partition_fields=new A(t)}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=c.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}u.ASTMovingAverageExpression=h;class w extends e{constructor(t){super(t,{filter:u.ASTFilter.from(t.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}u.ASTFilterOperation=w;class F extends d{constructor(t){super(t,t.map(a=>new w(a)))}get expression(){return this.parent.as.FilteredFieldExpression()}}u.ASTFilterOperationList=F;class T extends e{constructor(t){super(t,{kind:t.kind,field_reference:new x(t.field_reference),where:new F(t.where)}),this.node=t,this.kind="filtered_field"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get where(){return this.children.where}get field(){return this.parent.as.Field()}getFieldInfo(){const t=this.field.segment.getInputSchema(),a=c.schemaGet(t,this.name,this.fieldReference.path);if(a.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var t;return(t=this.getFieldInfo().annotations)!==null&&t!==void 0?t:[]}}u.ASTFilteredFieldExpression=T;function M($){switch($){case"day":case"week":case"month":case"year":case"quarter":return $;default:throw new Error("Invalid date timeframe")}}class Y extends e{constructor(t){super(t,{kind:"nest",name:t.name,view:new Ie(t.view)}),this.node=t,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var t;const a=(t=this.children.name)!==null&&t!==void 0?t:this.view.name;if(a===void 0)throw new Error("Nest does not have a name");return a}set name(t){this.name!==t&&(this.edit(),this.view.name===t?this.children.name=void 0:this.children.name=t)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(t="# "){return st(t,this.view.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}delete(){this.list.remove(this)}rename(t){this.list.segment.renameField(this,t)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(t,a,m){return new Y({kind:"nest",name:m,view:{definition:{kind:"view_reference",name:t,path:a}}})}}u.ASTNestViewOperation=Y;class we extends e{constructor(t){super(t,{kind:"where",filter:u.ASTFilter.from(t.filter)}),this.node=t,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTWhereViewOperation=we;class Le extends e{constructor(t){super(t,{kind:"drill",filter:u.ASTFilter.from(t.filter)}),this.node=t,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTDrillViewOperation=Le;class Qe extends e{constructor(t){super(t,{kind:"having",filter:u.ASTFilter.from(t.filter)}),this.node=t,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTHavingViewOperation=Qe;class J extends e{constructor(t){super(t,{kind:"calculate",field:new _(t.field),name:t.name}),this.node=t,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(t){this.edit(),this.children.field.expression=t,t.parent=this}get name(){return this.node.name}set name(t){this.name!==t&&(this.edit(),this.node.name=t)}getFieldInfo(){return{annotations:[{value:l.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"calculate",name:this.name,type:this.expression.fieldType}}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTCalculateViewOperation=J,u.ASTFilter={from($){switch($.kind){case"filter_string":return new Be($);case"literal_equality":return new Xe($)}},getSegment($){const t=$.parent;return t instanceof w?t.list.expression.field.segment:t.list.segment}};class Be extends e{constructor(t){super(t,{kind:"filter_string",expression:u.ASTExpression.from(t.expression),filter:t.filter}),this.node=t,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(t){this.edit(),this.children.filter=t}setFilterString(t){const a=this.getFilterType();R(this.filterString,a),this.filterString=t}get segment(){return u.ASTFilter.getSegment(this)}getFieldInfo(){const t=this.expression.getFieldInfo();if(t===void 0||t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return t}getFilterType(){const t=this.getFieldInfo();return ft(t)}setFilter(t){const a=this.getFilterType();if(a!==t.kind)throw new Error(`Invalid filter: expected type ${a}, got ${t.kind}`);this.filterString=tt(t)}getFilter(){const t=this.getFilterType();return R(this.filterString,t)}}u.ASTFilterWithFilterString=Be;class Xe extends e{constructor(t){super(t,{kind:"literal_equality",expression:u.ASTExpression.from(t.expression),value:u.ASTLiteralValue.from(t.value)}),this.node=t,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return u.ASTFilter.getSegment(this)}}u.ASTFilterWithLiteralEquality=Xe;class Ie extends e{constructor(t){super(t,{definition:z.from(t.definition),annotations:t.annotations&&new it(t.annotations)}),this.node=t}get definition(){return this.children.definition}set definition(t){this.edit(),this.children.definition=t,t.parent=this}get name(){return this.definition.getImplicitName()}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}get nest(){return this.parent.as.NestViewOperation()}getInputSchema(){return this.nest.list.segment.getInputSchema()}getOutputSchema(){return this.definition.getRefinementSchema()}propagateUp(t){this.propagateDown(t)}propagateDown(t){t(this.definition),this.definition.propagateDown(t)}reorderFields(t){this.definition instanceof ce?this.definition.reorderFields(t):this.getOrAddAnnotations().setTagProperty(["field_order"],t)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const t=new it([]);return this.children.annotations=t,t.parent=this,t}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(t="# "){return st(t,this.getInheritedAnnotations())}getIntrinsicTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(t))!==null&&m!==void 0?m:new l.Tag}getTag(t="# "){var a,m;return(m=(a=this.annotations)===null||a===void 0?void 0:a.getTag(t))!==null&&m!==void 0?m:this.getInheritedTag(t)}setTagProperty(t,a=null,m="# "){this.getOrAddAnnotations().setTagProperty(t,a,m)}removeTagProperty(t,a="# "){this.getTag().has(...t)&&this.getOrAddAnnotations().removeTagProperty(t,a)}}u.ASTView=Ie;class et extends e{get limit(){return this.children.limit}set limit(t){et.validateLimit(t),this.edit(),this.children.limit=t}constructor(t){super(t,{kind:t.kind,limit:t.limit}),this.node=t,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(t){if(!Number.isInteger(t))throw new Error("Limit must be an integer")}}u.ASTLimitViewOperation=et;function Me($){switch($){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function wt($){return $}class it extends d{constructor(t){super(t,t.map(a=>new at(a)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(t="# "){return st(t,this.items)}getTag(t="# "){return st(t,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(t=>t.node)}setTagProperty(t,a=null,m="# "){let p;for(let K=this.items.length-1;K>=0;K--){const de=this.index(K);if(de.hasPrefix(m)&&(p=de,de.hasIntrinsicTagProperty(t))){de.setTagProperty(t,a);return}}p?p.setTagProperty(t,a):this.add(new at({value:new l.Tag({prefix:m}).set(t,a).toString()}))}removeTagProperty(t,a="# "){let m;for(let p=this.items.length-1;p>=0;p--){const K=this.index(p);if(K.hasPrefix(a)&&(m=K,K.hasIntrinsicTagProperty(t))){K.removeTagProperty(t);return}}m?m.removeTagProperty(t):this.add(new at({value:new l.Tag({prefix:a}).unset(...t).toString()}))}}u.ASTAnnotationList=it;class at extends e{get value(){return this.children.value}set value(t){this.edit(),this.children.value=t}constructor(t){super(t,{value:t.value}),this.node=t}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const t=new l.TagParser;return t.parseAnnotation(this.value),t.finish()}getTag(){const t=new l.TagParser;for(const a of this.list.getInheritedAnnotations())t.parseAnnotation(a.value);for(let a=0;a<=this.index;a++)t.parseAnnotation(this.list.index(a).value);return t.finish()}hasPrefix(t){return this.value.startsWith(t)}hasIntrinsicTagProperty(t){return this.getIntrinsicTag().has(...t)}setTagProperty(t,a){this.value=this.getIntrinsicTag().set(t,a).toString()}removeTagProperty(t){this.value=this.getTag().unset(...t).toString()}}u.ASTAnnotation=at;function st($,t=[],a=[]){const m=new l.TagParser;for(const K of a)m.parseAnnotation(K.value);const p=t.map(K=>K.value).filter(K=>typeof $=="string"?K.startsWith($):K.match($));for(const K of p)m.parseAnnotation(K);return m.finish()}function tt($){switch($.kind){case"string":return f.StringFilterExpression.unparse($.parsed);case"number":return f.NumberFilterExpression.unparse($.parsed);case"boolean":return f.BooleanFilterExpression.unparse($.parsed);case"timestamp":case"timestamptz":case"date":return f.TemporalFilterExpression.unparse($.parsed)}}function R($,t){function a(m){const p=m.filter(K=>K.severity==="error");if(p.length!==0)throw new Error(`Invalid Malloy filter string: ${p[0].message}`)}switch(t){case"string":{const m=f.StringFilterExpression.parse($);return a(m.log),{kind:t,parsed:m.parsed}}case"number":{const m=f.NumberFilterExpression.parse($);return a(m.log),{kind:t,parsed:m.parsed}}case"boolean":{const m=f.BooleanFilterExpression.parse($);return a(m.log),{kind:t,parsed:m.parsed}}case"timestamp":case"timestamptz":case"date":{const m=f.TemporalFilterExpression.parse($);return a(m.log),{kind:t,parsed:m.parsed}}case"other":throw new Error("Not implemented")}}function re($){return"kind"in $?$:{...$,kind:"source"}}function Oe($){switch($){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function pe($,t){return $.toString().padStart(t,"0")}function Ve($){const t=pe($.getUTCFullYear(),4),a=pe($.getUTCMonth()+1,2),m=pe($.getUTCDate(),2),p=pe($.getUTCHours(),2),K=pe($.getUTCMinutes(),2),de=pe($.getUTCSeconds(),2);return`${t}-${a}-${m} ${p}:${K}:${de}`}function ze($,t){const a=$??[],m=t??[];return a.length===m.length&&a.every((p,K)=>p===m[K])}function ft($){switch($.type.kind){case"string_type":return"string";case"boolean_type":return"boolean";case"number_type":return"number";case"date_type":return"date";case"timestamp_type":return"timestamp";case"timestamptz_type":return"timestamp";default:return"other"}}function ot($,t){if($.kind!=="dimension"&&$.kind!=="measure")throw new Error(`Cannot filter by field of type ${$.kind}`);const a=ft($);if(typeof t=="string")R(t,a);else if(t.kind!==a)throw new Error(`Invalid filter for field ${$.name}; expected type ${a}, but got ${t.kind}`)}function kt($){if($ instanceof ke)return $.getSourceInfo().schema;if($ instanceof me)throw new Error("unimplemented");return $.getInputSchema()}})(vt)),vt}var yn;function fs(){return yn||(yn=1,(function(u){var Q=It&&It.__createBinding||(Object.create?(function(V,g,l,f){f===void 0&&(f=l);var c=Object.getOwnPropertyDescriptor(g,l);(!c||("get"in c?!g.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return g[l]}}),Object.defineProperty(V,f,c)}):(function(V,g,l,f){f===void 0&&(f=l),V[f]=g[l]})),B=It&&It.__exportStar||function(V,g){for(var l in V)l!=="default"&&!Object.prototype.hasOwnProperty.call(g,l)&&Q(g,V,l)};Object.defineProperty(u,"__esModule",{value:!0}),B(ls(),u)})(It)),It}var bn=fs();const us=Ni(bn),ps=Mi({__proto__:null,default:us},[bn]);export{rs as a,os as b,bn as d,ps as i,Yi as r};