mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
2 lines • 1.1 MB
JavaScript
/*! For license information please see mathjslab.node.cjs2022.js.LICENSE.txt */
(()=>{var __webpack_modules__={3110(t,e,r){var s;!function(){"use strict";var i,n,a,o=9e15,l=1e9,c="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",h="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",d={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},m=!0,p="[DecimalError] ",f=p+"Invalid argument: ",g=p+"Precision limit exceeded",y=p+"crypto unavailable",x="[object Decimal]",C=Math.floor,E=Math.pow,A=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,_=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,S=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,v=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,T=1e7,b=u.length-1,N=h.length-1,I={toStringTag:x};function M(t){var e,r,s,i=t.length-1,n="",a=t[0];if(i>0){for(n+=a,e=1;e<i;e++)(r=7-(s=t[e]+"").length)&&(n+=$(r)),n+=s;(r=7-(s=(a=t[e])+"").length)&&(n+=$(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return n+a}function w(t,e,r){if(t!==~~t||t<e||t>r)throw Error(f+t)}function L(t,e,r,s){var i,n,a,o;for(n=t[0];n>=10;n/=10)--e;return--e<0?(e+=7,i=0):(i=Math.ceil((e+1)/7),e%=7),n=E(10,7-e),o=t[i]%n|0,null==s?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==n||r>3&&o+1==n/2)&&(t[i+1]/n/100|0)==E(10,e-2)-1||(o==n/2||0==o)&&!(t[i+1]/n/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),a=(s||r<4)&&9999==o||!s&&r>3&&4999==o):a=((s||r<4)&&o+1==n||!s&&r>3&&o+1==n/2)&&(t[i+1]/n/1e3|0)==E(10,e-3)-1,a}function O(t,e,r){for(var s,i,n=[0],a=0,o=t.length;a<o;){for(i=n.length;i--;)n[i]*=e;for(n[0]+=c.indexOf(t.charAt(a++)),s=0;s<n.length;s++)n[s]>r-1&&(void 0===n[s+1]&&(n[s+1]=0),n[s+1]+=n[s]/r|0,n[s]%=r)}return n.reverse()}I.absoluteValue=I.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),D(t)},I.ceil=function(){return D(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(t,e){var r=this,s=r.constructor;if(t=new s(t),e=new s(e),!t.s||!e.s)return new s(NaN);if(t.gt(e))throw Error(f+e);return r.cmp(t)<0?t:r.cmp(e)>0?e:new s(r)},I.comparedTo=I.cmp=function(t){var e,r,s,i,n=this,a=n.d,o=(t=new n.constructor(t)).d,l=n.s,c=t.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(n.e!==t.e)return n.e>t.e^l<0?1:-1;for(e=0,r=(s=a.length)<(i=o.length)?s:i;e<r;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return s===i?0:s>i^l<0?1:-1},I.cosine=I.cos=function(){var t,e,r=this,s=r.constructor;return r.d?r.d[0]?(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+7,s.rounding=1,r=function(t,e){var r,s,i;if(e.isZero())return e;(s=e.d.length)<32?i=(1/J(4,r=Math.ceil(s/3))).toString():(r=16,i="2.3283064365386962890625e-10"),t.precision+=r,e=K(t,1,e.times(i),new t(1));for(var n=r;n--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return t.precision-=r,e}(s,Z(s,r)),s.precision=t,s.rounding=e,D(2==a||3==a?r.neg():r,t,e,!0)):new s(1):new s(NaN)},I.cubeRoot=I.cbrt=function(){var t,e,r,s,i,n,a,o,l,c,u=this,h=u.constructor;if(!u.isFinite()||u.isZero())return new h(u);for(m=!1,(n=u.s*E(u.s*u,1/3))&&Math.abs(n)!=1/0?s=new h(n.toString()):(r=M(u.d),(n=((t=u.e)-r.length+1)%3)&&(r+=1==n||-2==n?"0":"00"),n=E(r,1/3),t=C((t+1)/3)-(t%3==(t<0?-1:2)),(s=new h(r=n==1/0?"5e"+t:(r=n.toExponential()).slice(0,r.indexOf("e")+1)+t)).s=u.s),a=(t=h.precision)+3;;)if(c=(l=(o=s).times(o).times(o)).plus(u),s=R(c.plus(u).times(o),c.plus(l),a+2,1),M(o.d).slice(0,a)===(r=M(s.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(s,t+1,1),e=!s.times(s).times(s).eq(u));break}if(!i&&(D(o,t+1,0),o.times(o).times(o).eq(u))){s=o;break}a+=4,i=1}return m=!0,D(s,t,h.rounding,e)},I.decimalPlaces=I.dp=function(){var t,e=this.d,r=NaN;if(e){if(r=7*((t=e.length-1)-C(this.e/7)),t=e[t])for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r},I.dividedBy=I.div=function(t){return R(this,new this.constructor(t))},I.dividedToIntegerBy=I.divToInt=function(t){var e=this.constructor;return D(R(this,new e(t),0,1,1),e.precision,e.rounding)},I.equals=I.eq=function(t){return 0===this.cmp(t)},I.floor=function(){return D(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(t){return this.cmp(t)>0},I.greaterThanOrEqualTo=I.gte=function(t){var e=this.cmp(t);return 1==e||0===e},I.hyperbolicCosine=I.cosh=function(){var t,e,r,s,i,n=this,a=n.constructor,o=new a(1);if(!n.isFinite())return new a(n.s?1/0:NaN);if(n.isZero())return o;r=a.precision,s=a.rounding,a.precision=r+Math.max(n.e,n.sd())+4,a.rounding=1,(i=n.d.length)<32?e=(1/J(4,t=Math.ceil(i/3))).toString():(t=16,e="2.3283064365386962890625e-10"),n=K(a,1,n.times(e),new a(1),!0);for(var l,c=t,u=new a(8);c--;)l=n.times(n),n=o.minus(l.times(u.minus(l.times(u))));return D(n,a.precision=r,a.rounding=s,!0)},I.hyperbolicSine=I.sinh=function(){var t,e,r,s,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(e=n.precision,r=n.rounding,n.precision=e+Math.max(i.e,i.sd())+4,n.rounding=1,(s=i.d.length)<3)i=K(n,2,i,i,!0);else{t=(t=1.4*Math.sqrt(s))>16?16:0|t,i=K(n,2,i=i.times(1/J(5,t)),i,!0);for(var a,o=new n(5),l=new n(16),c=new n(20);t--;)a=i.times(i),i=i.times(o.plus(a.times(l.times(a).plus(c))))}return n.precision=e,n.rounding=r,D(i,e,r,!0)},I.hyperbolicTangent=I.tanh=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+7,s.rounding=1,R(r.sinh(),r.cosh(),s.precision=t,s.rounding=e)):new s(r.s)},I.inverseCosine=I.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),s=e.precision,i=e.rounding;return-1!==r?0===r?t.isNeg()?V(e,s,i):new e(0):new e(NaN):t.isZero()?V(e,s+4,i).times(.5):(e.precision=s+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=s,e.rounding=i,t.times(2))},I.inverseHyperbolicCosine=I.acosh=function(){var t,e,r=this,s=r.constructor;return r.lte(1)?new s(r.eq(1)?0:NaN):r.isFinite()?(t=s.precision,e=s.rounding,s.precision=t+Math.max(Math.abs(r.e),r.sd())+4,s.rounding=1,m=!1,r=r.times(r).minus(1).sqrt().plus(r),m=!0,s.precision=t,s.rounding=e,r.ln()):new s(r)},I.inverseHyperbolicSine=I.asinh=function(){var t,e,r=this,s=r.constructor;return!r.isFinite()||r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,s.rounding=1,m=!1,r=r.times(r).plus(1).sqrt().plus(r),m=!0,s.precision=t,s.rounding=e,r.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var t,e,r,s,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=n.precision,e=n.rounding,s=i.sd(),Math.max(s,t)<2*-i.e-1?D(new n(i),t,e,!0):(n.precision=r=s-i.e,i=R(i.plus(1),new n(1).minus(i),r+t,1),n.precision=t+4,n.rounding=1,i=i.ln(),n.precision=t,n.rounding=e,i.times(.5))):new n(NaN)},I.inverseSine=I.asin=function(){var t,e,r,s,i=this,n=i.constructor;return i.isZero()?new n(i):(e=i.abs().cmp(1),r=n.precision,s=n.rounding,-1!==e?0===e?((t=V(n,r+4,s).times(.5)).s=i.s,t):new n(NaN):(n.precision=r+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=r,n.rounding=s,i.times(2)))},I.inverseTangent=I.atan=function(){var t,e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(c.isFinite()){if(c.isZero())return new u(c);if(c.abs().eq(1)&&h+4<=N)return(a=V(u,h+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new u(NaN);if(h+4<=N)return(a=V(u,h+4,d).times(.5)).s=c.s,a}for(u.precision=o=h+10,u.rounding=1,t=r=Math.min(28,o/7+2|0);t;--t)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(m=!1,e=Math.ceil(o/7),s=1,l=c.times(c),a=new u(c),i=c;-1!==t;)if(i=i.times(l),n=a.minus(i.div(s+=2)),i=i.times(l),void 0!==(a=n.plus(i.div(s+=2))).d[e])for(t=e;a.d[t]===n.d[t]&&t--;);return r&&(a=a.times(2<<r-1)),m=!0,D(a,u.precision=h,u.rounding=d,!0)},I.isFinite=function(){return!!this.d},I.isInteger=I.isInt=function(){return!!this.d&&C(this.e/7)>this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&0===this.d[0]},I.lessThan=I.lt=function(t){return this.cmp(t)<0},I.lessThanOrEqualTo=I.lte=function(t){return this.cmp(t)<1},I.logarithm=I.log=function(t){var e,r,s,i,n,a,o,l,c=this,u=c.constructor,h=u.precision,d=u.rounding;if(null==t)t=new u(10),e=!0;else{if(r=(t=new u(t)).d,t.s<0||!r||!r[0]||t.eq(1))return new u(NaN);e=t.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new u(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(e)if(r.length>1)n=!0;else{for(i=r[0];i%10==0;)i/=10;n=1!==i}if(m=!1,a=z(c,o=h+5),s=e?k(u,o+10):z(t,o),L((l=R(a,s,o,1)).d,i=h,d))do{if(a=z(c,o+=10),s=e?k(u,o+10):z(t,o),l=R(a,s,o,1),!n){+M(l.d).slice(i+1,i+15)+1==1e14&&(l=D(l,h+1,0));break}}while(L(l.d,i+=10,d));return m=!0,D(l,h,d)},I.minus=I.sub=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,p=this,f=p.constructor;if(t=new f(t),!p.d||!t.d)return p.s&&t.s?p.d?t.s=-t.s:t=new f(t.d||p.s!==t.s?p:NaN):t=new f(NaN),t;if(p.s!=t.s)return t.s=-t.s,p.plus(t);if(c=p.d,d=t.d,o=f.precision,l=f.rounding,!c[0]||!d[0]){if(d[0])t.s=-t.s;else{if(!c[0])return new f(3===l?-0:0);t=new f(p)}return m?D(t,o,l):t}if(r=C(t.e/7),u=C(p.e/7),c=c.slice(),n=u-r){for((h=n<0)?(e=c,n=-n,a=d.length):(e=d,r=u,a=c.length),n>(s=Math.max(Math.ceil(o/7),a)+2)&&(n=s,e.length=1),e.reverse(),s=n;s--;)e.push(0);e.reverse()}else{for((h=(s=c.length)<(a=d.length))&&(a=s),s=0;s<a;s++)if(c[s]!=d[s]){h=c[s]<d[s];break}n=0}for(h&&(e=c,c=d,d=e,t.s=-t.s),a=c.length,s=d.length-a;s>0;--s)c[a++]=0;for(s=d.length;s>n;){if(c[--s]<d[s]){for(i=s;i&&0===c[--i];)c[i]=T-1;--c[i],c[s]+=T}c[s]-=d[s]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(t.d=c,t.e=P(c,r),m?D(t,o,l):t):new f(3===l?-0:0)},I.modulo=I.mod=function(t){var e,r=this,s=r.constructor;return t=new s(t),!r.d||!t.s||t.d&&!t.d[0]?new s(NaN):!t.d||r.d&&!r.d[0]?D(new s(r),s.precision,s.rounding):(m=!1,9==s.modulo?(e=R(r,t.abs(),0,3,1)).s*=t.s:e=R(r,t,0,s.modulo,1),e=e.times(t),m=!0,r.minus(e))},I.naturalExponential=I.exp=function(){return j(this)},I.naturalLogarithm=I.ln=function(){return z(this)},I.negated=I.neg=function(){var t=new this.constructor(this);return t.s=-t.s,D(t)},I.plus=I.add=function(t){var e,r,s,i,n,a,o,l,c,u,h=this,d=h.constructor;if(t=new d(t),!h.d||!t.d)return h.s&&t.s?h.d||(t=new d(t.d||h.s===t.s?h:NaN)):t=new d(NaN),t;if(h.s!=t.s)return t.s=-t.s,h.minus(t);if(c=h.d,u=t.d,o=d.precision,l=d.rounding,!c[0]||!u[0])return u[0]||(t=new d(h)),m?D(t,o,l):t;if(n=C(h.e/7),s=C(t.e/7),c=c.slice(),i=n-s){for(i<0?(r=c,i=-i,a=u.length):(r=u,s=n,a=c.length),i>(a=(n=Math.ceil(o/7))>a?n+1:a+1)&&(i=a,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((a=c.length)-(i=u.length)<0&&(i=a,r=u,u=c,c=r),e=0;i;)e=(c[--i]=c[i]+u[i]+e)/T|0,c[i]%=T;for(e&&(c.unshift(e),++s),a=c.length;0==c[--a];)c.pop();return t.d=c,t.e=P(c,s),m?D(t,o,l):t},I.precision=I.sd=function(t){var e,r=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(f+t);return r.d?(e=U(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e},I.round=function(){var t=this,e=t.constructor;return D(new e(t),t.e+1,e.rounding)},I.sine=I.sin=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+Math.max(r.e,r.sd())+7,s.rounding=1,r=function(t,e){var r,s=e.d.length;if(s<3)return e.isZero()?e:K(t,2,e,e);r=(r=1.4*Math.sqrt(s))>16?16:0|r,e=K(t,2,e=e.times(1/J(5,r)),e);for(var i,n=new t(5),a=new t(16),o=new t(20);r--;)i=e.times(e),e=e.times(n.plus(i.times(a.times(i).minus(o))));return e}(s,Z(s,r)),s.precision=t,s.rounding=e,D(a>2?r.neg():r,t,e,!0)):new s(NaN)},I.squareRoot=I.sqrt=function(){var t,e,r,s,i,n,a=this,o=a.d,l=a.e,c=a.s,u=a.constructor;if(1!==c||!o||!o[0])return new u(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(m=!1,0==(c=Math.sqrt(+a))||c==1/0?(((e=M(o)).length+l)%2==0&&(e+="0"),c=Math.sqrt(e),l=C((l+1)/2)-(l<0||l%2),s=new u(e=c==1/0?"5e"+l:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+l)):s=new u(c.toString()),r=(l=u.precision)+3;;)if(s=(n=s).plus(R(a,n,r+2,1)).times(.5),M(n.d).slice(0,r)===(e=M(s.d)).slice(0,r)){if("9999"!=(e=e.slice(r-3,r+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(D(s,l+1,1),t=!s.times(s).eq(a));break}if(!i&&(D(n,l+1,0),n.times(n).eq(a))){s=n;break}r+=4,i=1}return m=!0,D(s,l,u.rounding,t)},I.tangent=I.tan=function(){var t,e,r=this,s=r.constructor;return r.isFinite()?r.isZero()?new s(r):(t=s.precision,e=s.rounding,s.precision=t+10,s.rounding=1,(r=r.sin()).s=1,r=R(r,new s(1).minus(r.times(r)).sqrt(),t+10,0),s.precision=t,s.rounding=e,D(2==a||4==a?r.neg():r,t,e,!0)):new s(NaN)},I.times=I.mul=function(t){var e,r,s,i,n,a,o,l,c,u=this,h=u.constructor,d=u.d,p=(t=new h(t)).d;if(t.s*=u.s,!(d&&d[0]&&p&&p[0]))return new h(!t.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:d&&p?0*t.s:t.s/0);for(r=C(u.e/7)+C(t.e/7),(l=d.length)<(c=p.length)&&(n=d,d=p,p=n,a=l,l=c,c=a),n=[],s=a=l+c;s--;)n.push(0);for(s=c;--s>=0;){for(e=0,i=l+s;i>s;)o=n[i]+p[s]*d[i-s-1]+e,n[i--]=o%T|0,e=o/T|0;n[i]=(n[i]+e)%T|0}for(;!n[--a];)n.pop();return e?++r:n.shift(),t.d=n,t.e=P(n,r),m?D(t,h.precision,h.rounding):t},I.toBinary=function(t,e){return X(this,2,t,e)},I.toDecimalPlaces=I.toDP=function(t,e){var r=this,s=r.constructor;return r=new s(r),void 0===t?r:(w(t,0,l),void 0===e?e=s.rounding:w(e,0,8),D(r,t+r.e+1,e))},I.toExponential=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=F(s,!0):(w(t,0,l),void 0===e?e=i.rounding:w(e,0,8),r=F(s=D(new i(s),t+1,e),!0,t+1)),s.isNeg()&&!s.isZero()?"-"+r:r},I.toFixed=function(t,e){var r,s,i=this,n=i.constructor;return void 0===t?r=F(i):(w(t,0,l),void 0===e?e=n.rounding:w(e,0,8),r=F(s=D(new n(i),t+i.e+1,e),!1,t+s.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},I.toFraction=function(t){var e,r,s,i,n,a,o,l,c,u,h,d,p=this,g=p.d,y=p.constructor;if(!g)return new y(p);if(c=r=new y(1),s=l=new y(0),a=(n=(e=new y(s)).e=U(g)-p.e-1)%7,e.d[0]=E(10,a<0?7+a:a),null==t)t=n>0?e:c;else{if(!(o=new y(t)).isInt()||o.lt(c))throw Error(f+o);t=o.gt(e)?n>0?e:c:o}for(m=!1,o=new y(M(g)),u=y.precision,y.precision=n=7*g.length*2;h=R(o,e,0,1,1),1!=(i=r.plus(h.times(s))).cmp(t);)r=s,s=i,i=c,c=l.plus(h.times(i)),l=i,i=e,e=o.minus(h.times(i)),o=i;return i=R(t.minus(r),s,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(s)),l.s=c.s=p.s,d=R(c,s,n,1).minus(p).abs().cmp(R(l,r,n,1).minus(p).abs())<1?[c,s]:[l,r],y.precision=u,m=!0,d},I.toHexadecimal=I.toHex=function(t,e){return X(this,16,t,e)},I.toNearest=function(t,e){var r=this,s=r.constructor;if(r=new s(r),null==t){if(!r.d)return r;t=new s(1),e=s.rounding}else{if(t=new s(t),void 0===e?e=s.rounding:w(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(m=!1,r=R(r,t,0,e,1).times(t),m=!0,D(r)):(t.s=r.s,r=t),r},I.toNumber=function(){return+this},I.toOctal=function(t,e){return X(this,8,t,e)},I.toPower=I.pow=function(t){var e,r,s,i,n,a,o=this,l=o.constructor,c=+(t=new l(t));if(!(o.d&&t.d&&o.d[0]&&t.d[0]))return new l(E(+o,c));if((o=new l(o)).eq(1))return o;if(s=l.precision,n=l.rounding,t.eq(1))return D(o,s,n);if((e=C(t.e/7))>=t.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=B(l,o,r,s),t.s<0?new l(1).div(i):D(i,s,n);if((a=o.s)<0){if(e<t.d.length-1)return new l(NaN);if(1&t.d[e]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(e=0!=(r=E(+o,c))&&isFinite(r)?new l(r+"").e:C(c*(Math.log("0."+M(o.d))/Math.LN10+o.e+1)))>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(m=!1,l.rounding=o.s=1,r=Math.min(12,(e+"").length),(i=j(t.times(z(o,s+r)),s)).d&&L((i=D(i,s+5,1)).d,s,n)&&(e=s+10,+M((i=D(j(t.times(z(o,e+r)),e),e+5,1)).d).slice(s+1,s+15)+1==1e14&&(i=D(i,s+1,0))),i.s=a,m=!0,l.rounding=n,D(i,s,n))},I.toPrecision=function(t,e){var r,s=this,i=s.constructor;return void 0===t?r=F(s,s.e<=i.toExpNeg||s.e>=i.toExpPos):(w(t,1,l),void 0===e?e=i.rounding:w(e,0,8),r=F(s=D(new i(s),t,e),t<=s.e||s.e<=i.toExpNeg,t)),s.isNeg()&&!s.isZero()?"-"+r:r},I.toSignificantDigits=I.toSD=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(w(t,1,l),void 0===e?e=r.rounding:w(e,0,8)),D(new r(this),t,e)},I.toString=function(){var t=this,e=t.constructor,r=F(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r},I.truncated=I.trunc=function(){return D(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var t=this,e=t.constructor,r=F(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};var R=function(){function t(t,e,r){var s,i=0,n=t.length;for(t=t.slice();n--;)s=t[n]*e+i,t[n]=s%r|0,i=s/r|0;return i&&t.unshift(i),t}function e(t,e,r,s){var i,n;if(r!=s)n=r>s?1:-1;else for(i=n=0;i<r;i++)if(t[i]!=e[i]){n=t[i]>e[i]?1:-1;break}return n}function r(t,e,r,s){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*s+t[r]-e[r];for(;!t[0]&&t.length>1;)t.shift()}return function(s,i,a,o,l,c){var u,h,d,m,p,f,g,y,x,E,A,_,S,v,b,N,I,M,w,L,O=s.constructor,R=s.s==i.s?1:-1,F=s.d,P=i.d;if(!(F&&F[0]&&P&&P[0]))return new O(s.s&&i.s&&(F?!P||F[0]!=P[0]:P)?F&&0==F[0]||!P?0*R:R/0:NaN);for(c?(p=1,h=s.e-i.e):(c=T,p=7,h=C(s.e/p)-C(i.e/p)),w=P.length,I=F.length,E=(x=new O(R)).d=[],d=0;P[d]==(F[d]||0);d++);if(P[d]>(F[d]||0)&&h--,null==a?(v=a=O.precision,o=O.rounding):v=l?a+(s.e-i.e)+1:a,v<0)E.push(1),f=!0;else{if(v=v/p+2|0,d=0,1==w){for(m=0,P=P[0],v++;(d<I||m)&&v--;d++)b=m*c+(F[d]||0),E[d]=b/P|0,m=b%P|0;f=m||d<I}else{for((m=c/(P[0]+1)|0)>1&&(P=t(P,m,c),F=t(F,m,c),w=P.length,I=F.length),N=w,_=(A=F.slice(0,w)).length;_<w;)A[_++]=0;(L=P.slice()).unshift(0),M=P[0],P[1]>=c/2&&++M;do{m=0,(u=e(P,A,w,_))<0?(S=A[0],w!=_&&(S=S*c+(A[1]||0)),(m=S/M|0)>1?(m>=c&&(m=c-1),1==(u=e(g=t(P,m,c),A,y=g.length,_=A.length))&&(m--,r(g,w<y?L:P,y,c))):(0==m&&(u=m=1),g=P.slice()),(y=g.length)<_&&g.unshift(0),r(A,g,_,c),-1==u&&(u=e(P,A,w,_=A.length))<1&&(m++,r(A,w<_?L:P,_,c)),_=A.length):0===u&&(m++,A=[0]),E[d++]=m,u&&A[0]?A[_++]=F[N]||0:(A=[F[N]],_=1)}while((N++<I||void 0!==A[0])&&v--);f=void 0!==A[0]}E[0]||E.shift()}if(1==p)x.e=h,n=f;else{for(d=1,m=E[0];m>=10;m/=10)d++;x.e=d+h*p-1,D(x,l?a+x.e+1:a,o,f)}return x}}();function D(t,e,r,s){var i,n,a,o,l,c,u,h,d,p=t.constructor;t:if(null!=e){if(!(h=t.d))return t;for(i=1,o=h[0];o>=10;o/=10)i++;if((n=e-i)<0)n+=7,a=e,l=(u=h[d=0])/E(10,i-a-1)%10|0;else if((d=Math.ceil((n+1)/7))>=(o=h.length)){if(!s)break t;for(;o++<=d;)h.push(0);u=l=0,i=1,a=(n%=7)-7+1}else{for(u=o=h[d],i=1;o>=10;o/=10)i++;l=(a=(n%=7)-7+i)<0?0:u/E(10,i-a-1)%10|0}if(s=s||e<0||void 0!==h[d+1]||(a<0?u:u%E(10,i-a-1)),c=r<4?(l||s)&&(0==r||r==(t.s<0?3:2)):l>5||5==l&&(4==r||s||6==r&&(n>0?a>0?u/E(10,i-a):0:h[d-1])%10&1||r==(t.s<0?8:7)),e<1||!h[0])return h.length=0,c?(e-=t.e+1,h[0]=E(10,(7-e%7)%7),t.e=-e||0):h[0]=t.e=0,t;if(0==n?(h.length=d,o=1,d--):(h.length=d+1,o=E(10,7-n),h[d]=a>0?(u/E(10,i-a)%E(10,a)|0)*o:0),c)for(;;){if(0==d){for(n=1,a=h[0];a>=10;a/=10)n++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;n!=o&&(t.e++,h[0]==T&&(h[0]=1));break}if(h[d]+=o,h[d]!=T)break;h[d--]=0,o=1}for(n=h.length;0===h[--n];)h.pop()}return m&&(t.e>p.maxE?(t.d=null,t.e=NaN):t.e<p.minE&&(t.e=0,t.d=[0])),t}function F(t,e,r){if(!t.isFinite())return G(t);var s,i=t.e,n=M(t.d),a=n.length;return e?(r&&(s=r-a)>0?n=n.charAt(0)+"."+n.slice(1)+$(s):a>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(t.e<0?"e":"e+")+t.e):i<0?(n="0."+$(-i-1)+n,r&&(s=r-a)>0&&(n+=$(s))):i>=a?(n+=$(i+1-a),r&&(s=r-i-1)>0&&(n=n+"."+$(s))):((s=i+1)<a&&(n=n.slice(0,s)+"."+n.slice(s)),r&&(s=r-a)>0&&(i+1===a&&(n+="."),n+=$(s))),n}function P(t,e){var r=t[0];for(e*=7;r>=10;r/=10)e++;return e}function k(t,e,r){if(e>b)throw m=!0,r&&(t.precision=r),Error(g);return D(new t(u),e,1,!0)}function V(t,e,r){if(e>N)throw Error(g);return D(new t(h),e,r,!0)}function U(t){var e=t.length-1,r=7*e+1;if(e=t[e]){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function $(t){for(var e="";t--;)e+="0";return e}function B(t,e,r,s){var i,n=new t(1),a=Math.ceil(s/7+4);for(m=!1;;){if(r%2&&Y((n=n.times(e)).d,a)&&(i=!0),0===(r=C(r/2))){r=n.d.length-1,i&&0===n.d[r]&&++n.d[r];break}Y((e=e.times(e)).d,a)}return m=!0,n}function H(t){return 1&t.d[t.d.length-1]}function q(t,e,r){for(var s,i,n=new t(e[0]),a=0;++a<e.length;){if(!(i=new t(e[a])).s){n=i;break}((s=n.cmp(i))===r||0===s&&n.s===r)&&(n=i)}return n}function j(t,e){var r,s,i,n,a,o,l,c=0,u=0,h=0,d=t.constructor,p=d.rounding,f=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==e?(m=!1,l=f):l=e,o=new d(.03125);t.e>-2;)t=t.times(o),h+=5;for(l+=s=Math.log(E(2,h))/Math.LN10*2+5|0,r=n=a=new d(1),d.precision=l;;){if(n=D(n.times(t),l,1),r=r.times(++u),M((o=a.plus(R(n,r,l,1))).d).slice(0,l)===M(a.d).slice(0,l)){for(i=h;i--;)a=D(a.times(a),l,1);if(null!=e)return d.precision=f,a;if(!(c<3&&L(a.d,l-s,p,c)))return D(a,d.precision=f,p,m=!0);d.precision=l+=10,r=n=o=new d(1),u=0,c++}a=o}}function z(t,e){var r,s,i,n,a,o,l,c,u,h,d,p=1,f=t,g=f.d,y=f.constructor,x=y.rounding,C=y.precision;if(f.s<0||!g||!g[0]||!f.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=f.s?NaN:g?0:f);if(null==e?(m=!1,u=C):u=e,y.precision=u+=10,s=(r=M(g)).charAt(0),!(Math.abs(n=f.e)<15e14))return c=k(y,u+2,C).times(n+""),f=z(new y(s+"."+r.slice(1)),u-10).plus(c),y.precision=C,null==e?D(f,C,x,m=!0):f;for(;s<7&&1!=s||1==s&&r.charAt(1)>3;)s=(r=M((f=f.times(t)).d)).charAt(0),p++;for(n=f.e,s>1?(f=new y("0."+r),n++):f=new y(s+"."+r.slice(1)),h=f,l=a=f=R(f.minus(1),f.plus(1),u,1),d=D(f.times(f),u,1),i=3;;){if(a=D(a.times(d),u,1),M((c=l.plus(R(a,new y(i),u,1))).d).slice(0,u)===M(l.d).slice(0,u)){if(l=l.times(2),0!==n&&(l=l.plus(k(y,u+2,C).times(n+""))),l=R(l,new y(p),u,1),null!=e)return y.precision=C,l;if(!L(l.d,u-10,x,o))return D(l,y.precision=C,x,m=!0);y.precision=u+=10,c=a=f=R(h.minus(1),h.plus(1),u,1),d=D(f.times(f),u,1),i=o=1}l=c,i+=2}}function G(t){return String(t.s*t.s/0)}function W(t,e){var r,s,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(r<0&&(r=s),r+=+e.slice(s+1),e=e.substring(0,s)):r<0&&(r=e.length),s=0;48===e.charCodeAt(s);s++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(s,i)){if(i-=s,t.e=r=r-s-1,t.d=[],s=(r+1)%7,r<0&&(s+=7),s<i){for(s&&t.d.push(+e.slice(0,s)),i-=7;s<i;)t.d.push(+e.slice(s,s+=7));s=7-(e=e.slice(s)).length}else s-=i;for(;s--;)e+="0";t.d.push(+e),m&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Q(t,e){var r,s,n,a,o,l,c,u,h;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),v.test(e))return W(t,e)}else if("Infinity"===e||"NaN"===e)return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(_.test(e))r=16,e=e.toLowerCase();else if(A.test(e))r=2;else{if(!S.test(e))throw Error(f+e);r=8}for((a=e.search(/p/i))>0?(c=+e.slice(a+1),e=e.substring(2,a)):e=e.slice(2),o=(a=e.indexOf("."))>=0,s=t.constructor,o&&(a=(l=(e=e.replace(".","")).length)-a,n=B(s,new s(r),a,2*a)),a=h=(u=O(e,r,T)).length-1;0===u[a];--a)u.pop();return a<0?new s(0*t.s):(t.e=P(u,h),t.d=u,m=!1,o&&(t=R(t,n,4*l)),c&&(t=t.times(Math.abs(c)<54?E(2,c):i.pow(2,c))),m=!0,t)}function K(t,e,r,s,i){var n,a,o,l,c=t.precision,u=Math.ceil(c/7);for(m=!1,l=r.times(r),o=new t(s);;){if(a=R(o.times(l),new t(e++*e++),c,1),o=i?s.plus(a):s.minus(a),s=R(a.times(l),new t(e++*e++),c,1),void 0!==(a=o.plus(s)).d[u]){for(n=u;a.d[n]===o.d[n]&&n--;);if(-1==n)break}n=o,o=s,s=a,a=n}return m=!0,a.d.length=u+1,a}function J(t,e){for(var r=t;--e;)r*=t;return r}function Z(t,e){var r,s=e.s<0,i=V(t,t.precision,1),n=i.times(.5);if((e=e.abs()).lte(n))return a=s?4:1,e;if((r=e.divToInt(i)).isZero())a=s?3:2;else{if((e=e.minus(r.times(i))).lte(n))return a=H(r)?s?2:3:s?4:1,e;a=H(r)?s?1:4:s?3:2}return e.minus(i).abs()}function X(t,e,r,s){var i,a,o,u,h,d,m,p,f,g=t.constructor,y=void 0!==r;if(y?(w(r,1,l),void 0===s?s=g.rounding:w(s,0,8)):(r=g.precision,s=g.rounding),t.isFinite()){for(y?(i=2,16==e?r=4*r-3:8==e&&(r=3*r-2)):i=e,(o=(m=F(t)).indexOf("."))>=0&&(m=m.replace(".",""),(f=new g(1)).e=m.length-o,f.d=O(F(f),10,i),f.e=f.d.length),a=h=(p=O(m,10,i)).length;0==p[--h];)p.pop();if(p[0]){if(o<0?a--:((t=new g(t)).d=p,t.e=a,p=(t=R(t,f,r,s,0,i)).d,a=t.e,d=n),o=p[r],u=i/2,d=d||void 0!==p[r+1],d=s<4?(void 0!==o||d)&&(0===s||s===(t.s<0?3:2)):o>u||o===u&&(4===s||d||6===s&&1&p[r-1]||s===(t.s<0?8:7)),p.length=r,d)for(;++p[--r]>i-1;)p[r]=0,r||(++a,p.unshift(1));for(h=p.length;!p[h-1];--h);for(o=0,m="";o<h;o++)m+=c.charAt(p[o]);if(y){if(h>1)if(16==e||8==e){for(o=16==e?4:3,--h;h%o;h++)m+="0";for(h=(p=O(m,i,e)).length;!p[h-1];--h);for(o=1,m="1.";o<h;o++)m+=c.charAt(p[o])}else m=m.charAt(0)+"."+m.slice(1);m=m+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)m="0"+m;m="0."+m}else if(++a>h)for(a-=h;a--;)m+="0";else a<h&&(m=m.slice(0,a)+"."+m.slice(a))}else m=y?"0p+0":"0";m=(16==e?"0x":2==e?"0b":8==e?"0o":"")+m}else m=G(t);return t.s<0?"-"+m:m}function Y(t,e){if(t.length>e)return t.length=e,!0}function tt(t){return new this(t).abs()}function et(t){return new this(t).acos()}function rt(t){return new this(t).acosh()}function st(t,e){return new this(t).plus(e)}function it(t){return new this(t).asin()}function nt(t){return new this(t).asinh()}function at(t){return new this(t).atan()}function ot(t){return new this(t).atanh()}function lt(t,e){t=new this(t),e=new this(e);var r,s=this.precision,i=this.rounding,n=s+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(r=e.s<0?V(this,s,i):new this(0)).s=t.s:!t.d||e.isZero()?(r=V(this,n,1).times(.5)).s=t.s:e.s<0?(this.precision=n,this.rounding=1,r=this.atan(R(t,e,n,1)),e=V(this,n,1),this.precision=s,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(R(t,e,n,1)):(r=V(this,n,1).times(e.s>0?.25:.75)).s=t.s:r=new this(NaN),r}function ct(t){return new this(t).cbrt()}function ut(t){return D(t=new this(t),t.e+1,2)}function ht(t,e,r){return new this(t).clamp(e,r)}function dt(t){if(!t||"object"!=typeof t)throw Error(p+"Object expected");var e,r,s,i=!0===t.defaults,n=["precision",1,l,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(e=0;e<n.length;e+=3)if(r=n[e],i&&(this[r]=d[r]),void 0!==(s=t[r])){if(!(C(s)===s&&s>=n[e+1]&&s<=n[e+2]))throw Error(f+r+": "+s);this[r]=s}if(r="crypto",i&&(this[r]=d[r]),void 0!==(s=t[r])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(f+r+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(y);this[r]=!0}else this[r]=!1}return this}function mt(t){return new this(t).cos()}function pt(t){return new this(t).cosh()}function ft(t,e){return new this(t).div(e)}function gt(t){return new this(t).exp()}function yt(t){return D(t=new this(t),t.e+1,3)}function xt(){var t,e,r=new this(0);for(m=!1,t=0;t<arguments.length;)if((e=new this(arguments[t++])).d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return m=!0,new this(1/0);r=e}return m=!0,r.sqrt()}function Ct(t){return t instanceof i||t&&t.toStringTag===x||!1}function Et(t){return new this(t).ln()}function At(t,e){return new this(t).log(e)}function _t(t){return new this(t).log(2)}function St(t){return new this(t).log(10)}function vt(){return q(this,arguments,-1)}function Tt(){return q(this,arguments,1)}function bt(t,e){return new this(t).mod(e)}function Nt(t,e){return new this(t).mul(e)}function It(t,e){return new this(t).pow(e)}function Mt(t){var e,r,s,i,n=0,a=new this(1),o=[];if(void 0===t?t=this.precision:w(t,1,l),s=Math.ceil(t/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(s));n<s;)(i=e[n])>=429e7?e[n]=crypto.getRandomValues(new Uint32Array(1))[0]:o[n++]=i%1e7;else{if(!crypto.randomBytes)throw Error(y);for(e=crypto.randomBytes(s*=4);n<s;)(i=e[n]+(e[n+1]<<8)+(e[n+2]<<16)+((127&e[n+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,n):(o.push(i%1e7),n+=4);n=s/4}else for(;n<s;)o[n++]=1e7*Math.random()|0;for(t%=7,(s=o[--n])&&t&&(i=E(10,7-t),o[n]=(s/i|0)*i);0===o[n];n--)o.pop();if(n<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=7)o.shift();for(s=1,i=o[0];i>=10;i/=10)s++;s<7&&(r-=7-s)}return a.e=r,a.d=o,a}function wt(t){return D(t=new this(t),t.e+1,this.rounding)}function Lt(t){return(t=new this(t)).d?t.d[0]?t.s:0*t.s:t.s||NaN}function Ot(t){return new this(t).sin()}function Rt(t){return new this(t).sinh()}function Dt(t){return new this(t).sqrt()}function Ft(t,e){return new this(t).sub(e)}function Pt(){var t=0,e=arguments,r=new this(e[t]);for(m=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return m=!0,D(r,this.precision,this.rounding)}function kt(t){return new this(t).tan()}function Vt(t){return new this(t).tanh()}function Ut(t){return D(t=new this(t),t.e+1,1)}(i=function t(e){var r,s,i;function n(t){var e,r,s,i=this;if(!(i instanceof n))return new n(t);if(i.constructor=n,Ct(t))return i.s=t.s,void(m?!t.d||t.e>n.maxE?(i.e=NaN,i.d=null):t.e<n.minE?(i.e=0,i.d=[0]):(i.e=t.e,i.d=t.d.slice()):(i.e=t.e,i.d=t.d?t.d.slice():t.d));if("number"==(s=typeof t)){if(0===t)return i.s=1/t<0?-1:1,i.e=0,void(i.d=[0]);if(t<0?(t=-t,i.s=-1):i.s=1,t===~~t&&t<1e7){for(e=0,r=t;r>=10;r/=10)e++;return void(m?e>n.maxE?(i.e=NaN,i.d=null):e<n.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[t]):(i.e=e,i.d=[t]))}return 0*t!=0?(t||(i.s=NaN),i.e=NaN,void(i.d=null)):W(i,t.toString())}if("string"===s)return 45===(r=t.charCodeAt(0))?(t=t.slice(1),i.s=-1):(43===r&&(t=t.slice(1)),i.s=1),v.test(t)?W(i,t):Q(i,t);if("bigint"===s)return t<0?(t=-t,i.s=-1):i.s=1,W(i,t.toString());throw Error(f+t)}if(n.prototype=I,n.ROUND_UP=0,n.ROUND_DOWN=1,n.ROUND_CEIL=2,n.ROUND_FLOOR=3,n.ROUND_HALF_UP=4,n.ROUND_HALF_DOWN=5,n.ROUND_HALF_EVEN=6,n.ROUND_HALF_CEIL=7,n.ROUND_HALF_FLOOR=8,n.EUCLID=9,n.config=n.set=dt,n.clone=t,n.isDecimal=Ct,n.abs=tt,n.acos=et,n.acosh=rt,n.add=st,n.asin=it,n.asinh=nt,n.atan=at,n.atanh=ot,n.atan2=lt,n.cbrt=ct,n.ceil=ut,n.clamp=ht,n.cos=mt,n.cosh=pt,n.div=ft,n.exp=gt,n.floor=yt,n.hypot=xt,n.ln=Et,n.log=At,n.log10=St,n.log2=_t,n.max=vt,n.min=Tt,n.mod=bt,n.mul=Nt,n.pow=It,n.random=Mt,n.round=wt,n.sign=Lt,n.sin=Ot,n.sinh=Rt,n.sqrt=Dt,n.sub=Ft,n.sum=Pt,n.tan=kt,n.tanh=Vt,n.trunc=Ut,void 0===e&&(e={}),e&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)e.hasOwnProperty(s=i[r++])||(e[s]=this[s]);return n.config(e),n}(d)).prototype.constructor=i,i.default=i.Decimal=i,u=new i(u),h=new i(h),void 0===(s=function(){return i}.call(e,r,e,t))||(t.exports=s)}()},6109(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AST=void 0;const s=r(5956),i=r(845),n=r(1271),a=r(7679),o=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","()","!","~","+_","-_","++_","--_",".'","'","_++","_--"],l=["+","-",".*","*","./","/",".\\","\\",".^","^",".**","**","<","<=","==",">=",">","!=","~=","&","|","&&","||","=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="],c=["()","!","~","+_","-_","++_","--_"],u=[".'","'","_++","_--"];class h{static nodeString=s.CharString.create;static nodeNumber=i.Complex.parse;static firstRow=a.MultiArray.firstRow;static appendRow=a.MultiArray.appendRow;static emptyArray=a.MultiArray.emptyArray;static reload=()=>{h.nodeString=s.CharString.create,h.nodeNumber=i.Complex.parse,h.firstRow=a.MultiArray.firstRow,h.appendRow=a.MultiArray.appendRow,h.emptyArray=a.MultiArray.emptyArray};static nodeCopy=t=>Object.assign({},t);static isNodeBase=t=>{if("object"!=typeof t||null===t||!("type"in t))return!1;const e=Reflect.get(t,"type");return"string"==typeof e||"number"==typeof e};static isNodeIdentifier=t=>h.isNodeBase(t)&&"IDENT"===t.type&&"string"==typeof Reflect.get(t,"id");static isNodeList=t=>h.isNodeBase(t)&&"LIST"===t.type&&Array.isArray(Reflect.get(t,"list"));static isNodeCmdWList=t=>h.isNodeBase(t)&&"CMDWLIST"===t.type&&"string"==typeof Reflect.get(t,"id")&&Array.isArray(Reflect.get(t,"args"));static isNodeIndexExpr=t=>h.isNodeBase(t)&&"IDX"===t.type&&("()"===Reflect.get(t,"delim")||"{}"===Reflect.get(t,"delim"))&&Array.isArray(Reflect.get(t,"args"));static isNodeSuperclassConstructor=t=>h.isNodeBase(t)&&"SUPERCLASS_CTOR"===t.type&&h.isNodeIdentifier(Reflect.get(t,"superclass"))&&Array.isArray(Reflect.get(t,"args"));static isNodeRange=t=>h.isNodeBase(t)&&"RANGE"===t.type&&"start_"in t&&"stop_"in t;static isNodeColon=t=>h.isNodeBase(t)&&":"===t.type;static isNodeEndRange=t=>h.isNodeBase(t)&&"ENDRANGE"===t.type;static isNodeIndirectRef=t=>h.isNodeBase(t)&&"."===t.type&&Array.isArray(Reflect.get(t,"field"));static isNodeReturnList=t=>h.isNodeBase(t)&&"RETLIST"===t.type&&"function"==typeof Reflect.get(t,"selector")&&"function"==typeof Reflect.get(t,"handler");static isNodeIgnoredTarget=t=>h.isNodeBase(t)&&"<~>"===t.type;static isNodeOperation=t=>h.isNodeBase(t)&&o.includes(t.type);static isNodeBinaryOperation=t=>h.isNodeOperation(t)&&l.includes(t.type)&&"left"in t&&"right"in t;static isNodePrefixOperation=t=>h.isNodeOperation(t)&&c.includes(t.type)&&"right"in t;static isNodePostfixOperation=t=>h.isNodeOperation(t)&&u.includes(t.type)&&"left"in t;static isNodeFunctionReturn=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t);static isNodeDeclarationElement=t=>h.isNodeIdentifier(t)||h.isNodeDefaultedParameter(t);static isNodeDefaultedParameter=t=>h.isNodeBinaryOperation(t)&&"="===t.type&&h.isNodeIdentifier(t.left);static isNodeFunctionParameter=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t)||h.isNodeDefaultedParameter(t);static isNodeAssignmentTarget=t=>h.isNodeIdentifier(t)||h.isNodeIgnoredTarget(t)||h.isNodeIndexExpr(t)||h.isNodeIndirectRef(t)||a.MultiArray.isInstanceOf(t);static isNodeDeclaration=t=>h.isNodeBase(t)&&("GLOBAL"===t.type||"PERSIST"===t.type);static isNodeImport=t=>h.isNodeBase(t)&&"IMPORT"===t.type&&Array.isArray(t.imports);static isNodeStatement=t=>h.isNodeDeclaration(t)||h.isNodeImport(t)||h.isNodeBase(t)&&("RETURN"===t.type||"BREAK"===t.type||"CONTINUE"===t.type||"IF"===t.type||"SWITCH"===t.type||"WHILE"===t.type||"DO_UNTIL"===t.type||"FOR"===t.type||"SPMD"===t.type||"TRY"===t.type||"UNWIND_PROTECT"===t.type)||h.isNodeFunctionDefinition(t)||h.isNodeClassDef(t);static isNodeClassMember=t=>h.isNodeClassSection(t)||h.isNodeClassAttribute(t)||h.isNodeClassProperty(t)||h.isNodeClassEvent(t)||h.isNodeClassEnumeration(t);static isNodeProgramElement=t=>h.isStrictNodeExpr(t)||h.isNodeStatement(t)||h.isNodeClassMember(t);static isNodeFunctionDefinition=t=>h.isNodeBase(t)&&"FCNDEF"===t.type;static isNodeClassDef=t=>h.isNodeBase(t)&&"CLASSDEF"===t.type;static isNodeMetaClass=t=>h.isNodeBase(t)&&"METACLASS"===t.type&&h.isNodeIdentifier(t.className);static isRuntimeExpressionValue=t=>null!=t&&(a.MultiArray.isInstanceOf(t)||i.Complex.isInstanceOf(t)||s.CharString.isInstanceOf(t)||"object"==typeof t&&"number"==typeof t.type);static isStrictNodeExpr=t=>h.isRuntimeExpressionValue(t)||h.isNodeBase(t)&&("VOID"===t.type||h.isNodeIdentifier(t)||h.isNodeCmdWList(t)||h.isNodeIndexExpr(t)||h.isNodeSuperclassConstructor(t)||h.isNodeMetaClass(t)||h.isNodeRange(t)||h.isNodeColon(t)||h.isNodeEndRange(t)||h.isNodeOperation(t)||h.isNodeIgnoredTarget(t)||h.isNodeIndirectRef(t)||h.isNodeImport(t)||h.isNodeReturnList(t));static isExpressionBoundaryValue=t=>h.isStrictNodeExpr(t)||h.isNodeList(t);static requireStrictNodeExpr=(t,e="expression")=>{if(!h.isStrictNodeExpr(t))throw new TypeError(`${e} is not an expression node.`);return t};static isNodeArguments=t=>h.isNodeBase(t)&&"ARGS"===t.type&&Array.isArray(t.validation);static isNodeArgumentValidation=t=>h.isNodeBase(t)&&"ARGVALID"===t.type&&"name"in t&&Array.isArray(t.size);static isNodeSwitchCase=t=>h.isNodeBase(t)&&"CASE"===t.type;static isNodeClassSection=t=>h.isNodeBase(t)&&"CLASS_SECTION"===t.type;static isNodeClassAttribute=t=>h.isNodeBase(t)&&"CLASS_ATTRIBUTE"===t.type;static isNodeClassProperty=t=>h.isNodeBase(t)&&"CLASS_PROPERTY"===t.type;static isNodeClassEvent=t=>h.isNodeBase(t)&&"CLASS_EVENT"===t.type;static isNodeClassEnumeration=t=>h.isNodeBase(t)&&"CLASS_ENUMERATION"===t.type;static nodeVoid=()=>({type:"VOID",omitAnswer:!0,omitOutput:!0});static nodeIdentifier=t=>({type:"IDENT",id:t.replace(/(\r\n|[\n\r])|[\ ]/gm,""),omitAnswer:!1,omitOutput:!1});static nodeMetaClass=t=>{const e={type:"METACLASS",className:t,omitAnswer:!1,omitOutput:!1};return e.className.parent=e,e};static factoryExpression=(t,e,r=!1)=>r&&h.isNodeList(t)?t:h.requireStrictNodeExpr(t,e);static factoryExpressionList=(t,e)=>t?t.list.map((t,r)=>h.factoryExpression(t,`${e}${r+1}`)):[];static factoryCommandWordList=(t,e)=>t?t.list.map((t,r)=>{if(!s.CharString.isInstanceOf(t))throw new TypeError(`${e}${r+1} is not a command word.`);return t}):[];static factoryNodeList=(t,e,r)=>t.list.map((t,s)=>{if(!e(t))throw new TypeError(`${r}${s+1} has invalid node type.`);return t});static factoryProgramElementList=(t,e)=>h.factoryNodeList(t,h.isNodeProgramElement,e);static factoryArrayElementList=(t,e)=>h.factoryExpressionList(t,e);static factoryArgumentClass=(t,e)=>{if(null===t||h.isNodeList(t)&&0===t.list.length)return t;if(!h.isNodeIdentifier(t)&&!h.isNodeMetaClass(t))throw new TypeError(`${e} has invalid node type.`);return t};static nodeCmdWList=(t,e)=>{const r={type:"CMDWLIST",id:t.id,args:h.factoryCommandWordList(e,"command argument ")};return t.parent=r,r.args.forEach(t=>{t.parent=r}),r.omitAnswer=!0,r.omitOutput=!1,r};static nodeEmptyCmdWList=t=>{const e={type:"CMDWLIST",id:t.id,args:[],parent:t.parent,index:t.index,start:t.start,stop:t.stop,omitAnswer:!0,omitOutput:t.omitOutput??!1};return t.parent=e,e};static nodeIndexExpr=(t,e=null,r="()")=>{const s={type:"IDX",expr:h.factoryExpression(t,"indexed expression"),args:h.factoryExpressionList(e,"index argument "),delim:r,omitAnswer:!1,omitOutput:!1};return s.expr.parent=s,s.args.forEach((t,e)=>{h.isNodeBase(t)&&(t.parent=s,t.index=e)}),s};static nodeSuperclassConstructor=(t,e,r=null)=>{const s={type:"SUPERCLASS_CTOR",instance:h.factoryExpression(t,"superclass constructor instance"),superclass:e,args:h.factoryExpressionList(r,"superclass constructor argument "),omitAnswer:!1,omitOutput:!1};return s.instance.parent=s,s.superclass.parent=s,s.args.forEach(t=>{h.isNodeBase(t)&&(t.parent=s)}),s};static nodeRange=(t,e,r)=>{const s={type:"RANGE",start_:h.factoryExpression(t,"range start"),stop_:h.factoryExpression(e,"range stop"),stride_:r?h.factoryExpression(r,"range stride"):null,omitAnswer:!1,omitOutput:!1};return s.start_.parent=s,s.stop_.parent=s,r&&(s.stride_.parent=s),s};static nodeColon=()=>({type:":",omitAnswer:!1,omitOutput:!1});static nodeEndRange=()=>({type:"ENDRANGE",omitAnswer:!1,omitOutput:!1});static omitAnswerNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assignmentNodeOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]);static anonymousFunctionForbiddenOperation=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|=","++_","--_","_++","_--"]);static assertAnonymousFunctionExpression=t=>{if(h.isNodeOperation(t)&&h.anonymousFunctionForbiddenOperation.has(t.type))throw new SyntaxError("anonymous function bodies cannot contain assignment, increment, or decrement operators.");h.isNodeBinaryOperation(t)?(h.assertAnonymousFunctionExpression(t.left),h.assertAnonymousFunctionExpression(t.right)):h.isNodePrefixOperation(t)?h.assertAnonymousFunctionExpression(t.right):h.isNodePostfixOperation(t)?h.assertAnonymousFunctionExpression(t.left):h.isNodeIndexExpr(t)?(h.assertAnonymousFunctionExpression(t.expr),t.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeSuperclassConstructor(t)?(h.assertAnonymousFunctionExpression(t.instance),t.args.forEach(h.assertAnonymousFunctionExpression)):h.isNodeRange(t)?(h.assertAnonymousFunctionExpression(t.start_),h.assertAnonymousFunctionExpression(t.stop_),t.stride_&&h.assertAnonymousFunctionExpression(t.stride_)):h.isNodeIndirectRef(t)?(h.assertAnonymousFunctionExpression(t.obj),t.field.forEach(t=>{"string"!=typeof t&&h.assertAnonymousFunctionExpression(t)})):h.isNodeList(t)?t.list.forEach(h.assertAnonymousFunctionExpression):a.MultiArray.isInstanceOf(t)?a.MultiArray.linearize(t).forEach(h.assertAnonymousFunctionExpression):n.FunctionHandle.isInstanceOf(t)&&t.expression&&h.assertAnonymousFunctionExpression(t.expression)};static assertFunctionSignatureList=(t,e,r,s)=>{const i=new Set;t.forEach((n,a)=>{if(h.isNodeIgnoredTarget(n))return;let o;if(h.isNodeDefaultedParameter(n)){if("parameter"!==r||"anonymous function"===s)throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.left.id}else{if(!h.isNodeIdentifier(n))throw new SyntaxError(`invalid ${r} list in ${s}.`);o=n.id}if(i.has(o))throw new SyntaxError(`duplicate ${r} name '${o}' in ${s}.`);if(i.add(o),o===e&&a!==t.length-1)throw new SyntaxError(`${e} must be the last ${r} in ${s}.`);if(h.isNodeDefaultedParameter(n)&&o===e)throw new SyntaxError(`${e} default value is not supported in ${s}.`)})};static assertAnonymousFunctionParameters=t=>{h.assertFunctionSignatureList(t,"varargin","parameter","anonymous function")};static nodeOperation=(t,e,r)=>{let s;switch(t){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":if(void 0===r)throw new TypeError(`right operand for ${t} is missing.`);s={type:t,left:h.factoryExpression(e,`left operand for ${t}`),right:h.factoryExpression(r,`right operand for ${t}`,h.assignmentNodeOperation.has(t))},s.left.parent=s,s.right.parent=s;break;case"()":case"!":case"~":case"+_":case"-_":case"++_":case"--_":s={type:t,right:h.factoryExpression(e,`operand for ${t}`)},s.right.parent=s;break;case".'":case"'":case"_++":case"_--":s={type:t,left:h.factoryExpression(e,`operand for ${t}`)},s.left.parent=s;break;default:s={type:`INVALID:${t}`}}return s.omitAnswer=h.omitAnswerNodeOperation.has(s.type),s.omitOutput=!1,s};static nodeDefaultedParameter=(t,e)=>{const r=h.nodeOperation("=",t,e);if(!h.isNodeDefaultedParameter(r))throw new TypeError("defaulted parameter has invalid node type.");return r};static nodeIgnoredTarget=()=>({type:"<~>",omitAnswer:!0,omitOutput:!1});static nodeListFirst=t=>{const e={type:"LIST",list:t?[t]:[],omitAnswer:!1,omitOutput:!1};return t&&(e.list[0].parent=e),e};static appendNodeList=(t,e)=>(e.parent=t,t.list.push(e),t);static nodeList=t=>{const e={type:"LIST",list:t,omitAnswer:!1,omitOutput:!1};return e.list.forEach(t=>t.parent=e),e};static nodeFirstRow=(t=null,e)=>t?h.firstRow(h.factoryArrayElementList(t,"array element "),e):h.emptyArray(e);static nodeAppendRow=(t,e=null)=>e?h.appendRow(t,h.factoryArrayElementList(e,"array element ")):t;static nodeIndirectRef=(t,e)=>{if(h.isNodeIndirectRef(t))return t.field.push("string"==typeof e?e:h.factoryExpression(e,"indirect reference field")),"string"!=typeof e&&(e.parent=t),t;{const r={type:".",obj:h.factoryExpression(t,"indirect reference object"),field:["string"==typeof e?e:h.factoryExpression(e,"indirect reference field")],omitAnswer:!1,omitOutput:!1};return r.obj.parent=r,"string"!=typeof e&&(e.parent=r),r}};static nodeReturnList=(t,e)=>({type:"RETLIST",selector:t,...void 0===e?{handler:t=>({length:t})}:"function"==typeof e?{handler:e}:e});static nodeCommaSeparatedReturnList=(t,e,r)=>{const s=h.nodeReturnList(e,r);return s.commaSeparated=!0,s.returnListLength=t,s};static nodeBoundedReturnList=(t,e,r,s)=>h.nodeReturnList((r,i)=>(h.throwErrorIfGreaterThanReturnList(t,r.length,s),e(r,i)),e=>(h.throwErrorIfGreaterThanReturnList(t,e,s),r?r(e):{length:e}));static ensureReturnList=t=>{if(h.isNodeReturnList(t))return t;const e=t;return h.nodeReturnList((t,r)=>{if(0===r)return e;throw h.throwErrorIfGreaterThanReturnList(1,r+1),new EvalError("unreachable return-list selector branch.")})};static throwErrorIfGreaterThanReturnList=(t,e,r)=>{if(e>t){const e=`element number ${t+1} undefined in return list`;throw r&&r(e),new EvalError(e)}};static reduceToFirstIfReturnList=t=>{if(h.isNodeReturnList(t)){const e=t.selector(t.handler(1),0);return e.parent=t.parent,e}return t};static throwInvalidCallError=(t,e=!0,r)=>{if(e){const e=`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`;throw r&&r(e),new SyntaxError(e)}};static nodeFunctionHandle=(t=null,e=null,r=null)=>{const s=e?h.factoryNodeList(e,h.isNodeFunctionParameter,"function handle parameter "):[],i=r?h.factoryExpression(r,"function handle expression"):null;t||(h.assertAnonymousFunctionParameters(s),i&&h.assertAnonymousFunctionExpression(i));const a=n.FunctionHandle.create(t?t.id:void 0,s,i);return a.parameter.forEach(t=>{t.parent=a}),a.expression&&(a.expression.parent=a),a};static nodeFunctionDefinition=(t,e,r,s,i)=>{const n=h.factoryNodeList(e,h.isNodeFunctionReturn,"function return "),a=h.factoryNodeList(r,h.isNodeFunctionParameter,"function parameter "),o=h.factoryNodeList(s,h.isNodeArguments,"function arguments block "),l=h.factoryNodeList(i,h.isNodeProgramElement,"function statement "),c={type:"FCNDEF",id:t.id,mapper:1===a.length&&1===n.length,ev:new Array(a.length).fill(!0),func:null,return:e,parameter:r,arguments:s,statements:i,omitAnswer:!0,omitOutput:!0};return c.return.parent=c,c.parameter.parent=c,c.arguments.parent=c,c.statements.parent=c,n.forEach(t=>t.parent=c),a.forEach(t=>t.parent=c),o.forEach(t=>t.parent=c),l.forEach(t=>t.parent=c),c};static nodeClassAttributeTable=t=>{const e={};for(const r of t)e[r.id]??=[],e[r.id].push(r);return e};static nodeClassSectionMemberGuard=t=>{switch(t){case"PROPERTIES":return h.isNodeClassProperty;case"METHODS":return h.isNodeFunctionDefinition;case"EVENTS":return h.isNodeClassEvent;case"ENUMERATION":return h.isNodeClassEnumeration;default:return t=>!1}};static nodeArgumentValidation=(t,e,r=null,s,i=null)=>{const n={type:"ARGVALID",name:h.factoryExpression(t,"argument validation name"),size:h.factoryExpressionList(e,"argument validation size "),class:h.factoryArgumentClass(r,"argument validation class"),functions:h.factoryExpressionList(s,"argument validation function "),default:i?h.factoryExpression(i,"argument validation default"):null,omitAnswer:!0,omitOutput:!0};return n.name.parent=n,n.size.forEach(t=>{h.isNodeBase(t)&&(t.parent=n)}),n.class&&(n.class.parent=n),n.functions.forEach(t=>{h.isNodeBase(t)&&(t.parent=n)}),n.default&&(n.default.parent=n),n};static nodeArguments=(t,e)=>{const r=t?h.isNodeList(t)?h.factoryNodeList(t,h.isNodeIdentifier,"arguments block attribute "):[t]:[],s={type:"ARGS",attribute:r[0]??null,attributes:r,validation:h.factoryNodeList(e,h.isNodeArgumentValidation,"arguments validation "),omitAnswer:!0,omitOutput:!0};return s.attributes.forEach(t=>t.parent=s),s.validation.forEach(t=>t.parent=s),s};static nodeDeclarationFirst=t=>({type:t,list:[],omitAnswer:!0,omitOutput:!0});static nodeReturn=()=>({type:"RETURN",omitAnswer:!0,omitOutput:!0});static nodeBreak=()=>({type:"BREAK",omitAnswer:!0,omitOutput:!0});static nodeContinue=()=>({type:"CONTINUE",omitAnswer:!0,omitOutput:!0});static getDeclarationNode=t=>"node"in t?t.node:t;static nodeAppendDeclaration=(t,e)=>{const r=h.getDeclarationNode(e);if(!h.isNodeDeclarationElement(r))throw new TypeError("declaration entry has invalid node type.");return r.parent=t,t.list.push(r),t};static nodeImport=()=>({type:"IMPORT",imports:[]});static nodeImportFirst=t=>{const e=h.nodeImport();return e.omitAnswer=!0,e.omitOutput=!0,h.nodeAppendImport(e,t)};static nodeAppendImport=(t,e)=>(e.parent=t,e.index=t.imports.length,t.imports.push(e),t);static nodeIfBegin=(t,e)=>{h.factoryProgramElementList(e,"if body ");const r={type:"IF",expression:[h.factoryExpression(t,"if condition")],then:[e],else:null,omitAnswer:!0,omitOutput:!0};return r.expression[0].parent=r,r.then[0].parent=r,r};static nodeIfAppendElse=(t,e)=>(h.factoryProgramElementList(e.else,"else body "),t.else=e.else,t.else.parent=t,t);static nodeIfAppendElseIf=(t,e)=>(h.factoryProgramElementList(e.then,"elseif body "),e.expression.parent=t,t.expression.push(e.expression),e.then.parent=t,t.then.push(e.then),t);static nodeElseIf=(t,e)=>{h.factoryProgramElementList(e,"elseif body ");const r={type:"ELSEIF",expression:h.factoryExpression(t,"elseif condition"),then:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r};static nodeElse=t=>{h.factoryProgramElementList(t,"else body ");const e={type:"ELSE",else:t,omitAnswer:!0,omitOutput:!0};return e.else.parent=e,e};static nodeSwitch=(t,e,r=null)=>{r&&h.factoryProgramElementList(r,"otherwise body ");const s={type:"SWITCH",expression:h.factoryExpression(t,"switch expression"),cases:h.factoryNodeList(e,h.isNodeSwitchCase,"switch case "),otherwise:r,omitAnswer:!0,omitOutput:!0};return s.expression.parent=s,s.cases.forEach(t=>t.parent=s),s.otherwise&&(s.otherwise.parent=s),s};static nodeSwitchCase=(t,e)=>{h.factoryProgramElementList(e,"case body ");const r={type:"CASE",expression:h.factoryExpression(t,"case expression"),then:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.then.parent=r,r};static nodeWhile=(t,e)=>{h.factoryProgramElementList(e,"while body ");const r={type:"WHILE",expression:h.factoryExpression(t,"while condition"),body:e,omitAnswer:!0,omitOutput:!0};return r.expression.parent=r,r.body.parent=r,r};static nodeDoUntil=(t,e)=>{h.factoryProgramElementList(t,"do body ");const r={type:"DO_UNTIL",body:t,expression:h.factoryExpression(e,"until condition"),omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.expression.parent=r,r};static nodeFor=(t,e,r,s=!1,i=null)=>{h.factoryProgramElementList(r,"for body ");const n={type:"FOR",target:h.factoryExpression(t,"for target"),expression:h.factoryExpression(e,"for expression"),workers:i?h.factoryExpression(i,"for workers"):null,body:r,parallel:s,omitAnswer:!0,omitOutput:!0};return n.target.parent=n,n.expression.parent=n,n.workers&&(n.workers.parent=n),n.body.parent=n,n};static nodeSpmd=(t,e=null)=>{h.factoryProgramElementList(t,"spmd body "),h.factoryExpressionList(e,"spmd worker ");const r={type:"SPMD",workers:e,body:t,omitAnswer:!0,omitOutput:!0};return r.workers&&(r.workers.parent=r),r.body.parent=r,r};static nodeTry=(t,e=null,r=null)=>{h.factoryProgramElementList(t,"try body "),e&&h.factoryProgramElementList(e,"catch body ");const s={type:"TRY",body:t,catchIdentifier:r,catchBody:e,omitAnswer:!0,omitOutput:!0};return s.body.parent=s,s.catchIdentifier&&(s.catchIdentifier.parent=s),s.catchBody&&(s.catchBody.parent=s),s};static nodeUnwindProtect=(t,e)=>{h.factoryProgramElementList(t,"unwind_protect body "),h.factoryProgramElementList(e,"unwind_protect cleanup ");const r={type:"UNWIND_PROTECT",body:t,cleanup:e,omitAnswer:!0,omitOutput:!0};return r.body.parent=r,r.cleanup.parent=r,r};static nodeClassDef=(t,e,r=h.nodeListFirst(),s=h.nodeListFirst())=>{const i={type:"CLASSDEF",id:t.id,attributes:h.factoryNodeList(r,h.isNodeClassAttribute,"class attribute "),attributeTable:{},superclasses:h.factoryNodeList(s,h.isNodeIdentifier,"superclass "),sections:h.factoryNodeList(e,h.isNodeClassSection,"class section "),omitAnswer:!0,omitOutput:!0};return i.attributeTable=h.nodeClassAttributeTable(i.attributes),i.attributes.forEach(t=>t.parent=i),i.superclasses.forEach(t=>t.parent=i),i.sections.forEach(t=>t.parent=i),i};static nodeClassSection=(t,e,r=h.nodeListFirst())=>{const s=h.factoryNodeList(e,h.nodeClassSectionMemberGuard(t),`${t.toLowerCase()} member `),i={type:"CLASS_SECTION",kind:t,attributes:h.factoryNodeList(r,h.isNodeClassAttribute,"class section attribute "),attributeTable:{},members:e,omitAnswer:!0,omitOutput:!0};return i.attributeTable=h.nodeClassAttributeTable(i.attributes),i.attributes.forEach(t=>t.parent=i),i.members.parent=i,s.forEach(t=>t.parent=i),i};static nodeClassProperty=(t,e=h.nodeListFirst(),r=null,s=h.nodeListFirst(),i=null)=>{const n=e&&"LIST"!==e.type?h.factoryExpression(e,"argument validation default"):null,a=h.isNodeList(e)?e:h.nodeListFirst(),o=h.nodeArgumentValidation(t,a,r,s,n??i),l={type:"CLASS_PROPERTY",id:t.id,validation:o,name:o.name,size:o.size,class:o.class,functions:o.functions,defaultValue:o.default,omitAnswer:!0,omitOutput:!0};return l.validation.parent=l,l};static nodeClassEvent=t=>({type:"CLASS_EVENT",id:t.id,omitAnswer:!0,omitOutput:!0});static nodeClassEnumeration=(t,e=h.nodeListFirst())=>{const r={type:"CLASS_ENUMERATION",id:t.id,args:h.factoryExpressionList(e,"enumeration argument "),omitAnswer:!0,omitOutput:!0};return r.args.forEach(t=>{h.isNodeBase(t)&&(t.parent=r)}),r};static nodeClassAttribute=(t,e=null)=>{const r={type:"CLASS_ATTRIBUTE",id:t.id,value:e?h.factoryExpression(e,"class attribute value"):null,omitAnswer:!0,omitOutput:!0};return r.value&&(r.value.parent=r),r}}e.AST=h,e.default={AST:h}},6115(t,e,r){"use strict";e.BLAS=e.cT=void 0;const s=r(845),i=r(7679);e.cT=["blockThreshold","blockSize"];const n=new Set(e.cT),a={blockThreshold:1e5,blockSize:64};class o{static defaultSettings=Object.assign({},a);static settings=o.defaultSettings;static set=t=>{Object.entries(t).forEach(t=>{if(!n.has(t[0]))throw new Error(`BLAS.set: invalid configuration parameter: ${t[0]}`);o.settings[t[0]]=t[1]})};static axpy=(t,e,r)=>{const i=e.length,n=e[0].length;for(let a=0;a<i;a++){const i=e[a],o=r[a];for(let e=0;e<n;e++)o[e]=s.Complex.add(o[e],s.Complex.mul(t,i[e]))}return r};static scal=(t,e,r,i)=>{if(s.Complex.realToNumber(s.Complex.eq(t,s.Complex.zero())))for(let t=r;t<i;t++)e[t]=s.Complex.zero();else if(!s.Complex.realToNumber(s.Complex.eq(t,s.Complex.one())))for(let n=r;n<i;n++)e[n]=s.Complex.mul(t,e[n])};static copy=t=>{if(Array.isArray(t))return Array.isArray(t[0])?Array.from({length:t.length},(e,r)=>Array.from({length:t[0].length},(e,i)=>s.Complex.copy(t[r][i]))):Array.from({length:t.length},(e,r)=>s.Complex.copy(t[r]));throw new Error("BLAS.copy: invalid argument")};static dotu=(t,e)=>{const r=t.length;let i=s.Complex.zero();for(let n=0;n<r;n++)s.Complex.mulAndSumTo(i,t[n],e[n]);return i};static dot=o.dotu;static dotc=(t,e)=>{const r=t.length;let i=s.Complex.zero();for(let n=0;n<r;n++)s.Complex.mulAndSumTo(i,s.Complex.conj(t[n]),e[n]);return i};static nrm2sq=(t,e,r,i)=>{let n=s.Complex.zero();for(let a=r;a<i;a++)s.Complex.mulAndSumTo(n,t.array[a][e],s.Complex.conj(t.array[a][e]));return s.Complex.create(n.re)};static nrm2=t=>{let e=s.Complex.zero(),r=s.Complex.one();for(let i=0;i<t.length;i++){const n=t[i],a=s.Complex.abs(s.Complex.real(n)),o=s.Complex.abs(s.Complex.imag(n));if(s.Complex.toBoolean(s.Complex.ne(a,s.Complex.zero())))if(s.Complex.lt(e,a)){const t=s.Complex.rdiv(e,a);r=s.Complex.add(s.Complex.one(),s.Complex.mul(r,s.Complex.mul(t,t))),e=a}else{const t=s.Complex.rdiv(a,e);r=s.Complex.add(r,s.Complex.mul(t,t))}if(s.Complex.toBoolean(s.Complex.ne(o,s.Complex.zero())))if(s.Complex.lt(e,o)){const t=s.Complex.rdiv(e,o);r=s.Complex.add(s.Complex.one(),s.Complex.mul(r,s.Complex.mul(t,t))),e=o}else{const t=s.Complex.rdiv(o,e);r=s.Complex.add(r,s.Complex.mul(t,t))}}return s.Complex.toBoolean(s.Complex.eq(e,s.Complex.zero()))?s.Complex.zero():s.Complex.mul(e,s.Complex.sqrt(r))};static gemv=(t,e,r,i,n,a,o,l,c,u,h,d="N")=>{const m="N"===d?e:r,p="N"===d?r:e;for(let t=0;t<m;t++)l[c+t]=s.Complex.eq(h,s.Complex.zero())?s.Complex.zero():s.Complex.eq(h,s.Complex.one())?l[c+t]:s.Complex.mul(h,l[c+t]);for(let e=0;e<m;e++){let r=s.Complex.zero();for(let l=0;l<p;l++){const c="N"===d?t[i+e][n+l]:"T"===d?t[i+l][n+e]:s.Complex.conj(t[i+l][n+e]);s.Complex.mulAndSumTo(r,c,a[o+l])}s.Complex.mulAndSumTo(l[c+e],u,r)}};static trsv=(t,e,r)=>{const s=t.length;if(t.some(t=>t.length!==s))throw new Error("BLAS.trsv: A must be square.");if(e.length!==s)throw new Error("BLAS.trsv: x has incompatible dimension.");const i=Array.from({length:s},(t,r)=>[e[r]]);return o.trsm(t,i,{side:"left",uplo:r.uplo,transA:r.transA,unitDiagonal:r.unitDiagonal}).map(t=>t[0])};static ger=(t,e,r,i,n,a,o,l,c,u,h,d)=>{if(!s.Complex.realIsZero(s.Complex.abs(a)))for(let m=0;m<i;m++){const i=o[l+m][c],p=s.Complex.mul(a,i),f=t[e+m];for(let t=0;t<n;t++)s.Complex.mulAndSumTo(f[r+t],p,s.Complex.conj(u[h+t][d]))}};static geru=(t,e,r,i,n,a)=>{if(!s.Complex.realIsZero(s.Complex.abs(r)))for(let o=0;o<t.length;o++){const l=t[o],c=i[n+o];for(let t=0;t<e.length;t++)s.Complex.mulAndSumTo(c[a+t],r,s.Complex.mul(l,e[t]))}};static gerc=(t,e,r,i,n=0,a=0)=>{for(let o=0;o<t.length;o++){const l=t[o],c=i[n+o];for(let t=0;t<e.length;t++)c[a+t]=s.Complex.add(c[a+t],s.Complex.mul(r,s.Complex.mul(l,s.Complex.conj(e[t]))))}};static gerc_nd=(t,e,r)=>{const n=[];for(let e=0;e<i.MultiArray.linearLength(t);e++){const[r,s]=i.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);n.push(t.array[r][s])}const a=[];for(let t=0;t<i.MultiArray.linearLength(e);t++){const[r,s]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);a.push(e.array[r][s])}const o=n.length,l=a.length;if(r.dimension[0]!==o||r.dimension[1]!==l)throw new Error(`BLAS.gerc_nd: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${o}, y is ${l})`);for(let t=0;t<o;t++){const e=s.Complex.conj(n[t]);for(let i=0;i<l;i++){const n=s.Complex.mul(e,a[i]);r.array[t][i]?r.array[t][i]=s.Complex.add(r.array[t][i],n):r.array[t][i]=s.Complex.copy(n)}}i.MultiArray.setType(r)};static gerc_nd_direct=(t,e,r)=>{const n=i.MultiArray.linearLength(t),a=i.MultiArray.linearLength(e);if(r.dimension[0]!==n||r.dimension[1]!==a)throw new Error(`BLAS.gerc_nd_direct: dimension mismatch (C is ${r.dimension[0]}x${r.dimension[1]}, x is ${n}, y is ${a})`);t.dimension[0],t.dimension[1],e.dimension[0],e.dimension[1],r.dimension[0],r.dimension[1];for(let o=0;o<n;o++){const[l,c]=i.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1]||1,o),u=s.Complex.conj(t.array[l][c]);for(let t=0;t<a;t++){const[a,l]=i.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1]||1,t),c=e.array[a][l],[h,d]=i.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],o+t*n);r.array[h][d]?r.array[h][d]=s.Complex.add(r.array[h][d],s.Complex.mul(u,c)):r.array[h][d]=s.Complex.mul(u,c)}}i.MultiArray.setType(r)};static gemm_kernel=(t,e,r,i,n,a,o,l,c)=>{for(let u=i;u<n;u++){const i=t[u],n=r[u];for(let t=a;t<o;t++){let r=n[t]??s.Complex.zero();for(let n=l;n<c;n++)s.Complex.mulAndSumTo(r,i[n],e[n][t]);n[t]=r}}};static gemm=(t,e,r,i,n,a,l,c,u)=>{if(s.Complex.realIsZero(s.Complex.abs(t)))for(let t=0;t<r;t++){const e=c[t];for(let t=0;t<a;t++)e[t]=s.Complex.mul(l,e[t])}else{if(!s.Complex.eq(l,s.Complex.one()))for(let t=0;t<r;t++){const e=c[t];for(let t=0;t<a;t++)e[t]=s.Complex.mul(l,e[t])}if(r*i*a>o.settings.blockThreshold)for(let t=0;t<r;t+=u??o.settings.blockSize){const s=Math.min(t+(u??o.settings.blockSize),r);for(let r=0;r<i;r+=u??o.settings.blockSize){const l=Math.min(r+(u??o.settings.blockSize),i);for(let i=0;i<a;i+=u??o.settings.blockSize){const h=Math.min(i+(u??o.settings.blockSize),a);o.gemm_kernel(e,n,c,t,s,i,h,r,l)}}}else for(let o=0;o<r;o++){const r=e[o],l=c[o];for(let e=0;e<a;e++){let a=s.Complex.zero();for(let t=0;t<i;t++)s.Complex.mulAndSumTo(a,r[t],n[t][e]);l[e]=s.Complex.add(l[e],s.Complex.mul(t,a))}}}};static gemm_block=(t,e,r,i,n,a)=>{const l=t.length,c=t[0]?.length??0,u=e.length,h=e[0]?.length??0;if(c!==u)throw new Error("BLAS.gemm_block: inner dimensions mismatch A.cols != B.rows");if(r.length!==l||r[0]?.length!==h)throw new Error("BLAS.gemm_block: output dimension mismatch with C");if(s.Complex.realIsZero(s.Complex.abs(i))){if(s.Complex.realIsZero(s.Complex.abs(n)))for(let t=0;t<l;t++)for(let e=0;e<h;e++)r[t][e]=s.Complex.zero();else if(s.Complex.toBoolean(s.Complex.ne(n,s.Complex.one())))for(let t=0;t<l;t++)for(let e=0;e<h;e++)r[t][e]=s.Complex.mul(n,r[t][e]);return}const d=Math.max(1,Math.floor(a??o.settings.blockSize));for(let a=0;a<l;a+=d){const o=Math.min(a+d,l);for(let l=0;l<h;l+=d){const u=Math.min(l+d,h);for(let t=a;t<o;t++)for(let e=l;e<u;e++)s.Complex.realIsZero(s.Complex.abs(n))?r[t][e]=s.Complex.zero():s.Complex.toBoolean(s.Complex.ne(n,s.Complex.one()))&&(r[t][e]=s.Complex.mul(n,r[t][e]));for(let n=0;n<c;n+=d){const h=Math.min(n+d,c);for(let c=a;c<o;c++){const a=t[c],o=r[c];for(let t=n;t<h;t++){const r=a[t];if(!s.Complex.realIsZero(s.Complex.abs(r)))for(let n=l;n<u;n++){const a=s.Complex.mul(r,e[t][n]),l=s.Complex.mul(i,a);o[n]=s.Complex.add(o[n],l)}}}}}}};static trsm=(t,e,r)=>{const i=r?.side??"left",n=r?.uplo??"upper",a=r?.transA??"N",o=r?.unitDiagonal??!1,l=e.length,c=e[0]?.length??0;if(t.length!==t[0]?.length)throw new Error("BLAS.trsm: A must be square.");if("left"===i&&t.length!==l||"right"===i&&t.length!==c)throw new Error("BLAS.trsm: nonconformant dimensions.");const u=e.map(t=>t.map(t=>t)),h=(e,r)=>"N"===a?t[e][r]:"T"===a?t[r][e]:s.Complex.conj(t[r][e]);if("left"===i)if("upper"===n&&"N"===a||"lower"===n&&"N"!==a)for(let t=0;t<c;t++)for(let e=l-1;e>=0;e--){let r=u[e][t];for(let i=e+1;i<l;i++)r=s.Complex.sub(r,s.Complex.mul(h(e,i),u[i][t]));o||(r=s.Complex.rdiv(r,h(e,e))),u[e][t]=r}else for(let t=0;t<c;t++)for(let e=0;e<l;e++){let r=u[e][t];for(let i=0;i<e;i++)r=s.Complex.sub(r,s.Complex.mul(h(e,i),u[i][t]));o||(r=s.Complex.rdiv(r,h(e,e))),u[e][t]=r}else if("upper"===n&&"N"===a||"lower"===n&&"N"!==a)for(let t=0;t<l;t++)for(let e=0;e<c;e++){let r=u[t][e];for(let i=0;i<e;i++)r=s.Complex.sub(r,s.Complex.mul(u[t][i],h(i,e)));o||(r=s.Complex.rdiv(r,h(e,e))),u[t][e]=r}else for(let t=0;t<l;t++)for(let e=c-1;e>=0;e--){let r=u[t][e];for(let i=e+1;i<c;i++)r=s.Complex.sub(r,s.Complex.mul(u[t][i],h(i,e)));o||(r=s.Complex.rdiv(r,h(e,e))),u[t][e]=r}return u};static functions={axpy:o.axpy,scal:o.scal,copy:o.copy,dotu:o.dotu,dotc:o.dotc,nrm2sq:o.nrm2sq,nrm2:o.nrm2,gemv:o.gemv,trsv:o.trsv,ger:o.ger,geru:o.geru,gerc:o.gerc,gerc_nd:o.gerc_nd,gerc_nd_direct:o.gerc_nd_direct,gemm_kernel:o.gemm_kernel,gemm:o.gemm,gemm_block:o.gemm_block,trsm:o.trsm}}e.BLAS=o},3812(t,e){"use strict";e.CallFrame=void 0;e.CallFrame=class{scope;func;callSite;name;nargin;nargout;inputArgs;parentFrame;outputMask;constructor(t,e,r,s,i=0,n=0,a=[],o,l=[]){this.scope=t,this.func=e,this.callSite=r,this.name=s,this.nargin=i,this.nargout=n,this.inputArgs=a,this.parentFrame=o,this.outputMask=l}}},3225(t,e){"use strict";e.Callables=void 0;const r={builtin:t=>({type:"BUILTIN",node:t}),lambda:t=>({type:"LAMBDA",node:t}),functionDefinition:t=>({type:"FCNDEF",node:t}),staticMethod:t=>({type:"STATIC_METHOD",node:t}),fromFunctionNode(t){return"BUILTIN"===t.type?this.builtin(t):this.functionDefinition(t)},isBuiltin:t=>"BUILTIN"===t.type,isLambda:t=>"LAMBDA"===t.type,isFunctionDefinition:t=>"FCNDEF"===t.type,isStaticMethod:t=>"STATIC_METHOD"===t.type};e.Callables=r},5956(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CharString=e.stringClass=e.doubleQuoteCharacter=e.singleQuoteCharacter=void 0;const s=r(845);e.singleQuoteCharacter="'";const i='"';e.doubleQuoteCharacter=i,e.stringClass=3;class n{characters;quote;static STRING=3;type=n.STRING;parent;constructor(t,e=i){this.characters=t.split(""),this.quote=e}get str(){return this.characters.join("")}set str(t){this.characters=t.split("")}get length(){return this.characters.length}get dimension(){return[1,this.length]}static create=(t,e='"')=>new n(t,e);static isInstanceOf=t=>t instanceof n;static isChar=t=>n.isInstanceOf(t)&&"'"===t.quote;static isString=t=>n.isInstanceOf(t)&&t.quote===i;static copy=t=>new n(t.str,t.quote);copy(){return new n(this.str,this.quote)}static vector=t=>t.characters.slice();vector(){return n.vector(this)}static toCharacterScalars=t=>t.characters.map(e=>new n(e,t.quote));toCharacterScalars(){return n.toCharacterScalars(this)}static fromCharacterScalars=(t,e=t[0]?.quote??i)=>new n(t.map(t=>t.str).join(""),e);static fromNumericCode=(t,e=i)=>{const r=Math.max(0,Math.min(65535,Math.trunc(t)));return new n(String.fromCharCode(r),e)};characterAt(t){const e=this.characters[t];return void 0===e?void 0:new n(e,this.quote)}select(t){return new n(t.map(t=>this.characters[t]).filter(t=>void 0!==t).join(""),this.quote)}static parse=t=>new n(t);static unparse=(t,e=0)=>t.str;static toString=t=>t.str;toString(){return this.str}static unparseEscaped=t=>{let e=JSON.stringify(t.str);return e=e.substring(1,e.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'"'+e+'"'};static unparseMathML=(t,e=0)=>"<mi><pre>"+t.str+"</pre></mi>";static unparseEscapedMathML=t=>{let e=JSON.stringify(t.str);return e=e.substring(1,e.length-1).replace(/\\\\/,"\\").replace(/\\\"/,'""'),'<mi><pre>"'+e+'"</pre></mi>'};static logical=t=>t.str?s.Complex.true():s.Complex.false();static toLogical=t=>n.logical(t);toLogical(){return n.logical(this)}}e.CharString=n,e.default={singleQuoteCharacter:"'",doubleQuoteCharacter:i,stringClass:3,CharString:n}},9656(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassBoundMethod=void 0;class r{static CLASS_BOUND_METHOD=8;type=r.CLASS_BOUND_METHOD;parent;instance;method;static isInstanceOf=t=>t instanceof r;constructor(t,e){this.instance=t,this.method=e}static bind=(t,e)=>new r(t,e);static copy=t=>new r(t.instance,t.method);static unparse=(t,e)=>`${t.instance.classDefinition.name}.${t.method.name} method`;copy(){return r.copy(this)}}e.ClassBoundMethod=r,e.default={ClassBoundMethod:r}},6816(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassDefinition=void 0;const s=r(6109),i=r(9283);class n{static CLASS_DEFINITION=6;static classAttributes=new Set(["Abstract","AllowedSubclasses","ConstructOnLoad","HandleCompatible","Hidden","InferiorClasses","RestrictsSubclassing","Sealed"]);static propertyAttributes=new Set(["AbortSet","Abstract","Access","Constant","Dependent","GetAccess","GetMethod","GetObservable","Hidden","NonCopyable","PartialMatchPriority","SetAccess","SetMethod","SetObservable","Transient"]);static methodAttributes=new Set(["Abstract","Access","Hidden","Sealed","Static"]);static eventAttributes=new Set(["Hidden","ListenAccess","NotifyAccess"]);static enumerationAttributes=new Set(["Hidden"]);static classBooleanAttributes=new Set(["Abstract","ConstructOnLoad","HandleCompatible","Hidden","RestrictsSubclassing","Sealed"]);static propertyBooleanAttributes=new Set(["AbortSet","Abstract","Constant","Dependent","GetObservable","Hidden","NonCopyable","SetObservable","Transient"]);static methodBooleanAttributes=new Set(["Abstract","Hidden","Sealed","Static"]);static eventBooleanAttributes=new Set(["Hidden"]);static enumerationBooleanAttributes=new Set(["Hidden"]);static builtinSuperclassNames=new Set(["handle","event.EventData","event.PropertyEvent","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"]);static sealedBuiltinSuperclassNames=new Set(["event.PropertyEvent"]);static eventDataInheritedPropertyNames=new Set(["Source","EventName"]);static firstByKey=(t,e)=>{const r=new Set;return t.filter(t=>{const s=e(t);return!r.has(s)&&(r.add(s),!0)})};type=n.CLASS_DEFINITION;parent;name;packageName;simpleName;ast;attributes;isAbstract;isSealed;isHidden;isConstructOnLoad;isHandleCompatible;explicitHandleCompatible;inferiorClasses;allowedSubclasses;hasAllowedSubclassesAttribute;isRestrictsSubclassing;isBuiltinHandleClass;superclasses;superclassDefinitions;sections;properties;propertyTable;methods;staticMethods;instanceMethods;methodsByAccess;methodTable;events;enumerations;enumerationTable;static isInstanceOf=t=>t instanceof n;constructor(t){this.ast=t,this.name=t.id;const e=this.name.lastIndexOf(".");this.packageName=e<0?"":this.name.slice(0,e),this.simpleName=e<0?this.name:this.name.slice(e+1),this.attributes=t.attributeTable;const r=i.ClassMember.hasAttribute(this.attributes,"Sealed");this.isHidden=i.ClassMember.hasAttribute(this.attributes,"Hidden"),this.isConstructOnLoad=i.ClassMember.hasAttribute(this.attributes,"ConstructOnLoad"),this.explicitHandleCompatible=i.ClassMember.attributeBooleanValue(this.attributes.HandleCompatible?.[0]),this.isHandleCompatible=!0===this.explicitHandleCompatible,this.inferiorClasses=i.ClassMember.classNameListFromAttribute(this.attributes.InferiorClasses?.[0])??[];const s=i.ClassMember.classNameListFromAttribute(this.attributes.AllowedSubclasses?.[0]);this.allowedSubclasses=s??[],this.hasAllowedSubclassesAttribute=null!==s,this.isBuiltinHandleClass="handle"===this.name,this.superclasses=t.superclasses.map(t=>t.id),this.superclassDefinitions=[],this.sections=t.sections,this.properties=[],this.propertyTable={},this.methods=[],this.staticMethods=[],this.instanceMethods=[],this.methodsByAccess={},this.methodTable={},this.events=[],this.enumerations=[],this.enumerationTable={},this.collectMembers(),this.isSealed=r||this.enumerations.length>0||this.hasAllowedSubclassesAttribute&&0===this.allowedSubclasses.length,this.isRestrictsSubclassing=this.isSealed||this.hasAllowedSubclassesAttribute||i.ClassMember.hasAttribute(this.attributes,"RestrictsSubclassing"),this.isAbstract=i.ClassMember.hasAttribute(this.attributes,"Abstract")||this.properties.some(t=>t.isAbstract)||this.methods.some(t=>t.isAbstract)}static create=t=>new n(t);static copy=t=>t;static unparse=(t,e)=>e.Unparse(t.ast);copy(){return n.copy(this)}validateLocalDefinition(t){this.validateSupportedAttributes(t),this.validateAccessAttributes(t),this.validateAttributeCombinations(t),this.validateDuplicateMembers(t),this.validatePropertyAccessors(t)}resolveSuperclasses(t,e){this.validateLocalDefinition(e),this.superclassDefinitions.length=0;for(const r of this.superclasses){if(n.sealedBuiltinSuperclassNames.has(r)&&e(`class ${this.name} cannot inherit from sealed class ${r}.`),n.builtinSuperclassNames.has(r))continue;r===this.name&&e(`class ${this.name} cannot inherit from itself.`);const s=t(r);s||e(`superclass '${r}' for class ${this.name} is not defined.`),s.isSealed&&e(`class ${this.name} cannot inherit from sealed class ${s.name}.`),s.allowedSubclasses.length>0&&!s.allowedSubclasses.includes(this.name)&&e(`class ${this.name} cannot inherit from class ${s.name}: subclass is not listed in AllowedSubclasses.`),this.superclassDefinitions.push(s)}this.validateInheritanceCycles(e),this.validateSealedMethodOverrides(e),this.validateInheritedMethodCompatibility(e),this.validateInheritedPropertyCompatibility(e),this.validateInheritedEventCompatibility(e),this.validateHandleCompatibility(e),this.validateResolvedClassRestrictions(e)}isSubclassOf(t){return this.superclassDefinitions.some(e=>e===t||e.isSubclassOf(t))}isSubclassOfName(t){return"handle"===t?this.isHandleClass():!!this.superclasses.includes(t)||this.superclassDefinitions.some(e=>e.name===t||e.isSubclassOfName(t))}isHandleClass(){return this.isBuiltinHandleClass||this.superclasses.includes("handle")||this.superclasses.includes("event.EventData")||this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isHandleClass())}isHandleCompatibleClass(){return this.isHandleClass()||this.isHandleCompatible}isSetGetClass(){return this.superclasses.includes("matlab.mixin.SetGet")||this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isSetGetClass())}isSetGetExactNamesClass(){return this.superclasses.includes("matlab.mixin.SetGetExactNames")||this.superclassDefinitions.some(t=>t.isSetGetExactNamesClass())}findSuperclass(t){for(const e of this.superclassDefinitions){if(e.name===t)return e;const r=e.findSuperclass(t);if(r)return r}}allProperties(){const t=n.firstByKey(this.superclassDefinitions.flatMap(t=>t.allProperties()),t=>t.name),e=new Set(this.properties.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.properties]}allMethods(){const t=n.firstByKey(this.inheritedMethods(),t=>this.methodOverrideKey(t)),e=new Set(this.methods.map(t=>this.methodOverrideKey(t)));return[...t.filter(t=>!e.has(this.methodOverrideKey(t))),...this.methods]}inheritedMethods(){return this.superclassDefinitions.flatMap(t=>t.allMethods())}allEvents(){const t=n.firstByKey(this.superclassDefinitions.flatMap(t=>t.allEvents()),t=>t.name),e=new Set(this.events.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.events]}allEnumerations(){const t=n.firstByKey(this.superclassDefinitions.flatMap(t=>t.allEnumerations()),t=>t.name),e=new Set(this.enumerations.map(t=>t.name));return[...t.filter(t=>!e.has(t.name)),...this.enumerations]}findProperty(t){return this.propertyTable[t]??this.superclassDefinitions.map(e=>e.findProperty(t)).find(t=>Boolean(t))}findMethod(t,e=()=>!0){const r=this.methodTable[t]?.find(e);return r??this.superclassDefinitions.map(r=>r.findMethod(t,e)).find(t=>Boolean(t))}findConstructor(){return this.methodTable[this.name]?.find(t=>!t.isStatic)??this.methodTable[this.simpleName]?.find(t=>!t.isStatic)}findEnumeration(t){return this.enumerationTable[t]??this.superclassDefinitions.map(e=>e.findEnumeration(t)).find(t=>Boolean(t))}findEvent(t){return this.events.find(e=>e.name===t)??this.superclassDefinitions.map(e=>e.findEvent(t)).find(t=>Boolean(t))}abstractMethodNames(){return new Set(this.unresolvedAbstractMethods().map(t=>t.name))}abstractPropertyNames(){return new Set(this.unresolvedAbstractProperties().map(t=>t.name))}unresolvedAbstractMethods(){const t=new Map;for(const e of this.superclassDefinitions)for(const r of e.unresolvedAbstractMethodEntries())t.set(r.key,r.method);for(const e of this.methods){const r=this.methodOverrideKey(e);e.isAbstract?t.set(r,e):t.delete(r)}return[...t.values()]}unresolvedAbstractProperties(){const t=new Map;for(const e of this.superclassDefinitions)for(const r of e.unresolvedAbstractPropertyEntries())t.set(r.key,r.property);for(const e of this.properties){const r=this.propertyOverrideKey(e);e.isAbstract?t.set(r,e):t.delete(r)}return[...t.values()]}isEffectivelyAbstract(){return this.isAbstract||this.unresolvedAbstractMethods().length>0||this.unresolvedAbstractProperties().length>0}unresolvedAbstractMethodEntries(){return this.unresolvedAbstractMethods().map(t=>({key:this.methodOverrideKey(t),method:t}))}unresolvedAbstractPropertyEntries(){return this.unresolvedAbstractProperties().map(t=>({key:this.propertyOverrideKey(t),property:t}))}methodOverrideKey(t){return`${t.isStatic?"static":"instance"}:${t.name}`}propertyOverrideKey(t){return t.name}validateSealedMethodOverrides(t){const e=new Map;for(const t of this.inheritedMethods())t.isSealed&&e.set(this.methodOverrideKey(t),t);for(const r of this.methods){const s=e.get(this.methodOverrideKey(r));s&&t(`method '${r.name}' in class ${this.name} cannot override sealed method from class ${s.classDefinition.name}.`)}}isPrivateMethodDefinition(t){return"private"===t.access}validateInheritedMethodCompatibility(t){const e=new Map;for(const t of this.inheritedMethods()){const r=this.methodOverrideKey(t),s=e.get(r)??[];s.some(e=>e.classDefinition===t.classDefinition&&e.name===t.name&&e.isStatic===t.isStatic)||s.push(t),e.set(r,s)}for(const r of this.methods)for(const s of e.get(this.methodOverrideKey(r))??[])this.isPrivateMethodDefinition(s)||r.access!==s.access&&t(`method '${r.name}' in class ${this.name} must match inherited Access from method in class ${s.classDefinition.name}.`);const r=new Set(this.methods.map(t=>this.methodOverrideKey(t)));for(const[s,i]of e){if(r.has(s))continue;const e=i.filter(t=>!t.isAbstract&&!this.isPrivateMethodDefinition(t));if(new Set(e.map(t=>t.classDefinition.name)).size<=1)continue;if(1===e.filter(t=>t.isSealed).length)continue;const n=e[0]?.name??s.slice(s.indexOf(":")+1);t(`class ${this.name} inherits incompatible method '${n}' from multiple superclasses.`)}}validateSupportedAttributes(t){this.validateAttributeNames(this.attributes,n.classAttributes,`class ${this.name}`,t),this.validateDuplicateAttributes(this.attributes,`class ${this.name}`,t),this.validateBooleanAttributes(this.attributes,n.classBooleanAttributes,`class ${this.name}`,t),this.validateClassNameListAttributes(this.attributes,new Set(["AllowedSubclasses","InferiorClasses"]),`class ${this.name}`,t);for(const e of this.sections){const r=`${e.kind.toLowerCase()} section of class ${this.name}`;switch(e.kind){case"PROPERTIES":this.validateAttributeNames(e.attributeTable,n.propertyAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,n.propertyBooleanAttributes,r,t),this.validatePositiveIntegerAttributes(e.attributeTable,new Set(["PartialMatchPriority"]),r,t);break;case"METHODS":this.validateAttributeNames(e.attributeTable,n.methodAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,n.methodBooleanAttributes,r,t);break;case"EVENTS":this.validateAttributeNames(e.attributeTable,n.eventAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,n.eventBooleanAttributes,r,t);break;case"ENUMERATION":this.validateAttributeNames(e.attributeTable,n.enumerationAttributes,r,t),this.validateBooleanAttributes(e.attributeTable,n.enumerationBooleanAttributes,r,t)}this.validateDuplicateAttributes(e.attributeTable,r,t)}}validateAttributeNames(t,e,r,s){for(const i of Object.keys(t))e.has(i)||s(`unsupported ${i} attribute for ${r}.`)}validateDuplicateAttributes(t,e,r){for(const[s,i]of Object.entries(t))i.length>1&&r(`duplicate ${s} attribute for ${e}.`)}validateBooleanAttributes(t,e,r,s){for(const n of e){const e=t[n]?.[0];e&&null===i.ClassMember.attributeBooleanValue(e)&&s(`invalid boolean ${n} attribute for ${r}.`)}}validateClassNameListAttributes(t,e,r,s){for(const n of e){const e=t[n]?.[0];e&&null===i.ClassMember.classNameListFromAttribute(e)&&s(`invalid class-name list ${n} attribute for ${r}.`)}}validatePositiveIntegerAttributes(t,e,r,s){for(const n of e){const e=t[n]?.[0];e&&null===i.ClassMember.positiveIntegerFromAttribute(e)&&s(`invalid positive integer ${n} attribute for ${r}.`)}}validateAccessAttributes(t){for(const e of this.sections){const r=`${e.kind.toLowerCase()} section of class ${this.name}`;switch(e.kind){case"PROPERTIES":i.ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t),i.ClassMember.validateAccessAttribute(e.attributeTable,"GetAccess",r,t),i.ClassMember.validateAccessAttribute(e.attributeTable,"SetAccess",r,t);break;case"METHODS":i.ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t);break;case"EVENTS":i.ClassMember.validateAccessAttribute(e.attributeTable,"Access",r,t),i.ClassMember.validateAccessAttribute(e.attributeTable,"ListenAccess",r,t),i.ClassMember.validateAccessAttribute(e.attributeTable,"NotifyAccess",r,t)}}}validateInheritanceCycles(t){for(const e of this.superclassDefinitions){e===this&&t(`class ${this.name} cannot inherit from itself.`);const r=e.inheritanceCyclePath(this,[this.name,e.name],new Set([this]))??e.inheritanceNameCyclePath(this.name,[this.name,e.name],new Set([this.name]));r&&t(`circular class inheritance detected: ${r.join(" -> ")}.`)}}inheritanceCyclePath(t,e,r){if(this===t)return e;if(!r.has(this)){r.add(this);for(const s of this.superclassDefinitions){const i=s.inheritanceCyclePath(t,[...e,s.name],r);if(i)return i}}}inheritanceNameCyclePath(t,e,r){if(this.superclasses.includes(t))return[...e,t];if(!r.has(this.name)){r.add(this.name);for(const s of this.superclassDefinitions){const i=s.inheritanceNameCyclePath(t,[...e,s.name],r);if(i)return i}}}validatePropertyAccessors(t){const e=(e,r,i)=>{if(!i)return void(e.attributes[r]?.[0]&&t(`invalid ${r} attribute for property '${e.name}' in class ${this.name}.`));const n=this.findMethod(i,t=>!t.isStatic);n||t(`${r} method '${i}' for property '${e.name}' in class ${this.name} is not defined.`);const a=this.methodParameters(n).length,o=this.methodReturns(n),l=o.length;"GetMethod"!==r||1===a&&1===l&&!s.AST.isNodeIgnoredTarget(o[0])||t(`${r} method '${i}' for property '${e.name}' in class ${this.name} must declare one input and one output.`),"SetMethod"!==r||2===a&&1===l&&!s.AST.isNodeIgnoredTarget(o[0])||t(`${r} method '${i}' for property '${e.name}' in class ${this.name} must declare two inputs and one output.`)};for(const t of this.properties)e(t,"GetMethod",t.getMethodName),e(t,"SetMethod",t.setMethodName);for(const e of this.methods){const r=/^(get|set)\.(.+)$/.exec(e.name);if(!r)continue;const[,i,n]=r;this.findProperty(n)||t(`${i} accessor '${e.name}' in class ${this.name} does not match a class property.`),e.isStatic&&t(`${i} accessor '${e.name}' in class ${this.name} cannot be static.`);const a=this.methodParameters(e).length,o=this.methodReturns(e),l=o.length;"get"!==i||1===a&&1===l&&!s.AST.isNodeIgnoredTarget(o[0])||t(`get accessor '${e.name}' in class ${this.name} must declare one input and one output.`),"set"!==i||2===a&&1===l&&!s.AST.isNodeIgnoredTarget(o[0])||t(`set accessor '${e.name}' in class ${this.name} must declare two inputs and one output.`)}}validateResolvedClassRestrictions(t){this.events.length>0&&!this.isHandleClass()&&t(`class ${this.name} cannot define events because it is not a handle class.`),this.isSubclassOfName("event.EventData")&&!this.isConstructOnLoad&&t(`class ${this.name} must set ConstructOnLoad because it subclasses event.EventData.`);for(const e of this.properties)this.isSubclassOfName("event.EventData")&&n.eventDataInheritedPropertyNames.has(e.name)&&t(`class ${this.name} cannot redefine inherited event.EventData property '${e.name}'.`),e.isNonCopyable&&!this.isHandleClass()&&t(`NonCopyable property '${e.name}' in class ${this.name} requires a handle class.`),e.isAbortSet&&!this.isHandleClass()&&t(`AbortSet property '${e.name}' in class ${this.name} requires a handle class.`),1===e.partialMatchPriority||this.isSetGetClass()||t(`PartialMatchPriority property '${e.name}' in class ${this.name} requires matlab.mixin.SetGet.`)}validateHandleCompatibility(t){const e=this.superclasses.some(t=>n.builtinSuperclassNames.has(t))||this.superclassDefinitions.some(t=>t.isHandleClass()),r=this.superclassDefinitions.find(t=>!t.isHandleCompatibleClass());!1===this.explicitHandleCompatible&&e&&t(`class ${this.name} cannot set HandleCompatible to false while inheriting from a handle class.`),(!0===this.explicitHandleCompatible||e)&&r&&t(`class ${this.name} cannot combine handle semantics with non-handle-compatible superclass ${r.name}.`)}isPrivatePropertyDefinition(t){return"private"===t.getAccess&&"private"===t.setAccess}validateInheritedPropertyCompatibility(t){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.allProperties()){const t=e.get(r.name)??[];t.some(t=>t.classDefinition===r.classDefinition&&t.name===r.name)||t.push(r),e.set(r.name,t)}for(const r of this.properties)for(const s of e.get(r.name)??[])s.isAbstract?r.getAccess===s.getAccess&&r.setAccess===s.setAccess||t(`property '${r.name}' in class ${this.name} must match inherited GetAccess and SetAccess from abstract property in class ${s.classDefinition.name}.`):this.isPrivatePropertyDefinition(s)||t(`property '${r.name}' in class ${this.name} cannot redefine inherited property from class ${s.classDefinition.name}.`);for(const[r,s]of e){const e=s.filter(t=>!t.isAbstract&&!this.isPrivatePropertyDefinition(t));new Set(e.map(t=>t.classDefinition.name)).size>1&&!this.properties.some(t=>t.name===r)&&t(`class ${this.name} inherits incompatible property '${r}' from multiple superclasses.`)}}isPrivateEventDefinition(t){return"private"===t.listenAccess&&"private"===t.notifyAccess}validateInheritedEventCompatibility(t){const e=new Map;for(const t of this.superclassDefinitions)for(const r of t.allEvents()){const t=e.get(r.name)??[];t.some(t=>t.classDefinition===r.classDefinition&&t.name===r.name)||t.push(r),e.set(r.name,t)}for(const[r,s]of e){const e=s.filter(t=>!this.isPrivateEventDefinition(t));new Set(e.map(t=>t.classDefinition.name)).size>1&&t(`class ${this.name} inherits incompatible event '${r}' from multiple superclasses.`)}}validateAttributeCombinations(t){if(i.ClassMember.hasAttribute(this.attributes,"Abstract")&&i.ClassMember.hasAttribute(this.attributes,"Sealed")&&t(`class ${this.name} cannot be both abstract and sealed.`),this.isSealed){const e=this.methods.find(t=>t.isAbstract);e&&t(`sealed class ${this.name} cannot define abstract method '${e.name}'.`);const r=this.properties.find(t=>t.isAbstract);r&&t(`sealed class ${this.name} cannot define abstract property '${r.name}'.`)}for(const e of this.sections)"METHODS"===e.kind&&i.ClassMember.hasAttribute(e.attributeTable,"Abstract")&&i.ClassMember.hasAttribute(e.attributeTable,"Sealed")&&t(`methods section of class ${this.name} cannot be both abstract and sealed.`);for(const e of this.properties)e.isDependent&&e.isConstant&&t(`property '${e.name}' in class ${this.name} cannot be both dependent and constant.`),e.isAbstract&&e.isConstant&&t(`property '${e.name}' in class ${this.name} cannot be both abstract and constant.`),e.isAbstract&&e.getMethodName&&t(`abstract property '${e.name}' in class ${this.name} cannot define a GetMethod.`),e.isAbstract&&e.setMethodName&&t(`abstract property '${e.name}' in class ${this.name} cannot define a SetMethod.`),e.isDependent&&e.defaultValue&&t(`dependent property '${e.name}' in class ${this.name} cannot define a default value.`),e.isAbstract&&e.defaultValue&&t(`abstract property '${e.name}' in class ${this.name} cannot define a default value.`),e.isConstant&&!e.defaultValue&&t(`constant property '${e.name}' in class ${this.name} must define a default value.`);for(const e of this.methods){e.isAbstract&&e.node.statements.list.length>0&&t(`abstract method '${e.name}' in class ${this.name} cannot define a method body.`),e.isAbstract&&e.node.arguments.list.length>0&&t(`arguments blocks are not allowed in abstract method '${e.name}' of class ${this.name}.`),this.isConstructorMethodName(e.name)&&e.isStatic&&t(`constructor for class ${this.name} cannot be static.`),this.isConstructorMethodName(e.name)&&e.isAbstract&&t(`constructor for class ${this.name} cannot be abstract.`),"delete"===e.name&&e.node.arguments.list.length>0&&t(`arguments blocks are not allowed in delete method of class ${this.name}.`);const r=this.methodReturns(e);this.isConstructorMethodName(e.name)&&(1!==r.length||s.AST.isNodeIgnoredTarget(r[0]))&&t(`constructor for class ${this.name} must declare exactly one output.`),this.isConstructorMethodName(e.name)&&this.isConstructOnLoad&&!this.constructorAcceptsNoInputs(e)&&t(`ConstructOnLoad class ${this.name} constructor must support zero input arguments.`)}}constructorAcceptsNoInputs(t){return this.methodParameters(t).every(t=>s.AST.isNodeDefaultedParameter(t)||s.AST.isNodeIdentifier(t)&&"varargin"===t.id)}validateDuplicateMembers(t){this.validateDuplicateNames(this.properties.map(t=>t.name),"property",t),this.validateDuplicateNames(this.events.map(t=>t.name),"event",t),this.validateDuplicateNames(this.enumerations.map(t=>t.name),"enumeration member",t),this.validateDuplicateNames(this.methods.map(t=>this.methodOverrideKey(t)),"method",t,t=>t.slice(t.indexOf(":")+1)),this.validateCrossMemberNameConflicts(t)}validateCrossMemberNameConflicts(t){const e=new Map,r=(r,s)=>{r!==this.simpleName&&r!==this.name||t(`class ${this.name} cannot define ${s} with the same name as the class.`);const i=e.get(r);i&&t(`class ${this.name} has conflicting ${i} and ${s} named '${r}'.`),e.set(r,s)};for(const t of this.properties)r(t.name,"property");for(const t of this.methods)this.isConstructorMethodName(t.name)||t.name.startsWith("get.")||t.name.startsWith("set.")||r(t.name,"method");for(const t of this.events)r(t.name,"event");for(const t of this.enumerations)r(t.name,"enumeration member")}isConstructorMethodName(t){return t===this.name||t===this.simpleName}validateDuplicateNames(t,e,r,s=t=>t){const i=new Set;for(const n of t)i.has(n)&&r(`duplicate ${e} '${s(n)}' in class ${this.name}.`),i.add(n)}collectMembers(){for(const t of this.sections)switch(t.kind){case"PROPERTIES":this.collectProperties(t);break;case"METHODS":this.collectMethods(t);break;case"EVENTS":this.collectEvents(t);break;case"ENUMERATION":this.collectEnumerations(t)}}classSectionMembers(t,e){return t.members.list.map((r,s)=>{if(!e(r))throw new TypeError(`internal AST error: ${t.kind.toLowerCase()} member ${s+1} has invalid node type.`);return r})}checkedMethodHeaderList(t,e,r,s){return t.map((t,i)=>{if(!e(t))throw new TypeError(`internal AST error: method '${r}' ${s} ${i+1} has invalid node type.`);return t})}methodParameters(t){return this.checkedMethodHeaderList(t.node.parameter.list,s.AST.isNodeFunctionParameter,t.name,"parameter")}methodReturns(t){return this.checkedMethodHeaderList(t.node.return.list,s.AST.isNodeFunctionReturn,t.name,"return")}collectProperties(t){const e=i.ClassMember.accessFromAttributes(t.attributeTable),r=i.ClassMember.hasAttribute(t.attributeTable,"Constant"),n=i.ClassMember.hasAttribute(t.attributeTable,"Dependent"),a=i.ClassMember.hasAttribute(t.attributeTable,"Abstract");for(const o of this.classSectionMembers(t,s.AST.isNodeClassProperty)){const s={name:o.id,node:o,defaultValue:o.defaultValue,size:o.size,class:o.class,functions:o.functions,section:t,attributes:t.attributeTable,access:e,getAccess:i.ClassMember.accessFromAttributes(t.attributeTable,"GetAccess",e),setAccess:i.ClassMember.accessFromAttributes(t.attributeTable,"SetAccess",e),getMethodName:i.ClassMember.methodNameFromAttribute(t.attributeTable,"GetMethod"),setMethodName:i.ClassMember.methodNameFromAttribute(t.attributeTable,"SetMethod"),isConstant:r,isDependent:n,isAbstract:a,isHidden:i.ClassMember.hasAttribute(t.attributeTable,"Hidden"),isTransient:i.ClassMember.hasAttribute(t.attributeTable,"Transient"),isNonCopyable:i.ClassMember.hasAttribute(t.attributeTable,"NonCopyable"),isGetObservable:i.ClassMember.hasAttribute(t.attributeTable,"GetObservable"),isSetObservable:i.ClassMember.hasAttribute(t.attributeTable,"SetObservable"),isAbortSet:i.ClassMember.hasAttribute(t.attributeTable,"AbortSet"),partialMatchPriority:i.ClassMember.positiveIntegerFromAttribute(t.attributeTable.PartialMatchPriority?.[0])??1,classDefinition:this};this.properties.push(s),this.propertyTable[s.name]=s}}collectMethods(t){const e=i.ClassMember.accessFromAttributes(t.attributeTable),r=i.ClassMember.hasAttribute(t.attributeTable,"Static"),n=i.ClassMember.hasAttribute(t.attributeTable,"Abstract"),a=i.ClassMember.hasAttribute(t.attributeTable,"Sealed"),o=i.ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const i of this.classSectionMembers(t,s.AST.isNodeFunctionDefinition)){const s={name:i.id,node:i,section:t,attributes:t.attributeTable,access:e,isStatic:r,isAbstract:n,isSealed:a,isHidden:o,classDefinition:this};this.methods.push(s),(r?this.staticMethods:this.instanceMethods).push(s),this.methodsByAccess[e]??=[],this.methodsByAccess[e].push(s),this.methodTable[s.name]??=[],this.methodTable[s.name].push(s)}}collectEvents(t){const e=i.ClassMember.accessFromAttributes(t.attributeTable),r=i.ClassMember.accessFromAttributes(t.attributeTable,"ListenAccess",e),n=i.ClassMember.accessFromAttributes(t.attributeTable,"NotifyAccess",e),a=i.ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const i of this.classSectionMembers(t,s.AST.isNodeClassEvent))this.events.push({name:i.id,node:i,section:t,attributes:t.attributeTable,access:e,listenAccess:r,notifyAccess:n,isHidden:a,classDefinition:this})}collectEnumerations(t){const e=i.ClassMember.hasAttribute(t.attributeTable,"Hidden");for(const r of this.classSectionMembers(t,s.AST.isNodeClassEnumeration)){const s={name:r.id,node:r,args:r.args,section:t,attributes:t.attributeTable,isHidden:e,classDefinition:this};this.enumerations.push(s),this.enumerationTable[s.name]=s}}}e.ClassDefinition=n,e.default={ClassDefinition:n}},3226(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassEmptyMethod=void 0;class r{static CLASS_EMPTY_METHOD=14;type=r.CLASS_EMPTY_METHOD;parent;classDefinition;static isInstanceOf=t=>t instanceof r;constructor(t){this.classDefinition=t}static bind=t=>new r(t);static copy=t=>new r(t.classDefinition);static unparse=(t,e)=>`${t.classDefinition.name}.empty static method`;copy(){return r.copy(this)}}e.ClassEmptyMethod=r,e.default={ClassEmptyMethod:r}},7325(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassEnumerationValue=void 0;class r{static CLASS_ENUMERATION_VALUE=10;type=r.CLASS_ENUMERATION_VALUE;parent;classDefinition;enumeration;args;static isInstanceOf=t=>t instanceof r;constructor(t,e,r=[]){this.classDefinition=t,this.enumeration=e,this.args=r}static create=(t,e,s=[])=>new r(t,e,s);static copy=t=>new r(t.classDefinition,t.enumeration,t.args.slice());static unparse=(t,e)=>`${t.classDefinition.name}.${t.enumeration.name}`;copy(){return r.copy(this)}}e.ClassEnumerationValue=r,e.default={ClassEnumerationValue:r}},169(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassEventData=void 0;const s=r(5956);class i{static CLASS_EVENT_DATA=12;type=i.CLASS_EVENT_DATA;parent;source;eventName;static isInstanceOf=t=>t instanceof i;constructor(t,e){this.source=t,this.eventName=e}static create=(t,e)=>new i(t,e);static getProperty=(t,e)=>{switch(e){case"Source":return t.source;case"EventName":return void 0===t.eventName?void 0:s.CharString.create(t.eventName);default:return}};static unparse=(t,e)=>t.source&&t.eventName?`event.EventData ${t.source.classDefinition.name}.${t.eventName}`:"event.EventData";copy(){return this}}e.ClassEventData=i,e.default={ClassEventData:i}},5577(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassEventListener=void 0;class r{static CLASS_EVENT_LISTENER=11;type=r.CLASS_EVENT_LISTENER;parent;source;kind;eventName;listenerKey;callback;enabled=!0;recursive=!1;notifying=!1;deleted=!1;static isInstanceOf=t=>t instanceof r;constructor(t,e,r,s=e,i="event.listener"){this.source=t,this.kind=i,this.eventName=e,this.listenerKey=s,this.callback=r}static create=(t,e,s,i=e,n="event.listener")=>new r(t,e,s,i,n);static isValid=t=>!t.deleted;static delete=t=>{t.deleted=!0,t.enabled=!1};static unparse=(t,e)=>`${t.kind} ${t.source.classDefinition.name}.${t.eventName}`;copy(){return this}}e.ClassEventListener=r,e.default={ClassEventListener:r}},9770(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassInstance=void 0;const s=r(6109),i=r(5577),n=r(5956),a=r(8146),o=r(7679),l=r(1604);class c{static CLASS_INSTANCE=7;type=c.CLASS_INSTANCE;parent;classDefinition;properties;listeners={};eventDataSource;eventDataEventName;deleted=!1;static isInstanceOf=t=>t instanceof c;constructor(t,e={}){this.classDefinition=t,this.properties={};for(const[t,r]of Object.entries(e))this.properties[t]=c.runtimePropertyValue(t,r)}static runtimePropertyValue=(t,e)=>(0,a.runtimeExpressionValue)(e,t,"property",t=>{throw new Error(t)});static propertyClassNames=t=>null===t?[]:s.AST.isNodeIdentifier(t)?[t.id]:s.AST.isNodeList(t)?t.list.flatMap(t=>s.AST.isNodeIdentifier(t)?[t.id]:[]):[];static implicitPropertyDefault=t=>{const e=c.propertyClassNames(t.class);return e.includes("char")?n.CharString.create("","'"):e.includes("string")?n.CharString.create("",'"'):e.includes("cell")?o.MultiArray.emptyArray(!0):o.MultiArray.emptyArray()};static instantiate=(t,e)=>{const r={};for(const s of t.allProperties())s.isDependent||(r[s.name]=s.defaultValue?e(s.defaultValue):c.implicitPropertyDefault(s));return new c(t,r)};static throwIfDeleted=t=>{if(t.deleted)throw new Error(`invalid or deleted object for class ${t.classDefinition.name}.`)};static delete=t=>{t.classDefinition.isHandleClass()&&(t.deleted=!0)};static isValid=t=>t.classDefinition.isHandleClass()&&!t.deleted;static getProperty=(t,e)=>(c.throwIfDeleted(t),t.properties[e]);static hasProperty=(t,e)=>l.RuntimeValue.hasOwnField(t.properties,e);static setProperty=(t,e,r)=>{if(c.throwIfDeleted(t),!c.hasProperty(t,e))throw new Error(`unknown property '${e}' for class ${t.classDefinition.name}.`);t.properties[e]=c.runtimePropertyValue(e,r)};static addListener=(t,e,r,s=e,n="event.listener")=>{c.throwIfDeleted(t);const a=i.ClassEventListener.create(t,e,r,s,n);return t.listeners[s]??=[],t.listeners[s].push(a),a};static listenersFor=(t,e)=>(c.throwIfDeleted(t),t.listeners[e]?.filter(t=>i.ClassEventListener.isValid(t)&&t.enabled).slice()??[]);static copy=t=>{if(c.throwIfDeleted(t),t.classDefinition.isHandleClass())return t;const e={};for(const[r,s]of Object.entries(t.properties))e[r]=l.RuntimeValue.copy(s);return new c(t.classDefinition,e)};static methodArgument=t=>(c.throwIfDeleted(t),t.classDefinition.isHandleClass()?t:c.copy(t));static unparse=(t,e)=>{const r=Object.keys(t.properties);return`${t.classDefinition.name} object${r.length>0?` with properties: ${r.join(",")}`:""}`};copy(){return c.copy(this)}}e.ClassInstance=c,e.default={ClassInstance:c}},9283(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassMember=void 0;const s=r(6109),i=r(5956),n=r(7679);class a{static defaultAccess="public";static isMetaClassNode=t=>s.AST.isNodeMetaClass(t);static isNegatedAttributeNode=t=>s.AST.isNodePrefixOperation(t)&&("~"===t.type||"!"===t.type);static classNameValue=t=>s.AST.isNodeIdentifier(t)?t.id:i.CharString.isInstanceOf(t)?t.str:this.isMetaClassNode(t)?t.className.id:null;static hasAttribute=(t,e)=>!0===this.attributeBooleanValue(t[e]?.[0]);static attributeBooleanValue=t=>{if(!t)return null;if(!t.value)return!0;const e=t.value;if(this.isNegatedAttributeNode(e))return!1;if(s.AST.isNodeIdentifier(e)){if("true"===e.id)return!0;if("false"===e.id)return!1}return null};static isSupportedAccess=t=>{if("public"===t||"protected"===t||"private"===t)return!0;const e=/^\?[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/;if(e.test(t))return!0;if(t.startsWith("{")&&t.endsWith("}")){const r=t.slice(1,-1).split(",");return r.length>0&&r.every(t=>e.test(t))}return!1};static attributeValue=t=>{if(!t||!t.value)return null;const e=t.value;if(s.AST.isNodeIdentifier(e))return e.id;if(i.CharString.isInstanceOf(e))return e.toString();if(this.isMetaClassNode(e))return`?${e.className.id}`;if(n.MultiArray.isInstanceOf(e)&&e.isCell){const t=n.MultiArray.linearize(e).map(t=>{const e=t;return this.isMetaClassNode(e)?`?${e.className.id}`:null});if(t.every(t=>"string"==typeof t))return`{${t.join(",")}}`}return null};static classNameListFromAttribute=t=>{if(!t||!t.value)return null;const e=this.classNameValue(t.value);if(e)return[e];if(n.MultiArray.isInstanceOf(t.value)&&t.value.isCell){const e=n.MultiArray.linearize(t.value).map(t=>this.classNameValue(t));if(e.every(t=>Boolean(t)))return e}return null};static positiveIntegerFromAttribute=t=>{const e=t?.value;if(!e||void 0===e.re||void 0===e.im||0!==Number(e.im))return null;const r=Number(e.re);return Number.isInteger(r)&&r>0?r:null};static accessFromAttributes=(t,e="Access",r=this.defaultAccess)=>this.attributeValue(t[e]?.[0])??r;static methodNameFromAttribute=(t,e)=>{const r=this.attributeValue(t[e]?.[0]);return r&&/^[A-Za-z]\w*(?:\.[A-Za-z]\w*)*$/.test(r)?r:null};static validateAccessAttribute=(t,e,r,s)=>{const i=t[e]?.[0];if(!i)return;const n=this.attributeValue(i);n&&this.isSupportedAccess(n)||s(`invalid ${e} attribute for ${r}.`)}}e.ClassMember=a,e.default={ClassMember:a}},7268(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassMetaEnumerationMember=e.ClassMetaEvent=e.ClassMetaMethod=e.ClassMetaProperty=e.ClassMetaMember=e.ClassMetaClass=e.ClassMetaObject=void 0;const s=r(5956),i=r(845),n=r(7679),a=r(5212),o=r(6109),l=t=>{const e=n.MultiArray.toColumnVector(t.map(t=>s.CharString.create(t)));return e.isCell=!0,e},c=t=>n.MultiArray.toColumnVector(t),u=t=>t?i.Complex.true():i.Complex.false(),h=()=>s.CharString.create(""),d=t=>l(Object.keys(t).sort()),m=t=>o.AST.isNodeIdentifier(t)?t.id:o.AST.isNodeIndirectRef(t)?`${m(t.obj)}.${String(t.field[0])}`:void 0,p=t=>{if(o.AST.isNodeList(t))return t.list.map(t=>p(t)).join(",");if(!o.AST.isStrictNodeExpr(t))return"";return m(t)||(s.CharString.isInstanceOf(t)?t.str:i.Complex.isInstanceOf(t)?t.toString():o.AST.isNodeIndexExpr(t)?`${p(t.expr)}(${t.args.map(t=>p(t)).join(",")})`:"")},f=t=>{const e=n.MultiArray.toColumnVector(t.map(t=>(t=>{const e=t.default??t.defaultValue??null;return new a.Structure({Name:s.CharString.create(m(t.name)??""),Size:l(t.size.map(t=>p(t))),Class:t.class?s.CharString.create(p(t.class)):h(),Validators:l(t.functions.map(t=>p(t))),HasDefault:u(Boolean(e)),DefaultValue:e??n.MultiArray.emptyArray()})})(t)));return e.isCell=!0,e},g=(t,e)=>t.node.arguments.list.flatMap(t=>(t.attribute?.id??null)===e?t.validation:[]);class y{static CLASS_META=7;type=y.CLASS_META;parent;static isInstanceOf=t=>t instanceof y;static copy=t=>t;copy(){return y.copy(this)}static unparse=(t,e)=>`${t.kind} ${t.displayName()}`}e.ClassMetaObject=y;class x extends y{definition;propertyDefaultProvider;kind="meta.class";constructor(t,e){super(),this.definition=t,this.propertyDefaultProvider=e}static isInstanceOf=t=>t instanceof x;static create=(t,e)=>new x(t,e);displayName(){return this.definition.name}getProperty(t){switch(t){case"Name":return s.CharString.create(this.definition.name);case"Description":case"DetailedDescription":return h();case"SuperclassList":return c(this.definition.superclassDefinitions.map(t=>x.create(t,this.propertyDefaultProvider)));case"SuperClasses":return l(this.definition.superclasses);case"PropertyList":return c(this.definition.allProperties().map(t=>E.create(t,this.propertyDefaultProvider)));case"MethodList":return c(this.definition.allMethods().map(t=>A.create(t,this.propertyDefaultProvider)));case"EventList":return c(this.definition.allEvents().map(t=>_.create(t,this.propertyDefaultProvider)));case"EnumerationMemberList":return c(this.definition.allEnumerations().map(t=>S.create(t,this.propertyDefaultProvider)));case"Abstract":return u(this.definition.isEffectivelyAbstract());case"Sealed":return u(this.definition.isSealed);case"Hidden":return u(this.definition.isHidden);case"ConstructOnLoad":return u(this.definition.isConstructOnLoad);case"HandleCompatible":return u(this.definition.isHandleCompatibleClass());case"InferiorClasses":return l(this.definition.inferiorClasses);case"AllowedSubclasses":return l(this.definition.allowedSubclasses);case"ContainingPackage":return s.CharString.create(this.definition.packageName);case"RestrictsSubclassing":return u(this.definition.isRestrictsSubclassing);case"AttributeNames":return d(this.definition.attributes);default:return}}}e.ClassMetaClass=x;class C extends y{member;propertyDefaultProvider;constructor(t,e){super(),this.member=t,this.propertyDefaultProvider=e}displayName(){return`${this.member.classDefinition.name}.${this.member.name}`}commonProperty(t){switch(t){case"Name":return s.CharString.create(this.member.name);case"DefiningClass":return x.create(this.member.classDefinition,this.propertyDefaultProvider);case"Hidden":return u("isHidden"in this.member&&this.member.isHidden);case"Description":case"DetailedDescription":return h();case"AttributeNames":return d(this.member.attributes);default:return}}}e.ClassMetaMember=C;class E extends C{property;defaultProvider;kind="meta.property";static isInstanceOf=t=>t instanceof E;constructor(t,e){super(t,e),this.property=t,this.defaultProvider=e}static create=(t,e)=>new E(t,e);defaultValue(){return this.property.defaultValue?this.defaultProvider?.(this.property)??(t=this.property.defaultValue,o.AST.isRuntimeExpressionValue(t)?t:s.CharString.create(p(t))):null;var t}getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"GetAccess":return s.CharString.create(this.property.getAccess);case"SetAccess":return s.CharString.create(this.property.setAccess);case"Access":return s.CharString.create(this.property.access);case"Constant":return u(this.property.isConstant);case"Dependent":return u(this.property.isDependent);case"Abstract":return u(this.property.isAbstract);case"Transient":return u(this.property.isTransient);case"GetObservable":return u(this.property.isGetObservable);case"SetObservable":return u(this.property.isSetObservable);case"AbortSet":return u(this.property.isAbortSet);case"HasDefault":return u(Boolean(this.property.defaultValue));case"DefaultValue":return this.defaultValue()??n.MultiArray.emptyArray();case"Validation":return f(this.property.size.length>0||this.property.class||this.property.functions.length>0||this.property.defaultValue?[{name:this.property.node.name,size:this.property.size,class:this.property.class,functions:this.property.functions,defaultValue:this.defaultValue()}]:[]);case"GetMethod":return this.property.getMethodName?s.CharString.create(this.property.getMethodName):n.MultiArray.emptyArray();case"SetMethod":return this.property.setMethodName?s.CharString.create(this.property.setMethodName):n.MultiArray.emptyArray();case"NonCopyable":return u(this.property.isNonCopyable);case"PartialMatchPriority":return i.Complex.create(this.property.partialMatchPriority);default:return}}}e.ClassMetaProperty=E;class A extends C{method;kind="meta.method";constructor(t,e){super(t,e),this.method=t}static create=(t,e)=>new A(t,e);getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"Access":return s.CharString.create(this.method.access);case"Static":return u(this.method.isStatic);case"Abstract":return u(this.method.isAbstract);case"Sealed":return u(this.method.isSealed);case"InputNames":return l(this.method.node.parameter.list.flatMap(t=>o.AST.isNodeIdentifier(t)?[t.id]:o.AST.isNodeDefaultedParameter(t)?[t.left.id]:[]));case"OutputNames":return l((()=>this.method.node.return.list.flatMap(t=>o.AST.isNodeIdentifier(t)?[t.id]:[]))());case"InputValidation":return f(g(this.method,null));case"OutputValidation":return f(g(this.method,"Output"));case"RepeatingInputValidation":return f(g(this.method,"Repeating"));default:return}}}e.ClassMetaMethod=A;class _ extends C{event;kind="meta.event";constructor(t,e){super(t,e),this.event=t}static create=(t,e)=>new _(t,e);getProperty(t){const e=this.commonProperty(t);if(void 0!==e)return e;switch(t){case"ListenAccess":return s.CharString.create(this.event.listenAccess);case"NotifyAccess":return s.CharString.create(this.event.notifyAccess);case"Access":return s.CharString.create(this.event.access);default:return}}}e.ClassMetaEvent=_;class S extends C{enumeration;kind="meta.EnumerationMember";constructor(t,e){super(t,e),this.enumeration=t}static create=(t,e)=>new S(t,e);getProperty(t){const e=this.commonProperty(t);return void 0!==e?e:"ConstructorArguments"===t?0===this.enumeration.args.length?n.MultiArray.emptyArray():l(this.enumeration.args.map(t=>p(t))):void 0}}e.ClassMetaEnumerationMember=S,e.default={ClassMetaObject:y,ClassMetaClass:x,ClassMetaMember:C,ClassMetaProperty:E,ClassMetaMethod:A,ClassMetaEvent:_,ClassMetaEnumerationMember:S}},482(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassPropertyEvent=void 0;const s=r(5956),i=r(169);class n extends i.ClassEventData{static CLASS_PROPERTY_EVENT=13;type=n.CLASS_PROPERTY_EVENT;propertyName;affectedObject;propertySource;static isInstanceOf=t=>t instanceof n;constructor(t,e,r=e,s=t){super(t,r),this.propertyName=e,this.affectedObject=t,this.propertySource=s}static create=(t,e,r=e??"",s)=>new n(t,e??"",r,s??t);static getProperty=(t,e)=>{if(!n.isInstanceOf(t))return i.ClassEventData.getProperty(t,e);switch(e){case"Source":return t.propertySource;case"AffectedObject":return t.affectedObject;case"PropertyName":return s.CharString.create(t.propertyName);default:return i.ClassEventData.getProperty(t,e)}};static unparse=(t,e)=>n.isInstanceOf(t)?`event.PropertyEvent ${t.affectedObject.classDefinition.name}.${t.propertyName}`:i.ClassEventData.unparse(t,e);copy(){return this}}e.ClassPropertyEvent=n,e.default={ClassPropertyEvent:n}},8986(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClassStaticMethod=void 0;class r{static CLASS_STATIC_METHOD=9;type=r.CLASS_STATIC_METHOD;parent;classDefinition;method;static isInstanceOf=t=>t instanceof r;constructor(t,e){this.classDefinition=t,this.method=e}static bind=(t,e)=>new r(t,e);static copy=t=>new r(t.classDefinition,t.method);static unparse=(t,e)=>`${t.classDefinition.name}.${t.method.name} static method`;copy(){return r.copy(this)}}e.ClassStaticMethod=r,e.default={ClassStaticMethod:r}},845(t,e,r){"use strict";var s,i=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||(s=function(t){return s=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},s(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=s(t),a=0;a<r.length;a++)"default"!==r[a]&&i(e,t,r[a]);return n(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.toNumber=e.Complex=void 0;const o=a(r(5142)),l=r(3428),c=r(3826);e.toNumber=t=>t instanceof c.Decimal?t.toNumber():Number(t);class u{static _engineBackend;static _engine;static get engineBackend(){return this._engineBackend}static get engine(){return this._engine}static set engine(t){switch(this._engine=t,t){case"number":this._engineBackend=l.ComplexNumber;break;case"decimal":this._engineBackend=c.ComplexDecimal;break;default:throw new Error(`invalid complex backend engine: '${t}'.`)}o.ComplexInterfaceStaticKeyTable.forEach(t=>{const e=this._engineBackend;this[t]=e[t]}),this.set(this.defaultSettings)}static LOGICAL;static REAL;static COMPLEX;static defaultSettings;static settings;static isInstanceOf;static set;static setNumberType;static create;static realSet;static imagSet;static realApply;static imagApply;static from;static real;static imag;static isComplexValue;static isRealValue;static realIsFinite;static imagIsFinite;static realIsNaN;static imagIsNaN;static realIsInteger;static imagIsInteger;static realIsNegative;static imagIsNegative;static realIsZero;static imagIsZero;static realIsPositive;static imagIsPositive;static realToNumber;static toBoolean;static imagToNumber;static realLessThan;static imagLessThan;static realLessThanOrEqualTo;static imagLessThanOrEqualTo;static realEquals;static imagEquals;static realGreaterThanOrEqualTo;static imagGreaterThanOrEqualTo;static realGreaterThan;static imagGreaterThan;static parse;static precedence;static unparseValue;static unparse;static toString;static unparseMathMLValue;static unparseMathML;static copy;static toMaxPrecisionValue;static toMaxPrecision;static epsilon;static random;static eq;static ne;static cmp;static minMaxArrayReal;static minMaxArrayRealWithIndex;static minMaxArrayComplex;static minMaxArrayComplexWithIndex;static min;static minWise;static max;static maxWise;static lt;static le;static gt;static ge;static false;static true;static toLogical;static logical;static and;static or;static xor;static not;static zero;static one;static onediv2;static minusonediv2;static minusone;static pi;static pidiv2;static onei;static onediv2i;static minusonediv2i;static minusonei;static two;static sqrt2pi;static e;static NaN_0;static inf_0;static add;static sub;static neg;static mul;static mulAndSumTo;static rdiv;static ldiv;static inv;static power;static root;static abs;static abs2;static hypot;static arg;static conj;static mod;static rem;static fix;static ceil;static floor;static round;static sign;static sqrt;static exp;static log;static logb;static log2;static log10;static deg2rad;static rad2deg;static sin;static sind;static cos;static cosd;static tan;static tand;static csc;static cscd;static sec;static secd;static cot;static cotd;static asin;static asind;static acos;static acosd;static atan;static atan2;static atand;static acsc;static acscd;static asec;static asecd;static acot;static acotd;static sinh;static cosh;static tanh;static csch;static sech;static coth;static asinh;static acosh;static atanh;static acsch;static asech;static acoth;static gamma;static factorial;static applyFunction;static mapFunction;static twoArgFunction}e.Complex=u,u.engine="decimal",e.default={Complex:u}},4034(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ComplexConfigKeyTable=void 0,e.ComplexConfigKeyTable=["precision","precisionCompare","rounding","toExpPos","minE","maxE","toExpNeg","modulo","crypto"]},3826(t,e,r){"use strict";var s,i=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||(s=function(t){return s=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},s(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=s(t),a=0;a<r.length;a++)"default"!==r[a]&&i(e,t,r[a]);return n(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.ComplexDecimal=e.Decimal=void 0;const o=r(3110);Object.defineProperty(e,"Decimal",{enumerable:!0,get:function(){return o.Decimal}});const l=a(r(5142)),c={precision:336,rounding:o.Decimal.ROUND_HALF_DOWN,toExpPos:20,toExpNeg:-7,minE:-9e15,maxE:9e15,modulo:o.Decimal.ROUND_DOWN,crypto:!1};o.Decimal.set(c);const u=o.Decimal;u.create=t=>new o.Decimal(t),u.neg=t=>t.neg(),u.MINUSONE=new o.Decimal(-1),u.ZERO=new o.Decimal(0),u.TWO=new o.Decimal(2),u.PI=o.Decimal.acos(-1),u.PI_DEG=new o.Decimal(180),u.INF=new o.Decimal(1/0),u.unparse=t=>t.valueOf(),u.isZero=t=>t.isZero(),u.isNeg=t=>t.isNeg(),u.isNaN=t=>t.isNaN(),u.isFinite=t=>t.isFinite();const h=(t,e,r)=>{t[e]=r};class d{static LOGICAL=l.numberClass.LOGICAL;static REAL=l.numberClass.REAL;static COMPLEX=l.numberClass.COMPLEX;static defaultSettings=Object.assign({precisionCompare:7},c);static settings=d.defaultSettings;static isInstanceOf=t=>t instanceof d;static set=t=>{const e={};l.ComplexConfigKeyTable.forEach(r=>{if(void 0!==t[r]){const s=t[r];"precisionCompare"!==r?(h(this.settings,r,s),((t,e,r)=>{t[e]=r})(e,r,s)):h(this.settings,r,s)}}),Object.keys(e).length>0&&o.Decimal.set(e)};re;im;type;parent;static setNumberType=l.setNumberTypeFactory(d);constructor(t,e,r,s){this.re=void 0!==t?new o.Decimal(t):new o.Decimal(0),this.im=void 0!==e?new o.Decimal(e):new o.Decimal(0),this.type=r??d.COMPLEX,this.parent=s??void 0,d.setNumberType(this)}static create=l.createFactory(d);static realSet=(t,e)=>{t.re=new o.Decimal(e)};static imagSet=(t,e)=>{t.im=new o.Decimal(e)};static realApply=(t,e)=>{t.re=e(t.re)};static imagApply=(t,e)=>{t.im=e(t.im)};static from=t=>new d(t.re,t.im,t.type,t.parent);static real=t=>new d(t.re);static imag=t=>new d(t.im);static isComplexValue=t=>!t.im.isZero();static isRealValue=t=>t.im.isZero();static realIsInteger=t=>t.re.isInteger();static imagIsInteger=t=>t.im.isInteger();static realIsFinite=t=>t.re.isFinite();static imagIsFinite=t=>t.im.isFinite();static realIsNaN=t=>t.re.isNaN();static imagIsNaN=t=>t.im.isNaN();static realIsNegative=t=>t.re.isNegative();static imagIsNegative=t=>t.im.isNegative();static realIsZero=t=>t.re.isZero();static imagIsZero=t=>t.im.isZero();static realIsPositive=t=>t.re.isPositive();static imagIsPositive=t=>t.im.isPositive();static realToNumber=t=>t.re.toNumber();static toBoolean=t=>t.type===d.LOGICAL?Boolean(t.re.toNumber()):Boolean(t.re.toNumber())||Boolean(t.im.toNumber());static imagToNumber=t=>t.im.toNumber();static realLessThan=(t,e)=>t.re.lt(e);static imagLessThan=(t,e)=>t.im.lt(e);static realLessThanOrEqualTo=(t,e)=>t.re.lte(e);static imagLessThanOrEqualTo=(t,e)=>t.im.lte(e);static realEquals=(t,e)=>t.re.eq(e);static imagEquals=(t,e)=>t.im.eq(e);static realGreaterThanOrEqualTo=(t,e)=>t.re.gte(e);static imagGreaterThanOrEqualTo=(t,e)=>t.im.gte(e);static realGreaterThan=(t,e)=>t.re.gt(e);static imagGreaterThan=(t,e)=>t.im.gt(e);static parse=l.parseFactory(d);static precedence=l.precedenceFactory(d);static unparseValue=l.unparseValueFactory(o.Decimal,d);static unparse=l.unparseFactory(d);static toString=l.toStringFactory(d);toString(){return d.toString(this)}static unparseMathMLValue=l.unparseMathMLValueFactory(o.Decimal,d);static unparseMathML=l.unparseMathMLFactory(d);static copy=l.copyFactory(d);copy=()=>new d(this.re,this.im,this.type);static toMaxPrecisionValue=t=>{const e=this.settings.precision-this.settings.precisionCompare;return t.toSignificantDigits(e).toDecimalPlaces(e)};static toMaxPrecision=l.toMaxPrecisionFactory(d);static epsilonValue=()=>o.Decimal.pow(10,-this.settings.precision+this.settings.precisionCompare);static epsilon=l.epsilonFactory(d);static random=t=>new d(o.Decimal.random(t));static eq=l.equalsFactory(d,!0);static ne=l.equalsFactory(d,!1);static compareValue=(t,e,r)=>e[t](r);static cmp=l.cmpFactory(d);static minMaxArrayReal=l.minMaxArrayRealFactory(d);static minMaxArrayRealWithIndex=l.minMaxArrayRealWithIndexFactory(d);static minMaxArrayComplex=l.minMaxArrayComplexFactory(d);static minMaxArrayComplexWithIndex=l.minMaxArrayComplexWithIndexFactory(d);static min=l.minMaxFactory(d,"lt");static minWise=l.minMaxWiseFactory(d,"lt");static max=l.minMaxFactory(d,"gte");static maxWise=l.minMaxWiseFactory(d,"gte");static lt=l.comparisonFactory(d,"lt");static le=l.comparisonFactory(d,"lte");static gt=l.comparisonFactory(d,"gt");static ge=l.comparisonFactory(d,"gte");static false=l.literalFactory(d,0,0,d.LOGICAL);static true=l.literalFactory(d,1,0,d.LOGICAL);static logical=l.logicalFactory(d);static toLogical=t=>d.logical(t);toLogical=()=>d.logical(this);static and=l.andFactory(d);static or=l.orFactory(d);static xor=l.xorFactory(d);static not=l.notFactory(d);static zero=l.literalFactory(d,0,0);static one=l.literalFactory(d,1,0);static onediv2=l.literalFactory(d,.5,0);static minusonediv2=l.literalFactory(d,-.5,0);static minusone=l.literalFactory(d,-1,0);static pi=l.literalFactory(d,o.Decimal.acos(-1),0);static pidiv2=l.literalFactory(d,o.Decimal.div(o.Decimal.acos(-1),2),0);static onei=l.literalFactory(d,0,1);static onediv2i=l.literalFactory(d,0,.5);static minusonediv2i=l.literalFactory(d,0,-.5);static minusonei=l.literalFactory(d,0,-1);static two=l.literalFactory(d,2,0);static sqrt2pi=l.literalFactory(d,o.Decimal.sqrt(o.Decimal.mul(2,o.Decimal.acos(-1))),0);static e=l.literalFactory(d,o.Decimal.exp(1),0);static NaN_0=l.literalFactory(d,NaN,0);static inf_0=l.literalFactory(d,1/0,0);static add=(t,e)=>new d(o.Decimal.add(t.re,e.re),o.Decimal.add(t.im,e.im));static sub=(t,e)=>new d(o.Decimal.sub(t.re,e.re),o.Decimal.sub(t.im,e.im));static neg=t=>new d(t.re.neg(),t.im.neg());static mul=l.mulFactory(o.Decimal,d);static mulAndSumTo=l.mulAndSumToFactory(o.Decimal,d);static rdiv=l.rdivFactory(o.Decimal,d);static ldiv=l.ldivFactory(o.Decimal,d);static inv=l.invFactory(o.Decimal,d);static power=l.powerFactory(o.Decimal,d);static root=l.rootFactory(d);static absValue=l.absValueFactory(o.Decimal);static abs2Value=l.abs2ValueFactory(o.Decimal);static abs=l.absFactory(o.Decimal,d);static abs2=l.abs2Factory(o.Decimal,d);static hypot=l.hypotFactory(d);static arg=l.argFactory(o.Decimal,d);static conj=l.conjFactory(o.Decimal,d);static mod=l.modFactory(o.Decimal,d);static rem=l.remFactory(o.Decimal,d);static fix=l.fixFactory(o.Decimal,d);static ceil=l.ceilFactory(o.Decimal,d);static floor=l.floorFactory(o.Decimal,d);static round=l.roundFactory(o.Decimal,d);static sign=l.signFactory(o.Decimal,d);static sqrt=l.sqrtFactory(o.Decimal,d);static exp=l.expFactory(o.Decimal,d);static log=l.logFactory(o.Decimal,d);static logb=l.logbFactory(o.Decimal,d);static log2=l.log2Factory(d);static log10=l.log10Factory(d);static deg2rad=l.deg2radFactory(o.Decimal,d);static rad2deg=l.rad2degFactory(o.Decimal,d);static sin=l.sinFactory(o.Decimal,d);static sind=l.sindFactory(d);static cos=l.cosFactory(o.Decimal,d);static cosd=l.cosdFactory(d);static tan=l.tanFactory(d);static tand=l.tandFactory(d);static csc=l.cscFactory(d);static cscd=l.cscdFactory(d);static sec=l.secFactory(d);static secd=l.secdFactory(d);static cot=l.cotFactory(d);static cotd=l.cotdFactory(d);static asin=l.asinFactory(d);static asind=l.asindFactory(d);static acos=l.acosFactory(d);static acosd=l.acosdFactory(d);static atan=l.atanFactory(d);static atan2=l.atan2Factory(o.Decimal,d);static atand=l.atandFactory(d);static acsc=l.acscFactory(d);static acscd=l.acscdFactory(d);static asec=l.asecFactory(d);static asecd=l.asecdFactory(d);static acot=l.acotFactory(d);static acotd=l.acotdFactory(d);static sinh=l.sinhFactory(o.Decimal,d);static cosh=l.coshFactory(o.Decimal,d);static tanh=l.tanhFactory(d);static csch=l.cschFactory(d);static sech=l.sechFactory(d);static coth=l.cothFactory(d);static asinh=l.asinhFactory(d);static acosh=l.acoshFactory(d);static atanh=l.atanhFactory(d);static acsch=l.acschFactory(d);static asech=l.asechFactory(d);static acoth=l.acothFactory(d);static gamma=l.gammaFactory(d);static factorial=l.factorialFactory(o.Decimal,d);static applyFunction=l.applyFunctionFactory(o.Decimal);static mapFunction=l.mapFunctionFactory(d);static twoArgFunction=l.twoArgFunctionFactory(d)}e.ComplexDecimal=d,d.set(d.defaultSettings),e.default={ComplexDecimal:d}},5142(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.remFactory=e.modFactory=e.conjFactory=e.argFactory=e.hypotFactory=e.abs2Factory=e.absFactory=e.abs2ValueFactory=e.absValueFactory=e.rootFactory=e.powerFactory=e.invFactory=e.ldivFactory=e.rdivFactory=e.mulAndSumToFactory=e.mulFactory=e.literalFactory=e.notFactory=e.xorFactory=e.orFactory=e.andFactory=e.logicalFactory=e.comparisonFactory=e.minMaxWiseFactory=e.minMaxFactory=e.minMaxArrayComplexWithIndexFactory=e.minMaxArrayComplexFactory=e.minMaxArrayRealWithIndexFactory=e.minMaxArrayRealFactory=e.cmpFactory=e.equalsFactory=e.epsilonFactory=e.copyFactory=e.toMaxPrecisionFactory=e.unparseMathMLFactory=e.unparseMathMLValueFactory=e.toStringFactory=e.unparseFactory=e.unparseValueFactory=e.precedenceFactory=e.parseFactory=e.createFactory=e.setNumberTypeFactory=e.numberClass=e.moduloName=e.roundingName=e.roundingMode=e.ComplexInterfaceStaticKeyTable=e.ComplexInterfaceKeyTable=e.ComplexConfigKeyTable=void 0,e.acothFactory=e.asechFactory=e.acschFactory=e.atanhFactory=e.acoshFactory=e.asinhFactory=e.cothFactory=e.sechFactory=e.cschFactory=e.tanhFactory=e.coshFactory=e.sinhFactory=e.acotdFactory=e.acotFactory=e.asecdFactory=e.asecFactory=e.acscdFactory=e.acscFactory=e.atandFactory=e.atan2Factory=e.atanFactory=e.acosdFactory=e.acosFactory=e.asindFactory=e.asinFactory=e.cotdFactory=e.cotFactory=e.secdFactory=e.secFactory=e.cscdFactory=e.cscFactory=e.tandFactory=e.tanFactory=e.cosdFactory=e.cosFactory=e.sindFactory=e.sinFactory=e.rad2degFactory=e.deg2radFactory=e.log10Factory=e.log2Factory=e.logbFactory=e.logFactory=e.expFactory=e.sqrtFactory=e.signFactory=e.roundFactory=e.floorFactory=e.ceilFactory=e.fixFactory=void 0,e.twoArgFunctionFactory=e.mapFunctionFactory=e.applyFunctionFactory=e.factorialFactory=e.gammaFactory=void 0;var s=r(4034);Object.defineProperty(e,"ComplexConfigKeyTable",{enumerable:!0,get:function(){return s.ComplexConfigKeyTable}});var i=r(3139);Object.defineProperty(e,"ComplexInterfaceKeyTable",{enumerable:!0,get:function(){return i.ComplexInterfaceKeyTable}});var n=r(5377);Object.defineProperty(e,"ComplexInterfaceStaticKeyTable",{enumerable:!0,get:function(){return n.ComplexInterfaceStaticKeyTable}}),e.roundingMode={ROUND_UP:0,ROUND_DOWN:1,ROUND_CEIL:2,ROUND_FLOOR:3,ROUND_HALF_UP:4,ROUND_HALF_DOWN:5,ROUND_HALF_EVEN:6,ROUND_HALF_CEIL:7,ROUND_HALF_FLOOR:8,EUCLID:9},e.roundingName=["up","down","ceil","floor","half_up","half_down","half_even","half_ceil","half_floor"],e.moduloName=["up","down",void 0,"floor",void 0,void 0,"half_even",void 0,void 0,"euclid"],e.numberClass={LOGICAL:0,REAL:1,COMPLEX:2},e.setNumberTypeFactory=t=>e=>{t.imagIsZero(e)?(t.realIsZero(e)||t.realEquals(e,1))&&e.type===t.LOGICAL||(e.type=t.REAL):e.type=t.COMPLEX},e.createFactory=t=>(e,r,s,i)=>new t(e,r,s,i),e.parseFactory=t=>e=>{const r="0"!==e[0]||"x"!==e[1]&&"X"!==e[1]?e.replace(/[dD]/,"e"):e.replace("_","");return/[ijIJ]$/.test(r)?t.create(0,r.slice(0,-1)):t.create(r,0)},e.precedenceFactory=t=>(e,r)=>{if(e.type!==t.LOGICAL){const s=t.toMaxPrecision(e);return t.realIsZero(s)||t.imagIsZero(s)?t.realIsZero(s)?t.imagIsZero(s)?t.realIsNegative(s)||t.imagIsNegative(s)?t.realIsNegative(s)&&t.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["+"]:r.precedenceTable["()"]:t.imagIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"]:t.realIsNegative(s)?r.precedenceTable["-_"]:r.precedenceTable["()"]:r.precedenceTable["+"]}return r.precedenceTable["()"]},e.unparseValueFactory=(t,e)=>r=>{if(t.isFinite(r)){const s=t.unparse(r).split("e");return 1===s.length?s[0].slice(0,e.settings.toExpPos):s[0].slice(0,e.settings.toExpPos)+"e"+Number(s[1])}return t.isNaN(r)?"NaN":(t.isNeg(r)?"-":"")+"∞"},e.unparseFactory=t=>(e,r,s=0)=>{if(e.type!==t.LOGICAL){const i=t.toMaxPrecision(e);if(t.realIsZero(i)||t.imagIsZero(i)){if(t.realIsZero(i)){if(t.imagIsZero(i)){if(t.realIsNegative(i)||t.imagIsNegative(i)){if(t.realIsNegative(i)&&t.imagIsNegative(i)){const t="-0";return s>r.precedenceTable["-_"]?"("+t+")":t}if(t.realIsNegative(i)&&!t.imagIsNegative(i)){const t="-0+0i";return s>r.precedenceTable["+"]?"("+t+")":t}{const t="0-0i";return s>r.precedenceTable["+"]?"("+t+")":t}}return"0"}{const e=(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"-":t.unparseValue(i.im))+"i";return s>(t.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+e+")":e}}{const e=t.unparseValue(i.re);return s>(t.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?"("+e+")":e}}{const e=t.unparseValue(i.re)+(t.imagGreaterThan(i,0)?"+":"")+(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"-":t.unparseValue(i.im))+"i";return s>r.precedenceTable["+"]?"("+e+")":e}}return t.realIsZero(e)?"false":"true"},e.toStringFactory=t=>e=>{if(e.type!==t.LOGICAL){const r=t.toMaxPrecision(e);return t.realIsZero(r)||t.imagIsZero(r)?t.realIsZero(r)?t.imagIsZero(r)?t.realIsNegative(r)||t.imagIsNegative(r)?t.realIsNegative(r)&&t.imagIsNegative(r)?"-0":t.realIsNegative(r)&&!t.imagIsNegative(r)?"-0+0i":"0-0i":"0":(t.imagEquals(r,1)?"":t.imagEquals(r,-1)?"-":t.unparseValue(r.im))+"i":t.unparseValue(r.re):t.unparseValue(r.re)+(t.imagGreaterThan(r,0)?"+":"")+(t.imagEquals(r,1)?"":t.imagEquals(r,-1)?"-":t.unparseValue(r.im))+"i"}return t.realIsZero(e)?"false":"true"},e.unparseMathMLValueFactory=(t,e)=>r=>{if(t.isFinite(r)){const s=t.unparse(r).split("e");return 1==s.length?"<mn>"+s[0].slice(0,e.settings.toExpPos)+"</mn>":"<mn>"+s[0].slice(0,e.settings.toExpPos)+"</mn><mo>⋅</mo><msup><mrow><mn>10</mn></mrow><mrow><mn>"+Number(s[1])+"</mn></mrow></msup>"}return t.isNaN(r)?"<mi><b>NaN</b></mi>":(t.isNeg(r)?"<mo>-</mo>":"")+"<mi>∞</mi>"},e.unparseMathMLFactory=t=>(e,r,s=0)=>{if(e.type!==t.LOGICAL){const i=t.toMaxPrecision(e);if(t.realIsZero(i)||t.imagIsZero(i)){if(t.realIsZero(i)){if(t.imagIsZero(i)){if(t.realIsNegative(i)||t.imagIsNegative(i)){if(t.realIsNegative(i)&&t.imagIsNegative(i)){const t="<mn>-0</mn>";return s>r.precedenceTable["-_"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}if(t.realIsNegative(i)&&!t.imagIsNegative(i)){const t="<mn>-0</mn><mo>+</mo><mn>0</mn><mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}{const t="<mn>0</mn><mo>-</mo><mn>0</mn><mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${t}<mo fence="true" stretchy="true">)</mo>`:t}}return"<mn>0</mn>"}{const e=(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"<mo>-</mo>":t.unparseMathMLValue(i.im))+"<mi>i</mi>";return s>(t.imagIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const e=t.unparseMathMLValue(i.re);return s>(t.realIsNegative(i)?r.precedenceTable["-_"]:r.precedenceTable["()"])?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}{const e=t.unparseMathMLValue(i.re)+(t.imagGreaterThan(i,0)?"<mo>+</mo>":"")+(t.imagEquals(i,1)?"":t.imagEquals(i,-1)?"<mo>-</mo>":t.unparseMathMLValue(i.im))+"<mi>i</mi>";return s>r.precedenceTable["+"]?`<mo fence="true" stretchy="true">(</mo>${e}<mo fence="true" stretchy="true">)</mo>`:e}}return t.realIsZero(e)?"<mi>false</mi>":"<mi>true</mi>"},e.toMaxPrecisionFactory=t=>e=>new t(t.toMaxPrecisionValue(e.re),t.toMaxPrecisionValue(e.im)),e.copyFactory=t=>e=>new t(e.re,e.im,e.type),e.epsilonFactory=t=>()=>new t(t.epsilonValue()),e.equalsFactory=(t,e=!0)=>e?(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realEquals(s,i.re)&&t.imagEquals(s,i.im)?t.true():t.false()}:(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realEquals(s,i.re)&&t.imagEquals(s,i.im)?t.false():t.true()},e.cmpFactory=t=>(e,r,s)=>{const i=t.toMaxPrecision(r),n=t.toMaxPrecision(s);if(t.imagIsZero(i)&&t.imagIsZero(n))return t.compareValue(e,i.re,n.re)?t.true():t.false();const a=t.toMaxPrecisionValue(t.abs(r).re),o=t.toMaxPrecisionValue(t.abs(s).re);return t.compareValue("eq",a,o)?t.compareValue(e,t.toMaxPrecisionValue(t.arg(r).re),t.toMaxPrecisionValue(t.arg(s).re))?t.true():t.false():t.compareValue(e,a,o)?t.true():t.false()},e.minMaxArrayRealFactory=t=>(e,...r)=>r.reduce((r,s)=>t.compareValue(e,r.re,s.re)?r:s,r[0]),e.minMaxArrayRealWithIndexFactory=t=>(e,...r)=>{let s=0;return[r.reduceRight((r,i,n)=>t.compareValue(e,r.re,i.re)?r:(s=n,i),r[r.length-1]),s]},e.minMaxArrayComplexFactory=t=>(e,...r)=>r.reduce((r,s)=>{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s},r[0]),e.minMaxArrayComplexWithIndexFactory=t=>(e,...r)=>{let s=0;return[r.reduceRight((r,i,n)=>{const a=t.abs(r).re,o=t.abs(i).re;return t.compareValue("eq",a,o)?t.compareValue(e,t.arg(r).re,t.arg(i).re)?r:(s=n,i):t.compareValue(e,a,o)?r:(s=n,i)},r[r.length-1]),s]},e.minMaxFactory=(t,e)=>(r,s)=>{if(t.imagIsZero(r)&&t.imagIsZero(s))return t.compareValue(e,r.re,s.re)?r:s;{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s}},e.minMaxWiseFactory=(t,e)=>(r,s)=>{if(r.type<=t.REAL&&r.type<=t.REAL)return t.compareValue(e,r.re,s.re)?r:s;{const i=t.abs(r).re,n=t.abs(s).re;return t.compareValue("eq",i,n)?t.compareValue(e,t.arg(r).re,t.arg(s).re)?r:s:t.compareValue(e,i,n)?r:s}},e.comparisonFactory=(t,e)=>(r,s)=>t.cmp(e,r,s),e.logicalFactory=t=>e=>{const r=t.toMaxPrecision(e);return new t(t.realIsZero(r)&&t.imagIsZero(r)?0:1,0,t.LOGICAL)},e.andFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)||t.realIsZero(i)&&t.imagIsZero(i)?t.false():t.true()},e.orFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)&&t.realIsZero(i)&&t.imagIsZero(i)?t.false():t.true()},e.xorFactory=t=>(e,r)=>{const s=t.toMaxPrecision(e),i=t.toMaxPrecision(r);return t.realIsZero(s)&&t.imagIsZero(s)&&(!t.realIsZero(i)||!t.imagIsZero(i))||(!t.realIsZero(s)||!t.imagIsZero(s))&&t.realIsZero(i)&&t.imagIsZero(i)?t.true():t.false()},e.notFactory=t=>e=>{const r=t.toMaxPrecision(e);return t.realIsZero(r)&&t.imagIsZero(r)?t.true():t.false()},e.literalFactory=(t,e,r,s)=>()=>new t(e,r,s),e.mulFactory=(t,e)=>(r,s)=>e.imagIsZero(r)&&e.imagIsZero(s)?new e(t.mul(r.re,s.re),t.ZERO):new e(t.sub(t.mul(r.re,s.re),t.mul(r.im,s.im)),t.add(t.mul(r.re,s.im),t.mul(r.im,s.re))),e.mulAndSumToFactory=(t,e)=>(r,s,i)=>(e.imagIsZero(s)&&e.imagIsZero(i)&&e.imagIsZero(r)?r.re=t.add(r.re,t.mul(s.re,i.re)):(r.re=t.add(r.re,t.sub(t.mul(s.re,i.re),t.mul(s.im,i.im))),r.im=t.add(r.im,t.add(t.mul(s.re,i.im),t.mul(s.im,i.re)))),r),e.rdivFactory=(t,e)=>(r,s)=>{if(t.isZero(s.im))return t.isFinite(s.re)?t.isZero(s.re)?new e(t.mul(r.re,t.INF),t.mul(r.im,t.INF)):new e(t.div(r.re,s.re),t.div(r.im,s.re)):t.isNaN(s.re)?(e.realIsFinite(s)||e.realIsNaN(s))&&(e.imagIsFinite(s)||e.imagIsNaN(s))?new e(NaN,0):e.zero():e.realIsFinite(r)&&e.imagIsFinite(r)?e.zero():new e(NaN,0);{const i=t.add(t.mul(s.re,s.re),t.mul(s.im,s.im));return t.isFinite(i)?t.isZero(i)?new e(t.mul(r.re,t.INF),e.imagIsZero(r)?t.ZERO:t.mul(r.im,t.INF)):new e(t.div(t.add(t.mul(r.re,s.re),t.mul(r.im,s.im)),i),t.div(t.sub(t.mul(r.im,s.re),t.mul(r.re,s.im)),i)):t.isNaN(i)?(e.realIsFinite(s)||e.realIsNaN(s))&&(e.imagIsFinite(s)||e.imagIsNaN(s))?new e(NaN,0):e.zero():e.realIsFinite(r)&&e.imagIsFinite(r)?e.zero():new e(NaN,0)}},e.ldivFactory=(t,r)=>{const s=(0,e.rdivFactory)(t,r);return(t,e)=>s(e,t)},e.invFactory=(t,e)=>r=>{const s=t.add(t.mul(r.re,r.re),t.mul(r.im,r.im));return t.isFinite(s)?t.isZero(s)?new e(1/0,0):new e(t.div(r.re,s),t.neg(t.div(r.im,s))):t.isNaN(s)&&(e.realIsFinite(r)||e.realIsNaN(r))&&(e.imagIsFinite(r)||e.imagIsNaN(r))?new e(NaN,0):e.zero()},e.powerFactory=(t,e)=>(r,s)=>{if(e.imagIsZero(r)&&e.imagIsZero(s)&&e.realGreaterThanOrEqualTo(r,0))return new e(t.pow(r.re,s.re),0);{const i=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,e.realIsZero(r)?t.ZERO:r.re),n=t.add(t.mul(r.re,r.re),t.mul(r.im,r.im)),a=t.mul(t.pow(n,t.div(s.re,t.TWO)),t.exp(t.mul(t.mul(t.MINUSONE,s.im),i))),o=t.add(t.mul(s.re,i),t.mul(t.div(s.im,t.TWO),t.ln(n)));return new e(t.mul(a,t.cos(o)),e.imagIsZero(r)&&e.imagIsZero(s)&&(e.realGreaterThanOrEqualTo(s,1)||e.realLessThanOrEqualTo(s,-1))?0:t.mul(a,t.sin(o)))}},e.rootFactory=t=>(e,r)=>t.power(e,t.inv(r)),e.absValueFactory=t=>e=>t.sqrt(t.add(t.mul(e.re,e.re),t.mul(e.im,e.im))),e.abs2ValueFactory=t=>e=>t.add(t.mul(e.re,e.re),t.mul(e.im,e.im)),e.absFactory=(t,e)=>r=>e.imagIsZero(r)?new e(t.abs(r.re)):new e(e.absValue(r)),e.abs2Factory=(t,e)=>r=>{const s=t.abs(r.re);return e.imagIsZero(r)?new e(t.mul(s,s)):new e(e.abs2Value(r))},e.hypotFactory=t=>(e,r)=>new t(t.absValue(new t(t.absValue(e),t.absValue(r)))),e.argFactory=(t,e)=>r=>new e(t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re),0),e.conjFactory=(t,e)=>r=>new e(r.re,t.neg(r.im)),e.modFactory=(t,e)=>(r,s)=>{if(!e.imagIsZero(r)||!e.imagIsZero(s))throw new Error("mod: not defined for complex numbers");return e.realIsZero(s)?r:new e(t.mod(r.re,s.re))},e.remFactory=(t,e)=>(r,s)=>{if(!e.imagIsZero(r)||!e.imagIsZero(s))throw new Error("rem: not defined for complex numbers");return new e(t.mod(r.re,s.re))},e.fixFactory=(t,e)=>r=>new e(t.trunc(r.re),t.trunc(r.im)),e.ceilFactory=(t,e)=>r=>new e(t.ceil(r.re),t.ceil(r.im)),e.floorFactory=(t,e)=>r=>new e(t.floor(r.re),t.floor(r.im)),e.roundFactory=(t,e)=>r=>new e(t.round(r.re),t.round(r.im)),e.signFactory=(t,e)=>r=>e.realIsZero(r)?e.imagIsZero(r)?e.zero():new e(0,t.div(r.im,e.absValue(r))):e.imagIsZero(r)?new e(t.div(r.re,e.absValue(r)),0):new e(t.div(r.re,e.absValue(r)),t.div(r.im,e.absValue(r))),e.sqrtFactory=(t,e)=>r=>{const s=e.absValue(r),i=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re);return new e(t.mul(t.sqrt(s),t.cos(t.div(i,t.TWO))),t.mul(t.sqrt(s),t.sin(t.div(i,t.TWO))))},e.expFactory=(t,e)=>r=>new e(t.mul(t.exp(r.re),t.cos(r.im)),t.mul(t.exp(r.re),t.sin(r.im))),e.logFactory=(t,e)=>r=>new e(t.ln(e.absValue(r)),t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re)),e.logbFactory=(t,e)=>(r,s)=>{const i=e.absValue(r);if(t.isZero(i))return e.zero();{const n=t.atan2(e.imagIsZero(r)?t.ZERO:r.im,r.re),a=e.absValue(s),o=t.atan2(e.imagIsZero(s)?t.ZERO:s.im,s.re),l=t.add(t.mul(t.ln(i),t.ln(i)),t.mul(n,n));return new e(t.div(t.add(t.mul(t.ln(a),t.ln(i)),t.mul(o,n)),l),t.div(t.sub(t.mul(o,t.ln(i)),t.mul(t.ln(a),n)),l))}},e.log2Factory=t=>e=>t.logb(new t(2),e),e.log10Factory=t=>e=>t.logb(new t(10),e),e.deg2radFactory=(t,e)=>r=>new e(t.mul(t.div(t.PI,t.PI_DEG),r.re),t.mul(t.div(t.PI,t.PI_DEG),r.im)),e.rad2degFactory=(t,e)=>r=>new e(t.mul(t.div(t.PI_DEG,t.PI),r.re),t.mul(t.div(t.PI_DEG,t.PI),r.im)),e.sinFactory=(t,e)=>r=>new e(t.mul(t.sin(r.re),t.cosh(r.im)),t.mul(t.cos(r.re),t.sinh(r.im))),e.sindFactory=t=>e=>t.sin(t.deg2rad(e)),e.cosFactory=(t,e)=>r=>new e(t.mul(t.cos(r.re),t.cosh(r.im)),t.mul(t.sin(r.re),t.neg(t.sinh(r.im)))),e.cosdFactory=t=>e=>t.cos(t.deg2rad(e)),e.tanFactory=t=>e=>t.rdiv(t.sin(e),t.cos(e)),e.tandFactory=t=>e=>t.tan(t.deg2rad(e)),e.cscFactory=t=>e=>t.rdiv(t.one(),t.sin(e)),e.cscdFactory=t=>e=>t.csc(t.deg2rad(e)),e.secFactory=t=>e=>t.rdiv(t.one(),t.cos(e)),e.secdFactory=t=>e=>t.sec(t.deg2rad(e)),e.cotFactory=t=>e=>t.rdiv(t.cos(e),t.sin(e)),e.cotdFactory=t=>e=>t.rdiv(t.cos(e),t.sin(e)),e.asinFactory=t=>e=>t.mul(t.onei(),t.log(t.sub(t.sqrt(t.sub(t.one(),t.power(e,t.two()))),t.mul(t.onei(),e)))),e.asindFactory=t=>e=>t.rad2deg(t.asin(e)),e.acosFactory=t=>e=>t.sub(t.pidiv2(),t.asin(e)),e.acosdFactory=t=>e=>t.rad2deg(t.acos(e)),e.atanFactory=t=>e=>t.mul(t.minusonediv2i(),t.log(t.rdiv(t.sub(t.onei(),e),t.add(t.onei(),e)))),e.atan2Factory=(t,e)=>(r,s)=>{const i=t.div(t.add(t.mul(r.re,s.re),t.mul(r.im,s.im)),t.add(t.mul(s.re,s.re),t.mul(s.im,s.im))),n=t.div(t.sub(t.mul(r.im,s.re),t.mul(r.re,s.im)),t.add(t.mul(s.re,s.re),t.mul(s.im,s.im)));return e.create(t.mul(t.create(.5),t.atan(t.div(t.mul(t.create(2),i),t.sub(t.sub(t.create(1),t.mul(i,i)),t.mul(n,n))))),t.mul(t.create(-1/4),t.ln(t.div(t.add(t.mul(t.sub(t.create(1),n),t.sub(t.create(1),n)),t.mul(i,i)),t.add(t.mul(t.add(t.create(1),n),t.add(t.create(1),n)),t.mul(i,i))))))},e.atandFactory=t=>e=>t.rad2deg(t.atan(e)),e.acscFactory=t=>e=>t.asin(t.rdiv(t.one(),e)),e.acscdFactory=t=>e=>t.rad2deg(t.acsc(e)),e.asecFactory=t=>e=>t.acos(t.rdiv(t.one(),e)),e.asecdFactory=t=>e=>t.rad2deg(t.asec(e)),e.acotFactory=t=>e=>t.atan(t.rdiv(t.one(),e)),e.acotdFactory=t=>e=>t.rad2deg(t.acot(e)),e.sinhFactory=(t,e)=>r=>new e(t.mul(t.sinh(r.re),t.cos(r.im)),t.mul(t.cosh(r.re),t.sin(r.im))),e.coshFactory=(t,e)=>r=>new e(t.mul(t.cosh(r.re),t.cos(r.im)),t.mul(t.sinh(r.re),t.sin(r.im))),e.tanhFactory=t=>e=>t.rdiv(t.sinh(e),t.cosh(e)),e.cschFactory=t=>e=>t.rdiv(t.one(),t.sinh(e)),e.sechFactory=t=>e=>t.rdiv(t.one(),t.cosh(e)),e.cothFactory=t=>e=>t.rdiv(t.cosh(e),t.sinh(e)),e.asinhFactory=t=>e=>t.log(t.add(t.sqrt(t.add(t.one(),t.power(e,t.two()))),e)),e.acoshFactory=t=>e=>t.log(t.add(t.sqrt(t.add(t.minusone(),t.power(e,t.two()))),e)),e.atanhFactory=t=>e=>t.mul(t.onediv2(),t.log(t.rdiv(t.add(t.one(),e),t.sub(t.one(),e)))),e.acschFactory=t=>e=>t.rdiv(t.one(),t.asinh(e)),e.asechFactory=t=>e=>t.rdiv(t.one(),t.acosh(e)),e.acothFactory=t=>e=>t.rdiv(t.one(),t.atanh(e)),e.gammaFactory=t=>e=>{const r=["0.99999999999980993","676.5203681218851","-1259.1392167224028","771.32342877765313","-176.61502916214059","12.507343278686905","-0.13857109526572012","9.9843695780195716e-6","1.5056327351493116e-7"];if(t.realLessThan(e,.5))return t.rdiv(t.pi(),t.mul(t.sin(t.mul(t.pi(),e)),t.gamma(t.sub(t.one(),e))));{e=t.sub(e,t.one());let s=new t(r[0]);const i=t.add(e,new t(r.length-1.5));for(let i=1;i<r.length;i++)s=t.add(s,t.rdiv(new t(r[i]),t.add(e,new t(i))));return t.mul(t.mul(t.sqrt2pi(),t.power(i,t.add(e,new t(.5)))),t.mul(t.exp(t.neg(i)),s))}},e.factorialFactory=(t,e)=>r=>{if(!(e.realGreaterThanOrEqualTo(r,0)&&e.realIsInteger(r)&&e.imagIsZero(r)))throw new Error("factorial: all N must be real non-negative integers");const s=e.gamma(e.add(new e(t.round(r.re)),e.one()));return e.realApply(s,e.applyFunction.trunc),s},e.applyFunctionFactory=t=>({fix:e=>t.trunc(e),ceil:e=>t.ceil(e),floor:e=>t.floor(e),round:e=>t.round(e),sign:e=>t.create(t.sign(e)),trunc:e=>t.trunc(e)}),e.mapFunctionFactory=t=>({real:t.real,imag:t.imag,logical:t.logical,abs:t.abs,arg:t.arg,angle:t.arg,conj:t.conj,fix:t.fix,ceil:t.ceil,floor:t.floor,round:t.round,sign:t.sign,sqrt:t.sqrt,exp:t.exp,log:t.log,log2:t.log2,log10:t.log10,deg2rad:t.deg2rad,rad2deg:t.rad2deg,sin:t.sin,sind:t.sind,cos:t.cos,cosd:t.cosd,tan:t.tan,tand:t.tand,csc:t.csc,cscd:t.cscd,sec:t.sec,secd:t.secd,cot:t.cot,cotd:t.cotd,asin:t.asin,asind:t.asind,acos:t.acos,acosd:t.acosd,atan:t.atan,atand:t.atand,acsc:t.acsc,acscd:t.acscd,asec:t.asec,asecd:t.asecd,acot:t.acot,acotd:t.acotd,sinh:t.sinh,cosh:t.cosh,tanh:t.tanh,csch:t.csch,sech:t.sech,coth:t.coth,asinh:t.asinh,acosh:t.acosh,atanh:t.atanh,acsch:t.acsch,asech:t.asech,acoth:t.acoth,gamma:t.gamma,factorial:t.factorial}),e.twoArgFunctionFactory=t=>({root:t.root,hypot:t.hypot,power:t.power,logb:t.logb,atan2:t.atan2})},3139(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ComplexInterfaceKeyTable=void 0,e.ComplexInterfaceKeyTable=["re","im","type","parent","copy","toString","toLogical"]},5377(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ComplexInterfaceStaticKeyTable=void 0,e.ComplexInterfaceStaticKeyTable=["LOGICAL","REAL","COMPLEX","defaultSettings","settings","isInstanceOf","set","setNumberType","create","realSet","imagSet","realApply","imagApply","from","real","imag","isComplexValue","isRealValue","realIsInteger","imagIsInteger","realIsFinite","imagIsFinite","realIsNaN","imagIsNaN","realIsNegative","imagIsNegative","realIsZero","imagIsZero","realIsPositive","imagIsPositive","realToNumber","toBoolean","imagToNumber","realLessThan","imagLessThan","realLessThanOrEqualTo","imagLessThanOrEqualTo","realEquals","imagEquals","realGreaterThanOrEqualTo","imagGreaterThanOrEqualTo","realGreaterThan","imagGreaterThan","parse","unparseValue","unparse","toString","unparseMathMLValue","precedence","unparseMathML","copy","toMaxPrecisionValue","toMaxPrecision","epsilonValue","epsilon","random","eq","ne","compareValue","cmp","minMaxArrayReal","minMaxArrayRealWithIndex","minMaxArrayComplex","minMaxArrayComplexWithIndex","min","minWise","max","maxWise","lt","le","gt","ge","false","true","logical","toLogical","and","or","xor","not","zero","one","onediv2","minusonediv2","minusone","pi","pidiv2","onei","onediv2i","minusonediv2i","minusonei","two","sqrt2pi","e","NaN_0","inf_0","add","sub","neg","mul","mulAndSumTo","rdiv","ldiv","inv","power","root","absValue","abs2Value","abs","abs2","hypot","arg","conj","mod","rem","fix","ceil","floor","round","sign","sqrt","exp","log","logb","log2","log10","deg2rad","rad2deg","sin","sind","cos","cosd","tan","tand","csc","cscd","sec","secd","cot","cotd","asin","asind","acos","acosd","atan","atan2","atand","acsc","acscd","asec","asecd","acot","acotd","sinh","cosh","tanh","csch","sech","coth","asinh","acosh","atanh","acsch","asech","acoth","gamma","factorial","applyFunction","mapFunction","twoArgFunction"]},3428(t,e,r){"use strict";var s,i=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||(s=function(t){return s=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},s(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=s(t),a=0;a<r.length;a++)"default"!==r[a]&&i(e,t,r[a]);return n(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.ComplexNumber=void 0;const o=a(r(5142)),l={precision:15,precisionCompare:0,rounding:o.roundingMode.ROUND_HALF_EVEN,toExpPos:21,toExpNeg:-7,minE:-324,maxE:308,modulo:o.roundingMode.ROUND_DOWN,crypto:!1},c=Math;c.add=(t,e)=>t+e,c.sub=(t,e)=>t-e,c.neg=t=>-t,c.mul=(t,e)=>t*e,c.div=(t,e)=>t/e,c.mod=(t,e)=>t%e,c.ln=Math.log,c.create=t=>Number(t),c.MINUSONE=-1,c.ZERO=0,c.TWO=2,c.PI_DEG=180,c.INF=1/0,c.unparse=t=>0===t?Object.is(t,-0)?"-0":"0":t.toString(),c.isZero=t=>0===t,c.isNeg=t=>0===t?Object.is(t,-0):t<0,c.isNaN=Number.isNaN,c.isFinite=Number.isFinite;class u{static LOGICAL=o.numberClass.LOGICAL;static REAL=o.numberClass.REAL;static COMPLEX=o.numberClass.COMPLEX;static defaultSettings=Object.assign({},l);static settings=this.defaultSettings;static isInstanceOf=t=>t instanceof u;static set=t=>{};re;im;type;parent;static setNumberType=o.setNumberTypeFactory(u);constructor(t,e,r,s){this.re=void 0!==t?Number(t):0,this.im=void 0!==e?Number(e):0,this.type=r??u.COMPLEX,s&&(this.parent=s),u.setNumberType(this)}static create=(t,e,r,s)=>new u(t,e,r,s);static realSet=(t,e)=>{t.re=Number(e)};static imagSet=(t,e)=>{t.im=Number(e)};static realApply=(t,e)=>{t.re=e(t.re)};static imagApply=(t,e)=>{t.im=e(t.im)};static from=t=>new u(t.re,t.im,t.type);static real=t=>new u(t.re);static imag=t=>new u(t.im);static isComplexValue=t=>0!==t.im;static isRealValue=t=>0===t.im;static realIsInteger=t=>Number.isInteger(t.re);static imagIsInteger=t=>Number.isInteger(t.im);static realIsFinite=t=>Number.isFinite(t.re);static imagIsFinite=t=>Number.isFinite(t.im);static realIsNaN=t=>Number.isNaN(t.re);static imagIsNaN=t=>Number.isNaN(t.im);static realIsNegative=t=>t.re<0||Object.is(t.re,-0);static imagIsNegative=t=>t.im<0||Object.is(t.im,-0);static realIsZero=t=>0===t.re;static imagIsZero=t=>0===t.im;static realIsPositive=t=>t.re>=0;static imagIsPositive=t=>t.im>=0;static realToNumber=t=>t.re;static toBoolean=t=>t.type===u.LOGICAL?Boolean(t.re):Boolean(t.re)||Boolean(t.im);static imagToNumber=t=>t.im;static realLessThan=(t,e)=>t.re<Number(e);static imagLessThan=(t,e)=>t.im<Number(e);static realLessThanOrEqualTo=(t,e)=>t.re<=Number(e);static imagLessThanOrEqualTo=(t,e)=>t.im<=Number(e);static realEquals=(t,e)=>t.re===Number(e);static imagEquals=(t,e)=>t.im===Number(e);static realGreaterThanOrEqualTo=(t,e)=>t.re>=Number(e);static imagGreaterThanOrEqualTo=(t,e)=>t.im>=Number(e);static realGreaterThan=(t,e)=>t.re>Number(e);static imagGreaterThan=(t,e)=>t.im>Number(e);static parse=o.parseFactory(u);static precedence=o.precedenceFactory(u);static unparseValue=o.unparseValueFactory(Math,u);static unparse=o.unparseFactory(u);static toString=o.toStringFactory(u);toString(){return u.toString(this)}static unparseMathMLValue=o.unparseMathMLValueFactory(Math,u);static unparseMathML=o.unparseMathMLFactory(u);static copy=o.copyFactory(u);copy=()=>new u(this.re,this.im,this.type);static toMaxPrecisionValue=t=>{const e=this.settings.precision-this.settings.precisionCompare;return Number(Number(t.toPrecision(e)).toFixed(e))};static toMaxPrecision=o.toMaxPrecisionFactory(u);static epsilonValue(){return Math.max(Math.pow(10,-this.settings.precision+this.settings.precisionCompare),Number.EPSILON)}static epsilon=o.epsilonFactory(u);static random=t=>{if(void 0!==t&&15!==t){if(t<15)return new u(Math.random().toPrecision(t));throw new Error(`invalid number of significant digits: ${t}`)}return new u(Math.random())};static eq=o.equalsFactory(u,!0);static ne=o.equalsFactory(u,!1);static compareValue=(t,e,r)=>{switch(t){case"lt":return e<r;case"lte":return e<=r;case"eq":return e===r;case"gte":return e>=r;case"gt":return e>r}};static cmp=o.cmpFactory(u);static minMaxArrayReal=o.minMaxArrayRealFactory(u);static minMaxArrayRealWithIndex=o.minMaxArrayRealWithIndexFactory(u);static minMaxArrayComplex=o.minMaxArrayComplexFactory(u);static minMaxArrayComplexWithIndex=o.minMaxArrayComplexWithIndexFactory(u);static min=o.minMaxFactory(u,"lt");static minWise=o.minMaxWiseFactory(u,"lt");static max=o.minMaxFactory(u,"gte");static maxWise=o.minMaxWiseFactory(u,"gte");static lt=o.comparisonFactory(u,"lt");static le=o.comparisonFactory(u,"lte");static gt=o.comparisonFactory(u,"gt");static ge=o.comparisonFactory(u,"gte");static false=()=>new u(0,0,u.LOGICAL);static true=()=>new u(1,0,u.LOGICAL);static logical=o.logicalFactory(u);static toLogical=t=>u.logical(t);toLogical=()=>u.logical(this);static and=o.andFactory(u);static or=o.orFactory(u);static xor=o.xorFactory(u);static not=o.notFactory(u);static zero=o.literalFactory(u,0,0);static one=o.literalFactory(u,1,0);static onediv2=o.literalFactory(u,.5,0);static minusonediv2=o.literalFactory(u,-.5,0);static minusone=o.literalFactory(u,-1,0);static pi=o.literalFactory(u,Math.PI,0);static pidiv2=o.literalFactory(u,Math.PI/2,0);static onei=o.literalFactory(u,0,1);static onediv2i=o.literalFactory(u,0,.5);static minusonediv2i=o.literalFactory(u,0,-.5);static minusonei=o.literalFactory(u,0,-1);static two=o.literalFactory(u,2,0);static sqrt2pi=o.literalFactory(u,Math.sqrt(2*Math.PI),0);static e=o.literalFactory(u,Math.E,0);static NaN_0=o.literalFactory(u,NaN,0);static inf_0=o.literalFactory(u,1/0,0);static add=(t,e)=>new u(t.re+e.re,t.im+e.im);static sub=(t,e)=>new u(t.re-e.re,t.im-e.im);static neg=t=>new u(-t.re,-t.im);static mul=o.mulFactory(Math,u);static mulAndSumTo=o.mulAndSumToFactory(Math,u);static rdiv=o.rdivFactory(Math,u);static ldiv=o.ldivFactory(Math,u);static inv=o.invFactory(Math,u);static power=o.powerFactory(Math,u);static root=o.rootFactory(u);static absValue=o.absValueFactory(Math);static abs2Value=o.abs2ValueFactory(Math);static abs=o.absFactory(Math,u);static abs2=o.abs2Factory(Math,u);static hypot=o.hypotFactory(u);static arg=o.argFactory(Math,u);static conj=o.conjFactory(Math,u);static mod=o.modFactory(Math,u);static rem=o.remFactory(Math,u);static fix=o.fixFactory(Math,u);static ceil=o.ceilFactory(Math,u);static floor=o.floorFactory(Math,u);static round=o.roundFactory(Math,u);static sign=o.signFactory(Math,u);static sqrt=o.sqrtFactory(Math,u);static exp=o.expFactory(Math,u);static log=o.logFactory(Math,u);static logb=o.logbFactory(Math,u);static log2=o.log2Factory(u);static log10=o.log10Factory(u);static deg2rad=o.deg2radFactory(Math,u);static rad2deg=o.rad2degFactory(Math,u);static sin=o.sinFactory(Math,u);static sind=o.sindFactory(u);static cos=o.cosFactory(Math,u);static cosd=o.cosdFactory(u);static tan=o.tanFactory(u);static tand=o.tandFactory(u);static csc=o.cscFactory(u);static cscd=o.cscdFactory(u);static sec=o.secFactory(u);static secd=o.secdFactory(u);static cot=o.cotFactory(u);static cotd=o.cotdFactory(u);static asin=o.asinFactory(u);static asind=o.asindFactory(u);static acos=o.acosFactory(u);static acosd=o.acosdFactory(u);static atan=o.atanFactory(u);static atan2=o.atan2Factory(Math,u);static atand=o.atandFactory(u);static acsc=o.acscFactory(u);static acscd=o.acscdFactory(u);static asec=o.asecFactory(u);static asecd=o.asecdFactory(u);static acot=o.acotFactory(u);static acotd=o.acotdFactory(u);static sinh=o.sinhFactory(Math,u);static cosh=o.coshFactory(Math,u);static tanh=o.tanhFactory(u);static csch=o.cschFactory(u);static sech=o.sechFactory(u);static coth=o.cothFactory(u);static asinh=o.asinhFactory(u);static acosh=o.acoshFactory(u);static atanh=o.atanhFactory(u);static acsch=o.acschFactory(u);static asech=o.asechFactory(u);static acoth=o.acothFactory(u);static gamma=o.gammaFactory(u);static factorial=o.factorialFactory(Math,u);static applyFunction=o.applyFunctionFactory(Math);static mapFunction=o.mapFunctionFactory(u);static twoArgFunction=o.twoArgFunctionFactory(u)}e.ComplexNumber=u,u.set(u.defaultSettings),e.default={ComplexNumber:u}},9947(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Configuration=void 0;const s=r(5956),i=r(5142),n=r(845),a=r(7679),o=r(6109),l=r(6115);class c{static roundingName=i.roundingName;static moduloName=i.moduloName;static configuration={blockThreshold:{set:t=>l.BLAS.set({blockThreshold:a.MultiArray.testInteger(c.requireComplex(t),"configure","blockThreshold configuration parameter")}),setDefault:()=>l.BLAS.set({blockThreshold:l.BLAS.defaultSettings.blockThreshold}),get:()=>n.Complex.create(l.BLAS.settings.blockThreshold)},blockSize:{set:t=>l.BLAS.set({blockSize:a.MultiArray.testInteger(c.requireComplex(t),"configure","blockSize configuration parameter")}),setDefault:()=>l.BLAS.set({blockSize:l.BLAS.defaultSettings.blockSize}),get:()=>n.Complex.create(l.BLAS.settings.blockSize)},real:{set:t=>n.Complex.engine=c.requireCharString(t).str,setDefault:()=>n.Complex.engine="decimal",get:()=>new s.CharString(n.Complex.engine)},precision:{set:t=>n.Complex.set({precision:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({precision:n.Complex.defaultSettings.precision}),get:()=>n.Complex.create(n.Complex.settings.precision)},precisionCompare:{set:t=>n.Complex.set({precisionCompare:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({precisionCompare:n.Complex.defaultSettings.precisionCompare}),get:()=>n.Complex.create(n.Complex.settings.precisionCompare)},rounding:{set:t=>{const e=c.requireCharString(t),r=c.roundingName.indexOf(e.str);if(!(r>0))throw new Error(`configure: invalid rounding mode: ${e.str}`);n.Complex.set({rounding:r})},setDefault:()=>n.Complex.set({rounding:n.Complex.defaultSettings.rounding}),get:()=>new s.CharString(c.roundingName[n.Complex.settings.rounding])},toExpPos:{set:t=>n.Complex.set({toExpPos:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({toExpPos:n.Complex.defaultSettings.toExpPos}),get:()=>n.Complex.create(n.Complex.settings.toExpPos)},toExpNeg:{set:t=>n.Complex.set({toExpNeg:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({toExpNeg:n.Complex.defaultSettings.toExpNeg}),get:()=>n.Complex.create(n.Complex.settings.toExpNeg)},minE:{set:t=>n.Complex.set({minE:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({minE:n.Complex.defaultSettings.minE}),get:()=>n.Complex.create(n.Complex.settings.minE)},maxE:{set:t=>n.Complex.set({maxE:n.Complex.realToNumber(c.requireComplex(t))}),setDefault:()=>n.Complex.set({maxE:n.Complex.defaultSettings.maxE}),get:()=>n.Complex.create(n.Complex.settings.maxE)},modulo:{set:t=>{const e=c.requireCharString(t),r=c.moduloName.indexOf(e.str);if(!(r>0))throw new Error(`configure: invalid modulo mode: ${e.str}`);n.Complex.set({modulo:r})},setDefault:()=>n.Complex.set({modulo:n.Complex.defaultSettings.modulo}),get:()=>new s.CharString(c.moduloName[n.Complex.settings.modulo])},crypto:{set:t=>n.Complex.set({crypto:Boolean(n.Complex.realToNumber(c.requireComplex(t)))}),setDefault:()=>n.Complex.set({crypto:n.Complex.defaultSettings.crypto}),get:()=>n.Complex.create(Number(n.Complex.settings.crypto),0,n.Complex.LOGICAL)}};static requireComplex=t=>{if(n.Complex.isInstanceOf(t))return t;throw o.AST.throwInvalidCallError("configure"),new Error("unreachable")};static requireCharString=t=>{if(s.CharString.isInstanceOf(t))return t;throw o.AST.throwInvalidCallError("configure"),new Error("unreachable")};static configurationEntry=t=>c.configuration[t];static configureSignature={inputs:{arity:-2,min:0,max:2,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]},{name:"value",optional:!0}]},outputs:{arity:1}};static configure(...t){const e=(t,e)=>{if(s.CharString.isInstanceOf(t)){const r=c.configurationEntry(t.str);if(!r)throw new ReferenceError(`configure: invalid configuration: '${t.str}'.`);r.set(e)}else o.AST.throwInvalidCallError("configure")};if(0===t.length){for(const t in c.configuration)c.configuration[t].setDefault();return new s.CharString("All configuration set to default values.")}if(1===t.length&&a.MultiArray.isInstanceOf(t[0])){if(2===t[0].dimension[1])return t[0].array.forEach(t=>{e(t[0],t[1])}),new s.CharString(`${t[0].array.length} configuration values set.`);o.AST.throwInvalidCallError("configure")}else{if(2===t.length&&s.CharString.isInstanceOf(t[0]))return e(t[0],t[1]),new s.CharString(`Configuration parameter '${t[0].str}' set to '${c.configuration[t[0].str].get().toString()}'`);o.AST.throwInvalidCallError("configure")}}static getconfigSignature={inputs:{arity:-1,min:0,max:1,parameters:[{name:"configuration",optional:!0,alternatives:[{name:"name",classes:["char","string"]},{name:"configurationList",classes:["cell"]}]}]},outputs:{arity:1}};static getconfig(...t){let e;const r=Object.keys(c.configuration),i=t=>{t.forEach((t,r)=>{const i=c.configuration[t].get();e.array[r]=[new s.CharString(t),i]})};if(0===t.length)return e=new a.MultiArray([r.length,2],null,!0),i(r),e;if(1===t.length){const r=a.MultiArray.linearize(a.MultiArray.scalarToMultiArray(t[0])).map(t=>{if(s.CharString.isInstanceOf(t)&&t.str in c.configuration)return t.str;throw new Error("getconfig: invalid configuration parameter.")});return e=new a.MultiArray([r.length,2],null,!0),i(r),e}o.AST.throwInvalidCallError("getconfig")}static functions={configure:{func:c.configure,signature:c.configureSignature},getconfig:{func:c.getconfig,signature:c.getconfigSignature}}}e.Configuration=c,e.default={Configuration:c}},7162(t,e,r){"use strict";e.ContinueSignal=e.BreakSignal=e.ReturnSignal=e.Context=void 0;const s=r(6109),i=r(5956),n=r(845),a=r(1271),o=r(7679),l=r(5212),c=r(6816),u=r(9770),h=r(9656),d=r(8986),m=r(3226),p=r(5577),f=r(2981),g=r(3812),y=r(3225),x=r(491),C=r(5273),E=r(9217),A=r(6028),_=r(1201),S=r(8146),v=r(1604);class T extends Error{constructor(){super("return"),this.name="ReturnSignal"}}e.ReturnSignal=T;class b extends Error{constructor(){super("break"),this.name="BreakSignal"}}e.BreakSignal=b;class N extends Error{constructor(){super("continue"),this.name="ContinueSignal"}}e.ContinueSignal=N;class I{interpreter;globalScope;builtInFunctionTable;allowForwardReference;globalNameSet;globalInitializedNameSet;forwardReferenceTargetStack;requestedOutputCountStack;requestedOutputMaskStack;commaListExpansionStack;classAccessStack;static bareZeroArgumentBuiltins=new Set(["lastwarn","lasterr","lasterror","localfunctions","mfilename"]);static operatorFunctionNames=new Set(["uplus","uminus","not","transpose","ctranspose","minus","mod","rem","rdivide","mrdivide","ldivide","mldivide","power","mpower","lt","le","ge","gt","eq","ne","plus","times","mtimes","and","or","xor","colon","cat","horzcat","vertcat"]);static classBuiltinMethodFunctionNames=new Set(["size","numel","length","ndims","rows","columns","isempty","isequal","double","char","logical","cell","cellstr","num2cell","cell2mat","cell2struct","mat2cell","isscalar","ismatrix","isvector","isrow","iscolumn","iscell","iscellstr","isstruct","struct","fieldnames","properties","methods","events","enumeration","superclasses","isfield","isprop","ismethod","numfields","getfield","setfield","rmfield","orderfields","struct2cell","ischar","isstring","issparse","full","sparse","spalloc","nnz","nzmax","nonzeros","isnan","isinf","isfinite","isfloat","isinteger","isnumeric","islogical","isreal","isobject","isvalid","find","ind2sub","sub2ind","sort","all","any","sum","prod","sumsq","cumsum","cumprod","min","max","cummin","cummax","mean","var","std","linspace","logspace","meshgrid","ndgrid","zeros","ones","rand","randi","repmat","reshape","squeeze","flip","fliplr","flipud","rot90","permute","ipermute","circshift","shiftdim","norm"]);callStack=[];loadContext(t,e){t?this.globalScope=t:(this.globalScope=f.Scope.create(),this.globalScope.nameTable=Object.create(null),this.globalScope.functionTable=Object.create(null),this.globalScope.undefinedReferenceTable=Object.create(null)),this.globalNameSet=new Set,this.globalInitializedNameSet=new Set,this.callStack=e??[new g.CallFrame(this.globalScope)]}constructor(t,e,r,s=Object.create(null),i=!0,n=new Set,a=new Set,o=[],l=[],c=[],u=[],h=[]){this.interpreter=t,this.globalScope=e,this.builtInFunctionTable=s,this.allowForwardReference=i,this.globalNameSet=n,this.globalInitializedNameSet=a,this.forwardReferenceTargetStack=o,this.requestedOutputCountStack=l,this.requestedOutputMaskStack=c,this.commaListExpansionStack=u,this.classAccessStack=h,this.loadContext(e,r)}static create=(t,e,r)=>new I(t,e,r);nativeNameTable;nativeNameSet;aliasNameTable;aliasNameFunction=t=>t;setAliasNameTable(t){if(t){this.aliasNameTable=Object.create(null);for(const[e,r]of Object.entries(t))this.aliasNameTable[e]=r;this.aliasNameFunction=t=>{for(const[e,r]of Object.entries(this.aliasNameTable))if(r.test(t))return e;return t}}else this.aliasNameFunction=t=>t}get builtInFunctionList(){return Object.keys(this.builtInFunctionTable)}get currentFrame(){return this.callStack[this.callStack.length-1]}get currentScope(){return this.currentFrame.scope}resolveName(t){return this.currentScope.resolveName(t)}resolveSymbol(t,e=this.currentScope,r={}){const s=r.variables??!0,i=r.classes??!0,n=r.loadClasses??!0,a=r.loadFunctions??!0,o=r.functions??!0,l=r.imports??!0,u=this.aliasNameFunction(t),h=r=>{const s=this.aliasNameFunction(r);if(i){const r=this.resolveClassDefinitionByExactName(s,e,!1);if(r)return{kind:"class",name:t,resolvedName:s,source:"import",classDefinition:r}}if(o){const r=e.resolveFunction(s);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:t,resolvedName:s,source:"BUILTIN"===r.type?"builtin":"import",functionDefinition:r};if(a){const r=this.interpreter?.loadFunctionDefinition(s,e);if(r)return{kind:"function",name:t,resolvedName:s,source:"import",functionDefinition:r}}}if(i&&n){const r=this.resolveClassDefinitionByExactName(s,e,!0);if(r)return{kind:"class",name:t,resolvedName:s,source:"import",classDefinition:r}}};if(s){const r=e.resolveName(u);if(r&&void 0!==r.node&&!c.ClassDefinition.isInstanceOf(r.node))return{kind:"variable",name:t,resolvedName:u,source:"local",entry:r}}if(i){const r=this.resolveClassDefinitionByExactName(u,e,!1);if(r)return{kind:"class",name:t,resolvedName:u,source:"local",classDefinition:r}}if(o){const r=e.resolveFunction(u);if(r)return{kind:"BUILTIN"===r.type?"builtin":"function",name:t,resolvedName:u,source:"BUILTIN"===r.type?"builtin":"local",functionDefinition:r};if(a){const r=this.interpreter?.loadFunctionDefinition(u,e);if(r)return{kind:"function",name:t,resolvedName:u,source:"local",functionDefinition:r}}}if(i&&n){const r=this.resolveClassDefinitionByExactName(u,e,!0);if(r)return{kind:"class",name:t,resolvedName:u,source:"local",classDefinition:r}}if(l&&!u.includes(".")){const t=[...new Map(e.importedNameCandidates(u).map(h).filter(t=>void 0!==t).map(t=>[t.resolvedName,t])).values()];if(t.length>1&&this.throwEvalError(`imported name '${u}' is ambiguous: ${t.map(t=>t.resolvedName).join(", ")}.`),1===t.length)return t[0]}if(o){const e=this.builtInFunctionTable[u];if(e)return{kind:"builtin",name:t,resolvedName:u,source:"builtin",functionDefinition:e}}}resolveFunction(t,e=this.currentScope){return this.resolveSymbol(t,e,{variables:!1,classes:!1})?.functionDefinition}resolveClassDefinition(t,e=this.currentScope){return this.resolveSymbol(t,e,{variables:!1,functions:!1})?.classDefinition}resolveClassDefinitionByExactName(t,e=this.currentScope,r=!0){const s=e.resolveName(t);if(s&&c.ClassDefinition.isInstanceOf(s.node))return s.node;if(!r)return;const i=this.interpreter?.loadClassDefinition(t,e);if(!i)return;const n=this.globalScope??e;return this.defineClassDefinition(i,n),i}defineImport(t,e=this.currentScope){const r=t.trim(),s=r.endsWith(".*")?r.slice(0,-2):void 0;r&&(s||r.includes("."))&&""!==s||this.throwSyntaxError("import: imported name must be qualified."),e.defineImport(t)}assignName(t,e){this.currentScope.defineName(t,e)}resolvedIdentifierExpression(t,e,r){const s=(0,S.expressionValue)(t.node,e,"Identifier value",t=>this.throwEvalError(t));return s.parent=r,s}unresolvedCallTargetExpression(t){return s.AST.isNodeIdentifier(t)||this.throwEvalError("invalid unresolved call target."),t}assignFunction(t,e){this.currentScope.defineFunction(t,e)}defineClassDefinition(t,e=this.currentScope){return e.defineName(t.name,t),t}createChildScope(t=this.currentScope){return f.Scope.create(t)}pushForwardReferenceTargets(t){this.forwardReferenceTargetStack.push(t)}popForwardReferenceTargets(){return this.forwardReferenceTargetStack.pop()}pushRequestedOutputCount(t){this.requestedOutputCountStack.push(t)}popRequestedOutputCount(){return this.requestedOutputCountStack.pop()}pushRequestedOutputMask(t){this.requestedOutputMaskStack.push({depth:this.requestedOutputCountStack.length,mask:t.slice()})}popRequestedOutputMask(){return this.requestedOutputMaskStack.pop()?.mask}get requestedOutputCount(){return this.requestedOutputCountStack[this.requestedOutputCountStack.length-1]??1}requestedOutputMask(t=this.requestedOutputCount){const e=this.requestedOutputMaskStack[this.requestedOutputMaskStack.length-1],r=e?.depth===this.requestedOutputCountStack.length?e.mask:void 0;return Array.from({length:t},(t,e)=>r?.[e]??!0)}pushCommaListExpansion(t=!0){this.commaListExpansionStack.push(t)}popCommaListExpansion(){return this.commaListExpansionStack.pop()}get commaListExpansionEnabled(){return this.commaListExpansionStack[this.commaListExpansionStack.length-1]??!1}canAccessClassMember(t,e="public"){if("public"===e)return!0;if("private"===e)return this.classAccessStack.includes(t);if("protected"===e)return this.classAccessStack.some(e=>e===t||e.isSubclassOf(t));const r=e.startsWith("{")&&e.endsWith("}")?e.slice(1,-1).split(","):[e];return r.every(t=>t.startsWith("?"))?r.some(t=>{const e=t.slice(1);return this.classAccessStack.some(t=>t.name===e||t.isSubclassOfName(e))}):this.classAccessStack.includes(t)}currentClassAccessName(){const t=this.classAccessStack[this.classAccessStack.length-1]?.name;if(t)return t;for(let t=this.callStack.length-1;t>=0;t--){const e=this.callStack[t].func?.node?.className;if(e)return e}return""}withClassAccess(t,e){this.classAccessStack.push(t);try{return e()}finally{this.classAccessStack.pop()}}get currentForwardReferenceTargets(){return this.forwardReferenceTargetStack[this.forwardReferenceTargetStack.length-1]??[]}getUndefinedReferenceChain(t,e){const r=[t],s=new Set(r);let i=t;for(;;){const t=this.getNextUndefinedReference(i,e);if(!t)return r;if(r.push(t),s.has(t))return r;s.add(t),i=t}}getNextUndefinedReference(t,e){const r=e.resolveName(t);if(r)return this.findPendingIdentifier(r.node,e,r.undefinedReference)??r.undefinedReference}findPendingIdentifier(t,e,r,i=new WeakSet){if(!t||"object"!=typeof t)return;if(i.has(t))return;i.add(t);const n=t;if(s.AST.isNodeIdentifier(t)){const s=e.resolveName(t.id);if(s?.undefinedReference||!s&&t.id===r)return t.id}for(const t of Object.keys(n)){if("parent"===t||"start"===t||"stop"===t)continue;const s=n[t];if(Array.isArray(s))for(const t of s){const s=this.findPendingIdentifier(t,e,r,i);if(s)return s}else{const t=this.findPendingIdentifier(s,e,r,i);if(t)return t}}}throwIfCircularReference(t,e){const r=this.getUndefinedReferenceChain(t,e),s=r[r.length-1],i=r.slice(0,-1).indexOf(s);i>=0&&this.throwCircularReferenceError(r.slice(i));const n=this.currentForwardReferenceTargets.find(t=>r.includes(t));n&&this.throwCircularReferenceError([...r.slice(0,r.indexOf(n)+1),t])}resolveCallable(t){if(a.FunctionHandle.isInstanceOf(t)){if(t.id){const e=t.closure??this.currentScope,r=this.resolveSymbol(t.id,e,{variables:!1,classes:!1}),s=r?.functionDefinition;if(t.disallowNestedResolution&&"FCNDEF"===s?.type&&s.attributes?.nested&&this.throwReferenceError(`'${t.id}' undefined.`),s)return y.Callables.fromFunctionNode(s);const i=this.interpreter?.resolveStaticMethod(t.id,e);if(i)return y.Callables.staticMethod(i);s||this.throwReferenceError(`'${t.id}' undefined.`)}if(a.FunctionHandle.isAnonymous(t))return y.Callables.lambda(t)}}resolveIdentifier(t,e){const r=t.id,i=this.resolveSymbol(r,e,{classes:!1,functions:!1,imports:!1});if("variable"===i?.kind){const s=i.entry;return this.allowForwardReference&&s.undefinedReference&&(this.throwIfCircularReference(r,e),this.throwUndefinedReferenceError(s.undefinedReference)),this.resolvedIdentifierExpression(s,r,t)}if("nargin"===r&&!s.AST.isNodeIndexExpr(t.parent))return this.currentFunctionArgumentCount(r);if("nargout"===r&&!s.AST.isNodeIndexExpr(t.parent))return this.currentFunctionOutputCount(r);if("meta"===r)return new l.Structure({class:new l.Structure({fromName:a.FunctionHandle.create("__meta_class_fromName")})});const n=this.resolveSymbol(r,e,{variables:!1});switch(n?.kind){case"variable":{const s=n.entry;return this.allowForwardReference&&s.undefinedReference&&(this.throwIfCircularReference(r,e),this.throwUndefinedReferenceError(s.undefinedReference)),this.resolvedIdentifierExpression(s,r,t)}case"class":return n.classDefinition.parent=t,n.classDefinition;case"function":case"builtin":if(s.AST.isNodeIndexExpr(t.parent)){const e=a.FunctionHandle.create(n.resolvedName);return e.parent=t,e}if("builtin"===n.kind&&I.bareZeroArgumentBuiltins.has(r))return this.callCallable(y.Callables.builtin(n.functionDefinition),[],t);s.AST.throwInvalidCallError(r,!0,t=>this.throwSyntaxError(t))}const o=s.AST.isNodeIndexExpr(t.parent)?this.interpreter?.resolveStaticMethod(r,e):void 0;return o?(o.parent=t,o):s.AST.isNodeIndexExpr(t.parent)?this.unresolvedCallTargetExpression(t):void this.throwUndefinedReferenceError(r)}expandCommaSeparatedList(t){if(!s.AST.isNodeReturnList(t)||!t.commaSeparated)return[this.reducedCommaListScalar(t)];const e=t.returnListLength??t.handler(0).length,r=t.handler(e),i=[];for(let s=0;s<e;s++)i.push(t.selector(r,s));return i}reducedCommaListScalar(t){return s.AST.reduceToFirstIfReturnList(t)}evaluateCommaListExpression(t){this.pushRequestedOutputCount(1),this.pushCommaListExpansion();try{return this.expandCommaSeparatedList(this.rawEvaluationResult(t,this.currentScope))}finally{this.popCommaListExpansion(),this.popRequestedOutputCount()}}expandCommaListArguments(t){return t.flatMap(t=>this.expressionValues(this.evaluateCommaListExpression(t),"arg"))}evaluateExpandedArgument(t,e="arg"){return this.expressionValues(this.evaluateCommaListExpression(t),e)}evaluateArgs(t,e,r){return t.flatMap((t,e)=>{if("all"===r)return this.evaluateExpandedArgument(t);const s=r;return s.length>0&&e<s.length&&!s[e]?[t]:this.evaluateExpandedArgument(t)})}evaluateBuiltInArgs(t,e,r){if("feval"===t.id||"builtin"===t.id)return e.length>0?[this.evaluateArgs([e[0]],r,"all")[0],...e.slice(1)]:[];if("set"!==this.aliasNameFunction(t.id))return this.evaluateArgs(e,r,t.ev);const n=[];return e.forEach((e,a)=>{if(a>0&&s.AST.isNodeBinaryOperation(e)&&"="===e.type&&s.AST.isNodeIdentifier(e.left))return n.push(new i.CharString(e.left.id)),void n.push(...this.evaluateArgs([e.right],r,t.ev));n.push(...this.evaluateArgs([e],r,t.ev))}),n}throwEvalError(t){throw new _.EvalError(t,this.getStackTrace())}throwReferenceError(t){throw new _.ReferenceError(t,this.getStackTrace())}throwUndefinedReferenceError(t){throw new _.UndefinedReferenceError(t,this.getStackTrace())}throwCircularReferenceError(t){throw new _.CircularReferenceError(t,this.getStackTrace())}throwSyntaxError(t){throw new _.SyntaxError(t,this.getStackTrace())}getCurrentFunctionDefinition(){return E.FunctionStack.currentFunctionDefinition(this.callStack)}isInsideUserFunction(){return void 0!==this.getCurrentFunctionDefinition()}currentFunctionSourceName(){for(let t=this.callStack.length-1;t>=0;t--){const e=this.callStack[t].func?.node,r=e&&"object"==typeof e&&"sourceName"in e?e.sourceName:void 0;if(r)return"string"==typeof r?r:""}return""}getCurrentFunctionCountFrame(){return E.FunctionStack.currentFunctionCountFrame(this.callStack)}getCallerWorkspace(t=!1,e=!1){return E.FunctionStack.callerWorkspace(this.callStack,this.globalScope,t=>f.Scope.create(t),t,e)}resolveWorkspace(t,e=!1,r=!1){return A.FunctionWorkspace.resolveWorkspace(t,this.globalScope,this.getCallerWorkspace(e,r),t=>this.throwSyntaxError(t))}currentFunctionArgumentCount(t){const e=E.FunctionStack.currentArgumentCount(this.callStack);return void 0===e&&this.throwEvalError(`${t} is only valid inside a function.`),n.Complex.create(e)}currentFunctionArgumentCountOrZero(){return n.Complex.create(E.FunctionStack.currentArgumentCount(this.callStack)??0)}currentFunctionOutputCount(t){const e=E.FunctionStack.currentOutputCount(this.callStack);return void 0===e&&this.throwEvalError(`${t} is only valid inside a function.`),n.Complex.create(e)}currentFunctionOutputCountOrZero(){return n.Complex.create(E.FunctionStack.currentOutputCount(this.callStack)??0)}currentFunctionOutputIsRequested(t){const e=this.getCurrentFunctionCountFrame();e||this.throwEvalError("isargout is only valid inside a function.");const r=t=>{n.Complex.isInstanceOf(t)&&n.Complex.imagIsZero(t)||this.throwEvalError("isargout: argument must be a positive integer.");const r=n.Complex.realToNumber(t);return(!Number.isInteger(r)||r<1)&&this.throwEvalError("isargout: argument must be a positive integer."),r<=e.nargout&&(e.outputMask?.[r-1]??1)?n.Complex.true():n.Complex.false()};if(o.MultiArray.isInstanceOf(t)){const e=new o.MultiArray(t.dimension,void 0,!1);for(let s=0;s<o.MultiArray.linearLength(t);s++){const[i,n]=o.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);e.array[i][n]=r(t.array[i][n])}return o.MultiArray.setType(e),e}return r(t)}currentFunctionInputName(t,e=!0,r){const s=this.getCurrentFunctionCountFrame();return s||this.throwEvalError("inputname is only valid inside a function."),A.FunctionWorkspace.inputName(s.inputArgs,t,t=>this.throwSyntaxError(t),e,r)}currentFunctionName(){return E.FunctionStack.currentFunctionName(this.callStack)}declarePersistent(t,e,r){const s=this.getCurrentFunctionDefinition();s||this.throwSyntaxError("persistent declaration is only valid inside a function."),A.FunctionWorkspace.declarePersistent(t,e,s,r)}loadPersistentVariables(t,e){A.FunctionWorkspace.loadPersistentVariables(t,e)}storePersistentVariables(t,e){A.FunctionWorkspace.storePersistentVariables(t,e)}declareGlobal(t,e,r){const s=r.globalDeclarationTarget??r;A.FunctionWorkspace.declareGlobal(t,e,this.globalNameSet,this.globalScope.nameTable,s.nameTable,this.globalInitializedNameSet)}clearGlobalVariables(t){A.FunctionWorkspace.clearGlobalVariables(this.globalNameSet,this.globalScope,this.callStack.map(t=>t.scope),t)}clearClassDefinitions(){const t=[this.globalScope,...this.callStack.map(t=>t.scope)].filter(t=>void 0!==t);for(const e of t)for(const t of Object.keys(e.nameTable))c.ClassDefinition.isInstanceOf(e.nameTable[t]?.node)&&e.removeName(t)}clearCurrentVariables(t){const e=this.nativeNameSet instanceof Set?this.nativeNameSet:new Set,r=t||Object.keys(this.currentScope.nameTable);for(const t of r){const r=this.currentScope.nameTable[t];e.has(t)||c.ClassDefinition.isInstanceOf(r?.node)||this.currentScope.removeName(t)}}resolveCallSite(t){let e=t;for(;e;){if(e.start)return e;e=e.parent}}static debugIdentifier(t){const e=t?.id;return"string"==typeof e?e:void 0}builtInInputSignatures(t){return x.FunctionSignature.inputSignatures(t)}builtInOutputSignatures(t){return x.FunctionSignature.outputSignatures(t)}builtInDeclaredArity(t){return x.FunctionSignature.declaredArity(t)}validateBuiltInInputArity(t,e){s.AST.throwInvalidCallError(t.id,!x.FunctionSignature.inputArityIsValid(t,e),t=>this.throwSyntaxError(t))}validateBuiltInInputParameters(t,e){s.AST.throwInvalidCallError(t.id,!x.FunctionSignature.inputParametersAreValid(t,e),t=>this.throwSyntaxError(t))}valueDimensions(t){return v.RuntimeValue.dimensions(t)}sizeReturnList(t){const e=this.valueDimensions(t),r=this.requestedOutputMask(Math.max(this.requestedOutputCount,e.length)),i=t=>r[t]??!0;return s.AST.nodeReturnList((t,e)=>{const r=t[`dim${e}`];return void 0===r&&s.AST.throwErrorIfGreaterThanReturnList(t.length,e+1,t=>this.throwEvalError(t)),r},t=>{const r=e.slice();o.MultiArray.appendSingletonTail(r,Math.max(t,2));const s={length:t};for(let e=0;e<t;e++){if(!i(e))continue;const a=e===t-1?r.slice(e).reduce((t,e)=>t*e,1):r[e];s[`dim${e}`]=n.Complex.create(a)}return s})}callClassBuiltinMethod(t,e,r){const i=this.aliasNameFunction(t.id);if(s.AST.isNodeIdentifier(r)&&"builtin"===r.id)return;if(!I.classBuiltinMethodFunctionNames.has(i)||0===e.length)return;const n=e[0];if(!u.ClassInstance.isInstanceOf(n))return;const a=n.classDefinition.findMethod(i,t=>!t.isStatic);if(!a)return;this.canAccessClassMember(a.classDefinition,a.access)||this.throwEvalError(`method '${i}' has ${a.access} access for class ${n.classDefinition.name}.`);const o=e.slice(1).map((t,e)=>(0,S.expressionValue)(t,`argument ${e+2}`,"Argument value",t=>this.throwEvalError(t)));return this.callClassInstanceMethod(n,a,o,r)}callFunctionDefinition(t,e,r,s){const i=t.node,{inputLayout:n,returnLayout:a,callArguments:o,inputDefaults:l}=C.FunctionCall.prepareFunctionCall(i,e,s,{nameValueParameters:t=>this.interpreter.getFunctionNameValueParameters(t),splitCallArguments:(t,e)=>this.interpreter.splitFunctionCallNameValueArguments(t,e),expandPositionalArguments:t=>this.expandCommaListArguments(t),inputDefaults:t=>this.interpreter.getFunctionInputArgumentDefaults(t),outputRepeatingName:t=>this.interpreter.getFunctionOutputRepeatingName(t),throwEvalError:t=>this.throwEvalError(t)}),c=f.Scope.create(i.definingScope??this.currentScope);c.assignExistingParentNames=Boolean(i.attributes?.nested),this.interpreter.configureFunctionWorkspace(i,c),C.FunctionCall.initializeFixedReturnSlots(a.returnNames,c.nameTable);const u=t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},h=C.FunctionCall.evaluateCallArguments(o.positional,r,u,t=>this.throwEvalError(t),0,!0),d=C.FunctionCall.evaluateNameValueArguments(o.named,r,u,t=>this.throwEvalError(t));C.FunctionCall.bindPositionalInputs(i,n,h,l,(t,e)=>c.defineName(t,e),(t,e)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,c,"default argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.interpreter.bindFunctionNameValueArguments(i,c,d),C.FunctionCall.bindVarargin(n,h,(t,e)=>c.defineName(t,e)),C.FunctionCall.bindVarargout(a,s,(t,e)=>c.defineName(t,e));const m=o.positional.length+e.length-(o.rawPositionalCount??o.positional.length);let p;this.pushCallStackFrame(new g.CallFrame(c,t,this.resolveCallSite(r),i.id,m,s,e,void 0,this.requestedOutputMask(s))),this.loadPersistentVariables(i,c);try{this.interpreter.applyScopedImports(i.statements,c),this.interpreter.registerNestedFunctions(i,c),this.interpreter.validateFunctionInputArguments(i,c),this.interpreter.validateFunctionRepeatingArguments(i,c,C.FunctionCall.expressionArgumentValues(h.slice(n.positionalParamCount),"repeating argument",t=>this.throwEvalError(t)));try{i.statements.list.length>0&&this.evaluatedExecutionResult(i.statements,c)}catch(t){if(!(t instanceof T))throw t}const t=this.requestedOutputMask(s);this.interpreter.validateFunctionOutputArguments(i,c,s,t),p=C.FunctionCall.createReturnList(a,c.nameTable,t=>this.throwEvalError(t),t)}finally{this.storePersistentVariables(i,c),this.popCallStackFrame()}return p}instantiateClassDefaults(t){const e=u.ClassInstance.instantiate(t,t=>{this.pushRequestedOutputCount(1);try{return this.runtimeExpressionValue(this.evaluatedExecutionResult(t,this.currentScope),"property default")}finally{this.popRequestedOutputCount()}});return this.interpreter.validateClassInstancePropertyDefaults(e,this.currentScope),e}constructClassInstance(t,e,r){if(t.isEffectivelyAbstract()){const e=[...t.unresolvedAbstractMethods().map(t=>t.name),...t.unresolvedAbstractProperties().map(t=>t.name)];this.throwEvalError(e.length>0?`cannot instantiate abstract class ${t.name}: missing implementations for ${e.join(", ")}.`:`cannot instantiate abstract class ${t.name}.`)}const s=this.instantiateClassDefaults(t);return this.constructClassInstanceWithInstance(t,s,e,r)}constructSuperclassInstance(t,e,r,s){return t.classDefinition.isSubclassOf(e)||this.throwEvalError(`class ${e.name} is not a superclass of class ${t.classDefinition.name}.`),this.constructClassInstanceWithInstance(e,t,r,s)}constructClassInstanceWithInstance(t,e,r,s){const i=t.findConstructor();if(!i)return r.length>0&&this.throwEvalError(`constructor for class ${t.name} accepts no input arguments.`),e;this.ensureConcreteClassMethod(i);const n=i.node,{inputLayout:a,returnLayout:o,callArguments:l,inputDefaults:c}=C.FunctionCall.prepareFunctionCall(n,r,1,{nameValueParameters:t=>this.interpreter.getFunctionNameValueParameters(t),splitCallArguments:(t,e)=>this.interpreter.splitFunctionCallNameValueArguments(t,e),expandPositionalArguments:t=>this.expandCommaListArguments(t),inputDefaults:t=>this.interpreter.getFunctionInputArgumentDefaults(t),outputRepeatingName:t=>this.interpreter.getFunctionOutputRepeatingName(t),throwEvalError:t=>this.throwEvalError(t)}),h=f.Scope.create(n.definingScope??this.currentScope);this.interpreter.configureFunctionWorkspace(n,h),C.FunctionCall.initializeFixedReturnSlots(o.returnNames,h.nameTable);const d=o.returnNames[0];d&&"<~>"!==d.type&&h.defineName(d.id,e);const m=t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},p=C.FunctionCall.evaluateCallArguments(l.positional,s,m,t=>this.throwEvalError(t),0,!0),x=C.FunctionCall.evaluateNameValueArguments(l.named,s,m,t=>this.throwEvalError(t));C.FunctionCall.bindPositionalInputs(n,a,p,c,(t,e)=>h.defineName(t,e),(t,e)=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(e,h,"default argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.interpreter.bindFunctionNameValueArguments(n,h,x),C.FunctionCall.bindVarargin(a,p,(t,e)=>h.defineName(t,e)),C.FunctionCall.bindVarargout(o,1,(t,e)=>h.defineName(t,e));const E=y.Callables.fromFunctionNode(n),A=l.positional.length+r.length-(l.rawPositionalCount??l.positional.length);this.pushCallStackFrame(new g.CallFrame(h,E,this.resolveCallSite(s),n.id,A,1,r)),this.loadPersistentVariables(n,h),this.classAccessStack.push(t);try{this.interpreter.applyScopedImports(n.statements,h),this.interpreter.registerNestedFunctions(n,h),this.interpreter.validateFunctionInputArguments(n,h),this.interpreter.validateFunctionRepeatingArguments(n,h,C.FunctionCall.expressionArgumentValues(p.slice(a.positionalParamCount),"repeating argument",t=>this.throwEvalError(t)));try{n.statements.list.length>0&&this.evaluatedExecutionResult(n.statements,h)}catch(t){if(!(t instanceof T))throw t}this.interpreter.validateFunctionOutputArguments(n,h,1)}finally{this.classAccessStack.pop(),this.storePersistentVariables(n,h),this.popCallStackFrame()}if(!d||"<~>"===d.type)return e;const _=h.nameTable[d.id]?.node;return u.ClassInstance.isInstanceOf(_)&&(_.classDefinition===t||_.classDefinition.isSubclassOf(t))||this.throwEvalError(`constructor for class ${t.name} must return an object of class ${t.name}.`),_}callClassInstanceMethod(t,e,r,s){e.isAbstract&&this.throwEvalError(`cannot call abstract method '${e.name}' for class ${e.classDefinition.name}.`),this.ensureConcreteClassMethod(e);try{u.ClassInstance.throwIfDeleted(t)}catch(t){this.throwEvalError(t.message)}return this.withClassAccess(e.classDefinition,()=>this.callFunctionDefinition(y.Callables.functionDefinition(e.node),[this.classMethodReceiverArgument(t),...r],s,this.requestedOutputCount))}classMethodReceiverArgument(t){return(0,S.expressionValue)(u.ClassInstance.methodArgument(t),"obj","Argument value",t=>this.throwEvalError(t))}callClassStaticMethod(t,e,r){return t.isAbstract&&this.throwEvalError(`cannot call abstract method '${t.name}' for class ${t.classDefinition.name}.`),this.ensureConcreteClassMethod(t),this.withClassAccess(t.classDefinition,()=>this.callFunctionDefinition(y.Callables.functionDefinition(t.node),e,r,this.requestedOutputCount))}ensureConcreteClassMethod(t){if(!t.node.attributes?.prototype)return;const e=this.interpreter?.loadClassMethodDefinition(t.classDefinition.name,t.name,this.currentScope);e||this.throwEvalError(`method '${t.name}' for class ${t.classDefinition.name} is declared without a body.`),this.validateLoadedClassMethodSignature(t,e),t.node=e}validateLoadedClassMethodSignature(t,e){e.parameter.list.length===t.node.parameter.list.length&&e.return.list.length===t.node.return.list.length||this.throwEvalError(`method '${t.name}' for class ${t.classDefinition.name} external definition does not match its classdef prototype.`)}callClassEmptyMethod(t,e,r){const s=this.evaluateArgs(e,r,"all"),i=(0===s.length?[n.Complex.zero(),n.Complex.zero()]:1===s.length&&o.MultiArray.isInstanceOf(s[0])?o.MultiArray.linearize(s[0]):s).map(e=>(n.Complex.isInstanceOf(e)&&n.Complex.imagEquals(e,0)&&n.Complex.realIsInteger(e)&&!n.Complex.realLessThan(e,0)||this.throwEvalError(`${t.classDefinition.name}.empty dimensions must be nonnegative integer scalars.`),n.Complex.realToNumber(e)));return 0===i.length&&this.throwEvalError(`${t.classDefinition.name}.empty requires at least one dimension.`),i.some(t=>0===t)||this.throwEvalError(`${t.classDefinition.name}.empty requires at least one zero dimension.`),new o.MultiArray(i)}expressionValues(t,e){return(0,S.expressionValues)(t,e,"Argument value",t=>this.throwEvalError(t))}expressionValue(t,e){return(0,S.expressionValue)(t,e,"Argument value",t=>this.throwEvalError(t))}runtimeExpressionValue(t,e){return(0,S.runtimeExpressionValue)(t,e,"Argument value",t=>this.throwEvalError(t))}evaluatedExecutionResult(t,e=this.currentScope){return s.AST.reduceToFirstIfReturnList(this.rawEvaluationResult(t,e))}rawEvaluationResult(t,e=this.currentScope){return this.interpreter.Evaluator(t,e)}evaluatedExpressionValue(t,e,r){return this.expressionValue(this.evaluatedExecutionResult(t,e),r)}returnExpression(t,e){return(0,S.expressionValue)(t,e,"Return value",t=>this.throwEvalError(t))}returnExpressions(t,e){return(0,S.expressionValues)(t,e,"Return value",t=>this.throwEvalError(t))}scalarArrayReturnExpression(t,e){return this.returnExpression(o.MultiArray.MultiArrayToScalar(t),e)}allVoidArrayResults(t){return o.MultiArray.linearize(t).every(t=>s.AST.isNodeBase(t)&&"VOID"===t.type)}reducedClassMethodResult(t,e,r,i){this.pushRequestedOutputCount(1);try{return s.AST.reduceToFirstIfReturnList(this.callClassInstanceMethod(t,e,r,i))}finally{this.popRequestedOutputCount()}}classInstanceArrayElement(t,e,r,s){const i=t.array[e][r];return u.ClassInstance.isInstanceOf(i)||this.throwUndefinedReferenceError(s),i}callClassBoundMethodArray(t,e,r){const i=o.MultiArray.linearize(t);if(i.length>0&&i.every(t=>h.ClassBoundMethod.isInstanceOf(t)&&"delete"===t.method.name)){for(const t of i)h.ClassBoundMethod.isInstanceOf(t)||this.throwEvalError("internal error: bound method array contains a non-method value."),this.deleteClassInstance(t.instance,r);return s.AST.nodeVoid()}const n=new o.MultiArray(t.dimension);for(let s=0;s<o.MultiArray.linearLength(t);s++){const[i,a]=o.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),l=t.array[i][a];h.ClassBoundMethod.isInstanceOf(l)||this.throwEvalError("internal error: bound method array contains a non-method value."),n.array[i][a]=this.reducedClassMethodResult(l.instance,l.method,e,r)}if(o.MultiArray.setType(n),this.allVoidArrayResults(n))return s.AST.nodeVoid();if(this.requestedOutputCount>1){const t=o.MultiArray.linearize(n);return this.valueReturnList(t)}return this.scalarArrayReturnExpression(n,"ans")}callClassBoundMethodValue(t,e,r){return h.ClassBoundMethod.isInstanceOf(t)?this.callClassInstanceMethod(t.instance,t.method,e,r):this.callClassBoundMethodArray(t,e,r)}callFunctionalClassMethodArray(t,e,r,i){if(0!==o.MultiArray.linearLength(e)&&o.MultiArray.linearize(e).every(t=>u.ClassInstance.isInstanceOf(t))||this.throwUndefinedReferenceError(t),"delete"===t){for(let r=0;r<o.MultiArray.linearLength(e);r++){const[s,n]=o.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r);this.deleteClassInstance(this.classInstanceArrayElement(e,s,n,t),i)}return s.AST.nodeVoid()}const n=new o.MultiArray(e.dimension);for(let s=0;s<o.MultiArray.linearLength(e);s++){const[a,l]=o.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],s),c=this.classInstanceArrayElement(e,a,l,t),u=c.classDefinition.findMethod(t,t=>!t.isStatic);u||this.throwEvalError(`unknown method '${t}' for class ${c.classDefinition.name}.`),this.canAccessClassMember(u.classDefinition,u.access)||this.throwEvalError(`method '${t}' has ${u.access} access for class ${c.classDefinition.name}.`),n.array[a][l]=this.reducedClassMethodResult(c,u,r,i)}if(o.MultiArray.setType(n),this.allVoidArrayResults(n))return s.AST.nodeVoid();if(this.requestedOutputCount>1){const t=o.MultiArray.linearize(n);return this.valueReturnList(t)}return this.scalarArrayReturnExpression(n,"ans")}deleteClassInstance(t,e){t.classDefinition.isHandleClass()||this.throwEvalError("delete is only supported for handle class instances.");try{u.ClassInstance.throwIfDeleted(t)}catch(t){this.throwEvalError(t.message)}const r=t.classDefinition.findMethod("delete",t=>!t.isStatic);return r&&this.callClassInstanceMethod(t,r,[],e),u.ClassInstance.delete(t),s.AST.nodeVoid()}evaluateFunctionalClassMethodReceiver(t,e){if(0===t.length)return;const r=t[0];if(!this.interpreter)return r;let i;s.AST.isNodeBase(r)&&(r.parent=e,r.index=0),this.pushRequestedOutputCount(1);try{i=this.evaluatedExpressionValue(r,this.currentScope,"method receiver")}finally{this.popRequestedOutputCount()}return i}isFunctionalClassMethodReceiver(t){return u.ClassInstance.isInstanceOf(t)||p.ClassEventListener.isInstanceOf(t)||o.MultiArray.isInstanceOf(t)&&o.MultiArray.linearLength(t)>0&&o.MultiArray.linearize(t).every(t=>u.ClassInstance.isInstanceOf(t)||p.ClassEventListener.isInstanceOf(t))}callFunctionalClassMethod(t,e,r,i=this.evaluateFunctionalClassMethodReceiver(e,r)){if(i||this.throwUndefinedReferenceError(t),"delete"===t&&p.ClassEventListener.isInstanceOf(i))return p.ClassEventListener.delete(i),s.AST.nodeVoid();if("delete"===t&&o.MultiArray.isInstanceOf(i)&&o.MultiArray.linearLength(i)>0&&o.MultiArray.linearize(i).every(p.ClassEventListener.isInstanceOf)){for(const t of o.MultiArray.linearize(i))p.ClassEventListener.isInstanceOf(t)||this.throwEvalError("internal error: event listener array contains a non-listener value."),p.ClassEventListener.delete(t);return s.AST.nodeVoid()}if(o.MultiArray.isInstanceOf(i)&&o.MultiArray.linearLength(i)>0&&o.MultiArray.linearize(i).every(t=>u.ClassInstance.isInstanceOf(t)))return this.callFunctionalClassMethodArray(t,i,e.slice(1),r);if(u.ClassInstance.isInstanceOf(i)||this.throwUndefinedReferenceError(t),"delete"===t)return this.deleteClassInstance(i,r);const n=i.classDefinition.findMethod(t,t=>!t.isStatic);return n||this.throwEvalError(`unknown method '${t}' for class ${i.classDefinition.name}.`),this.canAccessClassMember(n.classDefinition,n.access)||this.throwEvalError(`method '${t}' has ${n.access} access for class ${i.classDefinition.name}.`),this.callClassInstanceMethod(i,n,e.slice(1),r)}callCallable(t,e,r){const s=this.requestedOutputCount;switch(t.type){case"BUILTIN":{const i=t.node,n=this.aliasNameFunction(i.id),a=this.callCallableFunctionalOperatorOverload(i,e,r);if(a)return a;const l=this.evaluateBuiltInArgs(i,e,r);this.validateBuiltInInputArity(i,l.length),this.pushCallStackFrame(new g.CallFrame(this.currentScope,t,this.resolveCallSite(r),i.id,l.length,s,e));try{const t=this.callClassBuiltinMethod(i,l,r);return void 0!==t?t:(this.validateBuiltInInputParameters(i,l),i.mapper&&1!==l.length&&this.throwEvalError(`Invalid call to ${n}.`),"size"===n&&1===l.length&&s>1?this.sizeReturnList(l[0]):i.mapper&&1===l.length&&o.MultiArray.isInstanceOf(l[0])?o.MultiArray.rawMap(l[0],i.func):i.func(...l))}finally{this.popCallStackFrame()}}case"LAMBDA":{const i=t.node,n=i.parameter,{hasVarargin:o,fixedParamCount:l}=C.FunctionCall.lambdaInputLayout(n),c=this.expandCommaListArguments(e);C.FunctionCall.validateLambdaInputArity(c.length,o,l,t=>this.throwEvalError(t));const u=f.Scope.create(i.closure??this.currentScope);this.configureAnonymousFunctionWorkspace(i,u),C.FunctionCall.bindLambdaInputs(n,c,r,o,l,(t,e)=>u.defineName(t,e),t=>{this.pushRequestedOutputCount(1);try{return this.evaluatedExpressionValue(t,this.currentScope,"argument")}finally{this.popRequestedOutputCount()}},t=>this.throwEvalError(t)),this.pushCallStackFrame(new g.CallFrame(u,t,this.resolveCallSite(r),a.FunctionHandle.toString(i),c.length,s,e,void 0,this.requestedOutputMask(s)));try{return this.rawEvaluationResult(i.expression,u)}finally{this.popCallStackFrame()}}case"FCNDEF":return this.callFunctionDefinition(t,e,r,s);case"STATIC_METHOD":return this.callClassStaticMethod(t.node.method,e,r);default:throw new Error("Invalid callable.")}}configureAnonymousFunctionWorkspace(t,e){const r=new Set;for(const e of t.parameter)s.AST.isNodeIdentifier(e)&&r.add(e.id);this.collectAnonymousExpressionNames(t.expression,r),e.allowStaticWorkspaceNames(r)}collectAnonymousExpressionNames(t,e,r=new WeakSet){if(!t||"object"!=typeof t||r.has(t))return;r.add(t),s.AST.isNodeIdentifier(t)&&e.add(t.id);const i=t;for(const[t,s]of Object.entries(i))if("parent"!==t&&"start"!==t&&"stop"!==t)if(Array.isArray(s))for(const t of s)this.collectAnonymousExpressionNames(t,e,r);else this.collectAnonymousExpressionNames(s,e,r)}valueReturnList(t){const e=this.requestedOutputMask(t.length),r=t=>e[t]??!0;return s.AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&s.AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.throwEvalError(t)),r},e=>{s.AST.throwErrorIfGreaterThanReturnList(t.length,e,t=>this.throwEvalError(t));const i={length:e};for(let s=0;s<e;s++)r(s)&&(i[`out${s}`]=this.returnExpression(t[s],`out${s+1}`));return i})}callFunctionalOperatorOverload(t,e,r){if("()"===e.delim&&"callable"===t.kind&&y.Callables.isBuiltin(t.callable)&&I.operatorFunctionNames.has(t.callable.node.id))return this.interpreter?.callFunctionalOperatorOverload(t.callable.node,r,e)}callCallableFunctionalOperatorOverload(t,e,r){if((!s.AST.isNodeIdentifier(r)||"builtin"!==r.id)&&I.operatorFunctionNames.has(t.id))return this.interpreter?.callFunctionalOperatorOverload(t,e,r)}resolveCallDispatch(t,e,r=[]){const i=this.resolveCallable(t);if(!i&&a.FunctionHandle.isInstanceOf(t))throw new Error("Unexpected non-callable FunctionHandle.");if(i)return{kind:"callable",callable:i,expr:t};if(h.ClassBoundMethod.isInstanceOf(t))return{kind:"bound-method",expr:t};if(o.MultiArray.isInstanceOf(t)&&o.MultiArray.linearLength(t)>0&&o.MultiArray.linearize(t).every(t=>h.ClassBoundMethod.isInstanceOf(t)))return{kind:"bound-method-array",expr:t};if(d.ClassStaticMethod.isInstanceOf(t))return{kind:"static-method",expr:t};if(m.ClassEmptyMethod.isInstanceOf(t))return{kind:"empty-method",expr:t};if(c.ClassDefinition.isInstanceOf(t))return{kind:"constructor",expr:t};if(s.AST.isNodeIdentifier(t)&&"()"===e.delim){const s=this.evaluateFunctionalClassMethodReceiver(r,e);return this.isFunctionalClassMethodReceiver(s)?{kind:"functional-class-method",expr:t,functionalName:t.id,functionalReceiver:s}:{kind:"undefined-function",expr:t,functionalName:t.id}}return{kind:"indexing",expr:t}}applyCallDispatch(t,e,r){switch(t.kind){case"callable":return this.callCallable(t.callable,e,r);case"bound-method":return this.callClassInstanceMethod(t.expr.instance,t.expr.method,e,r);case"bound-method-array":return this.callClassBoundMethodArray(t.expr,e,r);case"static-method":return this.callClassStaticMethod(t.expr.method,e,r);case"empty-method":return this.callClassEmptyMethod(t.expr,e,r);case"constructor":return this.constructClassInstance(t.expr,e,r);case"functional-class-method":return this.callFunctionalClassMethod(t.functionalName,e,r,t.functionalReceiver);case"undefined-function":this.throwUndefinedReferenceError(t.functionalName);case"indexing":return}}applyNativeIndexing(t,e,r){const s=()=>{const t=this.evaluateArgs(e,r,"all").map(t=>this.interpreter?.convertIndexArgument(t,r)??t);return o.MultiArray.indexArguments(t)};if(i.CharString.isInstanceOf(t)){"{}"===r.delim&&this.throwEvalError("matrix cannot be indexed with {");const e=o.MultiArray.characterVectorFromCharString(t),i=s(),n=o.MultiArray.getElements(e,r.expr.id,[],i);return n.parent=r,o.MultiArray.charStringFromCharacterVectorResult(n,t.quote)}"{}"!==r.delim||o.MultiArray.isInstanceOf(t)&&t.isCell||this.throwEvalError("matrix cannot be indexed with {");const n=o.MultiArray.scalarOrCellToMultiArray(t),a=s(),l=o.MultiArray.getElements(n,r.expr.id,[],a);if(l.parent=r,n.isCell&&"()"===r.delim)return o.MultiArray.isInstanceOf(l)||this.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),l.isCell=!0,l;if(n.isCell&&"{}"===r.delim&&(this.requestedOutputCount>1||this.commaListExpansionEnabled)){const t=o.MultiArray.linearize(l);if(t.length>1)return this.valueReturnList(this.returnExpressions(t,"out"))}return o.MultiArray.MultiArrayToScalar(l)}apply(t,e,r){this.interpreter.debug&&console.log("[APPLY]",{exprType:t?.type,isFunctionHandle:a.FunctionHandle.isInstanceOf(t),exprId:I.debugIdentifier(t),delim:r.delim,argsCount:e.length});const s=this.resolveCallDispatch(t,r,e),i=this.callFunctionalOperatorOverload(s,r,e);if(i)return i;this.interpreter.debug&&console.log("[DISPATCH]",s.kind,"callable"===s.kind?s.callable.type:"");return this.applyCallDispatch(s,e,r)||(this.interpreter.debug&&console.warn("[FALLBACK → INDEX]",{exprType:t?.type,exprId:I.debugIdentifier(t)}),this.applyNativeIndexing(t,e,r))}defineBuiltInFunction(t,e,r=!1,s=[],i){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:r,ev:s,func:e,definingScope:this.globalScope,signature:i}}assignBuiltInFunctionTable(t){t&&Object.assign(this.builtInFunctionTable,t)}defineUnaryOperatorFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(...r)=>{if(1===r.length)return e(r[0]);this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:1},outputs:{arity:1}}}}defineBinaryOperatorFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(r,...s)=>{if(1===s.length)return e(r,s[0]);this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:2},outputs:{arity:1}}}}defineLeftAssociativeMultipleOperationFunction(t,e){this.builtInFunctionTable[t]={type:"BUILTIN",id:t,mapper:!1,ev:[],func:(r,...s)=>{if(1===s.length)return e(r,s[0]);if(s.length>1){let t=e(r,s[0]);for(let r=1;r<s.length;r++)t=e(t,s[r]);return t}this.throwEvalError(`Invalid call to ${t}. Type 'help ${t}' to see correct usage.`)},definingScope:this.globalScope,signature:{inputs:{arity:-2},outputs:{arity:1}}}}pushCallStackFrame(t){const e=this.currentFrame;t.parentFrame=e,this.callStack.push(t)}popCallStackFrame(){return this.callStack.pop()}getStackTrace(){return this.callStack.filter(t=>void 0!==t.func).slice().reverse()}}e.Context=I},3717(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CoreFunctions=void 0;const s=r(5956),i=r(845),n=r(7679),a=r(5212),o=r(6816),l=r(9770),c=r(7325),u=r(5577),h=r(7268),d=r(6109),m=r(9170),p=r(8146),f=r(7673),g=r(1604),y=r(227);class x{static throwErrorIfCellArray=(t,e)=>{if(n.MultiArray.isInstanceOf(e)&&e.isCell)throw new Error(`${t}: wrong type argument 'cell'`)};static classInstancesIn=t=>n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).filter(l.ClassInstance.isInstanceOf);static validateObjectArrayConcatenation=(t,e)=>{let r;for(const s of e.flatMap(t=>x.classInstancesIn(t)))if(r){if(s.classDefinition!==r)throw new Error(`${t}: object arrays must contain objects of the same class.`)}else r=s.classDefinition};static isemptySignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isempty=(t,...e)=>(d.AST.throwInvalidCallError("isempty",!(void 0!==t&&0===e.length)),g.RuntimeValue.isEmpty(t)?i.Complex.true():i.Complex.false());static isscalarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isscalar=(t,...e)=>(d.AST.throwInvalidCallError("isscalar",!(void 0!==t&&0===e.length)),g.RuntimeValue.isScalar(t)?i.Complex.true():i.Complex.false());static ismatrixSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ismatrix=(t,...e)=>(d.AST.throwInvalidCallError("ismatrix",!(void 0!==t&&0===e.length)),g.RuntimeValue.isMatrix(t)?i.Complex.true():i.Complex.false());static isvectorSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isvector=(t,...e)=>(d.AST.throwInvalidCallError("isvector",!(void 0!==t&&0===e.length)),g.RuntimeValue.isVector(t)?i.Complex.true():i.Complex.false());static iscellSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscell=(t,...e)=>(d.AST.throwInvalidCallError("iscell",!(void 0!==t&&0===e.length)),n.MultiArray.isCellArray(t)?i.Complex.true():i.Complex.false());static issparseSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static issparse=(t,...e)=>(d.AST.throwInvalidCallError("issparse",!(void 0!==t&&0===e.length)),i.Complex.false());static fullSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static full=(t,...e)=>(d.AST.throwInvalidCallError("full",!(void 0!==t&&0===e.length)),g.RuntimeValue.copy(t));static isNonzeroElement=t=>i.Complex.isInstanceOf(t)?0!==i.Complex.realToNumber(t)||0!==i.Complex.imagToNumber(t):s.CharString.isInstanceOf(t)?t.str.length>0&&t.str.split("").some(t=>0!==t.charCodeAt(0)):n.MultiArray.isInstanceOf(t)?n.MultiArray.linearize(t).some(x.isNonzeroElement):null!=t;static nnzSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nnz=(t,...e)=>(d.AST.throwInvalidCallError("nnz",!(void 0!==t&&0===e.length)),i.Complex.create(n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).filter(x.isNonzeroElement).length));static nzmaxSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nzmax=(t,...e)=>(d.AST.throwInvalidCallError("nzmax",!(void 0!==t&&0===e.length)),x.nnz(t));static nonzerosSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static nonzeros=(t,...e)=>(d.AST.throwInvalidCallError("nonzeros",!(void 0!==t&&0===e.length)),n.MultiArray.MultiArrayToScalar(n.MultiArray.toColumnVector(n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).filter(x.isNonzeroElement).map(g.RuntimeValue.copy))));static sparseDimension=(t,e,r)=>{const s=n.MultiArray.MultiArrayToScalar(t);if(!i.Complex.isInstanceOf(s)||!i.Complex.imagIsZero(s)||!i.Complex.realIsInteger(s)||i.Complex.realToNumber(s)<0)throw new Error(`${e}: argument ${r} must be a nonnegative integer scalar.`);return i.Complex.realToNumber(s)};static sparseTripletValues=(t,e,r,s)=>{const i=n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t));if(i.length===e)return i.map(g.RuntimeValue.copy);if(1===i.length)return new Array(e).fill(void 0).map(()=>g.RuntimeValue.copy(i[0]));throw new Error(`${r}: argument ${s} must be scalar or match the sparse triplet count.`)};static sparseSubscripts=(t,e,r,s)=>x.sparseTripletValues(t,e,r,s).map(t=>{if(!i.Complex.isInstanceOf(t)||!i.Complex.imagIsZero(t)||!i.Complex.realIsInteger(t)||i.Complex.realToNumber(t)<1)throw new Error(`${r}: argument ${s} must contain positive integer subscripts.`);return i.Complex.realToNumber(t)});static sparseSignature={inputs:{arity:-6,min:1,max:6,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static sparse=(...t)=>{if(d.AST.throwInvalidCallError("sparse",t.length<1||t.length>6),1===t.length)return g.RuntimeValue.copy(t[0]);if(2===t.length)return new n.MultiArray([x.sparseDimension(t[0],"sparse",1),x.sparseDimension(t[1],"sparse",2)],i.Complex.zero());const e=Math.max(...t.slice(0,3).map(t=>n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).length)),r=x.sparseSubscripts(t[0],e,"sparse",1),a=x.sparseSubscripts(t[1],e,"sparse",2),o=x.sparseTripletValues(t[2],e,"sparse",3),l=t.length>=5?x.sparseDimension(t[3],"sparse",4):r.reduce((t,e)=>Math.max(t,e),0),c=t.length>=5?x.sparseDimension(t[4],"sparse",5):a.reduce((t,e)=>Math.max(t,e),0);if(6===t.length&&s.CharString.isInstanceOf(t[5])&&!["sum","unique"].includes(t[5].str))throw new Error("sparse: option must be 'sum' or 'unique'.");const u=6===t.length&&s.CharString.isInstanceOf(t[5])&&"unique"===t[5].str,h=new n.MultiArray([l,c],i.Complex.zero());for(let t=0;t<e;t++){if(r[t]>l||a[t]>c)throw new Error("sparse: subscript indices out of range.");const e=r[t]-1,s=a[t]-1,n=o[t],d=h.array[e][s];h.array[e][s]=!u&&i.Complex.isInstanceOf(d)&&i.Complex.isInstanceOf(n)?i.Complex.add(d,n):g.RuntimeValue.copy(n)}return n.MultiArray.setType(h),n.MultiArray.MultiArrayToScalar(h)};static spallocSignature={inputs:[{arity:3,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:4,parameters:[{name:"m",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"n",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"nz",validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"typename",classes:["char","string"],allowedStrings:["double","single","logical"]}]}],outputs:{arity:1}};static spalloc=(t,e,r,a,...o)=>{d.AST.throwInvalidCallError("spalloc",!(void 0!==t&&void 0!==e&&void 0!==r&&0===o.length));const l=x.sparseDimension(t,"spalloc",1),c=x.sparseDimension(e,"spalloc",2);if(x.sparseDimension(r,"spalloc",3),!(void 0===a||s.CharString.isInstanceOf(a)&&["double","single","logical"].includes(a.str)))throw new Error("spalloc: typename must be 'double', 'single', or 'logical'.");const u=s.CharString.isInstanceOf(a)&&"logical"===a.str?i.Complex.false():i.Complex.zero();return n.MultiArray.MultiArrayToScalar(new n.MultiArray([l,c],u))};static isrowSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isrow=(t,...e)=>(d.AST.throwInvalidCallError("isrow",!(void 0!==t&&0===e.length)),g.RuntimeValue.isRowVector(t)?i.Complex.true():i.Complex.false());static iscolumnSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscolumn=(t,...e)=>(d.AST.throwInvalidCallError("iscolumn",!(void 0!==t&&0===e.length)),g.RuntimeValue.isColumnVector(t)?i.Complex.true():i.Complex.false());static isstructSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isstruct=(t,...e)=>(d.AST.throwInvalidCallError("isstruct",!(void 0!==t&&0===e.length)),a.Structure.isStructure(t)?i.Complex.true():i.Complex.false());static ischarSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ischar=(t,...e)=>{d.AST.throwInvalidCallError("ischar",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t);return r&&m.FunctionValidation.matchesClass(r,"char")?i.Complex.true():i.Complex.false()};static isstringSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isstring=(t,...e)=>{d.AST.throwInvalidCallError("isstring",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t);return r&&m.FunctionValidation.matchesClass(r,"string")?i.Complex.true():i.Complex.false()};static iscellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static iscellstr=(t,...e)=>(d.AST.throwInvalidCallError("iscellstr",!(void 0!==t&&0===e.length)),x.cellStringElements(t).accepted?i.Complex.true():i.Complex.false());static cellstrSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static cellstr=(t,...e)=>{if(d.AST.throwInvalidCallError("cellstr",!(void 0!==t&&0===e.length)),s.CharString.isInstanceOf(t)){const e=n.MultiArray.toColumnVector([new s.CharString(t.str,"'")]);return e.isCell=!0,e}if(n.MultiArray.isInstanceOf(t)&&t.isCell){if(!x.cellStringElements(t).accepted)throw new EvalError("cellstr: C must be a cell array of character vectors.");return g.RuntimeValue.copy(t)}if(n.MultiArray.isInstanceOf(t)&&!t.isCell){if(0===n.MultiArray.linearLength(t))return n.MultiArray.emptyArray(!0);const e=n.MultiArray.linearize(t);if(e.every(s.CharString.isString)){const e=n.MultiArray.rawMap(t,t=>new s.CharString(t.str,"'"));return e.isCell=!0,e}if(2===t.dimension.length&&e.every(s.CharString.isChar)){const e=n.MultiArray.toColumnVector(t.array.map(t=>new s.CharString(t.map(t=>t.str).join("").trimEnd(),"'")));return e.isCell=!0,e}}throw new EvalError("cellstr: input must be a string, character array, or cell array of character vectors.")};static charSignature={inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static char=(...t)=>{d.AST.throwInvalidCallError("char",0===t.length);const e=t.flatMap(t=>x.charRows(t));if(0===e.length)return n.MultiArray.emptyArray();if(1===e.length)return s.CharString.fromCharacterScalars(e[0]);const r=e.reduce((t,e)=>Math.max(t,e.length),0),i=new n.MultiArray([e.length,r]);for(let t=0;t<e.length;t++){const n=e[t][0]?.quote??"'";for(let a=0;a<r;a++)i.array[t][a]=e[t][a]??s.CharString.create(" ",n)}return n.MultiArray.setType(i),i};static charElement=(t,e="'")=>{if(s.CharString.isInstanceOf(t))return t;if(i.Complex.isInstanceOf(t)){if(0!==i.Complex.imagToNumber(t))throw new Error("char: numeric character codes must be real.");return s.CharString.fromNumericCode(i.Complex.realToNumber(t),e)}throw new Error("char: invalid conversion input.")};static charRows=t=>{if(s.CharString.isInstanceOf(t))return[t.toCharacterScalars()];if(i.Complex.isInstanceOf(t))return[[x.charElement(t)]];if(n.MultiArray.isInstanceOf(t)&&!t.isCell&&2===t.dimension.length)return t.array.map(t=>t.map(t=>x.charElement(t)));const e=x.cellStringElements(t);if(e.accepted)return e.values.map(t=>t.toCharacterScalars());throw new Error("char: invalid conversion input.")};static cellStringElements=t=>{if(!n.MultiArray.isInstanceOf(t)||!t.isCell)return{accepted:!1,values:[]};const e=n.MultiArray.linearize(t);return e.every(s.CharString.isChar)?{accepted:!0,values:e}:{accepted:!1,values:[]}};static doubleSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static double=(t,...e)=>{if(d.AST.throwInvalidCallError("double",!(void 0!==t&&0===e.length)),s.CharString.isInstanceOf(t))return n.MultiArray.fromCharString(t);if(i.Complex.isInstanceOf(t))return x.doubleElement(t);if(n.MultiArray.isInstanceOf(t)&&!t.isCell){const e=new n.MultiArray(t.dimension);return e.array=t.array.map(t=>t.map(t=>x.doubleElement(t))),e.type=0===n.MultiArray.linearLength(e)?i.Complex.REAL:e.type,n.MultiArray.linearLength(e)>0&&n.MultiArray.setType(e),n.MultiArray.MultiArrayToScalar(e)}throw new Error("double: invalid conversion input.")};static doubleElement=t=>{if(i.Complex.isInstanceOf(t))return i.Complex.create(i.Complex.realToNumber(t),i.Complex.imagToNumber(t));if(s.CharString.isInstanceOf(t)&&1===t.length)return i.Complex.create(t.str.charCodeAt(0));throw new Error("double: invalid conversion input.")};static logicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static logical=(t,...e)=>{if(d.AST.throwInvalidCallError("logical",!(void 0!==t&&0===e.length)),s.CharString.isInstanceOf(t))return x.logical(n.MultiArray.fromCharString(t));if(i.Complex.isInstanceOf(t))return x.logicalElement(t);if(n.MultiArray.isInstanceOf(t)&&!t.isCell){const e=new n.MultiArray(t.dimension);return e.array=t.array.map(t=>t.map(t=>x.logicalElement(t))),e.type=i.Complex.LOGICAL,n.MultiArray.linearLength(e)>0&&n.MultiArray.setType(e),n.MultiArray.MultiArrayToScalar(e)}throw new Error("logical: invalid conversion input.")};static logicalElement=t=>{if(i.Complex.isInstanceOf(t)){if(!i.Complex.imagIsZero(t)||i.Complex.realIsNaN(t))throw new Error("logical: complex and NaN values cannot be converted to logical.");return i.Complex.realIsZero(t)?i.Complex.false():i.Complex.true()}if(s.CharString.isInstanceOf(t)&&1===t.length)return 0===t.str.charCodeAt(0)?i.Complex.false():i.Complex.true();throw new Error("logical: invalid conversion input.")};static numericClassification=(t,e,r,a)=>{if(d.AST.throwInvalidCallError(t,!(void 0!==e&&0===r.length)),s.CharString.isInstanceOf(e))return x.numericClassification(t,n.MultiArray.fromCharString(e),[],a);if(i.Complex.isInstanceOf(e))return a(e)?i.Complex.true():i.Complex.false();if(n.MultiArray.isInstanceOf(e)&&!e.isCell){const r=new n.MultiArray(e.dimension);return r.array=e.array.map(e=>e.map(e=>a(x.numericClassificationElement(t,e))?i.Complex.true():i.Complex.false())),r.type=i.Complex.LOGICAL,n.MultiArray.MultiArrayToScalar(r)}throw new Error(`${t}: invalid conversion input.`)};static numericClassificationElement=(t,e)=>{if(i.Complex.isInstanceOf(e))return e;if(s.CharString.isInstanceOf(e)&&1===e.length)return i.Complex.create(e.str.charCodeAt(0));throw new Error(`${t}: invalid conversion input.`)};static isnanSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isnan=(t,...e)=>x.numericClassification("isnan",t,e,t=>i.Complex.realIsNaN(t)||i.Complex.imagIsNaN(t));static isinfSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isinf=(t,...e)=>x.numericClassification("isinf",t,e,t=>!i.Complex.realIsFinite(t)&&!i.Complex.realIsNaN(t)||!i.Complex.imagIsFinite(t)&&!i.Complex.imagIsNaN(t));static isfiniteSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isfinite=(t,...e)=>x.numericClassification("isfinite",t,e,t=>i.Complex.realIsFinite(t)&&i.Complex.imagIsFinite(t));static isfloatSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isfloat=(t,...e)=>{d.AST.throwInvalidCallError("isfloat",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t);return r&&m.FunctionValidation.numericElements(r)?i.Complex.true():i.Complex.false()};static isintegerSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isinteger=(t,...e)=>(d.AST.throwInvalidCallError("isinteger",!(void 0!==t&&0===e.length)),i.Complex.false());static isnumericSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isnumeric=(t,...e)=>{d.AST.throwInvalidCallError("isnumeric",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t);return r&&m.FunctionValidation.numericElements(r)?i.Complex.true():i.Complex.false()};static islogicalSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static islogical=(t,...e)=>{d.AST.throwInvalidCallError("islogical",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t);return r&&m.FunctionValidation.isLogicalValue(r)?i.Complex.true():i.Complex.false()};static isrealSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isreal=(t,...e)=>{d.AST.throwInvalidCallError("isreal",!(void 0!==t&&0===e.length));const r=(0,p.optionalRuntimeExpressionValue)(t),s=r?m.FunctionValidation.numericElements(r,{includeLogical:!0}):void 0;return s&&s.every(t=>i.Complex.imagIsZero(t))?i.Complex.true():i.Complex.false()};static isvalidSignature={inputs:{arity:1,parameters:[{name:"handle"}]},outputs:{arity:1}};static isvalid=(t,...e)=>{d.AST.throwInvalidCallError("isvalid",!(void 0!==t&&0===e.length));const r=t=>{if(u.ClassEventListener.isInstanceOf(t))return u.ClassEventListener.isValid(t)?i.Complex.true():i.Complex.false();if(!l.ClassInstance.isInstanceOf(t)||!t.classDefinition.isHandleClass())throw new EvalError("isvalid: H must be a handle object.");return l.ClassInstance.isValid(t)?i.Complex.true():i.Complex.false()};return n.MultiArray.isInstanceOf(t)?n.MultiArray.MultiArrayToScalar(n.MultiArray.rawMap(t,r)):r(t)};static isobjectSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static isobject=(t,...e)=>{d.AST.throwInvalidCallError("isobject",!(void 0!==t&&0===e.length));const r=t=>l.ClassInstance.isInstanceOf(t)||c.ClassEnumerationValue.isInstanceOf(t)||h.ClassMetaObject.isInstanceOf(t);if(n.MultiArray.isInstanceOf(t)){const e=n.MultiArray.linearize(t);return!t.isCell&&e.length>0&&e.every(r)?i.Complex.true():i.Complex.false()}return r(t)?i.Complex.true():i.Complex.false()};static classDefinitionFromValue=(t,e)=>{if(o.ClassDefinition.isInstanceOf(t))return t;if(h.ClassMetaClass.isInstanceOf(t))return t.definition;if(l.ClassInstance.isInstanceOf(t)||c.ClassEnumerationValue.isInstanceOf(t))return t.classDefinition;if(n.MultiArray.isInstanceOf(t)&&!t.isCell){const e=t=>h.ClassMetaClass.isInstanceOf(t)?t.definition:l.ClassInstance.isInstanceOf(t)||c.ClassEnumerationValue.isInstanceOf(t)?t.classDefinition:void 0,r=n.MultiArray.linearize(t).map(e);if(r.length>0&&r.every(t=>void 0!==t)){const t=r[0];if(r.every(e=>e===t))return t}}throw new EvalError(`${e}: input must be a class object.`)};static stringCellColumn=t=>{const e=n.MultiArray.toColumnVector(t.map(t=>s.CharString.create(t)));return e.isCell=!0,e};static listedNames=(t,e)=>{const r=new Set;for(const s of t)e(s)&&r.add(s.name);return[...r].sort()};static propertiesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static properties=(t,...e)=>{d.AST.throwInvalidCallError("properties",!(void 0!==t&&0===e.length));const r=x.classDefinitionFromValue(t,"properties");return x.stringCellColumn(x.listedNames(r.allProperties(),t=>!t.isHidden&&"public"===t.getAccess))};static fieldnamesSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static fieldnames=(t,...e)=>{if(d.AST.throwInvalidCallError("fieldnames",!(void 0!==t&&0===e.length)),a.Structure.isStructure(t))return x.stringCellColumn(a.Structure.fieldNames(t));const r=x.classDefinitionFromValue(t,"fieldnames");return x.stringCellColumn(x.listedNames(r.allProperties(),t=>!t.isHidden&&"public"===t.getAccess))};static isfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fieldName"}]},outputs:{arity:1}};static isfield=(t,e,...r)=>{d.AST.throwInvalidCallError("isfield",!(void 0!==t&&void 0!==e&&0===r.length));const o=a.Structure.isStructure(t),l=e=>{if(!s.CharString.isInstanceOf(e)){if(!o)return i.Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}return a.Structure.hasField(t,e.str)?i.Complex.true():i.Complex.false()};if(n.MultiArray.isInstanceOf(e)){if(!e.isCell){if(!o)return i.Complex.false();throw new EvalError("isfield: FIELD must be a string or cell array of strings.")}const t=n.MultiArray.rawMap(e,l);return n.MultiArray.setType(t),n.MultiArray.MultiArrayToScalar(t)}return l(e)};static numfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static numfields=(t,...e)=>(d.AST.throwInvalidCallError("numfields",!(void 0!==t&&0===e.length&&a.Structure.isStructure(t))),i.Complex.create(a.Structure.fieldNames(t).length));static getfieldSignature={inputs:{arity:-2,min:2,parameters:[{name:"structure"},{name:"field",variadic:!0}]},outputs:{arity:1}};static getfield=(t,...e)=>(d.AST.throwInvalidCallError("getfield",!(void 0!==t&&e.length>0&&a.Structure.isStructure(t))),a.Structure.getField(t,e.map((t,e)=>x.stringArgument(t,"getfield",e+2))));static setfieldSignature={inputs:{arity:-3,min:3,parameters:[{name:"structure"},{name:"fieldOrValue",variadic:!0}]},outputs:{arity:1}};static setfield=(t,...e)=>{d.AST.throwInvalidCallError("setfield",!(void 0!==t&&e.length>=2&&a.Structure.isStructure(t)));const r=a.Structure.isInstanceOf(t)?a.Structure.copy(t):n.MultiArray.copy(t),s=e.slice(0,-1).map((t,e)=>x.stringArgument(t,"setfield",e+2));return a.Structure.setNewField(r,s,e[e.length-1]),r};static rmfieldSignature={inputs:{arity:2,parameters:[{name:"structure"},{name:"fields"}]},outputs:{arity:1}};static rmfield=(t,e,...r)=>(d.AST.throwInvalidCallError("rmfield",!(void 0!==t&&void 0!==e&&0===r.length&&a.Structure.isStructure(t))),a.Structure.removeFields(x.structureArgument(t,"rmfield"),x.fieldNameArguments(e,"rmfield",2)));static orderfieldsSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static orderfields=(t,...e)=>(d.AST.throwInvalidCallError("orderfields",!(void 0!==t&&0===e.length&&a.Structure.isStructure(t))),a.Structure.orderFields(x.structureArgument(t,"orderfields")));static struct2cellSignature={inputs:{arity:1,parameters:[{name:"structure"}]},outputs:{arity:1}};static struct2cell=(t,...e)=>{d.AST.throwInvalidCallError("struct2cell",!(void 0!==t&&0===e.length&&a.Structure.isStructure(t)));const r=x.structureArgument(t,"struct2cell"),s=a.Structure.fieldNames(r),i=a.Structure.structureElements(r),o=a.Structure.isInstanceOf(r)?[1,1]:r.dimension,l=new n.MultiArray([s.length,...o],void 0,!0);for(let t=0;t<i.length;t++){const e=n.MultiArray.linearIndexToSubscript(o,t);for(let r=0;r<s.length;r++){const[a,o]=n.MultiArray.subscriptToMultiArrayRowColumn(l.dimension,[r+1,...e]);l.array[a][o]=g.RuntimeValue.copy(i[t].field[s[r]])}}return n.MultiArray.setType(l),l.isCell=!0,l};static cell2structSignature={inputs:{arity:3,parameters:[{name:"cellArray",classes:["cell"]},{name:"fields"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]},outputs:{arity:1}};static cell2struct=(t,e,r,...s)=>{d.AST.throwInvalidCallError("cell2struct",!(n.MultiArray.isInstanceOf(t)&&t.isCell&&void 0!==e&&void 0!==r&&0===s.length));const o=t,l=x.fieldNameArguments(e,"cell2struct",2),c=i.Complex.realToNumber(n.MultiArray.firstElement(r))-1,u=o.dimension.slice();if(n.MultiArray.appendSingletonTail(u,c+1),l.length!==u[c])throw new EvalError("cell2struct: number of fields does not match dimension.");const h=u.filter((t,e)=>e!==c),m=0===h.length?[1,1]:h,p=new n.MultiArray(m);for(let t=0;t<n.MultiArray.linearLength(p);t++){const e=n.MultiArray.linearIndexToSubscript(m,t),r=new a.Structure({});for(let t=0;t<l.length;t++){const s=[];let i=0;for(let r=0;r<u.length;r++)s[r]=r===c?t+1:e[i++]??1;const[a,h]=n.MultiArray.subscriptToMultiArrayRowColumn(o.dimension,s.slice(0,o.dimension.length));r.field[l[t]]=g.RuntimeValue.copy(o.array[a][h])}const[s,i]=n.MultiArray.linearIndexToMultiArrayRowColumn(p.dimension[0],p.dimension[1],t);p.array[s][i]=r}return n.MultiArray.setType(p),n.MultiArray.MultiArrayToScalar(p)};static methodsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static methods=(t,...e)=>{d.AST.throwInvalidCallError("methods",!(void 0!==t&&0===e.length));const r=x.classDefinitionFromValue(t,"methods");return x.stringCellColumn(x.listedNames(r.allMethods(),t=>!t.isHidden&&"public"===t.access))};static eventsSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static events=(t,...e)=>{d.AST.throwInvalidCallError("events",!(void 0!==t&&0===e.length));const r=x.classDefinitionFromValue(t,"events");return x.stringCellColumn(x.listedNames(r.allEvents(),t=>!t.isHidden&&"public"===t.listenAccess))};static enumerationSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static enumeration=(t,...e)=>{d.AST.throwInvalidCallError("enumeration",!(void 0!==t&&0===e.length));const r=x.classDefinitionFromValue(t,"enumeration");return x.stringCellColumn(x.listedNames(r.allEnumerations(),t=>!t.isHidden))};static superclassesSignature={inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}};static superclasses=(t,...e)=>{d.AST.throwInvalidCallError("superclasses",!(void 0!==t&&0===e.length));const r=x.classDefinitionFromValue(t,"superclasses");return x.stringCellColumn(r.superclasses.slice().sort())};static stringArgument=(t,e,r)=>{if(!s.CharString.isInstanceOf(t))throw new EvalError(`${e}: argument ${r} must be a string.`);return t.str};static fieldNameArguments=(t,e,r)=>{if(s.CharString.isInstanceOf(t))return[t.str];if(n.MultiArray.isInstanceOf(t)&&t.isCell)return n.MultiArray.linearize(t).map(t=>x.stringArgument(t,e,r));throw new EvalError(`${e}: argument ${r} must be a string or cell array of strings.`)};static structureArgument=(t,e)=>{if(a.Structure.isInstanceOf(t)||n.MultiArray.isInstanceOf(t)&&a.Structure.isStructure(t))return t;throw new EvalError(`${e}: argument 1 must be a structure.`)};static ispropSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"propertyName"}]},outputs:{arity:1}};static isprop=(t,e,...r)=>{if(d.AST.throwInvalidCallError("isprop",!(void 0!==t&&void 0!==e&&0===r.length)),!s.CharString.isInstanceOf(e))return i.Complex.false();const a=e.str;if(n.MultiArray.isInstanceOf(t)){if(t.isCell)return i.Complex.false();const e=n.MultiArray.rawMap(t,t=>x.classDefinitionFromValue(t,"isprop").findProperty(a)?i.Complex.true():i.Complex.false());return n.MultiArray.setType(e),n.MultiArray.MultiArrayToScalar(e)}return x.classDefinitionFromValue(t,"isprop").findProperty(a)?i.Complex.true():i.Complex.false()};static ismethodSignature={inputs:{arity:2,parameters:[{name:"object"},{name:"methodName",classes:["char","string"]}]},outputs:{arity:1}};static ismethod=(t,e,...r)=>{d.AST.throwInvalidCallError("ismethod",!(void 0!==t&&void 0!==e&&0===r.length));const s=x.classDefinitionFromValue(t,"ismethod"),n=x.stringArgument(e,"ismethod",2);return s.findMethod(n,t=>!t.isHidden&&"public"===t.access)?i.Complex.true():i.Complex.false()};static isequalSignature={inputs:{arity:-1,min:2,parameters:[{name:"value",variadic:!0}]},outputs:{arity:1}};static isequal=(t,...e)=>(d.AST.throwInvalidCallError("isequal",!(void 0!==t&&e.length>=1)),e.every(e=>x.valuesEqual(t,e))?i.Complex.true():i.Complex.false());static valuesEqual=(t,e)=>f.RuntimeEquality.valuesEqual(t,e);static ndimsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ndims=(t,...e)=>(d.AST.throwInvalidCallError("ndims",!(void 0!==t&&0===e.length)),i.Complex.create(g.RuntimeValue.dimensions(t).length));static rowsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static rows=(t,...e)=>(d.AST.throwInvalidCallError("rows",!(void 0!==t&&0===e.length)),i.Complex.create(g.RuntimeValue.dimensions(t)[0]));static columnsSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static columns=(t,...e)=>(d.AST.throwInvalidCallError("columns",!(void 0!==t&&0===e.length)),i.Complex.create(g.RuntimeValue.dimensions(t)[1]));static lengthSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static Length=(t,...e)=>(d.AST.throwInvalidCallError("length",!(void 0!==t&&0===e.length)),i.Complex.create(Math.max(...g.RuntimeValue.dimensions(t))));static numelSignature={inputs:{arity:-2,min:1,parameters:[{name:"value"},{name:"index",variadic:!0}]},outputs:{arity:1}};static numel=(t,...e)=>{const r=g.RuntimeValue.dimensions(t);if(0===e.length)return i.Complex.create(g.RuntimeValue.elementCount(t));{const t=e.map((t,e)=>n.MultiArray.isInstanceOf(t)?n.MultiArray.linearLength(t):s.CharString.isInstanceOf(t)&&":"===t.str&&e<r.length?r[e]:1);return i.Complex.create(t.reduce((t,e)=>t*e,1))}};static findSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"direction",classes:["char","string"],allowedStrings:["first","last"]}]}],outputs:{arity:-3}};static find=(t,...e)=>{d.AST.throwInvalidCallError("find",e.length>2);const r=n.MultiArray.scalarToMultiArray(t);let s=1/0,a="first";e.length>=1&&(s=i.Complex.realToNumber(n.MultiArray.firstElement(e[0]))),2===e.length&&(a=e[1].str);let o=n.MultiArray.linearize(r).map((t,e)=>({index:e,value:t})).filter(({value:t})=>Boolean(i.Complex.realToNumber(t)||i.Complex.imagToNumber(t)));o="last"===a?o.slice(Math.max(0,o.length-s)):o.slice(0,s);const l=o.map(({index:t})=>i.Complex.create(t+1)),c=o.map(({index:t})=>i.Complex.create(n.MultiArray.linearIndexToSubscript(r.dimension,t)[0]??1)),u=o.map(({index:t})=>i.Complex.create(n.MultiArray.linearIndexToSubscript(r.dimension,t)[1]??1)),h=o.map(({value:t})=>t),m=t=>n.MultiArray.MultiArrayToScalar(n.MultiArray.toColumnVector(t));return d.AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length)return m(l);switch(e){case 0:return m(c);case 1:return m(u);case 2:return m(h);default:throw new EvalError("unreachable find return-list selector branch.")}})};static sortSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"dimensionOrDirection",alternatives:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}]},{arity:3,parameters:[{name:"value",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"direction",classes:["char","string"],allowedStrings:["ascend","descend"]}]}],outputs:{arity:-2}};static sort=(t,...e)=>{d.AST.throwInvalidCallError("sort",e.length>2);const r=n.MultiArray.scalarToMultiArray(t);let a,o="ascend";e.length>=1&&(s.CharString.isInstanceOf(e[0])?o=e[0].str:a=i.Complex.realToNumber(n.MultiArray.firstElement(e[0]))-1),2===e.length&&(o=e[1].str),a=void 0===a?n.MultiArray.firstNonSingleDimension(r):a;const l=new n.MultiArray(r.dimension),c=new n.MultiArray(r.dimension),u=r.dimension.slice();u[a]=1;const h=u.reduce((t,e)=>t*e,1);for(let t=0;t<h;t++){const e=n.MultiArray.linearIndexToSubscript(u,t),s=Array.from({length:r.dimension[a]??1},(t,s)=>{const i=e.slice();i[a]=s+1;const o=n.MultiArray.subscriptToLinearIndex(r.dimension,i),[l,c]=n.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],o);return{index:s,value:r.array[l][c]}}).sort((t,e)=>{if(i.Complex.toBoolean(i.Complex.eq(t.value,e.value)))return t.index-e.index;const r="descend"===o?i.Complex.gt(t.value,e.value):i.Complex.lt(t.value,e.value);return i.Complex.toBoolean(r)?-1:1});for(let t=0;t<s.length;t++){const o=e.slice();o[a]=t+1;const u=n.MultiArray.subscriptToLinearIndex(r.dimension,o),[h,d]=n.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],u);l.array[h][d]=s[t].value,c.array[h][d]=i.Complex.create(s[t].index+1)}}return n.MultiArray.setType(l),c.type=i.Complex.REAL,d.AST.nodeBoundedReturnList(2,(t,e)=>0===e||1===t.length?n.MultiArray.MultiArrayToScalar(l):n.MultiArray.MultiArrayToScalar(c))};static ind2subSignature={inputs:{arity:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"index",classes:["double"],validators:["numeric","real","finite","integer","positive"]}]},outputs:{arity:-1}};static ind2sub=(t,e)=>(d.AST.throwInvalidCallError("ind2sub",!(void 0!==t&&void 0!==e)),d.AST.nodeReturnList((r,s)=>{if(1===r.length)return e;{let a=n.MultiArray.linearize(t).map(t=>i.Complex.realToNumber(t)),o=!1;r.length>a.length?(n.MultiArray.appendSingletonTail(a,r.length),o=!0):a=a.slice(0,r.length-1);const l=n.MultiArray.scalarToMultiArray(e),c=new n.MultiArray(l.dimension),u=l.array.map(t=>t.map(t=>n.MultiArray.ind2subNumber(a,i.Complex.realToNumber(t))));return s===r.length-1&&o?c.array=u.map(t=>t.map(t=>i.Complex.create(t[r.length]))):c.array=u.map(t=>t.map(t=>i.Complex.create(t[s]))),c.type=i.Complex.REAL,n.MultiArray.MultiArrayToScalar(c)}}));static sub2indSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]},{name:"subscript",classes:["double"],validators:["numeric","real","finite","integer","positive"],variadic:!0}]},outputs:{arity:1}};static sub2ind=(t,...e)=>{d.AST.throwInvalidCallError("sub2ind",e.length<1);const r=n.MultiArray.linearize(t).map(t=>i.Complex.realToNumber(t)),s=e.map(t=>n.MultiArray.scalarToMultiArray(t));for(let t=1;t<s.length;t++)if(!n.MultiArray.arrayEquals(s[0].dimension,s[t].dimension))throw new Error("sub2ind: all subscripts must be of the same size.");n.MultiArray.appendSingletonTail(r,s.length);const a=new n.MultiArray(s[0].dimension);for(let t=0;t<n.MultiArray.linearLength(s[0]);t++){const e=s.map(e=>{const[r,s]=n.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],t);return e.array[r][s]}),o=n.MultiArray.parseSubscript(r,e,"index "),[l,c]=n.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);a.array[l][c]=i.Complex.create(o+1)}return n.MultiArray.MultiArrayToScalar(a)};static sizeSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:-2,min:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["numeric","positive","integer","real"],variadic:!0}]}],outputs:{arity:-1}};static size=(t,...e)=>{d.AST.throwInvalidCallError("size",!(void 0!==t));const r=t=>{const e=i.Complex.realToNumber(t);if(e<1||!i.Complex.realIsInteger(t))throw new Error(`size: requested dimension DIM (= ${e}) out of range. DIM must be a positive integer.`);return e},s=g.RuntimeValue.dimensions(t);if(0===e.length){const t=new n.MultiArray([1,s.length]);return t.array[0]=s.map(t=>i.Complex.create(t)),t.type=i.Complex.REAL,t}{const t=1===e.length&&n.MultiArray.isInstanceOf(e[0])?n.MultiArray.linearize(e[0]).map(t=>(i.Complex.isInstanceOf(t)||d.AST.throwInvalidCallError("size"),r(t))):e.map(t=>(t=>{const e=n.MultiArray.firstElement(t);return i.Complex.isInstanceOf(e)||d.AST.throwInvalidCallError("size"),r(e)})(t));n.MultiArray.appendSingletonTail(s,Math.max(...t));const a=new n.MultiArray([1,t.length]);return a.array[0]=t.map(t=>i.Complex.create(s[t-1])),a.type=i.Complex.REAL,n.MultiArray.MultiArrayToScalar(a)}};static colonSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalar"]},{name:"incrementOrEnd",classes:["double"],validators:["scalar"]},{name:"end",classes:["double"],validators:["scalar"],optional:!0}]},outputs:{arity:1}};static colon=(...t)=>2===t.length?n.MultiArray.expandRange(n.MultiArray.firstElement(t[0]),n.MultiArray.firstElement(t[1])):3===t.length?n.MultiArray.expandRange(n.MultiArray.firstElement(t[0]),n.MultiArray.firstElement(t[2]),n.MultiArray.firstElement(t[1])):void d.AST.throwInvalidCallError("colon");static linspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}};static linspace=(...t)=>{let e=[],r=[],s=i.Complex.one();const a=()=>{const s="linspace: START, END must be scalars or vectors.";if(n.MultiArray.isInstanceOf(t[0])){if(!n.MultiArray.isVector(t[0]))throw new Error(s);e=n.MultiArray.linearize(t[0])}else e=[t[0]];if(n.MultiArray.isInstanceOf(t[1])){if(!n.MultiArray.isVector(t[1]))throw new Error(s);r=n.MultiArray.linearize(t[1])}else r=[t[1]]};if(2===t.length)a(),s=i.Complex.create(100);else if(3===t.length){if(a(),s=n.MultiArray.MultiArrayToScalar(t[2]),n.MultiArray.isInstanceOf(s))throw new Error("linspace: N must be a scalar.")}else d.AST.throwInvalidCallError("linspace");if(e.length!==r.length)throw new Error("linspace: vectors must be of equal length");i.Complex.realApply(s,i.Complex.applyFunction.floor),i.Complex.realIsNegative(s)&&i.Complex.realSet(s,0),i.Complex.imagSet(s,0);const o=new n.MultiArray([e.length,i.Complex.realToNumber(s)]);for(let t=0;t<e.length;t++){const n=i.Complex.rdiv(i.Complex.sub(r[t],e[t]),i.Complex.sub(s,i.Complex.one()));o.array[t][0]=e[t];for(let r=1;r<i.Complex.realToNumber(s)-1;r++)o.array[t][r]=i.Complex.add(e[t],i.Complex.mul(i.Complex.create(r),n));o.array[t][i.Complex.realToNumber(s)-1]=r[t]}return n.MultiArray.MultiArrayToScalar(o)};static logspaceSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"start",classes:["double"],validators:["scalarOrVector"]},{name:"end",classes:["double"],validators:["scalarOrVector"]},{name:"count",classes:["double"],validators:["numeric","scalar","real"],optional:!0}]},outputs:{arity:1}};static logspace=(...t)=>{let e=[],r=[],s=i.Complex.one();const a=()=>{const s="logspace: START, END must be scalars or vectors.";if(n.MultiArray.isInstanceOf(t[0])){if(!n.MultiArray.isVector(t[0]))throw new Error(s);e=n.MultiArray.linearize(t[0])}else e=[t[0]];if(n.MultiArray.isInstanceOf(t[1])){if(!n.MultiArray.isVector(t[1]))throw new Error(s);r=n.MultiArray.linearize(t[1])}else r=[t[1]]};if(2===t.length)a(),s=i.Complex.create(50);else if(3===t.length){if(a(),s=n.MultiArray.MultiArrayToScalar(t[2]),n.MultiArray.isInstanceOf(s))throw new Error("logspace: N must be a scalar.")}else d.AST.throwInvalidCallError("logspace");if(e.length!==r.length)throw new Error("logspace: vectors must be of equal length");i.Complex.realApply(s,i.Complex.applyFunction.floor),i.Complex.realIsNegative(s)&&i.Complex.realSet(s,0),i.Complex.imagSet(s,0);const o=new n.MultiArray([e.length,i.Complex.realToNumber(s)]);for(let t=0;t<e.length;t++){i.Complex.realToNumber(i.Complex.eq(r[t],i.Complex.pi()))&&(r[t]=i.Complex.log10(i.Complex.pi()));const n=i.Complex.rdiv(i.Complex.sub(r[t],e[t]),i.Complex.sub(s,i.Complex.one()));o.array[t][0]=i.Complex.power(i.Complex.create(10),e[t]);for(let r=1;r<i.Complex.realToNumber(s)-1;r++)o.array[t][r]=i.Complex.power(i.Complex.create(10),i.Complex.add(e[t],i.Complex.mul(i.Complex.create(r),n)));o.array[t][i.Complex.realToNumber(s)-1]=i.Complex.power(i.Complex.create(10),r[t])}return n.MultiArray.MultiArrayToScalar(o)};static meshgridSignature={inputs:{arity:-3,min:1,max:3,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-3}};static meshgrid=(...t)=>{d.AST.throwInvalidCallError("meshgrid",t.length>3||t.length<1);const e=[];for(let r=0;r<3&&t.length>r;r++)if(n.MultiArray.isInstanceOf(t[r])){if(!n.MultiArray.isVector(t[r]))throw new Error("meshgrid: arguments must be vectors.");e[r]=n.MultiArray.firstVector(t[r])}else e[r]=[t[r]];return d.AST.nodeBoundedReturnList(3,(t,r)=>{const s=e;for(;s.length<t.length;)s[s.length]=s[s.length-1];const i=t.length>2?new n.MultiArray([s[1].length,s[0].length,s[2].length]):new n.MultiArray([s[1].length,s[0].length]);switch(r){case 0:for(let t=0;t<i.array.length;t++)i.array[t]=s[0];break;case 1:for(let t=0;t<i.array.length;t+=i.dimension[0])for(let e=0;e<i.dimension[0];e++)i.array[t+e]=new Array(i.dimension[1]).fill(s[1][e]);break;case 2:for(let t=0,e=0;t<i.array.length;t+=i.dimension[0],e++)for(let r=0;r<i.dimension[0];r++)i.array[t+r]=new Array(i.dimension[1]).fill(s[2][e])}return n.MultiArray.MultiArrayToScalar(i)})};static ndgridSignature={inputs:{arity:-1,min:1,parameters:[{name:"vector",classes:["double"],validators:["scalarOrVector"],variadic:!0}]},outputs:{arity:-1}};static ndgrid=(...t)=>{const e=[];for(let r=0;r<t.length;r++)if(n.MultiArray.isInstanceOf(t[r])){if(!n.MultiArray.isVector(t[r]))throw new Error("ndgrid: arguments must be vectors.");e[r]=t[r]}else e[r]=n.MultiArray.scalarToMultiArray(t[r]);return d.AST.nodeReturnList((t,r)=>{const s=e;if(1===s.length)for(;s.length<t.length;)s[s.length]=s[s.length-1];t.length>s.length&&d.AST.throwErrorIfGreaterThanReturnList(s.length,t.length);const i=s.map(t=>t.dimension[0]*t.dimension[1]),a=new Array(s.length).fill(1);return a[r]=i[r],i[r]=1,n.MultiArray.evaluate(new n.MultiArray(i,n.MultiArray.reshape(s[r],a)))})};static repmatSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension"],variadic:!0}]}],outputs:{arity:1}};static repmat=(t,...e)=>{let r;if(1===e.length)r=n.MultiArray.firstVector(e[0]);else{const t=new Array(e.length);if(r=e.map((e,r)=>{const s=n.MultiArray.MultiArrayToScalar(e);return t[r]=n.MultiArray.isInstanceOf(s)?1:0,s}),t.reduce((t,e)=>t+e,0))throw new Error("repmat: all input arguments must be scalar.")}const s=r.map(t=>i.Complex.realToNumber(t));return n.MultiArray.isInstanceOf(t)&&t.isCell?x.repmatCellArray(t,s):n.MultiArray.evaluate(new n.MultiArray(s,t))};static repmatCellArray=(t,e)=>{const r=Math.max(t.dimension.length,e.length,2),s=t.dimension.slice(),i=e.slice();n.MultiArray.appendSingletonTail(s,r),n.MultiArray.appendSingletonTail(i,r);const a=s.map((t,e)=>t*i[e]),o=new n.MultiArray(a,void 0,!0);for(let e=0;e<n.MultiArray.linearLength(o);e++){const r=n.MultiArray.linearIndexToSubscript(o.dimension,e).map((t,e)=>(t-1)%s[e]+1),i=n.MultiArray.subscriptToLinearIndex(s,r),[a,l]=n.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],i),[c,u]=n.MultiArray.linearIndexToMultiArrayRowColumn(o.dimension[0],o.dimension[1],e);o.array[c][u]=g.RuntimeValue.copy(t.array[a][l])}return o.isCell=!0,o};static reshapeSignature={inputs:[{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["reshapeDimension"],alternatives:[{name:"dimensions",validators:["reshapeDimensionVector"]}]}]},{arity:-3,min:3,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["reshapeDimension"],variadic:!0}]}],outputs:{arity:1}};static reshape=(t,...e)=>{if(e.length<1)throw new Error("invalid call to reshape");const r=n.MultiArray.scalarOrCellToMultiArray(t);let s=-1;1===e.length&&n.MultiArray.isInstanceOf(e[0])&&(e=n.MultiArray.linearize(e[0]));const a=e.map((t,e)=>{if(n.MultiArray.isEmpty(t)){if(s<0)return s=e,1;throw new Error("reshape: only a single dimension can be unknown.")}return i.Complex.realToNumber(n.MultiArray.firstElement(t))});return n.MultiArray.reshape(r,a,s)};static squeezeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static squeeze=(...t)=>{if(d.AST.throwInvalidCallError("squeeze",1!==t.length),!n.MultiArray.isInstanceOf(t[0]))return t[0];const e=t[0];if(e.dimension.length<=2)return e;const r=e.dimension.filter(t=>1!==t);for(;r.length<2;)r.push(1);return n.MultiArray.reshape(e,r)};static flipSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static flip=(t,e,...r)=>{d.AST.throwInvalidCallError("flip",!(void 0!==t&&0===r.length));const i=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t),a=void 0===e?n.MultiArray.firstNonSingleDimension(i)+1:x.positiveIntegerScalar(e,"flip","DIM");return x.flipArray(i,a)};static fliplrSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}};static fliplr=(t,...e)=>{d.AST.throwInvalidCallError("fliplr",!(void 0!==t&&0===e.length));const r=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t);return x.flipArray(r,2)};static flipudSignature={inputs:{arity:1,parameters:[{name:"array"}]},outputs:{arity:1}};static flipud=(t,...e)=>{d.AST.throwInvalidCallError("flipud",!(void 0!==t&&0===e.length));const r=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t);return x.flipArray(r,1)};static flipArray=(t,e)=>{const r=Math.max(t.dimension.length,e,2),s=t.dimension.slice();n.MultiArray.appendSingletonTail(s,r);const i=new n.MultiArray(s,void 0,t.isCell);for(let r=0;r<n.MultiArray.linearLength(t);r++){const a=n.MultiArray.linearIndexToSubscript(s,r),o=a.slice();o[e-1]=s[e-1]-a[e-1]+1;const[l,c]=n.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r),[u,h]=n.MultiArray.subscriptToMultiArrayRowColumn(i.dimension,o);i.array[u][h]=g.RuntimeValue.copy(t.array[l][c])}return i.isCell=t.isCell,i.type=t.type,n.MultiArray.removeSingletonTail(i.dimension),n.MultiArray.MultiArrayToScalar(i)};static rot90Signature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"k",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:1}};static rot90=(t,e,...r)=>{d.AST.throwInvalidCallError("rot90",!(void 0!==t&&0===r.length));const i=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t),a=((void 0===e?1:x.integerScalar(e,"rot90","K"))%4+4)%4;if(0===a)return i;const o=i.dimension.slice();n.MultiArray.appendSingletonTail(o,2);const l=o.slice();a%2==1&&([l[0],l[1]]=[l[1],l[0]]);const c=new n.MultiArray(l,void 0,i.isCell);for(let t=0;t<n.MultiArray.linearLength(i);t++){const e=n.MultiArray.linearIndexToSubscript(o,t),r=e.slice();1===a?(r[0]=o[1]-e[1]+1,r[1]=e[0]):2===a?(r[0]=o[0]-e[0]+1,r[1]=o[1]-e[1]+1):(r[0]=e[1],r[1]=o[0]-e[0]+1);const[s,l]=n.MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t),[u,h]=n.MultiArray.subscriptToMultiArrayRowColumn(c.dimension,r);c.array[u][h]=g.RuntimeValue.copy(i.array[s][l])}return c.isCell=i.isCell,c.type=i.type,n.MultiArray.removeSingletonTail(c.dimension),n.MultiArray.MultiArrayToScalar(c)};static permuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}};static permute=(t,e,...r)=>(d.AST.throwInvalidCallError("permute",!(void 0!==t&&void 0!==e&&0===r.length)),x.permuteArray(t,e,!1,"permute"));static ipermuteSignature={inputs:{arity:2,parameters:[{name:"array"},{name:"order",classes:["double"],validators:["dimensionVector"]}]},outputs:{arity:1}};static ipermute=(t,e,...r)=>(d.AST.throwInvalidCallError("ipermute",!(void 0!==t&&void 0!==e&&0===r.length)),x.permuteArray(t,e,!0,"ipermute"));static permuteArray=(t,e,r,i)=>{const a=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t),o=x.permutationOrder(e,a.dimension.length,i),l=r?x.inversePermutation(o):o,c=Math.max(a.dimension.length,l.length,2),u=a.dimension.slice();n.MultiArray.appendSingletonTail(u,c);const h=l.map(t=>u[t-1]);n.MultiArray.appendSingletonTail(h,c);const d=new n.MultiArray(h,void 0,a.isCell);for(let t=0;t<n.MultiArray.linearLength(d);t++){const e=n.MultiArray.linearIndexToSubscript(d.dimension,t),r=new Array(c).fill(1);l.forEach((t,s)=>{r[t-1]=e[s]});const s=n.MultiArray.subscriptToLinearIndex(u,r),[i,o]=n.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],s),[h,m]=n.MultiArray.linearIndexToMultiArrayRowColumn(d.dimension[0],d.dimension[1],t);d.array[h][m]=g.RuntimeValue.copy(a.array[i][o])}return d.isCell=a.isCell,d.type=a.type,n.MultiArray.removeSingletonTail(d.dimension),n.MultiArray.MultiArrayToScalar(d)};static permutationOrder=(t,e,r)=>{const s=n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).map(t=>{if(!i.Complex.isInstanceOf(t))throw new EvalError(`${r}: ORDER must be a permutation vector.`);const e=i.Complex.realToNumber(t);if(!Number.isInteger(e)||e<1||0!==i.Complex.imagToNumber(t))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return e}),a=Math.max(e,s.length,2),o=s.slice().sort((t,e)=>t-e);if(s.length!==a||o.some((t,e)=>t!==e+1))throw new EvalError(`${r}: ORDER must be a permutation vector.`);return s};static inversePermutation=t=>{const e=new Array(t.length);return t.forEach((t,r)=>{e[t-1]=r+1}),e};static circshiftSignature={inputs:[{arity:2,parameters:[{name:"array"},{name:"shifts",classes:["double"]}]},{arity:3,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static circshift=(t,e,r,...i)=>{d.AST.throwInvalidCallError("circshift",!(void 0!==t&&void 0!==e&&0===i.length));const a=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarOrCellToMultiArray(t),o=x.integerVector(e,"circshift","SHIFTS");if(void 0!==r){const t=x.positiveIntegerScalar(r,"circshift","DIM");if(1!==o.length)throw new EvalError("circshift: SHIFT must be a scalar when DIM is specified.");return x.circularShiftArray(a,[o[0]],t)}if(1===o.length)return x.circularShiftArray(a,o,n.MultiArray.firstNonSingleDimension(a)+1);if(o.length>a.dimension.length)throw new EvalError("circshift: SHIFTS vector must not be longer than ndims(A).");return x.circularShiftArray(a,o)};static circularShiftArray=(t,e,r)=>{const s=Math.max(t.dimension.length,r??0,e.length,2),i=t.dimension.slice();n.MultiArray.appendSingletonTail(i,s);const a=new Array(s).fill(0);"number"==typeof r?a[r-1]=e[0]:e.forEach((t,e)=>{a[e]=t});const o=new n.MultiArray(i,void 0,t.isCell);for(let e=0;e<n.MultiArray.linearLength(t);e++){const r=n.MultiArray.linearIndexToSubscript(i,e).map((t,e)=>{const r=i[e];return((t-1+a[e])%r+r)%r+1}),[s,l]=n.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),[c,u]=n.MultiArray.subscriptToMultiArrayRowColumn(o.dimension,r);o.array[c][u]=g.RuntimeValue.copy(t.array[s][l])}return o.isCell=t.isCell,o.type=t.type,n.MultiArray.removeSingletonTail(o.dimension),n.MultiArray.MultiArrayToScalar(o)};static shiftdimSignature={inputs:[{arity:1,parameters:[{name:"array"}]},{arity:2,parameters:[{name:"array"},{name:"shift",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]}],outputs:{arity:-2}};static shiftdim=(t,e,...r)=>{d.AST.throwInvalidCallError("shiftdim",!(void 0!==t&&0===r.length));const s=n.MultiArray.scalarOrCellToMultiArray(t);if(void 0===e){const t=x.leadingSingletonDimensions(s.dimension),e=x.shiftDimensions(s,t);return d.AST.nodeBoundedReturnList(2,(r,s)=>0===s?e:i.Complex.create(t))}const a=x.integerScalar(e,"shiftdim","N");return x.shiftDimensions(s,a)};static leadingSingletonDimensions=t=>{let e=0;for(;e<t.length-2&&1===t[e];)e++;return e};static shiftDimensions=(t,e)=>{if(0===e)return t;const r=t.dimension.slice(),s=0===r.length?0:e%r.length,i=e>0?r.slice(s).concat(r.slice(0,s)):new Array(-e).fill(1).concat(r);for(;i.length<2;)i.push(1);return n.MultiArray.reshape(t,i)};static integerVector=(t,e,r)=>n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).map(t=>{if(!i.Complex.isInstanceOf(t))throw new EvalError(`${e}: ${r} must contain integer values.`);const s=i.Complex.realToNumber(t);if(!Number.isInteger(s)||0!==i.Complex.imagToNumber(t)||!Number.isFinite(s))throw new EvalError(`${e}: ${r} must contain integer values.`);return s});static integerScalar=(t,e,r)=>{const s=n.MultiArray.MultiArrayToScalar(t);if(!i.Complex.isInstanceOf(s))throw new EvalError(`${e}: ${r} must be an integer scalar.`);const a=i.Complex.realToNumber(s);if(!Number.isInteger(a)||0!==i.Complex.imagToNumber(s)||!Number.isFinite(a))throw new EvalError(`${e}: ${r} must be an integer scalar.`);return a};static positiveIntegerScalar=(t,e,r)=>{const s=x.integerScalar(t,e,r);if(s<1)throw new EvalError(`${e}: ${r} must be a positive integer scalar.`);return s};static newFilled=(t,e,...r)=>{let s;if(0===r.length)return t;if(1===r.length){const t=n.MultiArray.scalarToMultiArray(r[0]);if(!n.MultiArray.isVector(t))throw new Error(`${e} (A): use ${e} (size (A)) instead.`);s=n.MultiArray.linearize(t).map(t=>i.Complex.realToNumber(t)),1===s.length&&(s[s.length]=s[0])}else s=r.map(t=>{if(n.MultiArray.isInstanceOf(t))throw new Error(`${e}: dimensions must be scalars.`);return i.Complex.realToNumber(t)});return n.MultiArray.MultiArrayToScalar(new n.MultiArray(s,t))};static newFilledEach=(t,...e)=>{let r;if(1===e.length)r=n.MultiArray.linearize(e[0]).map(t=>i.Complex.realToNumber(t));else{if(0===e.length)return t(0);r=e.map(t=>i.Complex.realToNumber(n.MultiArray.firstElement(t)))}1===r.length&&(r[r.length]=r[0]);const s=new n.MultiArray(r);for(let e=0;e<n.MultiArray.linearLength(s);e++){const[r,i]=n.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],e);s.array[r][i]=t(e)}return n.MultiArray.setType(s),n.MultiArray.MultiArrayToScalar(s)};static zerosSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static zeros=(...t)=>x.newFilled(i.Complex.zero(),"zeros",...t);static onesSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static ones=(...t)=>x.newFilled(i.Complex.one(),"ones",...t);static cellSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static cell=(...t)=>{let e;if(0===t.length)return n.MultiArray.emptyArray(!0);if(1===t.length){const r=n.MultiArray.scalarToMultiArray(t[0]);if(!n.MultiArray.isVector(r))throw new Error("cell (A): use cell (size (A)) instead.");e=n.MultiArray.linearize(r).map(t=>i.Complex.realToNumber(t)),1===e.length&&(e[e.length]=e[0])}else e=t.map(t=>{if(n.MultiArray.isInstanceOf(t))throw new Error("cell: dimensions must be scalars.");return i.Complex.realToNumber(t)});return new n.MultiArray(e,()=>n.MultiArray.emptyArray(),!0)};static num2cellSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"dimensions",classes:["double"],validators:["numeric","vector","real","finite","integer","positive"],alternatives:[{name:"dimension",validators:["numeric","scalar","real","finite","integer","positive"]}]}]}],outputs:{arity:1}};static num2cell=(t,e,...r)=>{d.AST.throwInvalidCallError("num2cell",!(void 0!==t&&0===r.length));const a=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.isInstanceOf(t)?t:n.MultiArray.scalarToMultiArray(t);if(void 0===e){const t=new n.MultiArray(a.dimension,void 0,!0);for(let e=0;e<n.MultiArray.linearLength(a);e++){const[r,s]=n.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],e);t.array[r][s]=g.RuntimeValue.copy(a.array[r][s])}return t.isCell=!0,t}const o=[...new Set(n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(e)).map(t=>i.Complex.realToNumber(t)-1))].sort((t,e)=>t-e);if(o.some(t=>t>=a.dimension.length))throw new EvalError("num2cell: DIM must be between 1 and ndims(A).");const l=a.dimension.slice();n.MultiArray.appendSingletonTail(l,Math.max(...o)+1);const c=l.map((t,e)=>o.includes(e)?1:t),u=l.map((t,e)=>o.includes(e)?t:1),h=new n.MultiArray(c,void 0,!0);for(let t=0;t<n.MultiArray.linearLength(h);t++){const e=n.MultiArray.linearIndexToSubscript(c,t),r=new n.MultiArray(u,void 0,a.isCell);for(let t=0;t<n.MultiArray.linearLength(r);t++){const s=n.MultiArray.linearIndexToSubscript(u,t),i=l.map((t,r)=>o.includes(r)?s[r]:e[r]),c=n.MultiArray.subscriptToLinearIndex(l,i),[h,d]=n.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],c),[m,p]=n.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],t);r.array[m][p]=g.RuntimeValue.copy(a.array[h][d])}n.MultiArray.setType(r);const[s,i]=n.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],t);h.array[s][i]=a.isCell?r:n.MultiArray.MultiArrayToScalar(r)}return h.isCell=!0,h};static cell2matSignature={inputs:{arity:1,parameters:[{name:"cellArray",classes:["cell"]}]},outputs:{arity:1}};static cell2mat=(t,...e)=>{d.AST.throwInvalidCallError("cell2mat",!(n.MultiArray.isInstanceOf(t)&&t.isCell&&0===e.length));const r=t;return n.MultiArray.isEmpty(r)?n.MultiArray.emptyArray():n.MultiArray.MultiArrayToScalar(x.cell2matCompose(r))};static cell2matBlock=t=>{if(n.MultiArray.isInstanceOf(t)&&t.isCell)throw new EvalError("cell2mat: nested cell contents are not supported.");return s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarToMultiArray(t)};static cell2matCompose=t=>{const e=[],r=Math.max(t.dimension.length,2),s=t.dimension.slice();n.MultiArray.appendSingletonTail(s,r);const i=s.map(t=>new Array(t));for(let a=0;a<n.MultiArray.linearLength(t);a++){const[o,l]=n.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],a),c=x.cell2matBlock(t.array[o][l]);e[a]=c;const u=c.dimension.slice();n.MultiArray.appendSingletonTail(u,r);const h=n.MultiArray.linearIndexToSubscript(s,a);for(let t=0;t<r;t++){const e=h[t]-1,r=i[t][e];if(void 0===r)i[t][e]=u[t];else if(r!==u[t])throw new EvalError("cell2mat: dimension mismatch")}}const a=i.map(t=>{let e=0;return t.forEach(t=>{e+=t??0}),e}),o=i.map(t=>{let e=0;return t.map(t=>{const r=e;return e+=t??0,r})}),l=new n.MultiArray(a);for(let t=0;t<e.length;t++){const i=e[t],a=i.dimension.slice();n.MultiArray.appendSingletonTail(a,r);const c=n.MultiArray.linearIndexToSubscript(s,t);for(let t=0;t<n.MultiArray.linearLength(i);t++){const e=n.MultiArray.linearIndexToSubscript(a,t).map((t,e)=>o[e][c[e]-1]+t),[r,s]=n.MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],t),[u,h]=n.MultiArray.subscriptToMultiArrayRowColumn(l.dimension,e);l.array[u][h]=g.RuntimeValue.copy(i.array[r][s])}}return n.MultiArray.setType(l),l};static mat2cellSignature={inputs:{arity:-2,min:2,parameters:[{name:"array"},{name:"dimensionSizes",classes:["double"],variadic:!0}]},outputs:{arity:1}};static mat2cell=(t,...e)=>{d.AST.throwInvalidCallError("mat2cell",!(void 0!==t&&e.length>0));const r=s.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):n.MultiArray.scalarToMultiArray(t);if(r.isCell)throw new EvalError("mat2cell: input must not be a cell array.");if(e.length!==r.dimension.length)throw new EvalError("mat2cell: number of dimension vectors must match ndims(A).");const i=e.map((t,e)=>x.mat2cellPartition(t,r.dimension[e],e+2)),a=new n.MultiArray(i.map(t=>t.length),void 0,!0),o=i.map(t=>{let e=0;return t.map(t=>{const r=e;return e+=t,r})});for(let t=0;t<n.MultiArray.linearLength(a);t++){const e=n.MultiArray.linearIndexToSubscript(a.dimension,t),s=e.map((t,e)=>i[e][t-1]),l=new n.MultiArray(s);for(let t=0;t<n.MultiArray.linearLength(l);t++){const s=n.MultiArray.linearIndexToSubscript(l.dimension,t).map((t,r)=>o[r][e[r]-1]+t),i=n.MultiArray.subscriptToLinearIndex(r.dimension,s),[a,c]=n.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],i),[u,h]=n.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[u][h]=g.RuntimeValue.copy(r.array[a][c])}n.MultiArray.setType(l);const[c,u]=n.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);a.array[c][u]=n.MultiArray.MultiArrayToScalar(l)}return a.isCell=!0,a};static mat2cellPartition=(t,e,r)=>{const s=n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(t)).map(t=>{if(!i.Complex.isInstanceOf(t))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);const e=i.Complex.realToNumber(t);if(!Number.isInteger(e)||e<0||0!==i.Complex.imagToNumber(t))throw new EvalError(`mat2cell: argument ${r} must contain nonnegative integer sizes.`);return e});if(s.reduce((t,e)=>t+e,0)!==e)throw new EvalError(`mat2cell: argument ${r} dimensions do not sum to input size.`);return s};static randSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static rand=(...t)=>x.newFilledEach(()=>i.Complex.random(),...t);static randiSignature={inputs:[{arity:1,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]}]},{arity:2,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],alternatives:[{name:"dimensions",validators:["numeric","vector","real","finite","integer","nonnegative"]}]}]},{arity:-3,min:3,parameters:[{name:"range",alternatives:[{name:"imax",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"bounds",classes:["double"],validators:["numeric","vector","twoElement","real","finite","integer"]}]},{name:"dimension",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],variadic:!0}]}],outputs:{arity:1}};static randi=(t,...e)=>{let r,s;if(n.MultiArray.isInstanceOf(t)){const e=n.MultiArray.linearize(t);if(2===e.length)r=e[0],s=e[1];else{if(!(e.length>0))throw new Error("bounds(1): out of bound 0 (dimensions are 0x0)");r=i.Complex.zero(),s=e[0]}}else r=i.Complex.zero(),s=t;if(!i.Complex.realIsInteger(r)||!i.Complex.realIsInteger(s))throw new Error("randi: must be integer bounds.");if(i.Complex.gt(s,r))return x.newFilledEach(i.Complex.realEquals(r,0)?()=>i.Complex.round(i.Complex.mul(s,i.Complex.random())):()=>i.Complex.round(i.Complex.add(i.Complex.mul(i.Complex.sub(s,r),i.Complex.random()),r)),...e);throw i.Complex.realEquals(r,0)?new Error("randi: require imax >= 1."):new Error("randi: require imax > imin.")};static catSignature={inputs:{arity:-2,min:2,parameters:[{name:"dimension",classes:["double"],validators:["dimension","positive"]},{name:"array",variadic:!0}]},outputs:{arity:1}};static cat=(t,...e)=>(x.validateObjectArrayConcatenation("cat",e),n.MultiArray.concatenate(i.Complex.realToNumber(n.MultiArray.firstElement(t))-1,"cat",...e.map(t=>n.MultiArray.scalarToMultiArray(t))));static horzcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}};static horzcat=(...t)=>0===t.length?n.MultiArray.emptyArray():(x.validateObjectArrayConcatenation("horzcat",t),n.MultiArray.concatenate(1,"horzcat",...t.map(t=>n.MultiArray.scalarToMultiArray(t))));static vertcatSignature={inputs:{arity:-1,min:0,parameters:[{name:"array",variadic:!0}]},outputs:{arity:1}};static vertcat=(...t)=>0===t.length?n.MultiArray.emptyArray():(x.validateObjectArrayConcatenation("vertcat",t),n.MultiArray.concatenate(0,"vertcat",...t.map(t=>n.MultiArray.scalarToMultiArray(t))));static allSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static all=n.MultiArray.reduceFactory((t,e)=>i.Complex.and(t,e),"reduce",i.Complex.one());static anySignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static any=n.MultiArray.reduceFactory((t,e)=>i.Complex.or(t,e),"reduce",i.Complex.zero());static sumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static sum=n.MultiArray.reduceFactory((t,e)=>i.Complex.add(t,e),"reduce",i.Complex.zero());static prodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static prod=n.MultiArray.reduceFactory((t,e)=>i.Complex.mul(t,e),"reduce",i.Complex.one());static sumsqSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static sumsq=n.MultiArray.reduceFactory((t,e)=>i.Complex.add(t,i.Complex.mul(e,e)),"reduce",i.Complex.zero());static cumsumSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static cumsum=n.MultiArray.reduceFactory((t,e)=>i.Complex.add(t,e),"cumulative");static cumprodSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static cumprod=n.MultiArray.reduceFactory((t,e)=>i.Complex.mul(t,e),"cumulative");static minSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}};static min=n.MultiArray.reduceFactory("lt","comparison");static maxSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"valueOrDimension",classes:["double"]}]},{arity:3,parameters:[{name:"value"},{name:"empty",classes:["double"],validators:["empty"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:-2}};static max=n.MultiArray.reduceFactory("gt","comparison");static cumminSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}};static cummin=n.MultiArray.reduceFactory("lt","cumcomparison");static cummaxSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:-2}};static cummax=n.MultiArray.reduceFactory("gt","cumcomparison");static meanSignature={inputs:{arity:-2,min:1,max:2,parameters:[{name:"value"},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static mean=(t,e)=>{const r=n.MultiArray.scalarToMultiArray(t),s=void 0!==e?i.Complex.realToNumber(n.MultiArray.firstElement(e))-1:n.MultiArray.firstNonSingleDimension(r),a=x.sum(r,i.Complex.create(s+1)),o=i.Complex.create(r.dimension[s]);return n.MultiArray.divideElementByScalar(a,o)};static varianceSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static variance=(t,e,r)=>{const s=n.MultiArray.scalarToMultiArray(t);let a,o=0;if(void 0!==e){const t=n.MultiArray.firstElement(e);if(void 0===r&&i.Complex.realIsInteger(t)&&i.Complex.realToNumber(t)>1)a=i.Complex.realToNumber(t)-1;else if(void 0!==r){o=1===i.Complex.realToNumber(t)?1:0;const e=n.MultiArray.firstElement(r);a=n.MultiArray.testInteger(e,"var","DIM",[1,1/0])-1}else o=1===i.Complex.realToNumber(t)?1:0,a=n.MultiArray.firstNonSingleDimension(s)}else if(void 0!==r){const t=n.MultiArray.firstElement(r);a=n.MultiArray.testInteger(t,"var","DIM",[1,1/0])-1}else a=n.MultiArray.firstNonSingleDimension(s);const l=s.dimension[a];if(l<=1)return i.Complex.zero();const c=n.MultiArray.reduce(a,s,(t,e)=>i.Complex.add(t,e),i.Complex.zero()),u=n.MultiArray.divideElementByScalar(c,i.Complex.create(l));let h;n.MultiArray.isInstanceOf(c)?h=c.dimension.slice():(h=s.dimension.slice(),h[a]=1);const d=new n.MultiArray(h),m=h.length>2?h.slice(2).reduce((t,e)=>t*e,1):1,p=h[0]*Math.max(1,m),f=h[1]??1;d.array=new Array(p);for(let t=0;t<p;t++)d.array[t]=new Array(f);const g=s.dimension.reduce((t,e)=>t*e,1);for(let t=0;t<g;t++){const e=n.MultiArray.linearIndexToSubscript(s.dimension,t).slice();let r;if(e[a]=1,n.MultiArray.isInstanceOf(u)){const t=u,s=n.MultiArray.subscriptToLinearIndex(t.dimension,e),[i,a]=n.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);r=t.array[i][a]}else r=u;const[o,l]=n.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t),c=s.array[o][l],m=i.Complex.sub(c,r),p=i.Complex.mul(m,m),f=n.MultiArray.subscriptToLinearIndex(h,e),[g,y]=n.MultiArray.linearIndexToMultiArrayRowColumn(h[0],h[1],f),x=d.array[g][y];d.array[g][y]=null==x?i.Complex.copy(p):i.Complex.add(x,p)}const y=i.Complex.create(l-(0===o?1:0)),x=n.MultiArray.divideElementByScalar(d,y);return n.MultiArray.isInstanceOf(x)&&n.MultiArray.setType(x),x};static stdSignature={inputs:[{arity:1,parameters:[{name:"value"}]},{arity:2,parameters:[{name:"value"},{name:"flagOrDimension",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"],alternatives:[{name:"dimension",validators:["dimensionGreaterThanOne"]}]}]},{arity:3,parameters:[{name:"value"},{name:"flag",classes:["double"],validators:["numeric","scalar","real","finite","zeroOrOne"]},{name:"dimension",classes:["double"],validators:["dimension","positive"]}]}],outputs:{arity:1}};static std=(t,e,r)=>{const s=x.variance(t,e,r);if(n.MultiArray.isInstanceOf(s)){const t=n.MultiArray.rawMap(s,t=>i.Complex.sqrt(t));return n.MultiArray.setType(t),t}return i.Complex.sqrt(s)};static structSignature={inputs:[{arity:1,parameters:[{name:"structOrEmptyArray",alternatives:[{name:"field",classes:["char","string"]},{name:"struct",classes:["struct"]},{name:"emptyArray",classes:["double","cell","array"]}]}]},{arity:-1,min:0,parameters:[{name:"field",variadic:!0,variadicGroup:[{name:"field",classes:["char","string"]},{name:"value"}]}]}],outputs:{arity:1}};static struct=(...t)=>{const e='struct: additional arguments must occur as "field", VALUE pairs';if(0===t.length)return new a.Structure({});if(1===t.length){if(n.MultiArray.isInstanceOf(t[0])&&n.MultiArray.isEmpty(t[0]))return n.MultiArray.emptyArray();if(a.Structure.isInstanceOf(t[0]))return t[0].copy();throw new Error(e)}{if(t.length%2!=0)throw new Error(e);const r={};for(let i=0;i<t.length;i+=2){if(!s.CharString.isInstanceOf(t[i]))throw new Error(e);{const s=(0,p.runtimeExpressionValue)(t[i+1],t[i].str,"struct field",()=>{throw new Error(e)});r[t[i].str]=s}}return new a.Structure(r)}};static substructSignature={inputs:{arity:-1,min:2,parameters:[{name:"typeAndSubscript",variadic:!0,variadicGroup:[{name:"type",classes:["char","string"]},{name:"subscript"}]}]},outputs:{arity:1}};static substruct=(...t)=>{const e="substruct: arguments must occur as TYPE, SUBS pairs";if(t.length<2||t.length%2!=0)throw new Error(e);const r=[];for(let i=0;i<t.length;i+=2){const n=t[i],a=t[i+1];if(!s.CharString.isInstanceOf(n))throw new Error(e);r.push(x.createSubstructDescriptor(n.str,a))}return 1===r.length?r[0]:n.MultiArray.firstRow(r)};static createSubstructDescriptor=(t,e)=>{switch(t){case".":if(!s.CharString.isInstanceOf(e))throw new Error("substruct: dot subscripts must be character strings.");return new a.Structure({type:s.CharString.create(t),subs:e.copy()});case"()":case"{}":if(!n.MultiArray.isInstanceOf(e)||!e.isCell)throw new Error(`substruct: ${t} subscripts must be supplied as a cell array.`);return new a.Structure({type:s.CharString.create(t),subs:e.copy()});default:throw new Error("substruct: TYPE must be '.', '()', or '{}'.")}};static normSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"order",alternatives:[{name:"numericOrder",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusOrder",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}};static isNonVectorMatrix2d=t=>n.MultiArray.isInstanceOf(t)&&2===t.dimension.length&&t.dimension[0]>1&&t.dimension[1]>1;static matrixNorm1=t=>{let e=0;for(let r=0;r<t.dimension[1];r++){let s=0;for(let e=0;e<t.dimension[0];e++)s+=i.Complex.realToNumber(i.Complex.abs(t.array[e][r]));e=Math.max(e,s)}return i.Complex.create(e)};static matrixNormInf=t=>{let e=0;for(let r=0;r<t.dimension[0];r++){let s=0;for(let e=0;e<t.dimension[1];e++)s+=i.Complex.realToNumber(i.Complex.abs(t.array[r][e]));e=Math.max(e,s)}return i.Complex.create(e)};static matrixNorm2=t=>{const e=t.dimension[1],r=Array.from({length:e},()=>Array.from({length:e},()=>i.Complex.zero()));for(let s=0;s<e;s++)for(let n=s;n<e;n++){let e=i.Complex.zero();for(let r=0;r<t.dimension[0];r++)e=i.Complex.add(e,i.Complex.mul(i.Complex.conj(t.array[r][s]),t.array[r][n]));r[s][n]=e,r[n][s]=s===n?e:i.Complex.conj(e)}const{D:s}=y.LAPACK.jacobi_symmetric_hermitian(r,1e3,1e-14),n=s.reduce((t,e)=>Math.max(t,i.Complex.realToNumber(e)),0);return i.Complex.sqrt(i.Complex.create(Math.max(0,n)))};static norm=(...t)=>{d.AST.throwInvalidCallError("norm",t.length<1||t.length>2);const e=t[0],r=n.MultiArray.linearize(n.MultiArray.scalarToMultiArray(e)).map(t=>i.Complex.abs(t)),a=2===t.length?t[1]:i.Complex.create(2);if(s.CharString.isInstanceOf(a))return"fro"!==a.str&&d.AST.throwInvalidCallError("norm"),i.Complex.sqrt(r.reduce((t,e)=>i.Complex.add(t,i.Complex.mul(e,e)),i.Complex.zero()));const o=i.Complex.realToNumber(n.MultiArray.firstElement(a));if(o===1/0)return x.isNonVectorMatrix2d(e)?x.matrixNormInf(e):r.reduce((t,e)=>i.Complex.realToNumber(e)>i.Complex.realToNumber(t)?e:t,i.Complex.zero());if(o===-1/0)return x.isNonVectorMatrix2d(e)&&d.AST.throwInvalidCallError("norm"),0===r.length?i.Complex.zero():r.reduce((t,e)=>i.Complex.realToNumber(e)<i.Complex.realToNumber(t)?e:t,i.Complex.inf_0());if(1===o)return x.isNonVectorMatrix2d(e)?x.matrixNorm1(e):r.reduce((t,e)=>i.Complex.add(t,e),i.Complex.zero());if(2===o)return x.isNonVectorMatrix2d(e)?x.matrixNorm2(e):i.Complex.sqrt(r.reduce((t,e)=>i.Complex.add(t,i.Complex.mul(e,e)),i.Complex.zero()));if(o>0&&Number.isFinite(o)){x.isNonVectorMatrix2d(e)&&d.AST.throwInvalidCallError("norm");const t=r.reduce((t,e)=>i.Complex.add(t,i.Complex.power(e,i.Complex.create(o))),i.Complex.zero());return i.Complex.power(t,i.Complex.create(1/o))}d.AST.throwInvalidCallError("norm")};static functions={isempty:{func:x.isempty,signature:x.isemptySignature},isscalar:{func:x.isscalar,signature:x.isscalarSignature},ismatrix:{func:x.ismatrix,signature:x.ismatrixSignature},isvector:{func:x.isvector,signature:x.isvectorSignature},iscell:{func:x.iscell,signature:x.iscellSignature},isrow:{func:x.isrow,signature:x.isrowSignature},iscolumn:{func:x.iscolumn,signature:x.iscolumnSignature},isstruct:{func:x.isstruct,signature:x.isstructSignature},issparse:{func:x.issparse,signature:x.issparseSignature},full:{func:x.full,signature:x.fullSignature},sparse:{func:x.sparse,signature:x.sparseSignature},spalloc:{func:x.spalloc,signature:x.spallocSignature},nnz:{func:x.nnz,signature:x.nnzSignature},nzmax:{func:x.nzmax,signature:x.nzmaxSignature},nonzeros:{func:x.nonzeros,signature:x.nonzerosSignature},ischar:{func:x.ischar,signature:x.ischarSignature},isstring:{func:x.isstring,signature:x.isstringSignature},iscellstr:{func:x.iscellstr,signature:x.iscellstrSignature},cellstr:{func:x.cellstr,signature:x.cellstrSignature},char:{func:x.char,signature:x.charSignature},double:{func:x.double,signature:x.doubleSignature},logical:{func:x.logical,signature:x.logicalSignature},isnan:{func:x.isnan,signature:x.isnanSignature},isinf:{func:x.isinf,signature:x.isinfSignature},isfinite:{func:x.isfinite,signature:x.isfiniteSignature},isfloat:{func:x.isfloat,signature:x.isfloatSignature},isinteger:{func:x.isinteger,signature:x.isintegerSignature},isnumeric:{func:x.isnumeric,signature:x.isnumericSignature},islogical:{func:x.islogical,signature:x.islogicalSignature},isreal:{func:x.isreal,signature:x.isrealSignature},isvalid:{func:x.isvalid,signature:x.isvalidSignature},isobject:{func:x.isobject,signature:x.isobjectSignature},properties:{func:x.properties,signature:x.propertiesSignature},fieldnames:{func:x.fieldnames,signature:x.fieldnamesSignature},isfield:{func:x.isfield,signature:x.isfieldSignature},methods:{func:x.methods,signature:x.methodsSignature},events:{func:x.events,signature:x.eventsSignature},enumeration:{func:x.enumeration,signature:x.enumerationSignature},superclasses:{func:x.superclasses,signature:x.superclassesSignature},isprop:{func:x.isprop,signature:x.ispropSignature},ismethod:{func:x.ismethod,signature:x.ismethodSignature},isequal:{func:x.isequal,signature:x.isequalSignature},ndims:{func:x.ndims,signature:x.ndimsSignature},rows:{func:x.rows,signature:x.rowsSignature},columns:{func:x.columns,signature:x.columnsSignature},length:{func:x.Length,signature:x.lengthSignature},numel:{func:x.numel,signature:x.numelSignature},find:{func:x.find,signature:x.findSignature},sort:{func:x.sort,signature:x.sortSignature},ind2sub:{func:x.ind2sub,signature:x.ind2subSignature},sub2ind:{func:x.sub2ind,signature:x.sub2indSignature},size:{func:x.size,signature:x.sizeSignature},colon:{func:x.colon,signature:x.colonSignature},linspace:{func:x.linspace,signature:x.linspaceSignature},logspace:{func:x.logspace,signature:x.logspaceSignature},meshgrid:{func:x.meshgrid,signature:x.meshgridSignature},ndgrid:{func:x.ndgrid,signature:x.ndgridSignature},repmat:{func:x.repmat,signature:x.repmatSignature},reshape:{func:x.reshape,signature:x.reshapeSignature},squeeze:{func:x.squeeze,signature:x.squeezeSignature},flip:{func:x.flip,signature:x.flipSignature},fliplr:{func:x.fliplr,signature:x.fliplrSignature},flipud:{func:x.flipud,signature:x.flipudSignature},rot90:{func:x.rot90,signature:x.rot90Signature},permute:{func:x.permute,signature:x.permuteSignature},ipermute:{func:x.ipermute,signature:x.ipermuteSignature},circshift:{func:x.circshift,signature:x.circshiftSignature},shiftdim:{func:x.shiftdim,signature:x.shiftdimSignature},zeros:{func:x.zeros,signature:x.zerosSignature},ones:{func:x.ones,signature:x.onesSignature},cell:{func:x.cell,signature:x.cellSignature},num2cell:{func:x.num2cell,signature:x.num2cellSignature},cell2mat:{func:x.cell2mat,signature:x.cell2matSignature},mat2cell:{func:x.mat2cell,signature:x.mat2cellSignature},rand:{func:x.rand,signature:x.randSignature},randi:{func:x.randi,signature:x.randiSignature},cat:{func:x.cat,signature:x.catSignature},horzcat:{func:x.horzcat,signature:x.horzcatSignature},vertcat:{func:x.vertcat,signature:x.vertcatSignature},all:{func:x.all,signature:x.allSignature},any:{func:x.any,signature:x.anySignature},sum:{func:x.sum,signature:x.sumSignature},prod:{func:x.prod,signature:x.prodSignature},sumsq:{func:x.sumsq,signature:x.sumsqSignature},max:{func:x.max,signature:x.maxSignature},min:{func:x.min,signature:x.minSignature},mean:{func:x.mean,signature:x.meanSignature},cumsum:{func:x.cumsum,signature:x.cumsumSignature},cumprod:{func:x.cumprod,signature:x.cumprodSignature},cummin:{func:x.cummin,signature:x.cumminSignature},cummax:{func:x.cummax,signature:x.cummaxSignature},var:{func:x.variance,signature:x.varianceSignature},std:{func:x.std,signature:x.stdSignature},struct:{func:x.struct,signature:x.structSignature},getfield:{func:x.getfield,signature:x.getfieldSignature},setfield:{func:x.setfield,signature:x.setfieldSignature},rmfield:{func:x.rmfield,signature:x.rmfieldSignature},orderfields:{func:x.orderfields,signature:x.orderfieldsSignature},numfields:{func:x.numfields,signature:x.numfieldsSignature},struct2cell:{func:x.struct2cell,signature:x.struct2cellSignature},cell2struct:{func:x.cell2struct,signature:x.cell2structSignature},substruct:{func:x.substruct,signature:x.substructSignature},norm:{func:x.norm,signature:x.normSignature}}}e.CoreFunctions=x,e.default={CoreFunctions:x}},4087(t,e,r){"use strict";e.DiagnosticMessage=void 0;const s=r(5956),i=r(845),n=r(7679);e.DiagnosticMessage=class{static formatArgument(t,e,r){const a=r.expressionValue(t,"diagnostic format argument");if("s"===e)return s.CharString.isInstanceOf(a)?a.str:r.unparse(a).trimEnd();const o=n.MultiArray.isInstanceOf(a)?n.MultiArray.MultiArrayToScalar(a):a;i.Complex.isInstanceOf(o)&&i.Complex.imagIsZero(o)||r.throwEvalError("diagnostic format argument must be a real numeric scalar.");const l=i.Complex.realToNumber(o);switch(e){case"d":case"i":return Math.trunc(l).toString();case"f":return l.toFixed(6);case"g":return l.toString();default:return r.unparse(a).trimEnd()}}static format(t,e,r){let s=0;return t.replace(/%([-+0 #]*)(\d*)(?:\.(\d+))?([sdifg%])/g,(t,a,o,l,c)=>{if("%"===c)return"%";if(s>=e.length&&r.throwEvalError("not enough arguments for diagnostic format string."),"f"===c&&void 0!==l){const t=r.expressionValue(e[s++],"diagnostic format argument"),a=n.MultiArray.isInstanceOf(t)?n.MultiArray.MultiArrayToScalar(t):t;return i.Complex.isInstanceOf(a)&&i.Complex.imagIsZero(a)||r.throwEvalError("diagnostic format argument must be a real numeric scalar."),i.Complex.realToNumber(a).toFixed(Number(l))}return this.formatArgument(e[s++],c,r)})}static parts(t,e,r,i){const n=r(t[0],`${e} identifier or message`);if(t.length>=2){const r=i.expressionValue(t[1],`${e} message`);if(n.str.includes(":")&&s.CharString.isInstanceOf(r))return{identifier:n.str,message:this.format(r.str,t.slice(2),i)}}return{identifier:"",message:this.format(n.str,t.slice(1),i)}}}},8146(t,e,r){"use strict";e.optionalRuntimeExpressionValue=e.runtimeExpressionValue=e.expressionValues=e.expressionValue=void 0;const s=r(6109),i=(t,e,r,i)=>(s.AST.isExpressionBoundaryValue(t)||i(`${r} '${e}' is not an expression.`),t);e.expressionValue=i,e.expressionValues=(t,e,r,s)=>t.map((t,n)=>i(t,`${e}${n+1}`,r,s));e.runtimeExpressionValue=(t,e,r,n)=>(i(t,e,r,n),s.AST.isRuntimeExpressionValue(t)||n(`${r} '${e}' is not a runtime value.`),t),e.optionalRuntimeExpressionValue=t=>s.AST.isRuntimeExpressionValue(t)?t:void 0},8989(t,e,r){"use strict";e.FunctionArguments=void 0;const s=r(6109),i=r(5956),n=r(845),a=r(7679),o=r(9170),l=r(1604),c=r(8146),u=r(7673);class h{static isIdentifier(t){return s.AST.isNodeIdentifier(t)}static isDefaultedIdentifier(t){return s.AST.isNodeDefaultedParameter(t)}static parameterName(t){return this.isIdentifier(t)?t.id:this.isDefaultedIdentifier(t)?t.left.id:void 0}static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static runtimeArgumentValue(t,e,r){return(0,c.runtimeExpressionValue)(t,e,"Argument value",r)}static functionParameters(t){return this.checkedList(t.parameter.list,s.AST.isNodeFunctionParameter,"function parameter")}static functionReturns(t){return this.checkedList(t.return.list,s.AST.isNodeFunctionReturn,"function return")}static argumentBlocks(t){return this.checkedList(t.arguments.list,s.AST.isNodeArguments,"function arguments block")}static argumentValidations(t){return this.checkedList(t.validation,s.AST.isNodeArgumentValidation,"arguments validation")}static supportedArgumentValidators=new Set(["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal"]);static supportedComparatorValidators=new Set(["mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual"]);static supportedRangeValidators=new Set(["mustBeInRange","mustBeBetween"]);static supportedMembershipValidators=new Set(["mustBeMember"]);static supportedClassRelationshipValidators=new Set(["mustBeA","mustBeUnderlyingType"]);static supportedRangeOptions=new Set(["inclusive","exclude-lower","exclude-upper","exclude-both"]);static supportedBetweenOptions=new Set(["closed","open","openleft","openright","closedleft","closedright"]);static supportedBlockAttributes=new Set(["Input","Output","Repeating"]);static blockAttributeNames(t){return t.attributes?.length?t.attributes.map(t=>t.id):t.attribute?[t.attribute.id]:[]}static blockKind(t,e){const r=this.blockAttributeNames(t);if(0===r.length)return"Input";const s=new Set;for(const t of r)this.supportedBlockAttributes.has(t)||e(`unsupported arguments block attribute '${t}'.`),s.has(t)&&e(`duplicate arguments block attribute '${t}'.`),s.add(t);const i=s.has("Input"),n=s.has("Output"),a=s.has("Repeating");return i&&n&&e("arguments block attributes 'Input' and 'Output' cannot be combined."),(s.size>2||!i&&!n&&!a)&&e(`unsupported arguments block attribute list '${r.join(",")}'.`),a&&n?"OutputRepeating":a?"Repeating":n?"Output":"Input"}static argumentSizeDimensionDisplay(t){return"number"==typeof t?String(t):"any"===t.type?":":t.name}static argumentSizeDisplay(t){const e=t.map(t=>this.argumentSizeDimensionDisplay(t));return t.some(t=>"number"!=typeof t&&"any"===t.type)?`(${e.join(",")})`:e.join("x")}static literalNumericSize(t,e,r){n.Complex.isInstanceOf(t)&&n.Complex.realIsInteger(t)&&n.Complex.imagIsZero(t)||r(`arguments block size validation for '${e}' must use positive integer, symbolic, or ':' dimensions.`);const s=n.Complex.realToNumber(t);return s<1&&r(`arguments block size validation for '${e}' must use positive integer dimensions.`),s}static validationName(t,e){const r=t.name;return s.AST.isNodeIdentifier(r)||e("arguments block declaration must be an identifier."),r.id}static nameValueTarget(t,e){const r=t.name;if(s.AST.isNodeIndirectRef(r))return s.AST.isNodeIdentifier(r.obj)&&1===r.field.length&&"string"==typeof r.field[0]||e("arguments block name-value declaration must be a single dotted identifier."),{parameter:r.obj.id,field:r.field[0]}}static validationDisplayName(t,e){const r=this.nameValueTarget(t,e);return r?`${r.parameter}.${r.field}`:this.validationName(t,e)}static nameValueReferenceDisplay(t,e,r,i=new WeakSet){if(null!==t&&"object"==typeof t&&!i.has(t)){if(i.add(t),s.AST.isNodeIdentifier(t)&&e.has(t.id))return t.id;if(s.AST.isNodeIndirectRef(t)&&s.AST.isNodeIdentifier(t.obj)&&e.has(t.obj.id)){const e=t.field[0],s="string"==typeof e?`${t.obj.id}.${e}`:t.obj.id;return s===r?void 0:s}if(s.AST.isNodeIndexExpr(t))return this.nameValueReferenceDisplay(t.expr,e,r,i)??this.firstNameValueReferenceDisplay(t.args,e,r,i);if(s.AST.isNodeRange(t))return this.nameValueReferenceDisplay(t.start_,e,r,i)??this.nameValueReferenceDisplay(t.stop_,e,r,i)??this.nameValueReferenceDisplay(t.stride_,e,r,i);if(s.AST.isNodeBinaryOperation(t))return this.nameValueReferenceDisplay(t.left,e,r,i)??this.nameValueReferenceDisplay(t.right,e,r,i);if(s.AST.isNodePrefixOperation(t))return this.nameValueReferenceDisplay(t.right,e,r,i);if(s.AST.isNodePostfixOperation(t))return this.nameValueReferenceDisplay(t.left,e,r,i);if(s.AST.isNodeSuperclassConstructor(t))return this.nameValueReferenceDisplay(t.instance,e,r,i)??this.firstNameValueReferenceDisplay(t.args,e,r,i);if(!s.AST.isNodeMetaClass(t))return s.AST.isNodeList(t)?this.firstNameValueReferenceDisplay(t.list,e,r,i):a.MultiArray.isInstanceOf(t)?this.firstNameValueReferenceDisplay(a.MultiArray.linearize(t),e,r,i):void 0}}static firstNameValueReferenceDisplay(t,e,r,s=new WeakSet){for(const i of t){const t=this.nameValueReferenceDisplay(i,e,r,s);if(t)return t}}static literalArgumentSize(t,e){if(!t.size.some(t=>void 0!==t))return;const r=this.validationDisplayName(t,e);return t.size.map(t=>s.AST.isNodeIdentifier(t)?{type:"symbol",name:t.id}:":"===t?.type?{type:"any"}:h.literalNumericSize(t,r,e))}static argumentClassNames(t,e){const r=t.class;if(!r||s.AST.isNodeList(r)&&0===r.list.length)return;const i=this.validationDisplayName(t,e),n=s.AST.isNodeList(r)?r.list:[r];n.every(s.AST.isNodeIdentifier)||e(`arguments block class validation for '${i}' must use class identifiers.`);const a=n.map(t=>t.id);return[...new Set(a)]}static argumentClassName(t,e){const r=this.argumentClassNames(t,e);return r&&1===r.length?r[0]:void 0}static argumentClassDisplay(t){return 1===t.length?t[0]:t.slice(0,-1).join(", ")+" or "+t[t.length-1]}static argumentValidators(t,e){const r=this.validationDisplayName(t,e);return t.functions.map(t=>s.AST.isNodeIdentifier(t)&&this.supportedArgumentValidators.has(t.id)?{name:t.id}:s.AST.isNodeIdentifier(t)?{name:t.id,custom:"implicit"}:s.AST.isNodeIndexExpr(t)&&"()"===t.delim&&s.AST.isNodeIdentifier(t.expr)&&this.supportedComparatorValidators.has(t.expr.id)&&2===t.args.length?{name:t.expr.id,value:t.args[0],bounds:[t.args[1]]}:s.AST.isNodeIndexExpr(t)&&"()"===t.delim&&s.AST.isNodeIdentifier(t.expr)&&this.supportedRangeValidators.has(t.expr.id)&&(3===t.args.length||4===t.args.length)?{name:t.expr.id,value:t.args[0],bounds:t.args.slice(1)}:s.AST.isNodeIndexExpr(t)&&"()"===t.delim&&s.AST.isNodeIdentifier(t.expr)&&this.supportedMembershipValidators.has(t.expr.id)&&2===t.args.length||s.AST.isNodeIndexExpr(t)&&"()"===t.delim&&s.AST.isNodeIdentifier(t.expr)&&this.supportedClassRelationshipValidators.has(t.expr.id)&&2===t.args.length?{name:t.expr.id,value:t.args[0],bounds:[t.args[1]]}:(s.AST.isNodeIndexExpr(t)&&s.AST.isNodeIdentifier(t.expr)&&(this.supportedComparatorValidators.has(t.expr.id)||this.supportedRangeValidators.has(t.expr.id)||this.supportedMembershipValidators.has(t.expr.id)||this.supportedClassRelationshipValidators.has(t.expr.id))&&e(`arguments block function validation for '${r}' has invalid ${t.expr.id} arguments.`),s.AST.isNodeIndexExpr(t)&&"()"===t.delim&&s.AST.isNodeIdentifier(t.expr)?{name:t.expr.id,custom:"explicit",expression:t}:void e(`arguments block function validation for '${r}' must be a validator identifier or function call.`)))}static valueSize(t){return l.RuntimeValue.dimensions(t)}static textElements(t){if(i.CharString.isInstanceOf(t))return[t.str];if(a.MultiArray.isInstanceOf(t)){const e=a.MultiArray.linearize(t);return e.every(i.CharString.isInstanceOf)?e.map(t=>t.str):void 0}}static classNameElements(t){const e=this.textElements(t);if(e&&0!==e.length&&!e.some(t=>0===t.length))return[...new Set(e)]}static membershipElements(t){return a.MultiArray.isInstanceOf(t)?a.MultiArray.linearize(t).map(t=>this.runtimeArgumentValue(t,"mustBeMember element",t=>{throw new EvalError(t)})):[t]}static validateArgumentFunction(t,e,r,s,a,l,c={},h="arguments block"){const d=o.FunctionValidation.numericElements(e),m=()=>a(`${h} validation failed for '${t}': ${r}.`),p=(t=0)=>{const e=s[t],r=void 0!==e?o.FunctionValidation.numericElements(e):void 0;return r&&1===r.length&&n.Complex.imagIsZero(r[0])||m(),n.Complex.realToNumber(r[0])},f=(t,e=0)=>{const r=p(e);return Boolean(d&&d.every(e=>n.Complex.imagIsZero(e)&&t(e,r)))},g=o.FunctionValidation.builtInValidatorForArgumentValidator(r);if(g)o.FunctionValidation.matchesBuiltInValidator(e,g)||m();else switch(r){case"mustBeFile":{const t=o.FunctionValidation.matchesBuiltInValidator(e,"textScalar")?this.textElements(e):void 0;return void(t&&1===t.length&&c.fileExists&&c.fileExists(t[0])||m())}case"mustBeFolder":{const t=o.FunctionValidation.matchesBuiltInValidator(e,"text")?this.textElements(e):void 0;return void(t&&0!==t.length&&c.folderExists&&t.every(c.folderExists)||m())}case"mustBeOdd":return void(d&&d.every(t=>n.Complex.realIsInteger(t)&&n.Complex.imagIsZero(t)&&1===Math.abs(n.Complex.realToNumber(t)%2))||m());case"mustBeGreaterThan":return void(f((t,e)=>n.Complex.realGreaterThan(t,e))||m());case"mustBeGreaterThanOrEqual":return void(f((t,e)=>n.Complex.realGreaterThanOrEqualTo(t,e))||m());case"mustBeLessThan":return void(f((t,e)=>n.Complex.realLessThan(t,e))||m());case"mustBeLessThanOrEqual":return void(f((t,e)=>n.Complex.realLessThanOrEqualTo(t,e))||m());case"mustBeInRange":{const t=p(0),e=p(1),r=s[2],a=void 0===r?"inclusive":i.CharString.isInstanceOf(r)?r.str:void 0;void 0!==a&&this.supportedRangeOptions.has(a)||m();const o="exclude-lower"===a||"exclude-both"===a?e=>n.Complex.realGreaterThan(e,t):e=>n.Complex.realGreaterThanOrEqualTo(e,t),l="exclude-upper"===a||"exclude-both"===a?t=>n.Complex.realLessThan(t,e):t=>n.Complex.realLessThanOrEqualTo(t,e);return void(d&&d.every(t=>n.Complex.imagIsZero(t)&&o(t)&&l(t))||m())}case"mustBeBetween":{const t=p(0),e=p(1),r=s[2],a=void 0===r?"closed":i.CharString.isInstanceOf(r)?r.str:void 0;void 0!==a&&this.supportedBetweenOptions.has(a)||m();const o="open"===a||"openleft"===a||"closedright"===a?e=>n.Complex.realGreaterThan(e,t):e=>n.Complex.realGreaterThanOrEqualTo(e,t),l="open"===a||"openright"===a||"closedleft"===a?t=>n.Complex.realLessThan(t,e):t=>n.Complex.realLessThanOrEqualTo(t,e);return void(d&&d.every(t=>n.Complex.imagIsZero(t)&&o(t)&&l(t))||m())}case"mustBeMember":{const t=o.FunctionValidation.numericElements(s[0]);if(d&&t)return void(d.every(e=>t.some(t=>n.Complex.imagEquals(e,n.Complex.imagToNumber(t))&&n.Complex.realEquals(e,n.Complex.realToNumber(t))))||m());const r=this.textElements(e),i=this.textElements(s[0]);if(r&&i)return void(r.every(t=>i.includes(t))||m());const a=this.membershipElements(e),l=this.membershipElements(s[0]);if(a.every(t=>l.some(e=>u.RuntimeEquality.valuesEqual(t,e))))return;return void m()}default:l(`${h} function validation for '${t}' uses unsupported validator '${r}'.`)}}static validateArgumentValidation(t,e,r,i=!1,n=this.validationDisplayName(t,r.throwSyntaxError),l="arguments block"){const c=this.literalArgumentSize(t,r.throwSyntaxError),u=this.argumentClassNames(t,r.throwSyntaxError),h=this.argumentValidators(t,r.throwSyntaxError);if(!c&&!u&&0===h.length)return;const d=r.resolveEntry(t,i);let m;d&&void 0!==d.node||r.throwEvalError(`'${n}' undefined.`);const p=()=>m??=this.runtimeArgumentValue(d.node,n,r.throwEvalError);if(c){const t=this.valueSize(p()),s=Math.max(c.length,t.length);s>c.length&&c.push(...new Array(s-c.length).fill(1)),a.MultiArray.appendSingletonTail(t,s),c.every((r,s)=>{if("number"==typeof r)return r===t[s];if("any"===r.type)return!0;const i=e.get(r.name);return void 0===i?(e.set(r.name,t[s]),!0):i===t[s]})||r.throwEvalError(`${l} validation failed for '${n}': expected size ${this.argumentSizeDisplay(c)}, got ${t.join("x")}.`)}const f=r.matchesClass??((t,e)=>o.FunctionValidation.matchesClass(t,e));u&&!u.some(t=>f(p(),t))&&r.throwEvalError(`${l} validation failed for '${n}': expected class ${this.argumentClassDisplay(u)}, got ${o.FunctionValidation.className(p())}.`);for(const t of h){if("explicit"===t.custom){r.evaluate(t.expression);continue}if("implicit"===t.custom){s.AST.isStrictNodeExpr(d.node)||r.throwEvalError(`${l} validation failed for '${n}': validator input is not an expression.`),r.evaluate(s.AST.nodeIndexExpr(s.AST.nodeIdentifier(t.name),s.AST.nodeList([d.node])));continue}const e=t.value?this.runtimeArgumentValue(r.evaluate(t.value),n,r.throwEvalError):p(),i=t.bounds?.map((t,e)=>this.runtimeArgumentValue(r.evaluate(t),`${n} bound ${e+1}`,r.throwEvalError))??[];if("mustBeA"===t.name){const a=[this.classNameElements(i[0]),t.bounds?.[0]&&s.AST.isExpressionBoundaryValue(t.bounds[0])?this.classNameElements(this.runtimeArgumentValue(t.bounds[0],`${n} class names`,r.throwEvalError)):void 0].filter(t=>Boolean(t));0!==a.length&&a.some(t=>t.some(t=>f(e,t)))||r.throwEvalError(`${l} validation failed for '${n}': mustBeA.`);continue}if("mustBeUnderlyingType"===t.name){const a=[this.classNameElements(i[0]),t.bounds?.[0]&&s.AST.isExpressionBoundaryValue(t.bounds[0])?this.classNameElements(this.runtimeArgumentValue(t.bounds[0],`${n} underlying types`,r.throwEvalError)):void 0].filter(t=>Boolean(t));0!==a.length&&a.some(t=>t.includes(o.FunctionValidation.underlyingType(e)))||r.throwEvalError(`${l} validation failed for '${n}': mustBeUnderlyingType.`);continue}this.validateArgumentFunction(n,e,t.name,i,r.throwEvalError,r.throwSyntaxError,r,l)}}static validateFunctionArguments(t,e,r,s,i=!1){const n=new Map;for(const a of this.argumentBlocks(t))if(this.blockKind(a,r.throwSyntaxError)===e)for(const t of this.argumentValidations(a))s&&!s.has(this.validationName(t,r.throwSyntaxError))||this.nameValueTarget(t,r.throwSyntaxError)&&void 0===r.resolveEntry(t,i)?.node||this.validateArgumentValidation(t,n,r,i)}static validateRepeatingArguments(t,e,r){for(const s of this.argumentBlocks(t)){if("Repeating"!==this.blockKind(s,r.throwSyntaxError))continue;const i=this.argumentValidations(s);e.length%i.length!==0&&r.throwEvalError(`invalid number of repeating arguments in function ${t.id}`);for(let t=0;t<e.length/i.length;t++){const s=new Map;i.forEach((n,a)=>{const o=e[t*i.length+a],l=this.validationName(n,r.throwSyntaxError);r.validateRepeatingValue(n,l,o,`${l}{${t+1}}`,s)})}}}static outputRepeatingInfo(t,e){const r=this.functionReturns(t).map(t=>s.AST.isNodeIgnoredTarget(t)?null:t.id);let i;for(const s of this.argumentBlocks(t)){if("OutputRepeating"!==this.blockKind(s,e))continue;i&&e(`function ${t.id} can contain only one arguments (Output,Repeating) block.`);const n=this.argumentValidations(s);1!==n.length&&e(`arguments (Output,Repeating) requires exactly one declaration in function ${t.id}.`);const a=n[0];this.nameValueTarget(a,e)&&e(`arguments (Output,Repeating) declaration in function ${t.id} must be a return identifier.`);const o=this.validationName(a,e),l=r.indexOf(o);l<0&&e(`arguments block declaration '${o}' does not match a return value in function ${t.id}.`),l!==r.length-1&&e(`arguments (Output,Repeating) declaration '${o}' must be the last return in function ${t.id}.`),"varargout"===o&&1!==r.length&&e(`arguments (Output,Repeating) declaration 'varargout' must be the only return in function ${t.id}.`),i={name:o,fixedReturnCount:l}}return i}static outputRepeatingName(t,e){return this.outputRepeatingInfo(t,e)?.name}static validateRepeatingOutputArguments(t,e,r){for(const s of this.argumentBlocks(t)){if("OutputRepeating"!==this.blockKind(s,r.throwSyntaxError))continue;const t=this.argumentValidations(s)[0],i=this.validationName(t,r.throwSyntaxError);e.forEach(e=>{r.validateRepeatingValue(t,i,e.value,`${i}{${e.index}}`,new Map)})}}static validateBlocks(t,e){t.attributes?.nested&&t.arguments.list.length>0&&e(`arguments blocks are not allowed in nested function ${t.id}.`);const r=new Set(this.functionParameters(t).map(t=>this.parameterName(t)).filter(t=>void 0!==t)),i=new Set(this.functionReturns(t).filter(s.AST.isNodeIdentifier).map(t=>t.id)),n=new Set;for(const r of this.argumentBlocks(t))if("Input"===this.blockKind(r,e))for(const t of this.argumentValidations(r)){const r=this.nameValueTarget(t,e);r&&n.add(r.parameter)}const a=r.has("varargin"),o=new Set,l=new Map,c=new Set,u=new Set,h=new Set,d=new Set;let m=!1,p=!1,f=!1,g=!1,y=!1;for(const x of this.argumentBlocks(t)){const C=this.blockKind(x,e);if("Input"!==C&&"Repeating"!==C||!y||e(`input arguments blocks must appear before output arguments blocks in function ${t.id}.`),"Input"===C){const r=this.argumentValidations(x).some(t=>!this.nameValueTarget(t,e));p&&r&&e(`ordinary input arguments blocks cannot follow repeating arguments block in function ${t.id}.`)}"Repeating"===C&&(p&&e(`function ${t.id} can contain only one arguments (Repeating) block.`),g&&e(`arguments (Repeating) block must appear before name-value arguments in function ${t.id}.`),p=!0),"Output"!==C&&"OutputRepeating"!==C||(y=!0),"OutputRepeating"===C&&(m&&e(`function ${t.id} can contain only one arguments (Output,Repeating) block.`),m=!0,this.outputRepeatingInfo(t,e)),"Repeating"!==C||a||e(`arguments (Repeating) requires a varargin parameter in function ${t.id}.`),"Repeating"!==C&&"OutputRepeating"!==C||0!==x.validation.length||e(`arguments (${"OutputRepeating"===C?"Output,Repeating":"Repeating"}) requires at least one declaration in function ${t.id}.`);const E="Output"===C?i:"Input"===C?r:void 0;for(const i of this.argumentValidations(x)){const a=this.nameValueTarget(i,e),m=a?`${a.parameter}.${a.field}`:this.validationName(i,e);if(a){"Input"!==C&&e(`arguments block name-value declaration '${m}' is only supported for input arguments.`),r.has(a.parameter)||e(`arguments block declaration '${m}' does not match a function parameter in function ${t.id}.`);const s=`${a.parameter}.${a.field}`;o.has(s)&&e(`duplicate arguments block name-value declaration '${m}' in function ${t.id}.`);const i=a.field.toLowerCase(),n=l.get(i);n&&e(`duplicate arguments block name-value field '${n}' in function ${t.id}.`),u.has(a.parameter)&&e(`arguments block parameter '${a.parameter}' cannot have both ordinary and name-value declarations in function ${t.id}.`),o.add(s),l.set(i,a.field),c.add(a.parameter),g=!0}else E&&!E.has(m)&&e(`arguments block declaration '${m}' does not match a ${"Output"===C?"return value":"function parameter"} in function ${t.id}.`);a||"Input"!==C||(u.has(m)&&e(`duplicate arguments block declaration '${m}' in function ${t.id}.`),c.has(m)&&e(`arguments block parameter '${m}' cannot have both ordinary and name-value declarations in function ${t.id}.`),g&&"varargin"!==m&&e(`ordinary input arguments must appear before name-value arguments in function ${t.id}.`),f&&!i.default&&"varargin"!==m&&e(`required input arguments cannot follow optional input arguments in function ${t.id}.`),u.add(m),i.default&&(f=!0)),a||"Repeating"!==C||(h.has(m)&&e(`duplicate arguments (Repeating) declaration '${m}' in function ${t.id}.`),h.add(m)),a||"Output"!==C||(d.has(m)&&e(`duplicate arguments block output declaration '${m}' in function ${t.id}.`),d.add(m));const p=i.size.some(t=>void 0!==t),y=Boolean(i.class&&(!s.AST.isNodeList(i.class)||i.class.list.length>0)),x=i.functions.some(t=>void 0!==t);if(p&&this.literalArgumentSize(i,e),y&&this.argumentClassNames(i,e),x&&this.argumentValidators(i,e),i.default&&"Input"!==C&&e(`arguments block default for '${m}' is only supported for input parameters.`),a&&i.default){const r=this.nameValueReferenceDisplay(i.default,n);r&&e(`arguments block name-value default for '${m}' cannot reference name-value argument '${r}' in function ${t.id}.`)}if(a&&x){const r=this.firstNameValueReferenceDisplay(i.functions,n,m);r&&e(`arguments block name-value validation for '${m}' cannot reference name-value argument '${r}' in function ${t.id}.`)}i.default&&!a&&"varargin"===m&&e("arguments block default for 'varargin' is not supported.")}}}static nameValueParameters(t,e){const r=new Set;for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s)){const s=this.nameValueTarget(t,e);s&&r.add(s.parameter)}return r}static nameValueDeclarations(t,e){const r=new Map;for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s)){const s=this.nameValueTarget(t,e);if(!s)continue;let i=r.get(s.parameter);i||(i=new Map,r.set(s.parameter,i)),i.set(s.field,t)}return r}static inputArgumentDefaults(t,e){const r=new Map;for(const e of this.functionParameters(t))this.isDefaultedIdentifier(e)&&r.set(e.left.id,e.right);for(const s of this.argumentBlocks(t))if("Input"===this.blockKind(s,e))for(const t of this.argumentValidations(s))!this.nameValueTarget(t,e)&&t.default&&r.set(this.validationName(t,e),t.default);return r}static splitCallNameValueArguments(t,e,r,n){const a=this.nameValueDeclarations(t,n),o=new Set([...a.values()].flatMap(t=>[...t.keys()])),l=this.functionParameters(t),c=l[l.length-1],u=l.length>0&&"varargin"===this.parameterName(c),h=u?l.length-1:l.length,d=this.nameValueParameters(t,n),m=l.slice(0,h).filter(t=>{const e=this.parameterName(t);return"<~>"===t.type||!e||!d.has(e)}),p=this.inputArgumentDefaults(t,n);let f=m.length;for(;f>0;){const t=m[f-1],e=this.parameterName(t);if(!e||!p.has(e))break;f--}const g=[],y=new Map;let x=!1;const C=[...o],E=t=>C.some(e=>e.toLowerCase().startsWith(t.toLowerCase())),A=(e,s)=>{x=!0;const i=(e=>{if(o.has(e))return e;const s=e.toLowerCase(),i=C.filter(t=>t.toLowerCase()===s);if(1===i.length)return i[0];i.length>1&&r(`ambiguous name-value argument '${e}' in function ${t.id}`);const n=C.filter(t=>t.toLowerCase().startsWith(s));if(1===n.length)return n[0];n.length>1&&r(`ambiguous name-value argument '${e}' in function ${t.id}`),r(`unknown name-value argument '${e}' in function ${t.id}`)})(e);y.set(i,s)};for(let n=0;n<e.length;n++){const o=e[n];s.AST.isNodeDefaultedParameter(o)&&a.size>0?A(o.left.id,o.right):i.CharString.isInstanceOf(o)&&a.size>0&&(g.length>=f&&E(o.str)||!u&&g.length>=m.length)?(n+1>=e.length&&r(`missing value for name-value argument '${o.str}' in function ${t.id}`),A(o.str,e[++n])):(x&&r(`positional arguments cannot follow name-value arguments in function ${t.id}`),g.push(o))}return{positional:g,named:y}}static outputNamesToValidate(t,e,r=[]){const i=this.functionReturns(t).map(t=>s.AST.isNodeIgnoredTarget(t)?null:t.id),n=i.length>0&&"varargout"===i[i.length-1];if(1===i.length&&n)return;const a=n?i.slice(0,-1):i;return new Set(a.slice(0,Math.min(Math.max(e,1),a.length)).filter((t,e)=>null!==t&&(r[e]??!0)))}}e.FunctionArguments=h},164(t,e,r){"use strict";e.FunctionArity=void 0;const s=r(6109),i=r(845),n=r(7679),a=r(491);e.FunctionArity=class{static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static inputArity(t){switch(t.type){case"LAMBDA":{const e=this.checkedList(t.node.parameter,s.AST.isNodeFunctionParameter,"function handle parameter");return this.identifierListArity(e,"varargin")}case"FCNDEF":{const e=this.checkedList(t.node.parameter.list,s.AST.isNodeFunctionParameter,"function parameter");return this.identifierListArity(e,"varargin")}case"STATIC_METHOD":{const e=this.checkedList(t.node.method.node.parameter.list,s.AST.isNodeFunctionParameter,"static method parameter");return this.identifierListArity(e,"varargin")}case"BUILTIN":return a.FunctionSignature.declaredArity(a.FunctionSignature.inputSignatures(t.node))??t.node.func.length}}static outputArity(t){switch(t.type){case"LAMBDA":return 1;case"FCNDEF":{const e=this.checkedList(t.node.return.list,s.AST.isNodeFunctionReturn,"function return");return this.identifierListArity(e,"varargout")}case"STATIC_METHOD":{const e=this.checkedList(t.node.method.node.return.list,s.AST.isNodeFunctionReturn,"static method return");return this.identifierListArity(e,"varargout")}case"BUILTIN":return a.FunctionSignature.declaredArity(a.FunctionSignature.outputSignatures(t.node))??1}}static countBound(t,e,r,s){const a=n.MultiArray.isInstanceOf(e)&&n.MultiArray.isScalar(e)?n.MultiArray.firstElement(e):e;i.Complex.isInstanceOf(a)&&i.Complex.imagIsZero(a)&&(r||Number.isFinite(i.Complex.realToNumber(a)))||s(`${t}: bounds must be real scalar numbers.`);const o=i.Complex.realToNumber(a);return(o<0||!Number.isInteger(o)&&(!r||o!==1/0))&&s(`${t}: bounds must be nonnegative integers.`),o}static checkFunctionCount(t,e,r,s,i,n){const a=this.countBound(t,e,!1,i),o=this.countBound(t,r,!0,i);o<a&&i(`${t}: maximum count must be greater than or equal to minimum count.`),(s<a||s>o)&&n(`${t}: invalid number of ${"nargoutchk"===t?"output":"input"} arguments.`)}static identifierListArity(t,e){const r=t[t.length-1];return t.length>0&&s.AST.isNodeIdentifier(r)&&r.id===e?-t.length:t.length}}},5273(t,e,r){"use strict";e.FunctionCall=void 0;const s=r(6109),i=r(8146),n=r(7679);e.FunctionCall=class{static defaultArgumentMarker={useDefaultArgument:!0};static isIdentifier(t){return s.AST.isNodeIdentifier(t)}static isDefaultedIdentifier(t){return s.AST.isNodeDefaultedParameter(t)}static parameterName(t){return this.isIdentifier(t)?t.id:this.isDefaultedIdentifier(t)?t.left.id:void 0}static isNamed(t,e){return this.parameterName(t)===e}static checkedList(t,e,r){return t.map((t,s)=>{if(!e(t))throw new TypeError(`internal AST error: ${r} ${s+1} has invalid node type.`);return t})}static returnExpression(t,e,r){return(0,i.expressionValue)(t,e,"Return variable",r)}static evaluatedArgument(t,e,r){return(0,i.expressionValue)(t,e,"Argument value",r)}static isDefaultArgumentMarker(t){return!0===t.useDefaultArgument}static callArgumentRequestsDefault(t){return s.AST.isNodeBase(t)&&":"===t.type}static requireEvaluatedArgument(t,e,r){return this.isDefaultArgumentMarker(t)&&r(`invalid use of default argument marker ':' for ${e}.`),t}static expressionArgumentValues(t,e,r){return t.map((t,s)=>this.requireEvaluatedArgument(t,`${e} ${s+1}`,r))}static inputLayout(t,e){const r=this.checkedList(t.parameter.list,s.AST.isNodeFunctionParameter,"function parameter"),i=r.length>0&&this.isNamed(r[r.length-1],"varargin"),n=i?r.length-1:r.length,a=r.slice(0,n).filter(t=>{const r=this.parameterName(t);return"<~>"===t.type||!r||!e.has(r)});return{params:r,hasVarargin:i,fixedParamCount:n,positionalParams:a,positionalParamCount:a.length}}static lambdaInputLayout(t){const e=t.length>0&&this.isNamed(t[t.length-1],"varargin");return{hasVarargin:e,fixedParamCount:e?t.length-1:t.length}}static returnLayout(t,e){const r=this.checkedList(t.return.list,s.AST.isNodeFunctionReturn,"function return"),i=r.map(t=>s.AST.isNodeIgnoredTarget(t)?"~":t.id),n=i.length>0&&"varargout"===i[i.length-1],a=e??(n?"varargout":void 0),o=void 0===a?-1:i.indexOf(a);return{returnNames:r,hasVarargout:n,variableOutputName:a,fixedReturnCount:o>=0?o:r.length,names:i}}static minimumPositionalCount(t,e){let r=t.length;for(;r>0;){const s=t[r-1],i=this.parameterName(s);if(!i||!e.has(i))break;r--}return r}static validateLambdaInputArity(t,e,r,s){(e&&t<r||!e&&t!==r)&&s("invalid number of arguments.")}static validateFunctionInputArity(t,e,r,s,i,n){(r&&e<i||!r&&(e<i||e>s))&&n(`invalid number of arguments in function ${t.id}`)}static validateFunctionOutputArity(t,e,r,i){!e&&t.length>0&&r>t.length&&s.AST.throwErrorIfGreaterThanReturnList(t.length,r,i)}static prepareFunctionCall(t,e,r,s){const i=this.inputLayout(t,s.nameValueParameters(t)),n=this.returnLayout(t,s.outputRepeatingName?.(t));let a=s.splitCallArguments(t,e);if(a.rawPositionalCount=a.positional.length,s.expandPositionalArguments){const e=a.positional.flatMap(t=>this.callArgumentRequestsDefault(t)?[t]:s.expandPositionalArguments([t])),r=s.splitCallArguments(t,e),i=new Map(r.named);for(const[t,e]of a.named)i.set(t,e);a={positional:r.positional,rawPositionalCount:a.rawPositionalCount,named:i}}const o=s.inputDefaults(t),l=this.minimumPositionalCount(i.positionalParams,o);return this.validateFunctionInputArity(t,a.positional.length,i.hasVarargin,i.positionalParamCount,l,s.throwEvalError),this.validateFunctionOutputArity(n.returnNames,void 0!==n.variableOutputName,r,s.throwEvalError),{inputLayout:i,returnLayout:n,callArguments:a,inputDefaults:o,minFixedParamCount:l}}static vararginCell(t){return n.MultiArray.firstRow(this.expressionArgumentValues(t,"varargin argument",t=>{throw new EvalError(t)}),!0)}static emptyVarargoutCell(t,e){return new n.MultiArray([1,Math.max(t-e,1)],()=>{},!0)}static initializeFixedReturnSlots(t,e){for(const r of t)s.AST.isNodeIgnoredTarget(r)||"varargout"===r.id||Object.prototype.hasOwnProperty.call(e,r.id)||(e[r.id]={})}static evaluateCallArguments(t,e,r,i,n=0,a=!1){return t.map((t,o)=>(s.AST.isNodeBase(t)&&(t.parent=e,t.index=n+o),a&&this.callArgumentRequestsDefault(t)?this.defaultArgumentMarker:this.evaluatedArgument(r(t),`argument ${n+o+1}`,i)))}static evaluateNameValueArguments(t,e,r,i){const n=new Map;for(const[a,o]of t)s.AST.isNodeBase(o)&&(o.parent=e),n.set(a,this.evaluatedArgument(r(o),a,i));return n}static bindLambdaInputs(t,e,r,s,i,n,a,o){for(let s=0;s<i;s++){const i=t[s],l=this.requireEvaluatedArgument(this.evaluateCallArguments([e[s]],r,a,o,s)[0],`argument ${s+1}`,o);this.isIdentifier(i)&&n(i.id,l)}s&&n("varargin",this.vararginCell(this.evaluateCallArguments(e.slice(i),r,a,o,i)))}static bindPositionalInputs(t,e,r,s,i,n,a){for(let o=0;o<e.positionalParamCount;o++){const l=e.positionalParams[o],c=this.parameterName(l);if(o<r.length){const e=r[o];if(!c)continue;if(this.isDefaultArgumentMarker(e)){const e=s.get(c);e||a(`invalid use of default argument marker ':' in function ${t.id}`),i(c,this.evaluatedArgument(n(c,e),c,a))}else i(c,e)}else{c||a(`invalid number of arguments in function ${t.id}`);const e=s.get(c);e||a(`invalid number of arguments in function ${t.id}`),i(c,this.evaluatedArgument(n(c,e),c,a))}}r.slice(e.positionalParamCount).some(t=>this.isDefaultArgumentMarker(t))&&a(`invalid use of default argument marker ':' in function ${t.id}`)}static bindVarargin(t,e,r){t.hasVarargin&&r("varargin",this.vararginCell(e.slice(t.positionalParamCount)))}static bindVarargout(t,e,r){t.variableOutputName&&r(t.variableOutputName,this.emptyVarargoutCell(e,t.fixedReturnCount))}static variableReturnKey(t,e){return`${t.variableOutputName??"varargout"}${e}`}static ignoredReturnValue(){return n.MultiArray.emptyArray()}static createReturnList(t,e,r,i=[]){const{fixedReturnCount:a,names:o,variableOutputName:l}=t,c=void 0!==l,u=t=>i[t]??!0;return 0===o.length?s.AST.nodeVoid():s.AST.nodeReturnList((e,i)=>{if(c){if(i<a){if("~"===o[i])return this.ignoredReturnValue();const t=e[o[i]];return void 0===t&&r(`Undefined return value '${o[i]}'`),t}const n=i-a,l=e[this.variableReturnKey(t,n)];return void 0===l&&s.AST.throwErrorIfGreaterThanReturnList(i,i+1,r),l}const n=o[i];if("~"===n)return this.ignoredReturnValue();const l=e[n];return void 0===l&&r(`Undefined return value '${n}'`),l},i=>{!c&&i>o.length&&s.AST.throwErrorIfGreaterThanReturnList(o.length,i,r);const h={length:i};if(c){for(let t=0;t<Math.min(i,a);t++){if(!u(t))continue;const s=o[t];if("~"===s)continue;const i=e[s];i&&i.node||r(`Undefined return variable '${s}'`),h[s]=this.returnExpression(i.node,s,r)}const c=e[l];c&&c.node instanceof n.MultiArray&&c.node.isCell||r(`Undefined return variable '${l}'`);const d=n.MultiArray.linearize(c.node);for(let e=a;e<i;e++){if(!u(e))continue;const i=d[e-a];void 0===i&&s.AST.throwErrorIfGreaterThanReturnList(e,e+1,r),h[this.variableReturnKey(t,e-a)]=this.returnExpression(i,`${l}{${e-a+1}}`,r)}return h}for(let t=0;t<i;t++){if(!u(t))continue;const s=o[t];if("~"===s)continue;const i=e[s];i&&i.node||r(`Undefined return variable '${s}'`),h[s]=this.returnExpression(i.node,s,r)}return h})}}},1271(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FunctionHandle=void 0;const s=r(845);class i{static FUNCTION_HANDLE=5;type=i.FUNCTION_HANDLE;parent;id;parameter=[];expression;closure;sourceName;className;disallowNestedResolution=!1;static isInstanceOf=t=>t instanceof i;static isAnonymous=t=>i.isInstanceOf(t)&&void 0===t.id;constructor(t,e=[],r=null,s){this.id=t,this.parameter=e??[],this.expression=r,s&&(this.closure=s)}static create=(t,e=[],r=null,s)=>new i(t,e,r,s);static unparse=(t,e,r=0)=>t.id?"@"+t.id:"@("+t.parameter.map(t=>e.Unparse(t)).join(",")+") "+e.Unparse(t.expression);static toString=t=>t.id?"@"+t.id:"@anonymous function handle";toString(){return i.toString(this)}static unparseMathML=(t,e,r=0)=>t.id?`<mo>@</mo><mi>${t.id}</mi>`:'<mo>@</mo><mo fence="true" stretchy="true">(</mo>'+t.parameter.map(t=>e.UnparserMathML(t)).join("<mo>,</mo>")+'<mo fence="true" stretchy="true">)</mo><mspace width="0.8em"/>'+e.UnparserMathML(t.expression);static copy=t=>{const e=new i(t.id,t.parameter.map(t=>i.copyNode(t)),i.copyNode(t.expression),t.closure);return e.parameter.forEach(t=>{t.parent=e}),e.expression&&(e.expression.parent=e),e.parent=t.parent,e.sourceName=t.sourceName,e.className=t.className,e.disallowNestedResolution=t.disallowNestedResolution,e};copy(){const t=i.copy(this);return t.parent=this.parent,t}static hasCopyMethod(t){return"function"==typeof t.copy}static isFunctionHandleNode(t){return!!t&&"object"==typeof t}static hasNodeType(t){return i.isFunctionHandleNode(t)&&"type"in t}static copyNodeValue(t){return Array.isArray(t)?t.map(t=>i.copyNodeValue(t)):i.isFunctionHandleNode(t)?i.copyNode(t):t}static copyNode(t){if(!t||"object"!=typeof t)return t;if(i.hasCopyMethod(t)){const e=t.copy();if(i.isFunctionHandleNode(e)||null==e)return e}const e={};for(const[r,s]of Object.entries(t))"parent"!==r&&Reflect.set(e,r,i.copyNodeValue(s));for(const t of Object.values(e))i.attachParent(t,e);return e}static attachParent(t,e){Array.isArray(t)?t.forEach(t=>i.attachParent(t,e)):i.hasNodeType(t)&&(t.parent=e)}static toLogical=t=>s.Complex.false();toLogical(){return s.Complex.false()}}e.FunctionHandle=i,e.default={FunctionHandle:i}},8342(t,e,r){"use strict";e.FunctionIntrospection=void 0;const s=r(5956),i=r(845),n=r(7679),a=r(5212),o=r(1271);e.FunctionIntrospection=class{static metadataString(t,e){if(t&&"object"==typeof t&&e in t){const r=t[e];return"string"==typeof r?r:void 0}}static functionNames(t){return Object.keys(t.functionTable).filter(e=>"FCNDEF"===t.functionTable[e]?.type)}static nearestFunctionScope(t,e){if(!t)return{scope:e,hasFunctionFrame:!1};if(this.functionNames(t.scope).length>0)return{scope:t.scope,hasFunctionFrame:!0};let r=t.scope.parent;for(;r;){if(this.functionNames(r).length>0)return{scope:r,excludeName:this.metadataString(t.func?.node,"id"),hasFunctionFrame:!0};r=r.parent}return{scope:t.scope,hasFunctionFrame:!0}}static localFunctionHandles(t,e){const r=this.nearestFunctionFrame(t),{scope:s,excludeName:i,hasFunctionFrame:a}=this.nearestFunctionScope(r,e),l=this.functionNames(s).filter(t=>t!==i).sort(),c=new n.MultiArray([l.length,1],null,!0);return c.array=l.map(t=>{const e=a?s:void 0;return[o.FunctionHandle.create(t,[],null,e)]}),c}static frameName(t){if(t.name)return t.name;const e=t.func;if(!e)return"";switch(e.type){case"BUILTIN":return this.metadataString(e.node,"id")??"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return this.metadataString(e.node,"id")??"<function>";default:return""}}static frameFile(t){return this.metadataString(t.func?.node,"sourceName")??""}static dbstackResult(t,e,r){const o=this.dbstackSkip(t,r),l=e.filter(t=>"FCNDEF"===t.func?.type||"LAMBDA"===t.func?.type).slice().reverse().slice(o),c=new n.MultiArray([l.length,1]);return c.array=l.map(t=>[new a.Structure({file:new s.CharString(this.frameFile(t)),name:new s.CharString(this.frameName(t)),line:i.Complex.create(t.callSite?.start?.line??0)})]),c.type=a.Structure.STRUCTURE,c}static nearestFunctionFrame(t){let e=t;for(;e&&"FCNDEF"!==e.func?.type;)e=e.parentFrame;return e}static dbstackSkip(t,e){let r=0;for(const a of t){const t=n.MultiArray.isInstanceOf(a)&&n.MultiArray.isScalar(a)?n.MultiArray.firstElement(a):a;if(i.Complex.isInstanceOf(t)){const s=i.Complex.realToNumber(t);(!i.Complex.imagIsZero(t)||!Number.isInteger(s)||s<0)&&e("dbstack: omitted frame count must be a nonnegative integer."),r=s}else s.CharString.isInstanceOf(t)?"-completenames"!==t.str&&e(`dbstack: unsupported option '${t.str}'.`):e("dbstack: arguments must be a frame count or option string.")}return r}}},2951(t,e,r){"use strict";e.FunctionLookup=void 0;const s=r(5956),i=r(6816),n=r(7679),a=r(5212),o=r(1271);class l{static runtimeClassNames=new Set(["double","single","logical","char","cell","struct","function_handle","event.listener","event.proplistener","event.EventData","event.PropertyEvent","handle","meta.class","meta.property","meta.method","meta.event","meta.EnumerationMember","matlab.mixin.SetGet","matlab.mixin.SetGetExactNames"]);static existCode(t,e,r,s,n=!1,a=!1){const o=e?.trim().toLowerCase(),l=r&&void 0!==r.node&&!i.ClassDefinition.isInstanceOf(r.node)?1:0,c="FCNDEF"===s?.type?2:"BUILTIN"===s?.type?5:0,u=n||r&&i.ClassDefinition.isInstanceOf(r.node)||this.isRuntimeClassName(t)?8:0,h=a?2:0;switch(o){case void 0:return l||c||u||h;case"var":case"variable":return l;case"builtin":return 5===c?5:0;case"file":return 2===c?2:5===c?5:h;case"function":return 2===c?2:5===c?5:0;case"class":return u;default:return 0}}static existCodeFromResolution(t,e,r){const s="variable"===r?.kind?r.entry:void 0,i="function"===r?.kind||"builtin"===r?.kind?r.functionDefinition:void 0,n="class"===r?.kind,a="script"===r?.kind,o="function"===r?.kind&&!r.functionDefinition,l="class"===r?.kind&&!r.classDefinition;if("directory"===r?.kind){const t=e?.trim().toLowerCase();switch(t){case void 0:case"dir":case"file":return 7;default:return 0}}if(o){const t=e?.trim().toLowerCase();switch(t){case void 0:case"file":case"function":return 2;default:return 0}}if(l){const t=e?.trim().toLowerCase();switch(t){case void 0:case"class":return 8;case"file":return 2;default:return 0}}return this.existCode(t,e,s,i,n,a)}static whichResult(t,e,r,n,a,o=!1,l=!1,c){return n&&!n.id?new s.CharString(`${a(n).trim()} is an anonymous function`):n||!e||void 0===e.node||i.ClassDefinition.isInstanceOf(e.node)?"FCNDEF"===r?.type?new s.CharString(`${t} is a ${r.attributes?.nested?"nested":"user-defined"} function`):"BUILTIN"===r?.type?new s.CharString(`${r.id} is a built-in function`):c?new s.CharString(`${c.className}.${c.methodName} is a static method`):o||e&&i.ClassDefinition.isInstanceOf(e.node)||this.isRuntimeClassName(t)?new s.CharString(`${t} is a class`):l?new s.CharString(`${t} is a script`):new s.CharString(`${t} not found`):new s.CharString(`${t} is a variable`)}static whichResultFromResolution(t,e,r,i,n){if("function"===e?.kind&&!e.functionDefinition)return new s.CharString(`${t} is a user-defined function`);if("directory"===e?.kind)return new s.CharString(`${t} is a folder`);const a="variable"===e?.kind?e.entry:void 0,o="function"===e?.kind||"builtin"===e?.kind?e.functionDefinition:void 0;return this.whichResult(t,a,o,r,i,"class"===e?.kind,"script"===e?.kind,n)}static func2str(t,e){return new s.CharString(t.id??e(t).trim())}static str2func(t,e,r){const s=t.trim();if(0===s.length&&r("str2func: function name cannot be empty."),!s.startsWith("@"))return o.FunctionHandle.create(s);const i=e(s);return o.FunctionHandle.isInstanceOf(i)||r("str2func: invalid function handle string."),i}static functionsInfo(t,e,r,i,o=()=>n.MultiArray.emptyArray(!0),l=()=>{}){let c="anonymous",u=t.sourceName??"";if(t.id){const s=e(t.id),i=t.closure?.resolveFunction(s)??r(t.id);if("FCNDEF"===i?.type)c=i.attributes?.nested?"nested":"simple",u=i.sourceName??"";else{const e=l(t.id,t);c="simple",u=e?.sourceName??u}}const h="simple"===c?n.MultiArray.emptyArray(!0):o(t);return new a.Structure({function:this.func2str(t,i),type:new s.CharString(c),file:new s.CharString(u),workspace:h})}static resolveHandleFunction(t,e,r,s){const i=r(e);return t.closure?.resolveFunction(i)??s(e)}static isRuntimeClassName(t){return this.runtimeClassNames.has(t)}}e.FunctionLookup=l},491(t,e,r){"use strict";e.FunctionSignature=void 0;const s=r(9170);e.FunctionSignature=class{static inputSignatures(t){const e=t.signature?.inputs;return e?Array.isArray(e)?e:[e]:[]}static outputSignatures(t){const e=t.signature?.outputs;return e?Array.isArray(e)?e:[e]:[]}static arityMinimum(t){return t.min??(t.arity<0?Math.max(Math.abs(t.arity)-1,0):t.arity)}static arityMaximum(t){return t.max??(t.arity<0?1/0:t.arity)}static variadicPosition(t,e=!1){const r=t.parameters?.findIndex(t=>t.variadic)??-1;return e&&r>=0?r+1:t.arity<0?Math.abs(t.arity):r>=0?r+1:void 0}static declaredArity(t){if(0===t.length)return;const e=t.map(t=>this.arityMinimum(t)),r=t.map(t=>this.arityMaximum(t));if(!r.some(t=>t===1/0)&&e.every((t,e)=>t===r[e])&&e.every(t=>t===e[0]))return e[0];if(r.some(t=>t===1/0)){const e=t.filter((t,e)=>r[e]===1/0).map(e=>this.variadicPosition(e,t.length>1)).filter(t=>"number"==typeof t);if(e.length>0)return-Math.min(...e)}const s=r.filter(t=>t!==1/0);return s.length>0?-Math.max(...s):-Math.max(...t.map(t=>this.variadicPosition(t)??Math.abs(t.arity)))}static arityMatches(t,e){const r=this.arityMinimum(t),s=this.arityMaximum(t);return e>=r&&e<=s}static matchingInputSignatures(t,e){return this.inputSignatures(t).filter(t=>this.arityMatches(t,e))}static inputArityIsValid(t,e){const r=this.inputSignatures(t);return 0===r.length||r.some(t=>this.arityMatches(t,e))}static inputParametersAreValid(t,e){const r=this.matchingInputSignatures(t,e.length);return 0===r.length||r.some(t=>s.FunctionValidation.argumentsMatchBuiltInParameters(e,t.parameters))}}},9217(t,e,r){"use strict";e.FunctionStack=void 0;const s=r(6028);e.FunctionStack=class{static currentFunctionDefinition(t){return this.currentFunctionFrame(t)?.func?.node}static currentFunctionFrame(t){for(let e=t.length-1;e>=0;e--)if("FCNDEF"===t[e].func?.type)return t[e]}static currentFunctionCountFrame(t){for(let e=t.length-1;e>=0;e--){const r=t[e].func?.type;if("FCNDEF"===r||"LAMBDA"===r)return t[e]}}static currentFunctionName(t){return this.currentFunctionFrame(t)?.name??""}static currentArgumentCount(t){return this.currentFunctionCountFrame(t)?.nargin}static currentOutputCount(t){return this.currentFunctionCountFrame(t)?.nargout}static callerWorkspace(t,e,r,s=!1,i=!1){const n=this.currentFunctionCountFrame(t);if("LAMBDA"===n?.func?.type&&!s&&i)return this.anonymousCallerWorkspace(n,e,r);const a=this.skipBuiltInFrames(n?.parentFrame),o=a?.scope??e;return!s&&i?this.variableOnlyCallerWorkspace(o,r):o}static anonymousCallerWorkspace(t,e,r){const s=this.skipBuiltInFrames(t.parentFrame),i=r(),n=new Map;return this.copyVisibleVariablesWithSources(i,s?.scope??e,n),this.copyVisibleVariablesWithSources(i,t.scope,n),i.rejectDynamicNameCreation=t.scope.rejectDynamicNameCreation,i.staticWorkspaceNameSet=t.scope.staticWorkspaceNameSet?new Set(t.scope.staticWorkspaceNameSet):void 0,i.globalDeclarationTarget=t.scope,this.attachVariableOnlyWriteThrough(i,e=>n.get(e)??t.scope),i}static variableOnlyCallerWorkspace(t,e){const r=e();return s.FunctionWorkspace.copyVisibleScopeEntries(r,t,!1),r.rejectDynamicNameCreation=t.rejectDynamicNameCreation,r.staticWorkspaceNameSet=t.staticWorkspaceNameSet?new Set(t.staticWorkspaceNameSet):void 0,r.globalDeclarationTarget=t,this.attachVariableOnlyWriteThrough(r,()=>t),r}static copyVisibleVariablesWithSources(t,e,r){const s=[];let i=e;for(;i&&(s.push(i),i.resolveParentNames);)i=i.parent;for(let e=s.length-1;e>=0;e--){const i=s[e];Object.assign(t.nameTable,i.nameTable);for(const t of Object.keys(i.nameTable))r.set(t,i)}}static attachVariableOnlyWriteThrough(t,e){const r=(e,r)=>{const s=e.rejectDynamicNameCreation;t.rejectDynamicNameCreation&&(e.rejectDynamicNameCreation=!0);try{return r()}finally{e.rejectDynamicNameCreation=s}};t.defineName=(s,i,n)=>{const a=e(s),o=r(a,()=>a.defineName(s,i,n));return t.nameTable[s]=o,o},t.assignName=(s,i,n)=>{const a=e(s),o=a.assignName?.bind(a),l=r(a,()=>o?o(s,i,n):a.defineName(s,i,n));return t.nameTable[s]=l,l},t.removeName=r=>{const s=e(r);s.removeName?s.removeName(r):delete s.nameTable[r],delete t.nameTable[r]},t.clearName=r=>{const s=e(r);s.clearName?s.clearName(r):s.removeName?s.removeName(r):delete s.nameTable[r],delete t.nameTable[r]}}static skipBuiltInFrames(t){for(;"BUILTIN"===t?.func?.type;)t=t.parentFrame;return t}}},9170(t,e,r){"use strict";e.FunctionValidation=void 0;const s=r(5956),i=r(845),n=r(1271),a=r(7679),o=r(5212),l=r(9770),c=r(7325),u=r(5577),h=r(169),d=r(482),m=r(7268),p=r(8146),f=r(1604);class g{static matlabNameLengthMax=2048;static reservedKeywords=new Set(["global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","break","continue","return","function","endfunction","try","catch","end_try_catch","unwind_protect","unwind_protect_cleanup","end_unwind_protect","classdef","endclassdef","enumeration","endenumeration","properties","endproperties","events","endevents","methods","endmethods","arguments","endarguments"]);static className(t){if(i.Complex.isInstanceOf(t))return t.type===i.Complex.LOGICAL?"logical":"double";if(s.CharString.isInstanceOf(t))return s.CharString.isChar(t)?"char":"string";if(n.FunctionHandle.isInstanceOf(t))return"function_handle";if(u.ClassEventListener.isInstanceOf(t))return t.kind;if(d.ClassPropertyEvent.isInstanceOf(t))return"event.PropertyEvent";if(h.ClassEventData.isInstanceOf(t))return"event.EventData";if(m.ClassMetaObject.isInstanceOf(t))return t.kind;if(l.ClassInstance.isInstanceOf(t))return t.classDefinition.name;if(c.ClassEnumerationValue.isInstanceOf(t))return t.classDefinition.name;if(o.Structure.isStructure(t))return"struct";if(a.MultiArray.isInstanceOf(t)){if(t.isCell)return"cell";const e=a.MultiArray.linearize(t);return e.every(t=>i.Complex.isInstanceOf(t))?e.length>0&&e.every(t=>t.type===i.Complex.LOGICAL)?"logical":"double":e.length>0&&e.every(s.CharString.isChar)?"char":e.length>0&&e.every(s.CharString.isString)?"string":"array"}return"unknown"}static underlyingType(t){return this.className(t)}static numericElements(t,e={}){const r=t=>i.Complex.isInstanceOf(t)&&(e.includeLogical||t.type!==i.Complex.LOGICAL);if(i.Complex.isInstanceOf(t))return r(t)?[t]:void 0;if(a.MultiArray.isInstanceOf(t)&&!t.isCell){const e=a.MultiArray.linearize(t);return e.every(r)?e:void 0}}static isLogicalValue(t){const e=this.numericElements(t,{includeLogical:!0});return Boolean(e&&e.length>0&&e.every(t=>t.type===i.Complex.LOGICAL))}static isCharArray(t){if(s.CharString.isChar(t))return!0;if(!a.MultiArray.isInstanceOf(t)||t.isCell)return!1;const e=a.MultiArray.linearize(t);return e.length>0&&e.every(s.CharString.isChar)}static isStringArray(t){if(s.CharString.isString(t))return!0;if(!a.MultiArray.isInstanceOf(t)||t.isCell)return!1;const e=a.MultiArray.linearize(t);return e.length>0&&e.every(s.CharString.isString)}static isCellStringArray(t){if(!a.MultiArray.isInstanceOf(t)||!t.isCell)return!1;const e=a.MultiArray.linearize(t);return e.length>0&&e.every(s.CharString.isChar)}static isTextValue(t){return this.isCharArray(t)||this.isStringArray(t)||this.isCellStringArray(t)}static isTextScalarValue(t){if(s.CharString.isInstanceOf(t))return!0;if(!a.MultiArray.isInstanceOf(t)||t.isCell||1!==f.RuntimeValue.elementCount(t))return!1;const e=a.MultiArray.firstElement(t);return s.CharString.isString(e)}static textElements(t){if(s.CharString.isInstanceOf(t))return[t.str];if(a.MultiArray.isInstanceOf(t)){const e=a.MultiArray.linearize(t);return e.length>0&&e.every(s.CharString.isInstanceOf)?e.map(t=>t.str):void 0}}static variableNameElements(t){if(s.CharString.isInstanceOf(t))return[t.str];if(!a.MultiArray.isInstanceOf(t)||!t.isCell)return;const e=a.MultiArray.linearize(t);return e.length>0&&e.every(s.CharString.isChar)?e.map(t=>t.str):void 0}static isValidVariableNameText(t){return/^[A-Za-z]\w*$/.test(t)&&t.length<=this.matlabNameLengthMax&&!this.reservedKeywords.has(t)}static matchesClass(t,e){switch(e){case"double":case"single":return Boolean(this.numericElements(t));case"logical":return this.isLogicalValue(t);case"char":return this.isCharArray(t);case"string":return this.isStringArray(t);case"cell":return a.MultiArray.isInstanceOf(t)&&t.isCell;case"array":return a.MultiArray.isInstanceOf(t);case"struct":return o.Structure.isStructure(t);case"function_handle":return n.FunctionHandle.isInstanceOf(t);default:return!1}}static normalizeValidators(t=[]){const e=new Set(t),r=(...t)=>{for(const r of t)e.delete(r)};return e.has("dimensionGreaterThanOne")&&r("numeric","scalar","real","finite","integer","positive","nonnegative","dimension"),e.has("dimension")&&r("numeric","scalar","real","finite","integer","nonnegative"),e.has("dimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),e.has("reshapeDimension")&&r("numeric","scalar","scalarOrEmpty","real","finite","integer","nonnegative"),e.has("reshapeDimensionVector")&&r("numeric","vector","real","finite","integer","nonnegative"),e.has("positive")&&r("nonnegative"),e.has("negative")&&r("nonpositive"),e.has("zeroOrOne")&&r("nonnegative"),e.has("textScalar")&&r("text","scalar","scalarOrEmpty","scalarOrVector"),e.has("squareMatrix")&&r("matrix2d"),e.has("scalar")&&r("scalarOrEmpty","scalarOrVector"),[...e]}static isDimensionValue(t,e){if(f.RuntimeValue.isEmpty(t))return e;const r=this.numericElements(t);return Boolean(r&&r.every(t=>i.Complex.imagIsZero(t)&&i.Complex.realIsFinite(t)&&i.Complex.realIsInteger(t)&&i.Complex.realGreaterThanOrEqualTo(t,0)))}static isDimensionVector(t,e){if(!f.RuntimeValue.isVector(t))return!1;const r=a.MultiArray.linearize(t),s=r.map(p.optionalRuntimeExpressionValue);return r.length>0&&s.every(t=>void 0!==t)&&s.every(t=>this.isDimensionValue(t,e))}static matchesParameter(t,e){return!(e.classes&&e.classes.length>0&&!e.classes.some(e=>this.matchesClass(t,e)))&&!(e.allowedStrings&&e.allowedStrings.length>0&&(!s.CharString.isInstanceOf(t)||!e.allowedStrings.includes(t.str)))&&!!(!e.identifier||s.CharString.isInstanceOf(t)&&this.isValidVariableNameText(t.str))&&this.normalizeValidators(e.validators).every(r=>this.matchesBuiltInValidator(t,r,e.allowInfinity))}static matchesBuiltInParameterBase(t,e){const r=this.normalizeValidators(e.validators),s=new Set(["dimension","dimensionGreaterThanOne","dimensionVector","reshapeDimension","reshapeDimensionVector"]),n={...e,validators:r.filter(t=>!s.has(t))};return!!this.matchesParameter(t,n)&&r.every(e=>{switch(e){case"dimension":return f.RuntimeValue.isScalar(t)&&this.isDimensionValue(t,!1);case"dimensionGreaterThanOne":return f.RuntimeValue.isScalar(t)&&this.isDimensionValue(t,!1)&&i.Complex.realGreaterThan(a.MultiArray.firstElement(t),1);case"dimensionVector":return this.isDimensionVector(t,!1);case"reshapeDimension":return(f.RuntimeValue.isScalar(t)||f.RuntimeValue.isEmpty(t))&&this.isDimensionValue(t,!0);case"reshapeDimensionVector":return this.isDimensionVector(t,!0);default:return!0}})}static matchesBuiltInParameter(t,e){const r=e.alternatives??[];return(Boolean(e.classes?.length||e.validators?.length||e.allowedStrings?.length||e.identifier)||0===r.length)&&this.matchesBuiltInParameterBase(t,e)||r.some(e=>this.matchesBuiltInParameter(t,e))}static argumentsMatchBuiltInParameters(t,e){if(!e)return!0;for(let r=0;r<t.length;r++){const s=e[Math.min(r,e.length-1)];if(!s||r>=e.length&&!s.variadic)continue;const i=s.variadic&&s.variadicGroup&&s.variadicGroup.length>0?s.variadicGroup[(r-Math.min(r,e.length-1))%s.variadicGroup.length]:s;if(!this.matchesBuiltInParameter(t[r],i))return!1}return!0}static matchesBuiltInValidator(t,e,r=!1){const n=this.numericElements(t),o=()=>this.numericElements(t,{includeLogical:!0}),l=t=>Boolean(r&&i.Complex.imagIsZero(t)&&i.Complex.realToNumber(t)===1/0);switch(e){case"numeric":case"float":return Boolean(n);case"numericOrLogical":return Boolean(this.numericElements(t,{includeLogical:!0}));case"text":return this.isTextValue(t);case"textScalar":return this.isTextScalarValue(t);case"nonzeroLengthText":{const e=this.textElements(t);return Boolean(e&&e.length>0&&e.every(t=>t.length>0))}case"validVariableName":{const e=this.variableNameElements(t);return Boolean(e&&e.length>0&&e.every(t=>this.isValidVariableNameText(t)))}case"scalar":return f.RuntimeValue.isScalar(t);case"scalarOrEmpty":return f.RuntimeValue.isScalar(t)||f.RuntimeValue.isEmpty(t);case"scalarOrVector":return f.RuntimeValue.isScalar(t)||f.RuntimeValue.isVector(t);case"empty":return f.RuntimeValue.isEmpty(t);case"matrix2d":return f.RuntimeValue.isMatrix(t);case"squareMatrix":return f.RuntimeValue.isSquareMatrix(t);case"vector":return f.RuntimeValue.isVector(t);case"rowVector":return f.RuntimeValue.isRowVector(t);case"columnVector":return f.RuntimeValue.isColumnVector(t);case"twoElement":return 2===f.RuntimeValue.elementCount(t);case"oneOrTwoElement":{const e=f.RuntimeValue.elementCount(t);return 1===e||2===e}case"nonempty":return!f.RuntimeValue.isEmpty(t);case"positive":return Boolean(o()?.every(t=>l(t)||i.Complex.imagIsZero(t)&&i.Complex.realGreaterThan(t,0)));case"nonnegative":return Boolean(o()?.every(t=>l(t)||i.Complex.imagIsZero(t)&&i.Complex.realGreaterThanOrEqualTo(t,0)));case"negative":return Boolean(o()?.every(t=>i.Complex.imagIsZero(t)&&i.Complex.realLessThan(t,0)));case"nonpositive":return Boolean(o()?.every(t=>i.Complex.imagIsZero(t)&&i.Complex.realLessThanOrEqualTo(t,0)));case"nonzero":return Boolean(o()?.every(t=>0!==i.Complex.realToNumber(t)||0!==i.Complex.imagToNumber(t)));case"nonnan":return!!s.CharString.isInstanceOf(t)||Boolean(o()?.every(t=>!i.Complex.realIsNaN(t)&&!i.Complex.imagIsNaN(t)));case"nonmissing":{const e=o();if(e)return e.every(t=>!i.Complex.realIsNaN(t)&&!i.Complex.imagIsNaN(t));if(s.CharString.isInstanceOf(t))return!0;if(a.MultiArray.isInstanceOf(t)){const e=a.MultiArray.linearize(t);return t.isCell?e.every(t=>!s.CharString.isChar(t)||t.str.length>0):e.length>0&&e.every(s.CharString.isInstanceOf)}return!0}case"nonsparse":return!0;case"sparse":default:return!1;case"zeroOrOne":return Boolean(o()?.every(t=>i.Complex.imagIsZero(t)&&(0===i.Complex.realToNumber(t)||1===i.Complex.realToNumber(t))));case"integer":return Boolean(o()?.every(t=>l(t)||i.Complex.imagIsZero(t)&&i.Complex.realIsInteger(t)));case"finite":return Boolean(o()?.every(t=>i.Complex.realIsFinite(t)&&i.Complex.imagIsFinite(t)));case"real":return Boolean(o()?.every(t=>i.Complex.imagIsZero(t)))}}static builtInValidatorForArgumentValidator(t){switch(t){case"mustBeNumeric":return"numeric";case"mustBeFloat":return"float";case"mustBeNumericOrLogical":return"numericOrLogical";case"mustBeText":return"text";case"mustBeTextScalar":return"textScalar";case"mustBeNonzeroLengthText":return"nonzeroLengthText";case"mustBeValidVariableName":return"validVariableName";case"mustBeScalarOrEmpty":return"scalarOrEmpty";case"mustBeScalar":return"scalar";case"mustBeMatrix":return"matrix2d";case"mustBeSquare":return"squareMatrix";case"mustBeVector":return"vector";case"mustBeRow":return"rowVector";case"mustBeColumn":return"columnVector";case"mustBeNonempty":return"nonempty";case"mustBePositive":return"positive";case"mustBeNonnegative":return"nonnegative";case"mustBeNegative":return"negative";case"mustBeNonpositive":return"nonpositive";case"mustBeNonzero":return"nonzero";case"mustBeNonNan":return"nonnan";case"mustBeNonmissing":return"nonmissing";case"mustBeNonsparse":return"nonsparse";case"mustBeSparse":return"sparse";case"mustBeInteger":return"integer";case"mustBeFinite":return"finite";case"mustBeReal":return"real";default:return}}}e.FunctionValidation=g},6028(t,e,r){"use strict";e.FunctionWorkspace=void 0;const s=r(6109),i=r(5956),n=r(845),a=r(8146),o=r(7679),l=r(1604);e.FunctionWorkspace=class{static ensurePersistentTable(t){return t.attributes||(t.attributes={}),t.attributes.persistent||(t.attributes.persistent=Object.create(null)),t.attributes.persistent}static copyVisibleScopeEntries(t,e,r=!0){if(!e)return;const s=[];let i=e;for(;i&&(s.unshift(i),i.resolveParentNames);)i=i.parent;for(const e of s)Object.assign(t.nameTable,e.nameTable),r&&Object.assign(t.functionTable,e.functionTable)}static inputName(t,e,r,a=!0,l){const c=o.MultiArray.isInstanceOf(e)&&o.MultiArray.isScalar(e)?o.MultiArray.firstElement(e):e;n.Complex.isInstanceOf(c)&&n.Complex.imagIsZero(c)||r("inputname: argument number must be a positive integer.");const u=n.Complex.realToNumber(c);(!Number.isInteger(u)||u<1)&&r("inputname: argument number must be a positive integer.");const h=t[u-1];return h?s.AST.isNodeIdentifier(h)?new i.CharString(h.id):new i.CharString(!a&&l?l(h).trim():""):new i.CharString("")}static resolveWorkspace(t,e,r,s){switch(t){case"base":return e;case"caller":return r;default:s(`unsupported workspace '${t}'.`)}}static evaluateWithCatch(t,e,r,s,i=()=>!0,n){try{return s(e,t)}catch(e){if(void 0===r||!i(e))throw e;return n?.(e),s(r,t)}}static assignIn(t,e,r){const i=l.RuntimeValue.copy(r);return t.assignName?t.assignName(e,i):t.defineName(e,i),s.AST.nodeVoid()}static declarePersistent(t,e,r,i){const n=this.ensurePersistentTable(r);i.nameTable?.[t]?.persistent||(void 0!==e&&void 0===n[t]?n[t]=l.RuntimeValue.copy(e):void 0===n[t]&&(n[t]=s.AST.emptyArray()),i.defineName(t,l.RuntimeValue.copy(n[t])).persistent=!0)}static loadPersistentVariables(t,e){const r=this.ensurePersistentTable(t);for(const t of Object.keys(r))void 0===r[t]&&(r[t]=s.AST.emptyArray()),e.defineName(t,l.RuntimeValue.copy(r[t])).persistent=!0}static storePersistentVariables(t,e){const r=this.ensurePersistentTable(t);for(const t of Object.keys(r)){const s=e.hasLocalName(t)?e.nameTable[t]:void 0;s&&void 0!==s.node&&(r[t]=l.RuntimeValue.copy((0,a.runtimeExpressionValue)(s.node,t,"persistent variable",t=>{throw new EvalError(t)})))}}static declareGlobal(t,e,r,i,n,a){r.add(t);let o=i[t];o||(o=i[t]={}),o.global=!0;const c=Boolean(o.globalInitialized||a?.has(t));void 0===e||c?void 0===o.node&&(o.node=s.AST.emptyArray()):(o.node=l.RuntimeValue.copy(e),delete o.undefinedReference,o.globalInitialized=!0,a?.add(t)),n[t]=o}static clearGlobalVariables(t,e,r,s){const i=s?s.filter(e=>t.has(e)):[...t],n=new Set,a=t=>{for(;t&&!n.has(t);){n.add(t);for(const e of i)t.nameTable[e]?.global&&delete t.nameTable[e];for(const e of Object.values(t.functionTable))a(e.definingScope);t=t.parent}};a(e);for(const t of r)a(t);if(s)for(const e of i)t.delete(e);else t.clear()}}},7727(t,e,r){"use strict";var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Interpreter=e.Context=e.SyntaxError=e.CircularReferenceError=e.UndefinedReferenceError=e.ReferenceError=e.EvalError=e.InterpreterError=e.CallFrame=e.Scope=e.TableSourceResolver=e.ManifestSourceResolver=void 0;const i=r(3222),n=s(r(2207)),a=s(r(6770)),o=r(7645),l=r(6430),c=r(6109),u=r(5956),h=r(845),d=r(7679),m=r(5212),p=r(1271),f=r(6816),g=r(9770),y=r(9656),x=r(8986),C=r(3226),E=r(7325),A=r(5577),_=r(169),S=r(482),v=r(7268),T=r(6554),b=r(2424),N=r(3717),I=r(4087),M=r(4610),w=r(9947),L=r(7686),O=r(9170),R=r(8989),D=r(164),F=r(6028),P=r(8342),k=r(2951),V=r(7673),U=r(1604),$=r(2981);Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return $.Scope}});const B=r(3812);Object.defineProperty(e,"CallFrame",{enumerable:!0,get:function(){return B.CallFrame}});const H=r(3225),q=r(9274),j=r(7162);Object.defineProperty(e,"Context",{enumerable:!0,get:function(){return j.Context}});const z=r(1201);Object.defineProperty(e,"CircularReferenceError",{enumerable:!0,get:function(){return z.CircularReferenceError}}),Object.defineProperty(e,"EvalError",{enumerable:!0,get:function(){return z.EvalError}}),Object.defineProperty(e,"InterpreterError",{enumerable:!0,get:function(){return z.InterpreterError}}),Object.defineProperty(e,"ReferenceError",{enumerable:!0,get:function(){return z.ReferenceError}}),Object.defineProperty(e,"SyntaxError",{enumerable:!0,get:function(){return z.SyntaxError}}),Object.defineProperty(e,"UndefinedReferenceError",{enumerable:!0,get:function(){return z.UndefinedReferenceError}});const G=r(8146);class W{static nameLengthMax=63;static keywordNames=n.default.keywordNames.filter(t=>"string"==typeof t&&t.length>0).sort();static keywordNameSet=new Set(W.keywordNames);static publicArgumentValidators=["mustBeNumeric","mustBeFloat","mustBeNumericOrLogical","mustBeText","mustBeTextScalar","mustBeNonzeroLengthText","mustBeValidVariableName","mustBeFile","mustBeFolder","mustBeScalarOrEmpty","mustBeScalar","mustBeMatrix","mustBeSquare","mustBeVector","mustBeRow","mustBeColumn","mustBeNonempty","mustBePositive","mustBeNonnegative","mustBeNegative","mustBeNonpositive","mustBeNonzero","mustBeNonNan","mustBeNonmissing","mustBeNonsparse","mustBeSparse","mustBeInteger","mustBeOdd","mustBeFinite","mustBeReal","mustBeGreaterThan","mustBeGreaterThanOrEqual","mustBeLessThan","mustBeLessThanOrEqual","mustBeInRange","mustBeBetween","mustBeMember","mustBeA","mustBeUnderlyingType"];static response={EXTERNAL:-2,WARNING:-1,OK:0,LEX_ERROR:1,PARSER_ERROR:2,EVAL_ERROR:3};_debug=!1;get debug(){return this._debug}set debug(t){this._debug=t}context;commandWordListTable={clear:{preserveAssignment:!0,func:(...t)=>(this.Clear(...t),c.AST.nodeVoid())},run:{preserveAssignment:!0,func:(...t)=>(1!==t.length&&this.context.throwEvalError("Invalid call to run."),this.RunScriptFile(t[0],this.context.currentScope))},source:{preserveAssignment:!0,func:(...t)=>{(t.length<1||t.length>2)&&this.context.throwEvalError("Invalid call to source.");const e=2===t.length?this.context.resolveWorkspace(t[1]):this.context.currentScope;return this.RunScriptFile(t[0],e)}},exist:{preserveAssignment:!0,func:(...t)=>((t.length<1||t.length>2)&&c.AST.throwInvalidCallError("exist",!0,t=>this.context.throwSyntaxError(t)),h.Complex.create(this.existCode(t[0],t[1])))},which:{preserveAssignment:!0,func:(...t)=>{const e=t.join(" ").match(/^\(([\s\S]*)\)$/);if(e){const t=this.evaluatedExecutionResult(this.Parse(e[1]),this.context.currentScope),r="LIST"===t.type&&1===t.list.length?t.list[0]:t;return this.functions.which.func(r)}return c.AST.throwInvalidCallError("which",t.length<1,t=>this.context.throwSyntaxError(t)),new u.CharString(t.map(t=>this.whichResult(t).str).join("\n"))}},who:{func:(...t)=>this.whoResultFromPatterns(t)},whos:{func:(...t)=>this.whosResultFromPatterns(t)},isglobal:{func:(...t)=>(c.AST.throwInvalidCallError("isglobal",1!==t.length,t=>this.context.throwSyntaxError(t)),this.isGlobalName(t[0])?h.Complex.true():h.Complex.false())},dbstack:{func:(...t)=>{const e=t.map(t=>/^\d+$/.test(t)?h.Complex.create(Number(t)):new u.CharString(t));return this.dbstackResult(e)}},warning:{func:(...t)=>{const e=this.warningControlResult(t.map(t=>new u.CharString(t)));return e?"query"===t[0]?.toLowerCase()?e:c.AST.nodeVoid():this.warningResult(this.diagnosticCommandArguments(t))}},error:{func:(...t)=>this.errorResult(this.diagnosticCommandArguments(t))},__operators__:{func:(...t)=>{const e=Object.keys(this.opTable).sort(),r=new d.MultiArray([e.length,1],null,!0);return r.array=e.map(t=>[new u.CharString(t)]),r}},__keywords__:{func:(...t)=>{const e=n.default.keywordNames.slice(1).sort(),r=new d.MultiArray([e.length,1],null,!0);return r.array=e.map(t=>[new u.CharString(t)]),r}},__builtins__:{func:(...t)=>{const e=new d.MultiArray([this.context.builtInFunctionList.length,1],null,!0);return e.array=this.context.builtInFunctionList.sort().map(t=>[new u.CharString(t)]),e}},__list_functions__:{func:(...t)=>d.MultiArray.emptyArray(!0)},__dump_symtab_info__:{func:(...t)=>d.MultiArray.emptyArray(!0)}};commandWordListNameSet=new Set;assignmentSensitiveCommandNameSet=new Set;static assignmentOperatorNames=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]);sourceResolver=q.TableSourceResolver.create();pathValidationCallbacks={};refreshCommandWordListNames(){this.commandWordListNameSet=new Set(Object.keys(this.commandWordListTable)),this.assignmentSensitiveCommandNameSet=new Set(Object.entries(this.commandWordListTable).filter(([,t])=>t.preserveAssignment).map(([t])=>t))}loadingFunctionNames=new Set;loadingClassNames=new Set;loadingClassMethodNames=new Set;scriptExecutionDepth=0;scriptSourceNameStack=[];_exitStatus;lastError;lastWarning={message:"",identifier:""};globalWarningState="on";warningIdentifierStates=new Map;get exitStatus(){return this._exitStatus}incDecOpFactory(t,e){return(r,s)=>{const i=t?void 0:U.RuntimeValue.copy(this.evaluatedExpressionValue(r,s,("plus"===e?"increment":"decrement")+" target")),n=c.AST.nodeOperation("plus"===e?"+=":"-=",this.cloneAssignmentTarget(r),h.Complex.one());return n.parent=r.parent,this.Evaluator(n,s),t?this.evaluatedExpressionValue(r,s,("plus"===e?"increment":"decrement")+" target"):i}}opTable={"+":T.MathOperation.plus,"-":T.MathOperation.minus,".*":T.MathOperation.times,"*":T.MathOperation.mtimes,"./":T.MathOperation.rdivide,"/":T.MathOperation.mrdivide,".\\":T.MathOperation.ldivide,"\\":T.MathOperation.mldivide,".^":T.MathOperation.power,"^":T.MathOperation.mpower,"+_":T.MathOperation.uplus,"-_":T.MathOperation.uminus,".'":T.MathOperation.transpose,"'":T.MathOperation.ctranspose,"<":T.MathOperation.lt,"<=":T.MathOperation.le,"==":T.MathOperation.eq,">=":T.MathOperation.ge,">":T.MathOperation.gt,"!=":T.MathOperation.ne,"&":T.MathOperation.and,"|":T.MathOperation.or,"!":T.MathOperation.not,"&&":T.MathOperation.mand,"||":T.MathOperation.mor,"++_":this.incDecOpFactory(!0,"plus"),"--_":this.incDecOpFactory(!0,"minus"),"_++":this.incDecOpFactory(!1,"plus"),"_--":this.incDecOpFactory(!1,"minus")};static binaryOperatorMethodTable={"+":"plus","-":"minus",".*":"times","*":"mtimes","./":"rdivide","/":"mrdivide",".\\":"ldivide","\\":"mldivide",".^":"power","^":"mpower","<":"lt","<=":"le","==":"eq",">=":"ge",">":"gt","!=":"ne","~=":"ne","&":"and","|":"or","&&":"and","||":"or"};static unaryOperatorMethodTable={"+_":"uplus","-_":"uminus","!":"not","~":"not",".'":"transpose","'":"ctranspose"};static precedence=[["min","=","+=","-=","*=","/=","\\="],["||"],["&&"],["|"],["&"],["!=","<",">","<=",">="],["+","-"],[".*","*","./","/",".\\","\\"],["^",".**","**",".'","'"],["!","~","-_","+_"],["preMax","_.^","_.**","_^","_**","__.'","__'","__++"],["max","()","IDENT","ENDRANGE",":","<~>","."]];precedenceTable;nodePrecedence(t){if("number"==typeof t.type)return h.Complex.isInstanceOf(t)?h.Complex.precedence(t,this):this.precedenceTable.max;if(c.AST.isNodeIndexExpr(t)){const e=c.AST.isNodeIdentifier(t.expr)?this.context.aliasNameFunction(t.expr.id):"";return c.AST.isNodeIdentifier(t.expr)&&e in this.context.builtInFunctionTable&&(this.context.builtInFunctionTable[e].UnparserMathML||e in L.MathML.format)?this.precedenceTable.max:this.precedenceTable.preMax}return"RANGE"===t.type?t.start_&&t.stop_?this.precedenceTable.min:this.precedenceTable.max:this.precedenceTable[t.type]||0}functionArityCallable(t,e){let r;if(p.FunctionHandle.isInstanceOf(e))r=e;else if(u.CharString.isInstanceOf(e)){const s=e.str.trim();0===s.length&&this.context.throwEvalError(`${t}: function name cannot be empty.`),r=s.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(s,this.context.currentScope,void 0,!1,!0)}else this.context.throwSyntaxError(`${t}: argument must be a function handle or function name.`);const s=this.context.resolveCallable(r);return s||this.context.throwEvalError(`${t}: invalid function.`),s}functionArgumentArity(t){return D.FunctionArity.inputArity(t)}functionOutputArity(t){return D.FunctionArity.outputArity(t)}functionHandleFromString(t,e=!1){const r=this.context.globalScope??this.context.currentScope,s=e?r:this.context.currentScope,i=k.FunctionLookup.str2func(t.str,t=>{const e=this.evaluatedExecutionResult(this.Parse(t),r);return"LIST"===e.type&&1===e.list.length?e.list[0]:e},t=>this.context.throwEvalError(t));if(!i.id||i.closure)return i;if(!e){const t=this.createResolvedFunctionHandle(i.id,s,i,"importsOnly");if(t.closure)return t}return this.createResolvedFunctionHandle(i.id,r,i,"global")}resolveRuntimeSymbol(t,e=this.context.currentScope,r={}){return this.context.resolveSymbol(t,e,r)}resolveRuntimeFunction(t,e=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(t,e,{...r,variables:!1,classes:!1})}resolveRuntimeClass(t,e=this.context.currentScope,r={}){return this.resolveRuntimeSymbol(t,e,{...r,variables:!1,functions:!1})}createResolvedFunctionHandle(t,e=this.context.currentScope,r,s=!1,i=!1){const n=this.resolveRuntimeFunction(t,e,{loadFunctions:!1}),a=n?.functionDefinition?void 0:this.lookupFunctionSourceResolution(t,e),o=n??a,l=this.context.aliasNameFunction(t),c=t.includes(".")&&o?o.resolvedName:l,u=p.FunctionHandle.create(c);u.parent=r,u.sourceName=a?.sourceName,u.disallowNestedResolution=i;const h=!t.includes(".")&&this.resolveImportedStaticMethod(t,e);return(!0===s?"FCNDEF"===n?.functionDefinition?.type||"import"===a?.source||h:"importsOnly"===s&&("import"===a?.source||h))&&(u.closure=e.capture(t=>T.MathOperation.copy(t),this.context.allowForwardReference)),"global"===s&&(u.closure=e),u}localFunctionHandles(){return P.FunctionIntrospection.localFunctionHandles(this.context.currentFrame,this.context.currentScope)}functionHandleWorkspaceValue(t,e){return this.runtimeExpressionValue(U.RuntimeValue.copy(t),`workspace ${e}`)}functionHandleWorkspaceInfo(t){if(!t.closure)return d.MultiArray.emptyArray(!0);const e={};for(const[r,s]of Object.entries(t.closure.nameTable))!s||s.global||void 0===s.node||f.ClassDefinition.isInstanceOf(s.node)||(e[r]=this.functionHandleWorkspaceValue(s.node,r));const r=d.MultiArray.scalarToMultiArray(new m.Structure(e));return r.isCell=!0,r}staticMethodInfo(t,e){const r=this.resolveStaticMethod(t,e);return r?{className:r.classDefinition.name,methodName:r.method.name,sourceName:r.method.node.sourceName}:void 0}dbstackResult(t){const e=P.FunctionIntrospection.dbstackResult(t,this.context.callStack,t=>this.context.throwSyntaxError(t));if(this.context.requestedOutputCount>1){const t=d.MultiArray.linearLength(e)>0?1:0;return this.valueReturnList([e,h.Complex.create(t)])}return e}currentMFilename(){const t=this.currentHandleSourceName();if(!t)return this.context.currentFunctionName();const e=t.replace(/\\/g,"/").split(/[?#]/,1)[0].split("/").pop()?.replace(/\.m$/i,"");return e||this.context.currentFunctionName()}currentMFilenameFullPath(){return this.currentHandleSourceName()||this.context.currentFunctionName()}currentHandleSourceName(){return this.context.currentFunctionSourceName()||this.scriptSourceNameStack[this.scriptSourceNameStack.length-1]}currentHandleClassName(){return this.context.currentClassAccessName()||void 0}exceptionToStruct(t){if(m.Structure.isInstanceOf(t))return m.Structure.copy(t);const e=t,r=void 0!==e?.publicStack?this.runtimeExpressionValue(U.RuntimeValue.copy(e.publicStack),"error stack"):P.FunctionIntrospection.dbstackResult([],t instanceof z.InterpreterError&&t.stackFrames?t.stackFrames.slice().reverse():this.context.callStack,t=>this.context.throwSyntaxError(t));return new m.Structure({message:new u.CharString(e?.message??String(t)),identifier:new u.CharString(e?.identifier??""),stack:r})}lastErrorStruct(){return this.lastError?this.exceptionToStruct(this.lastError):this.emptyLastErrorStruct()}emptyLastErrorStruct(){return new m.Structure({message:new u.CharString(""),identifier:new u.CharString(""),stack:d.MultiArray.emptyArray()})}resetLastError(){this.lastError=void 0}rememberLastError(t){return this.lastError=t,this.exceptionToStruct(t)}normalizeLastErrorStruct(t){const e=t.field,r=void 0===e.message?new u.CharString(""):e.message,s=void 0===e.identifier?new u.CharString(""):e.identifier,i=void 0===e.stack?d.MultiArray.emptyArray():e.stack;return u.CharString.isInstanceOf(r)&&u.CharString.isInstanceOf(s)||this.context.throwEvalError("lasterror: error structure message and identifier fields must be strings."),new m.Structure({message:r,identifier:s,stack:this.runtimeExpressionValue(i,"error stack")})}lastErrorResult(t=[]){const e=this.lastErrorStruct();if(0===t.length)return e;if(u.CharString.isInstanceOf(t[0])&&"reset"===t[0].str)return this.resetLastError(),e;if(m.Structure.isInstanceOf(t[0]))return this.lastError=this.normalizeLastErrorStruct(t[0]),e;throw c.AST.throwInvalidCallError("lasterror"),new Error("unreachable")}lastErrorMessageResult(t=[]){t.length>0&&(this.lastError=this.normalizeLastErrorStruct(new m.Structure({message:this.charControlArgument(t[0],"error message"),identifier:2===t.length?this.charControlArgument(t[1],"error identifier"):new u.CharString("")})));const e=this.lastErrorStruct();return this.valueReturnList([this.charControlArgument(e.field.message,"error message"),this.charControlArgument(e.field.identifier,"error identifier")])}setLastWarning(t,e=""){this.lastWarning={message:t,identifier:e}}resetWarningState(){this.setLastWarning(""),this.globalWarningState="on",this.warningIdentifierStates.clear()}warningState(t="all"){return"last"===t?this.warningState(this.lastWarning.identifier||"all"):"all"===t||0===t.length?this.globalWarningState:this.warningIdentifierStates.get(t)??this.globalWarningState}isWarningState(t){return"on"===t||"off"===t||"error"===t}warningStateStruct(t="all"){const e="last"===t?this.lastWarning.identifier||"all":t;return new m.Structure({identifier:new u.CharString(e),state:new u.CharString(this.warningState(e))})}warningStateSnapshot(){const t=[...this.warningIdentifierStates.keys()].sort(),e=[this.warningStateStruct("all"),...t.map(t=>this.warningStateStruct(t))];if(1===e.length)return e[0];const r=new d.MultiArray([e.length,1]);return e.forEach((t,e)=>{r.array[e][0]=t}),d.MultiArray.setType(r),r}warningStateStructParts(t){const e=t.field.identifier,r=t.field.state;return u.CharString.isInstanceOf(e)&&u.CharString.isInstanceOf(r)&&this.isWarningState(r.str)||this.context.throwEvalError("warning: state structure must contain string identifier and state fields."),{identifier:e.str,state:r.str}}restoreWarningState(t,e){const r="last"===t?this.lastWarning.identifier||"all":t;"all"===r||0===r.length?this.globalWarningState=e:this.warningIdentifierStates.set(r,e)}restoreWarningStateStruct(t){let e;if(m.Structure.isInstanceOf(t))e=[t];else{if(!d.MultiArray.isInstanceOf(t)||!m.Structure.isStructure(t))throw c.AST.throwInvalidCallError("warning"),new Error("unreachable");e=d.MultiArray.linearize(t).map(t=>{if(!m.Structure.isInstanceOf(t))throw c.AST.throwInvalidCallError("warning"),new Error("unreachable");return t})}for(const t of e){const e=this.warningStateStructParts(t);this.restoreWarningState(e.identifier,e.state)}return c.AST.nodeVoid()}warningControlResult(t){if(0===t.length)return this.warningStateSnapshot();if(1===t.length&&(m.Structure.isInstanceOf(t[0])||d.MultiArray.isInstanceOf(t[0])&&m.Structure.isStructure(t[0])))return this.restoreWarningStateStruct(t[0]);if(!u.CharString.isInstanceOf(t[0]))return;const e=t[0].str.toLowerCase();if(!this.isWarningState(e)&&"query"!==e)return;if(t.length>2||2===t.length&&!u.CharString.isInstanceOf(t[1]))return;const r=2===t.length?t[1].str:"all";if("query"===e)return 1===t.length?this.warningStateSnapshot():this.warningStateStruct(r);const s=this.warningStateStruct(r),i="last"===r?this.lastWarning.identifier||"all":r;return this.restoreWarningState(i,e),s}diagnosticMessageParts(t,e){return I.DiagnosticMessage.parts(t,e,(t,e)=>this.charControlArgument(t,e),{expressionValue:(t,e)=>this.expressionValue(t,e),unparse:t=>this.Unparse(t),throwEvalError:t=>this.context.throwEvalError(t)})}diagnosticCommandArguments(t){return t.length>1&&t[0].includes(":")?[new u.CharString(t[0]),new u.CharString(t.slice(1).join(" "))]:[new u.CharString(t.join(" "))]}warningResult(t){const e=this.warningControlResult(t);if(e)return e;const{identifier:r,message:s}=this.diagnosticMessageParts(t,"warning");if(this.setLastWarning(s,r),"error"===this.warningState(r))try{this.context.throwEvalError(s)}catch(t){throw r&&(t.identifier=r),t}return this._exitStatus=W.response.WARNING,c.AST.nodeVoid()}errorResult(t){if(1===t.length&&m.Structure.isInstanceOf(t[0])){const e=this.charControlArgument(t[0].field.message??new u.CharString(""),"error structure message").str,r=this.charControlArgument(t[0].field.identifier??new u.CharString(""),"error structure identifier").str;if(!e)return c.AST.nodeVoid();try{this.context.throwEvalError(e)}catch(t){throw r&&(t.identifier=r),t}}const{identifier:e,message:r}=this.diagnosticMessageParts(t,"error");if(!e&&!r)return c.AST.nodeVoid();try{this.context.throwEvalError(r)}catch(t){throw e&&(t.identifier=e),t}}assertUsesDiagnosticForm(t){return 1===t.length||t.length>=2&&u.CharString.isInstanceOf(t[1])&&!u.CharString.isInstanceOf(t[0])}assertNumericElements(t,e){const r=d.MultiArray.scalarToMultiArray(t),s=d.MultiArray.linearize(r);return!r.isCell&&s.every(h.Complex.isInstanceOf)||this.context.throwEvalError(`assert: ${e} must be numeric when tolerance is specified.`),{dimensions:r.dimension.slice(),elements:s}}assertValuesEqualWithinTolerance(t,e,r){const s=this.assertNumericElements(t,"actual value"),i=this.assertNumericElements(e,"expected value");if(s.dimensions.length!==i.dimensions.length||s.dimensions.some((t,e)=>t!==i.dimensions[e]))return!1;const n=this.validateattributesNumericScalar(r,"assert tolerance"),a=Math.abs(n),o=n<0;return s.elements.every((t,e)=>{const r=i.elements[e],s=h.Complex.abs(h.Complex.sub(t,r));return h.Complex.realToNumber(s)<=(o?a*h.Complex.realToNumber(h.Complex.abs(r)):a)})}assertComparisonParts(t){return t.length<=2?{diagnostic:[]}:u.CharString.isInstanceOf(t[2])?{diagnostic:t.slice(2)}:{tolerance:t[2],diagnostic:t.slice(3)}}assertComparisonResult(t){c.AST.throwInvalidCallError("assert",t.length<2,t=>this.context.throwEvalError(t));const e=this.expressionValue(t[0],"assert actual value"),r=this.expressionValue(t[1],"assert expected value"),s=this.assertComparisonParts(t);return(s.tolerance?this.assertValuesEqualWithinTolerance(e,r,s.tolerance):V.RuntimeEquality.valuesEqual(e,r))?c.AST.nodeVoid():s.diagnostic.length>0?this.errorResult(s.diagnostic):void this.context.throwEvalError("assertion failed: observed value does not match expected value.")}assertResult(t){return c.AST.throwInvalidCallError("assert",0===t.length,t=>this.context.throwEvalError(t)),this.assertUsesDiagnosticForm(t)?this.toBoolean(this.expressionValue(t[0],"assert condition"))?c.AST.nodeVoid():(1===t.length&&this.context.throwEvalError("assertion failed."),this.errorResult(t.slice(1))):this.assertComparisonResult(t)}validationTextList(t,e,r){if(u.CharString.isInstanceOf(t))return[t.str];if(d.MultiArray.isInstanceOf(t)){const e=d.MultiArray.linearize(t);if(e.every(u.CharString.isInstanceOf))return e.map(t=>t.str)}this.context.throwEvalError(`${e}: ${r} must be a string or cell array of strings.`)}validationTextItem(t,e,r){if(u.CharString.isInstanceOf(t))return t.str;this.context.throwEvalError(`${e}: ${r} must be a string.`)}validationListItems(t,e,r){return u.CharString.isInstanceOf(t)?[t]:d.MultiArray.isInstanceOf(t)?d.MultiArray.linearize(t):void this.context.throwEvalError(`${e}: ${r} must be a string or cell array.`)}validatestringResult(t){const e=this.charControlArgument(t[0],"validatestring string").str,r=this.validationTextList(t[1],"validatestring","valid strings"),s=e.toLowerCase(),i=this.validatestringDiagnosticPrefix(t),n=r.filter(t=>t.toLowerCase()===s);if(n.length>0)return new u.CharString(n[0]);const a=r.filter(t=>t.toLowerCase().startsWith(s));if(1===a.length)return new u.CharString(a[0]);a.length>1&&this.context.throwEvalError(`${i} ambiguous string '${e}'.`),this.context.throwEvalError(`${i} expected one of: ${r.join(", ")}.`)}validatestringDiagnosticPrefix(t){if(t.length<3)return"validatestring:";const e=this.charControlArgument(t[2],"validatestring function name").str;if(t.length<4)return`validatestring: input for function '${e}'`;const r=this.charControlArgument(t[3],"validatestring variable name").str;return t.length<5?`validatestring: variable '${r}' for function '${e}'`:`validatestring: argument ${this.validateattributesNumericScalar(t[4],"validatestring argument position")} '${r}' for function '${e}'`}validateattributesValidator(t){switch(t.toLowerCase()){case"scalar":return"scalar";case"vector":return"vector";case"row":return"rowVector";case"column":return"columnVector";case"2d":return"matrix2d";case"square":return"squareMatrix";case"nonempty":return"nonempty";case"empty":return"empty";case"real":return"real";case"finite":return"finite";case"nonnan":return"nonnan";case"positive":return"positive";case"nonnegative":return"nonnegative";case"negative":return"negative";case"nonpositive":return"nonpositive";case"nonzero":return"nonzero";case"integer":return"integer";case"nonsparse":return"nonsparse";case"sparse":return"sparse";default:return}}validateattributesDimensions(t){return u.CharString.isString(t)?[1,1]:U.RuntimeValue.dimensions(t)}validateattributesRealNumericElements(t,e){const r=d.MultiArray.linearize(d.MultiArray.scalarToMultiArray(t));return r.every(t=>h.Complex.isInstanceOf(t)&&h.Complex.imagIsZero(t))||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),r}validateattributesNumericScalar(t,e){const r=d.MultiArray.isInstanceOf(t)&&U.RuntimeValue.isScalar(t)?d.MultiArray.firstElement(t):t;return h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: attribute '${e}' parameter must be a real numeric scalar.`),h.Complex.realToNumber(r)}validateattributesNumericVector(t,e){const r=d.MultiArray.scalarToMultiArray(t),s=d.MultiArray.linearize(r);return!r.isCell&&U.RuntimeValue.isVector(r)&&s.every(t=>h.Complex.isInstanceOf(t)&&h.Complex.imagIsZero(t))||this.context.throwEvalError(`validateattributes: attribute '${e}' parameter must be a real numeric vector.`),s.map(t=>h.Complex.realToNumber(t))}validateattributesNumericComparison(t,e,r){const s=this.validateattributesRealNumericElements(t,e);switch(e){case">":return s.every(t=>h.Complex.realGreaterThan(t,r));case">=":return s.every(t=>h.Complex.realGreaterThanOrEqualTo(t,r));case"<":return s.every(t=>h.Complex.realLessThan(t,r));case"<=":return s.every(t=>h.Complex.realLessThanOrEqualTo(t,r));default:return!1}}validateattributesMonotonicColumns(t,e){const r=d.MultiArray.scalarToMultiArray(t);r.isCell&&this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`);for(let t=0;t<r.array.length;t+=r.dimension[0])for(let s=0;s<r.dimension[1];s++)for(let i=1;i<r.dimension[0];i++){const n=r.array[t+i-1][s],a=r.array[t+i][s];if(h.Complex.isInstanceOf(n)&&h.Complex.imagIsZero(n)&&h.Complex.isInstanceOf(a)&&h.Complex.imagIsZero(a)||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),!("increasing"===e?h.Complex.realGreaterThan(a,h.Complex.realToNumber(n)):"decreasing"===e?h.Complex.realLessThan(a,h.Complex.realToNumber(n)):"nondecreasing"===e?h.Complex.realGreaterThanOrEqualTo(a,h.Complex.realToNumber(n)):h.Complex.realLessThanOrEqualTo(a,h.Complex.realToNumber(n))))return!1}return!0}validateattributesSpecialAttribute(t,e){const r=e.toLowerCase();switch(r){case"3d":return this.validateattributesDimensions(t).length<=3;case"scalartext":return u.CharString.isInstanceOf(t)||d.MultiArray.isInstanceOf(t)&&!t.isCell&&U.RuntimeValue.isScalar(t)&&u.CharString.isInstanceOf(d.MultiArray.firstElement(t));case"even":case"odd":return this.validateattributesRealNumericElements(t,e).every(t=>h.Complex.realIsInteger(t)&&Math.abs(h.Complex.realToNumber(t)%2)===("odd"===r?1:0));case"binary":return this.validateattributesRealNumericElements(t,e).every(t=>h.Complex.realEquals(t,0)||h.Complex.realEquals(t,1));case"diag":case"diagonal":{const r=this.validateattributesDimensions(t);if(2!==r.length||r[0]!==r[1])return!1;const s=d.MultiArray.scalarToMultiArray(t);s.isCell&&this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`);for(let t=0;t<r[0];t++)for(let i=0;i<r[1];i++){const r=s.array[t][i];if(h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`validateattributes: ${e} requires real numeric input.`),t!==i&&!h.Complex.realEquals(r,0))return!1}return!0}case"increasing":case"decreasing":case"nondecreasing":case"nonincreasing":return this.validateattributesMonotonicColumns(t,r);default:return}}validateattributesMatchesValidator(t,e){return!("scalar"!==e||!u.CharString.isString(t))||O.FunctionValidation.matchesBuiltInValidator(t,e)}validateattributesParameterizedAttribute(t,e,r,s){const i=this.validateattributesDimensions(t);switch(e.toLowerCase()){case"size":{const t=this.validateattributesNumericVector(r,e);return void(t.length<=i.length&&t.every((t,e)=>Number.isNaN(t)||i[e]===t)&&i.slice(t.length).every(t=>1===t)||this.context.throwEvalError(`validateattributes: ${s} must have size ${t.join("x")}.`))}case"numel":{const i=this.validateattributesNumericVector(r,e);return void(i.includes(U.RuntimeValue.elementCount(t))||this.context.throwEvalError(`validateattributes: ${s} must have ${i.join(" or ")} elements.`))}case"numrows":case"nrows":{const t=this.validateattributesNumericScalar(r,e);return void(i[0]!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} rows.`))}case"numcols":case"ncols":{const t=this.validateattributesNumericScalar(r,e);return void(i[1]!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} columns.`))}case"ndims":{const t=this.validateattributesNumericScalar(r,e);return void(i.length!==t&&this.context.throwEvalError(`validateattributes: ${s} must have ${t} dimensions.`))}case">":case">=":case"<":case"<=":{const i=this.validateattributesNumericScalar(r,e);return void(this.validateattributesNumericComparison(t,e,i)||this.context.throwEvalError(`validateattributes: ${s} must be ${e} ${i}.`))}default:this.context.throwEvalError(`validateattributes: unsupported attribute '${e}'.`)}}validateattributesSubject(t){if(t.length>=6){const e=this.charControlArgument(t[3],"validateattributes function name").str,r=this.charControlArgument(t[4],"validateattributes variable name").str;return`argument ${this.validateattributesNumericScalar(t[5],"validateattributes argument position")} '${r}' for function '${e}'`}return t.length>=5?this.charControlArgument(t[4],"validateattributes variable name").str:t.length>=4?u.CharString.isInstanceOf(t[3])?`input for function '${this.charControlArgument(t[3],"validateattributes function name").str}'`:`argument ${this.validateattributesNumericScalar(t[3],"validateattributes argument position")}`:"input"}validateattributesMatchesClass(t,e){switch(e.toLowerCase()){case"numeric":return O.FunctionValidation.matchesBuiltInValidator(t,"numeric");case"float":return O.FunctionValidation.matchesBuiltInValidator(t,"float");case"integer":return O.FunctionValidation.matchesBuiltInValidator(t,"integer");case"object":return g.ClassInstance.isInstanceOf(t)||d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearize(t).some(g.ClassInstance.isInstanceOf);default:return O.FunctionValidation.matchesClass(t,e)||this.valueIsRuntimeClass(t,e)}}validateattributesResult(t){const e=this.expressionValue(t[0],"validateattributes value"),r=this.validationTextList(t[1],"validateattributes","class list"),s=this.validationListItems(t[2],"validateattributes","attribute list"),i=this.validateattributesSubject(t);r.length>0&&!r.some(t=>this.validateattributesMatchesClass(e,t))&&this.context.throwEvalError(`validateattributes: ${i} must be one of: ${r.join(", ")}.`);for(let t=0;t<s.length;t++){const r=this.validationTextItem(s[t],"validateattributes","attribute"),n=this.validateattributesValidator(r);if(!n){const n=this.validateattributesSpecialAttribute(e,r);if(void 0!==n){n||this.context.throwEvalError(`validateattributes: ${i} must be ${r}.`);continue}t+1>=s.length&&this.context.throwEvalError(`validateattributes: attribute '${r}' requires a parameter.`),this.validateattributesParameterizedAttribute(e,r,s[++t],i);continue}this.validateattributesMatchesValidator(e,n)||this.context.throwEvalError(`validateattributes: ${i} must be ${r}.`)}return c.AST.nodeVoid()}mustBeArity(t){switch(t){case"mustBeGreaterThan":case"mustBeGreaterThanOrEqual":case"mustBeLessThan":case"mustBeLessThanOrEqual":case"mustBeMember":case"mustBeA":case"mustBeUnderlyingType":return{min:2,max:2};case"mustBeInRange":case"mustBeBetween":return{min:3,max:4};default:return{min:1,max:1}}}mustBeResult(t,e){const r=this.mustBeArity(t);c.AST.throwInvalidCallError(t,e.length<r.min||e.length>r.max,t=>this.context.throwEvalError(t));const s=this.runtimeExpressionValue(e[0],`${t} value`),i=e.slice(1).map((e,r)=>this.runtimeExpressionValue(e,`${t} bound ${r+1}`));return"mustBeA"===t?(this.validationTextList(i[0],t,"class list").some(t=>this.valueMatchesValidationClass(s,t,this.context.currentScope))||this.context.throwEvalError(`${t} validation failed for 'input': ${t}.`),c.AST.nodeVoid()):"mustBeUnderlyingType"===t?(this.validationTextList(i[0],t,"type list").includes(O.FunctionValidation.underlyingType(s))||this.context.throwEvalError(`${t} validation failed for 'input': ${t}.`),c.AST.nodeVoid()):(R.FunctionArguments.validateArgumentFunction("input",s,t,i,t=>this.context.throwEvalError(t),t=>this.context.throwSyntaxError(t),this.pathValidationCallbacks,t),c.AST.nodeVoid())}mustBeFunctionEntries(){return Object.fromEntries(W.publicArgumentValidators.map(t=>[t,{func:(...e)=>this.mustBeResult(t,e),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}}]))}commandWordListResult(t){if(void 0!==t)return"string"==typeof t?new u.CharString(t):"number"==typeof t?h.Complex.create(t):"boolean"==typeof t?t?h.Complex.true():h.Complex.false():t}rethrowResult(t){m.Structure.isInstanceOf(t)||this.context.throwEvalError("rethrow: input must be an error structure.");const e=t.field.message,r=t.field.identifier,s=t.field.stack;u.CharString.isInstanceOf(e)&&u.CharString.isInstanceOf(r)&&void 0!==s||this.context.throwEvalError("rethrow: input must be an error structure.");const i=this.runtimeExpressionValue(s,"error stack");try{this.context.throwEvalError(e.str)}catch(t){throw t.publicStack=i,r.str&&(t.identifier=r.str),t}}lastWarningResult(t=[]){return 1===t.length?this.setLastWarning(this.charControlArgument(t[0],"warning message").str):2===t.length&&this.setLastWarning(this.charControlArgument(t[0],"warning message").str,this.charControlArgument(t[1],"warning identifier").str),this.valueReturnList([new u.CharString(this.lastWarning.message),new u.CharString(this.lastWarning.identifier)])}dealResult(t){const e=this.context.requestedOutputMask(Math.max(this.context.requestedOutputCount,t.length)),r=t=>e[t]??!0;return c.AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},e=>{1!==t.length&&1!==e&&e!==t.length&&this.context.throwEvalError("deal: nargin and nargout must match unless there is exactly one input.");const s={length:e};for(let i=0;i<e;i++){if(!r(i))continue;const e=1===t.length?t[0]:t[i];s[`out${i}`]=this.returnListValue(e,`out${i+1}`)}return s})}positiveIntegerIndex(t,e){const r=d.MultiArray.isInstanceOf(t)&&d.MultiArray.isScalar(t)?d.MultiArray.firstElement(t):t;h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError(`${e} must be a positive integer.`);const s=h.Complex.realToNumber(r);return(!Number.isInteger(s)||s<1)&&this.context.throwEvalError(`${e} must be a positive integer.`),s}nthargoutIndexes(t){if(!d.MultiArray.isInstanceOf(t))return{indexes:[this.positiveIntegerIndex(t,"nthargout index")],vector:!1};const e=d.MultiArray.linearize(t);return 0===e.length&&this.context.throwEvalError("nthargout index must be a positive integer."),{indexes:e.map(t=>this.positiveIntegerIndex(t,"nthargout index")),vector:e.length>1}}nthargoutCallable(t){let e=this.expressionValue(t,"nthargout function");if(u.CharString.isInstanceOf(e)){const t=e.str.trim();0===t.length&&this.context.throwEvalError("nthargout: function name cannot be empty."),e=t.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(t,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(e);return r||this.context.throwEvalError("nthargout: function must be a function handle or function name."),r}nthargoutResult(t){const{indexes:e,vector:r}=this.nthargoutIndexes(t[0]),s=t.length>=3&&h.Complex.isInstanceOf(d.MultiArray.isInstanceOf(t[1])&&d.MultiArray.isScalar(t[1])?d.MultiArray.firstElement(t[1]):t[1]),i=s?this.positiveIntegerIndex(t[1],"nthargout total output count"):Math.max(...e);i<Math.max(...e)&&this.context.throwEvalError("nthargout total output count must be at least the largest requested output index.");const n=s?2:1,a=this.nthargoutCallable(t[n]);let o;this.context.pushRequestedOutputCount(i),this.context.pushRequestedOutputMask(Array.from({length:i},()=>!0));try{o=this.context.callCallable(a,this.callArgumentValues(t.slice(n+1),"nthargout"),c.AST.nodeIdentifier("nthargout"))}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}const l=c.AST.ensureReturnList(this.expressionValue(o,"nthargout result")),u=l.handler(i),m=e.map(t=>this.returnListValue(l.selector(u,t-1),`nthargout output ${t}`));if(!r)return m[0];const p=d.MultiArray.toRowVector(m);return p.isCell=!0,p}expressionValue(t,e){return(0,G.expressionValue)(t,e,"Expression value",t=>this.context.throwEvalError(t))}runtimeExpressionValue(t,e){return(0,G.runtimeExpressionValue)(t,e,"Expression value",t=>this.context.throwEvalError(t))}evaluatedExpressionValue(t,e,r){return this.expressionValue(c.AST.reduceToFirstIfReturnList(this.Evaluator(t,e)),r)}evaluatedExecutionResult(t,e){return c.AST.reduceToFirstIfReturnList(this.Evaluator(t,e))}scopedExpressionValue(t,e,r){const s=t.resolveName(e);return s&&void 0!==s.node||this.context.throwEvalError(`internal error: missing scoped expression '${e}'.`),this.expressionValue(s.node,r)}scopedMultiArrayValue(t,e,r){const s=this.scopedExpressionValue(t,e,r);return d.MultiArray.isInstanceOf(s)||this.context.throwEvalError(`internal error: scoped expression '${e}' is not an array.`),s}callArgumentValues(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}charControlArgument(t,e){const r=this.expressionValue(t,e);return u.CharString.isInstanceOf(r)||this.context.throwEvalError(`${e} must be a character string.`),r}charStringList(t,e){return t.every(u.CharString.isInstanceOf)||this.context.throwEvalError(`${e} must contain character strings.`),t}functionHandleControlArgument(t,e){const r=this.expressionValue(t,e);return p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError(`${e} must be a function handle.`),r}booleanControlArgument(t,e){return this.toBoolean(this.expressionValue(t,e))}workerCountControlArgument(t,e){const r=this.expressionValue(t,e),s=d.MultiArray.isScalar(r)?d.MultiArray.firstElement(r):r;h.Complex.isInstanceOf(s)&&0===h.Complex.imagToNumber(s)||this.context.throwEvalError(`${e} must be a nonnegative integer.`);const i=h.Complex.realToNumber(s);return(!Number.isFinite(i)||!Number.isInteger(i)||i<0)&&this.context.throwEvalError(`${e} must be a nonnegative integer.`),i}classMethodArgumentValues(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}reducedClassMethodResult(t,e,r,s){return c.AST.reduceToFirstIfReturnList(this.context.callClassInstanceMethod(t,e,r,s))}reducedClassMethodResultWithOutputCount(t,e,r,s,i){return c.AST.reduceToFirstIfReturnList(this.callClassInstanceMethodWithOutputCount(t,e,r,s,i))}classSubsasgnResult(t,e,r,s){const i=this.reducedClassMethodResult(t,e,r,s);return g.ClassInstance.isInstanceOf(i)||this.context.throwEvalError(`subsasgn for class ${t.classDefinition.name} must return an object of class ${t.classDefinition.name}.`),i.classDefinition===t.classDefinition||i.classDefinition.isSubclassOf(t.classDefinition)||this.context.throwEvalError(`subsasgn for class ${t.classDefinition.name} must return an object of class ${t.classDefinition.name}.`),i}reducedAssignmentValue(t){return c.AST.reduceToFirstIfReturnList(t)}structureAssignmentValue(t,e){return this.runtimeExpressionValue(this.reducedAssignmentValue(t),e)}assignStructureFieldValue(t,e,r,s){if(s&&d.MultiArray.isInstanceOf(t)&&m.Structure.isStructure(t)){const s=m.Structure.structureElements(t),i=d.MultiArray.isInstanceOf(r)?d.MultiArray.linearize(r):[r];if(i.length===s.length)return void s.forEach((t,r)=>{m.Structure.setNewField(t,e,this.runtimeExpressionValue(i[r],`field ${e.join(".")} element ${r+1}`))})}m.Structure.setNewField(t,e,r)}reducedIndexingResult(t){return c.AST.reduceToFirstIfReturnList(t)}assignmentValues(t,e){return d.MultiArray.linearize(this.expressionValue(t,e)).map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}classPropertyPathAssignmentValues(t,e,r){return 1===e||r.tailDescriptors&&r.tailDescriptors.length>0&&d.MultiArray.isInstanceOf(t)&&d.MultiArray.isEmpty(t)?[this.expressionValue(t,"assignment")]:this.assignmentValues(t,"assignment")}expressionList(t,e){return t.map((t,r)=>this.expressionValue(t,`${e}${r+1}`))}linearExpressionValues(t,e){const r=this.expressionValue(t,e);return d.MultiArray.isInstanceOf(r)?d.MultiArray.linearize(r).map((t,r)=>this.expressionValue(t,`${e}${r+1}`)):[r]}copyExpressionValue(t,e){const r=this.expressionValue(t,e);return this.expressionValue(U.RuntimeValue.copy(r),e)}forLoopValues(t,e){if(m.Structure.isInstanceOf(t)){const r=d.MultiArray.isRowVector(e)?d.MultiArray.linearize(this.expressionValue(e,"for target")).length:1;return Object.entries(t.field).map(([t,e])=>{const s=this.expressionValue(e,t);return r>1?this.expressionValue(new d.MultiArray([1,2],[[s,u.CharString.create(t)]]),t):s})}if(u.CharString.isInstanceOf(t))return t.toCharacterScalars();if(!d.MultiArray.isInstanceOf(t))return[this.expressionValue(t,"for")];if(0===t.dimension[0]||0===t.dimension[1])return[];if(1===t.dimension[0]&&!t.isCell)return t.array[0].map((t,e)=>this.expressionValue(t,`for${e+1}`));const r=[];for(let e=0;e<t.dimension[1];e++){const s=new d.MultiArray([t.dimension[0],1],void 0,t.isCell);for(let r=0;r<t.dimension[0];r++)s.array[r][0]=t.array[r][e];r.push(this.expressionValue(s,`for${e+1}`))}return r}forLoopAssignmentValue(t,e){if(!d.MultiArray.isRowVector(t))return this.copyExpressionValue(e,"for");const r=this.linearExpressionValues(e,"for");return c.AST.nodeReturnList((t,e)=>{if(e<r.length)return this.copyExpressionValue(r[e],`for${e+1}`);c.AST.throwErrorIfGreaterThanReturnList(r.length,e+1,t=>this.context.throwEvalError(t))},t=>(t>r.length&&c.AST.throwErrorIfGreaterThanReturnList(r.length,t,t=>this.context.throwEvalError(t)),{length:t}))}validateParforHeader(t,e){c.AST.isNodeIdentifier(t)||this.context.throwEvalError("parfor loop variable must be a simple identifier.");const r=(()=>d.MultiArray.isInstanceOf(e)?((e.isCell||1!==e.dimension[0])&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),d.MultiArray.linearize(e)):[e])().map((t,e)=>{const r=this.expressionValue(t,`parfor range ${e+1}`);h.Complex.isInstanceOf(r)&&0===h.Complex.imagToNumber(r)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");const s=h.Complex.realToNumber(r);return Number.isFinite(s)&&Number.isInteger(s)||this.context.throwEvalError("parfor range must be a row vector of consecutive integer values."),s});if(r.length<=1)return;const s=r[1]-r[0];1!==Math.abs(s)&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.");for(let t=2;t<r.length;t++)r[t]-r[t-1]!==s&&this.context.throwEvalError("parfor range must be a row vector of consecutive integer values.")}validateParforBody(t,e){const r=new Set(["=","+=","-=","*=","/=","\\=","^=","**=",".*=","./=",".\\=",".^=",".**=","&=","|="]),s=t=>c.AST.isNodeIdentifier(t)?t.id===e:c.AST.isNodeIndexExpr(t)?s(t.expr):c.AST.isNodeIndirectRef(t)?s(t.obj):c.AST.isNodeList(t)?t.list.some(s):!!d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearize(t).some(s),i=t=>{if(c.AST.isNodeBase(t)){if("BREAK"!==t.type&&"RETURN"!==t.type||this.context.throwEvalError(("BREAK"===t.type?"break":"return")+" is not allowed inside a parfor loop."),c.AST.isNodeDeclaration(t)&&this.context.throwEvalError(("GLOBAL"===t.type?"global":"persistent")+" declarations are not allowed inside a parfor loop."),c.AST.isNodeCmdWList(t)&&"clear"===t.id&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),(t=>c.AST.isNodeIndexExpr(t)&&c.AST.isNodeIdentifier(t.expr)&&"clear"===t.expr.id&&"()"===t.delim)(t)&&this.context.throwEvalError("clear is not allowed inside a parfor loop."),"SPMD"===t.type&&this.context.throwEvalError("spmd is not allowed inside a parfor loop."),"FOR"===t.type&&!0===Reflect.get(t,"parallel")&&this.context.throwEvalError("nested parfor loops are not allowed."),c.AST.isNodeBinaryOperation(t))return r.has(t.type)&&s(t.left)&&this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),i(t.left),void i(t.right);if(c.AST.isNodePrefixOperation(t))return"++_"!==t.type&&"--_"!==t.type||!s(t.right)||this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),void i(t.right);if(c.AST.isNodePostfixOperation(t))return"_++"!==t.type&&"_--"!==t.type||!s(t.left)||this.context.throwEvalError(`assignment to parfor loop variable '${e}' is not allowed.`),void i(t.left);if(c.AST.isNodeIndexExpr(t))return i(t.expr),void t.args.forEach(i);if(c.AST.isNodeIndirectRef(t))return i(t.obj),void t.field.forEach(t=>{"string"!=typeof t&&i(t)});if(c.AST.isNodeList(t))t.list.forEach(i);else switch(t.type){case"IF":Reflect.get(t,"expression").forEach(i),Reflect.get(t,"then").forEach(i),Reflect.get(t,"else")&&i(Reflect.get(t,"else"));break;case"SWITCH":i(Reflect.get(t,"expression")),Reflect.get(t,"cases").forEach(i),Reflect.get(t,"otherwise")&&i(Reflect.get(t,"otherwise"));break;case"CASE":i(Reflect.get(t,"expression")),i(Reflect.get(t,"then"));break;case"WHILE":case"DO_UNTIL":i(Reflect.get(t,"expression")),i(Reflect.get(t,"body"));break;case"FOR":i(Reflect.get(t,"target")),i(Reflect.get(t,"expression")),i(Reflect.get(t,"body"));break;case"TRY":i(Reflect.get(t,"body")),Reflect.get(t,"catchBody")&&i(Reflect.get(t,"catchBody"));break;case"UNWIND_PROTECT":i(Reflect.get(t,"body")),i(Reflect.get(t,"cleanup"))}}};i(t)}validateSpmdBody(t){const e=t=>{if(p.FunctionHandle.isInstanceOf(t))void 0===t.id&&this.context.throwEvalError("anonymous function definitions are not allowed inside an spmd block.");else if(c.AST.isNodeBase(t)){if("BREAK"!==t.type&&"CONTINUE"!==t.type&&"RETURN"!==t.type||this.context.throwEvalError(("BREAK"===t.type?"break":"CONTINUE"===t.type?"continue":"return")+" is not allowed inside an spmd block."),c.AST.isNodeDeclaration(t)&&this.context.throwEvalError(("GLOBAL"===t.type?"global":"persistent")+" declarations are not allowed inside an spmd block."),c.AST.isNodeCmdWList(t)&&"clear"===t.id&&this.context.throwEvalError("clear is not allowed inside an spmd block."),(t=>c.AST.isNodeIndexExpr(t)&&c.AST.isNodeIdentifier(t.expr)&&"clear"===t.expr.id&&"()"===t.delim)(t)&&this.context.throwEvalError("clear is not allowed inside an spmd block."),"SPMD"===t.type&&this.context.throwEvalError("nested spmd blocks are not allowed."),"FOR"===t.type&&!0===Reflect.get(t,"parallel")&&this.context.throwEvalError("parfor is not allowed inside an spmd block."),c.AST.isNodeBinaryOperation(t))return e(t.left),void e(t.right);if(c.AST.isNodePrefixOperation(t))e(t.right);else if(c.AST.isNodePostfixOperation(t))e(t.left);else{if(c.AST.isNodeIndexExpr(t))return e(t.expr),void t.args.forEach(e);if(c.AST.isNodeIndirectRef(t))return e(t.obj),void t.field.forEach(t=>{"string"!=typeof t&&e(t)});if(c.AST.isNodeList(t))t.list.forEach(e);else switch(t.type){case"IF":Reflect.get(t,"expression").forEach(e),Reflect.get(t,"then").forEach(e),Reflect.get(t,"else")&&e(Reflect.get(t,"else"));break;case"SWITCH":e(Reflect.get(t,"expression")),Reflect.get(t,"cases").forEach(e),Reflect.get(t,"otherwise")&&e(Reflect.get(t,"otherwise"));break;case"CASE":e(Reflect.get(t,"expression")),e(Reflect.get(t,"then"));break;case"WHILE":case"DO_UNTIL":e(Reflect.get(t,"expression")),e(Reflect.get(t,"body"));break;case"FOR":e(Reflect.get(t,"target")),e(Reflect.get(t,"expression")),Reflect.get(t,"workers")&&e(Reflect.get(t,"workers")),e(Reflect.get(t,"body"));break;case"TRY":e(Reflect.get(t,"body")),Reflect.get(t,"catchBody")&&e(Reflect.get(t,"catchBody"));break;case"UNWIND_PROTECT":e(Reflect.get(t,"body")),e(Reflect.get(t,"cleanup"))}}}};e(t)}cloneAssignmentTarget(t){if(h.Complex.isInstanceOf(t)||u.CharString.isInstanceOf(t)||m.Structure.isInstanceOf(t)||p.FunctionHandle.isInstanceOf(t)||f.ClassDefinition.isInstanceOf(t)||g.ClassInstance.isInstanceOf(t)||y.ClassBoundMethod.isInstanceOf(t)||x.ClassStaticMethod.isInstanceOf(t)||C.ClassEmptyMethod.isInstanceOf(t)||E.ClassEnumerationValue.isInstanceOf(t)||v.ClassMetaObject.isInstanceOf(t))return this.copyExpressionValue(t,"assignment target");if(c.AST.isNodeIdentifier(t))return c.AST.nodeIdentifier(t.id);if(c.AST.isNodeIgnoredTarget(t))return c.AST.nodeIgnoredTarget();if(c.AST.isNodeIndexExpr(t))return c.AST.nodeIndexExpr(this.cloneAssignmentTarget(t.expr),c.AST.nodeList(t.args.map(t=>this.cloneAssignmentTarget(t))),t.delim);if(c.AST.isNodeIndirectRef(t)){const e=t.field[0];let r=c.AST.nodeIndirectRef(this.cloneAssignmentTarget(t.obj),"string"==typeof e?e:this.cloneAssignmentTarget(e));for(let e=1;e<t.field.length;e++){const s=t.field[e];r=c.AST.nodeIndirectRef(r,"string"==typeof s?s:this.cloneAssignmentTarget(s))}return r}if(d.MultiArray.isInstanceOf(t)){const e=t,r=new d.MultiArray(e.dimension,void 0,e.isCell);for(let t=0;t<e.dimension[0];t++)for(let s=0;s<e.dimension[1];s++)r.array[t][s]=this.cloneAssignmentTarget(e.array[t][s]);return d.MultiArray.setType(r),this.expressionValue(r,"assignment target")}return this.expressionValue(c.AST.nodeCopy(this.expressionValue(t,"assignment target")),"assignment target")}returnListValue(t,e){return(0,G.expressionValue)(t,e,"Return value",t=>this.context.throwEvalError(t))}valueReturnList(t,e){const r=e??this.context.requestedOutputMask(t.length),s=t=>r[t]??!0;return c.AST.nodeCommaSeparatedReturnList(t.length,(t,e)=>{const r=t[`out${e}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},e=>{c.AST.throwErrorIfGreaterThanReturnList(t.length,e,t=>this.context.throwEvalError(t));const r={length:e};for(let i=0;i<e;i++)s(i)&&(r[`out${i}`]=this.returnListValue(t[i],`out${i+1}`));return r})}compoundAssignmentOperand(t,e){if(!c.AST.isNodeReturnList(t)||!t.commaSeparated)return this.expressionValue(t,e);const r=t.returnListLength??t.handler(0).length,s=t.handler(r),i=[];for(let n=0;n<r;n++)i.push(this.expressionValue(t.selector(s,n),`${e}${n+1}`));return d.MultiArray.toRowVector(i)}nestedAssignmentValue(t){const e=t.list[0];return c.AST.isNodeBinaryOperation(e)&&"="===e.type||this.context.throwEvalError("invalid nested assignment result."),this.expressionValue(e.right,"assignment result")}evalStringInScope(t,e,r={}){const s=this.Parse(t);s.parent=null,this.validateDeclarationPlacement(s);const i=this.pushDynamicNameCreationGuard(e);this.context.pushCallStackFrame(new B.CallFrame(e));try{const t=r.requestedOutputCount??this.context.requestedOutputCount,i=r.requestedOutputMask??this.context.requestedOutputMask(t);this.context.pushRequestedOutputCount(t),this.context.pushRequestedOutputMask(i);try{if(c.AST.isNodeList(s)&&1===s.list.length&&!s.list[0].omitOutput){let t=s.list[0];return c.AST.isNodeIdentifier(t)&&!e.resolveName(t.id)&&this.commandWordListNameSet.has(t.id)&&(t=c.AST.nodeEmptyCmdWList(t),s.list[0]=t),t.index=0,this.Evaluator(t,e)}const t=this.Evaluator(s,e);return c.AST.isNodeList(t)&&1===t.list.length&&c.AST.isNodeReturnList(t.list[0])?t.list[0]:t}catch(t){if(r.topLevelReturn&&t instanceof j.ReturnSignal)return c.AST.nodeVoid();throw t}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}finally{this.context.popCallStackFrame(),i()}}pushDynamicNameCreationGuard(t){const e=t.rejectDynamicNameCreation;return t.staticWorkspaceNameSet&&(t.rejectDynamicNameCreation=!0),()=>{t.rejectDynamicNameCreation=e}}isEvalCatchableError(t){return!(t instanceof j.ReturnSignal||t instanceof j.BreakSignal||t instanceof j.ContinueSignal)}evalcResult(t,e){const r=this.context.requestedOutputCount,s=Math.max(r-1,1),i=this.context.requestedOutputMask(r),n=Array.from({length:s},(t,e)=>i[e+1]??!0);let a;a=F.FunctionWorkspace.evaluateWithCatch(this.context.currentScope,t,e,(t,e)=>this.evalStringInScope(t,e,{requestedOutputCount:s,requestedOutputMask:n}),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t));const o=new Array(s);let l=a;if(c.AST.isNodeReturnList(a)){const t=a.handler(s);for(let e=0;e<s;e++)n[e]&&(o[e]=this.returnListValue(a.selector(t,e),`evalc output ${e+1}`));const e=o.filter(t=>void 0!==t);l=0===e.length?c.AST.nodeVoid():1===e.length?e[0]:c.AST.nodeList(e.map(t=>this.returnListValue(t,"evalc display value")))}else"VOID"!==a.type&&(o[0]=this.returnListValue(a,"evalc output 1"));const h=new u.CharString(this.Unparse(l));return r>1?this.valueReturnList([h,...o],i):h}topLevelClassDefinitions(t){return c.AST.isNodeClassDef(t)?[t]:c.AST.isNodeList(t)?t.list.filter(c.AST.isNodeClassDef):[]}topLevelFunctionDefinitions(t){return c.AST.isNodeFunctionDefinition(t)?[t]:c.AST.isNodeList(t)?t.list.filter(c.AST.isNodeFunctionDefinition):[]}parseFunctionSource(t,e){const r=t.split(".").pop()??t,s=this.Parse(e);this.validateDeclarationPlacement(s);const i=this.topLevelFunctionDefinitions(s),n=i.find(e=>e.id===r||e.id===t);return n||this.context.throwEvalError(`function '${t}' could not be loaded: source does not contain primary function ${r}.`),n.id=t,{primary:n,subfunctions:i.filter(t=>t!==n)}}resolveFunctionSource(t){return this.sourceResolver.resolve("function",t)}hasFunctionSource(t){return Boolean(this.validFunctionSource(t))}validFunctionSource(t){const e=this.resolveFunctionSource(t);if(void 0!==e)try{const r=this.parseFunctionSource(e.name??t,e.source);return this.validateFunctionFileDefinitions(r.primary,r.subfunctions,`function file ${e.name??t}`),e}catch(t){return}}validateFunctionFileDefinitions(t,e,r=`function file ${t.id}`){this.validateFunctionSignature(t),this.validateFunctionArgumentsBlocks(t);const s=new Set([t.id]);for(const t of e)s.has(t.id)&&this.context.throwSyntaxError(`duplicate function '${t.id}' in ${r}.`),s.add(t.id),this.validateFunctionSignature(t),this.validateFunctionArgumentsBlocks(t)}registerFunctionFileDefinition(t,e,r,s=t.id){this.validateFunctionFileDefinitions(t,e,`function file ${t.id}`);const i=$.Scope.create(r,!1);i.defineFunction(t.id,t),t.definingScope=i,t.sourceName=s,(t.attributes?.nested||t.attributes?.subfunction)&&(t.attributes={...t.attributes},delete t.attributes.nested,delete t.attributes.subfunction);for(const t of e)t.definingScope=i,t.sourceName=s,t.attributes={...t.attributes??{},subfunction:!0},delete t.attributes.nested,i.defineFunction(t.id,t);return r.defineFunction(t.id,t),t}LoadFunctionFile(t,e,r=this.context.globalScope??this.context.currentScope,s=t){const i=this.parseFunctionSource(t,e);return this.registerFunctionFileDefinition(i.primary,i.subfunctions,r,s)}loadFunctionDefinition(t,e){const r=this.resolveFunctionSource(t);if(r&&!this.loadingFunctionNames.has(t)){this.loadingFunctionNames.add(t);try{return this.LoadFunctionFile(r.name??t,r.source,this.context.globalScope??e,r.sourceName??r.name??t)}finally{this.loadingFunctionNames.delete(t)}}}resolveScriptSource(t){return this.sourceResolver.resolve("script",t)}hasScriptSource(t){return Boolean(this.validScriptSource(t))}validScriptSource(t){const e=this.resolveScriptSource(t);if(void 0!==e)try{const t=this.Parse(e.source);return this.validateDeclarationPlacement(t),e}catch(t){return}}executeScriptTree(t,e,r){const s=this.topLevelFunctionDefinitions(t),i=new Map,n=e.importSnapshot(),a=this.pushDynamicNameCreationGuard(e);for(const t of s)i.has(t.id)||i.set(t.id,e.functionTable[t.id]);this.scriptExecutionDepth++,this.scriptSourceNameStack.push(r);try{return this.applyScopedImports(t,e),this.Evaluator(t,e)}catch(t){if(t instanceof j.ReturnSignal)return c.AST.nodeVoid();throw t}finally{this.scriptSourceNameStack.pop(),this.scriptExecutionDepth--,a();for(const[t,r]of i)r?e.defineFunction(t,r):e.removeFunction(t);e.restoreImports(n)}}LoadScriptFile(t,e,r=this.context.currentScope,s=t){const i=this.Parse(e);return i.parent=null,this.validateDeclarationPlacement(i),this.executeScriptTree(i,r,s)}RunScriptFile(t,e=this.context.currentScope){const r=this.resolveScriptSource(t);return r||this.context.throwEvalError(`script '${t}' could not be loaded.`),this.LoadScriptFile(r.name??t,r.source,e,r.sourceName??r.name??t)}parseClassSource(t,e){const r=this.tryParseClassSource(t,e);if(!r){const e=t.split(".").pop()??t;this.context.throwEvalError(`class '${t}' could not be loaded: source does not contain classdef ${e}.`)}return r}tryParseClassSource(t,e){const r=t.split(".").pop()??t,s=this.Parse(e);this.validateDeclarationPlacement(s);const i=this.topLevelClassDefinitions(s).find(t=>t.id===r);if(i)return i.id=t,i}isFunctionOnlySource(t){const e=this.Parse(t);return this.validateDeclarationPlacement(e),0===this.topLevelClassDefinitions(e).length&&this.topLevelFunctionDefinitions(e).length>0}parseClassMethodSource(t,e,r,s){const i=new Set([e,r]);e.includes(".")||i.add(r.split(".").pop()??r);const n=this.Parse(s);this.validateDeclarationPlacement(n);const a=this.topLevelFunctionDefinitions(n),o=a.find(t=>i.has(t.id));return o||this.context.throwEvalError(`method '${e}' for class ${t} could not be loaded: source does not contain primary function ${e}.`),o.id=e,o.attributes?.prototype&&(o.attributes={...o.attributes},delete o.attributes.prototype),{primary:o,subfunctions:a.filter(t=>t!==o)}}resolveClassSource(t){return this.sourceResolver.resolve("class",t)}hasClassSource(t){return Boolean(this.validClassSource(t))}validClassSource(t){const e=this.resolveClassSource(t);if(void 0!==e)try{const r=this.tryParseClassSource(e.name??t,e.source);if(!r)return;return f.ClassDefinition.create(r).validateLocalDefinition(t=>this.context.throwEvalError(t)),e}catch(t){return}}attachClassDefinitionSourceName(t,e){for(const r of t.methods)r.node.sourceName=e}loadClassDefinition(t,e){const r=this.resolveClassSource(t);if(r&&!this.loadingClassNames.has(t)){this.loadingClassNames.add(t);try{const s=this.tryParseClassSource(r.name??t,r.source);if(!s){if(this.isFunctionOnlySource(r.source))return;return void this.parseClassSource(r.name??t,r.source)}const i=f.ClassDefinition.create(s);return this.attachClassDefinitionSourceName(i,r.sourceName??r.name??t),i.resolveSuperclasses(t=>this.context.resolveClassDefinition(t,e),t=>this.context.throwEvalError(t)),i}finally{this.loadingClassNames.delete(t)}}}loadClassMethodDefinition(t,e,r){const s=`${t}.${e}`,i=this.resolveClassSource(s);if(i&&!this.loadingClassMethodNames.has(s)){this.loadingClassMethodNames.add(s);try{const n=this.parseClassMethodSource(t,e,i.name??s,i.source),a=$.Scope.create(this.context.globalScope??r,!1);this.validateFunctionFileDefinitions(n.primary,n.subfunctions,`method file ${s}`),n.primary.definingScope=a,n.primary.sourceName=i.sourceName??i.name??s,a.defineFunction(n.primary.id,n.primary);for(const t of n.subfunctions)t.definingScope=a,t.sourceName=i.sourceName??i.name??s,t.attributes={...t.attributes??{},subfunction:!0},delete t.attributes.nested,a.defineFunction(t.id,t);return n.primary}finally{this.loadingClassMethodNames.delete(s)}}}qualifiedReferenceParts(t){if("IDENT"===t.obj.type&&!t.field.some(t=>"string"!=typeof t))return[t.obj.id,...t.field]}resolveClassDefinitionMemberChain(t,e,r){let s=t;for(const t of e)if(f.ClassDefinition.isInstanceOf(s)){const e=s.findProperty(t);if(e?.isConstant){this.assertCanReadClassProperty(e,t,s.name),s=e.defaultValue?this.evaluatedExpressionValue(e.defaultValue,r,`constant property ${t}`):d.MultiArray.emptyArray();continue}const i=s.findEnumeration(t);if(i){const t=i.args.map((t,e)=>this.runtimeExpressionValue(this.evaluatedExpressionValue(t,r,`enumeration argument ${e+1}`),`enumeration argument ${e+1}`));s=E.ClassEnumerationValue.create(i.classDefinition,i,t);continue}if("empty"===t){s=C.ClassEmptyMethod.bind(s);continue}const n=s.findMethod(t,t=>t.isStatic);if(n){this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method '${t}' has ${n.access} access for class ${s.name}.`),s=x.ClassStaticMethod.bind(s,n);continue}this.context.throwEvalError(`unknown static method '${t}' for class ${s.name}.`)}else s=m.Structure.getField(s,[t]);return s}resolveQualifiedAccess(t,e){const r=this.qualifiedReferenceParts(t);if(!r||r.length<2||this.hasConcreteName(e,r[0]))return;for(let t=r.length;t>=2;t--){const s=r.slice(0,t).join("."),i=this.resolveRuntimeClass(s,e,{imports:!1});if("class"===i?.kind)return{kind:"class-member-chain",parts:r,prefixLength:t,resolvedName:i.resolvedName,classDefinition:i.classDefinition}}const s=r.join("."),i=this.resolveRuntimeFunction(s,e,{imports:!1});if(i?.functionDefinition){const e=p.FunctionHandle.create(i.resolvedName);return e.parent=t,{kind:"function",parts:r,prefixLength:r.length,resolvedName:i.resolvedName,functionHandle:e}}}resolveQualifiedNameAccess(t,e){const r=this.resolveQualifiedAccess(t,e);if(r)switch(r.kind){case"class-member-chain":return r.classDefinition.parent=t,this.resolveClassDefinitionMemberChain(r.classDefinition,r.parts.slice(r.prefixLength),e);case"function":return r.functionHandle}}hasConcreteName(t,e){const r=t.resolveName(e);return void 0!==r?.node&&!r.undefinedReference}resolveImportedStaticMethod(t,e){const r=[...new Map(e.importedNameCandidates(t).map(t=>this.importedStaticMethodCandidate(t,e)).filter(t=>void 0!==t).map(t=>[t.name,t.method])).entries()];return r.length>1&&this.context.throwEvalError(`imported name '${t}' is ambiguous: ${r.map(([t])=>t).join(", ")}.`),r[0]?.[1]}resolveStaticMethod(t,e){const r=this.context.aliasNameFunction(t);if(!r.includes("."))return this.resolveImportedStaticMethod(r,e);const s=r.split("."),i=s[s.length-1],n=s.slice(0,-1).join("."),a=this.resolveRuntimeClass(n,e,{imports:!1});if("class"!==a?.kind||!a.classDefinition)return;const o=a.classDefinition.findMethod(i,t=>t.isStatic);return o?(this.context.canAccessClassMember(o.classDefinition,o.access)||this.context.throwEvalError(`method '${i}' has ${o.access} access for class ${a.classDefinition.name}.`),x.ClassStaticMethod.bind(a.classDefinition,o)):void 0}importedStaticMethodCandidate(t,e){const r=t.split(".");if(r.length<2)return;const s=r[r.length-1],i=r.slice(0,-1).join("."),n=this.resolveRuntimeClass(i,e,{imports:!1});if("class"!==n?.kind||!n.classDefinition)return;const a=n.classDefinition.findMethod(s,t=>t.isStatic);return a?(this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method '${s}' has ${a.access} access for class ${n.classDefinition.name}.`),{name:t,method:x.ClassStaticMethod.bind(n.classDefinition,a)}):void 0}hasQualifiedNameAccessOperand(t,e){return c.AST.isNodeIndirectRef(t)?void 0!==this.resolveQualifiedAccess(t,e)||this.hasQualifiedNameAccessOperand(t.obj,e):!!c.AST.isNodeIndexExpr(t)&&this.hasQualifiedNameAccessOperand(t.expr,e)}resolveMetaclassLiteral(t,e){const r=t.split(".");for(let t=r.length;t>=1;t--){const s=r.slice(0,t).join("."),i=this.context.resolveClassDefinition(s,e);if(!i)continue;let n=this.createClassMetaClass(i,e);for(const e of r.slice(t))if(v.ClassMetaObject.isInstanceOf(n)){const t=n.getProperty(e);void 0===t&&this.context.throwEvalError(`unknown property '${e}' for ${n.kind}.`),n=t}else n=m.Structure.getField(n,[e]);return n}this.context.throwEvalError(`metaclass: class '${t}' is not defined.`)}createClassMetaClass(t,e=this.context.currentScope){return v.ClassMetaClass.create(t,t=>t.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(t.defaultValue,e,`property ${t.name} default`),`property ${t.name} default`):void 0)}createClassMetaProperty(t,e=this.context.currentScope){return v.ClassMetaProperty.create(t,t=>t.defaultValue?this.runtimeExpressionValue(this.evaluatedExpressionValue(t.defaultValue,e,`property ${t.name} default`),`property ${t.name} default`):void 0)}functionCountMessage(t,e){return"nargchk"===t?"low"===e?{message:"Not enough input arguments.",identifier:"MATLAB:nargchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:nargchk:tooManyInputs"}:"narginchk"===t?"low"===e?{message:"Not enough input arguments.",identifier:"MATLAB:narginchk:notEnoughInputs"}:{message:"Too many input arguments.",identifier:"MATLAB:narginchk:tooManyInputs"}:"low"===e?{message:"Not enough output arguments.",identifier:"MATLAB:nargoutchk:notEnoughOutputs"}:{message:"Too many output arguments.",identifier:"MATLAB:nargoutchk:tooManyOutputs"}}functionCountStatus(t,e,r,s){const i=D.FunctionArity.countBound(t,e,!1,t=>this.context.throwSyntaxError(t)),n=D.FunctionArity.countBound(t,r,!0,t=>this.context.throwSyntaxError(t));return n<i&&this.context.throwSyntaxError(`${t}: maximum count must be greater than or equal to minimum count.`),s<i?"low":s>n?"high":"ok"}checkFunctionCount(t,e,r){const s="narginchk"===t?h.Complex.realToNumber(this.context.currentFunctionArgumentCountOrZero()):h.Complex.realToNumber(this.context.currentFunctionOutputCountOrZero());return"ok"!==this.functionCountStatus(t,e,r,s)&&this.context.throwEvalError(`${t}: invalid number of ${"narginchk"===t?"input":"output"} arguments.`),c.AST.nodeVoid()}functionCountMessageResult(t,e){const r=D.FunctionArity.countBound(t,e[2],!1,t=>this.context.throwSyntaxError(t)),s=this.functionCountStatus(t,e[0],e[1],r);if(4===e.length){const r=this.charControlArgument(e[3],`${t} output kind`).str;if(c.AST.throwInvalidCallError(t,"struct"!==r&&"string"!==r,t=>this.context.throwSyntaxError(t)),"string"===r)return"ok"===s?new u.CharString(""):u.CharString.create(this.functionCountMessage(t,s).message,"'");if("ok"===s)return new m.Structure({});const i=this.functionCountMessage(t,s);return new m.Structure({message:u.CharString.create(i.message,"'"),identifier:u.CharString.create(i.identifier,"'")})}return"ok"===s?new u.CharString(""):u.CharString.create(this.functionCountMessage(t,s).message,"'")}nargoutchkResult(t){return 2===t.length?this.checkFunctionCount("nargoutchk",t[0],t[1]):this.functionCountMessageResult("nargoutchk",t)}nargchkResult(t){return this.functionCountMessageResult("nargchk",t)}lookupImportedSourceResolution(t,e,r,s){const i=this.context.aliasNameFunction(t),n=s(i);if(n)return{kind:r,name:t,resolvedName:i,source:"local",sourceName:n.sourceName??n.name??i};if(!i.includes(".")){const n=[...new Map(e.importedNameCandidates(i).map(t=>this.context.aliasNameFunction(t)).map(t=>({importedCanonical:t,source:s(t)})).filter(t=>void 0!==t.source).map(({importedCanonical:e,source:s})=>[e,{kind:r,name:t,resolvedName:e,source:"import",sourceName:s.sourceName??s.name??e}])).values()];if(n.length>1&&this.context.throwEvalError(`imported name '${i}' is ambiguous: ${n.map(t=>t.resolvedName).join(", ")}.`),1===n.length)return n[0]}}lookupClassSourceResolution(t,e){return this.lookupImportedSourceResolution(t,e,"class",t=>this.validClassSource(t))}lookupFunctionSourceResolution(t,e){return this.lookupImportedSourceResolution(t,e,"function",t=>this.validFunctionSource(t))}lookupScriptSourceResolution(t){const e=this.context.aliasNameFunction(t),r=this.validScriptSource(e);if(r)return{kind:"script",name:t,resolvedName:e,source:"local",sourceName:r.sourceName??r.name??e}}lookupDirectorySourceResolution(t){const e=this.context.aliasNameFunction(t);return this.sourceResolver.hasDirectory(e)?{kind:"directory",name:t,resolvedName:e,source:"local"}:void 0}resolveLookupSymbol(t,e,r=this.context.currentScope){const s=e?.trim().toLowerCase();if("dir"===s)return this.lookupDirectorySourceResolution(t);if("builtin"===s){const e=this.context.aliasNameFunction(t),r=this.context.builtInFunctionTable[e];return r?{kind:"builtin",name:t,resolvedName:e,source:"builtin",functionDefinition:r}:void 0}const i="class"===s||void 0===s,n=i||"file"===s,a="file"===s||void 0===s,o="class"!==s&&"var"!==s&&"variable"!==s,l=this.resolveRuntimeSymbol(t,r,{variables:"class"!==s&&"file"!==s&&"function"!==s,classes:i,loadClasses:!1,functions:o,loadFunctions:!1});if(l){if(o&&"builtin"===l.kind){const e=this.lookupFunctionSourceResolution(t,r);if(e)return e}return l}return(o?this.lookupFunctionSourceResolution(t,r):void 0)??(n?this.lookupClassSourceResolution(t,r):void 0)??(a?this.lookupScriptSourceResolution(t):void 0)??("file"===s||void 0===s?this.lookupDirectorySourceResolution(t):void 0)}existCode(t,e){const r=this.resolveLookupSymbol(t,e);return k.FunctionLookup.existCodeFromResolution(t,e,r)}whichResult(t,e){const r=e?.closure??this.context.currentScope,s=e?e.id?this.resolveLookupSymbol(e.id,"function",r):void 0:this.resolveLookupSymbol(t),i=!s&&t?this.staticMethodInfo(t,r):void 0;return k.FunctionLookup.whichResultFromResolution(t,s,e,t=>p.FunctionHandle.unparse(t,this),i)}isClassName(t,e=this.context.currentScope){return k.FunctionLookup.isRuntimeClassName(t)||Boolean(this.resolveRuntimeClass(t,e,{loadClasses:!1}))||Boolean(this.lookupClassSourceResolution(t,e))}valueIsRuntimeClass(t,e){switch(e){case"double":case"logical":case"char":case"cell":case"struct":case"function_handle":return this.getValueClassName(t)===e;case"event.listener":return A.ClassEventListener.isInstanceOf(t);case"event.proplistener":return A.ClassEventListener.isInstanceOf(t)&&"event.proplistener"===t.kind;case"event.EventData":return _.ClassEventData.isInstanceOf(t)||g.ClassInstance.isInstanceOf(t)&&t.classDefinition.isSubclassOfName("event.EventData");case"event.PropertyEvent":return S.ClassPropertyEvent.isInstanceOf(t);default:if(d.MultiArray.isInstanceOf(t)){const r=d.MultiArray.linearize(t);return r.length>0&&r.every(t=>this.valueIsRuntimeClass(t,e))}return v.ClassMetaObject.isInstanceOf(t)?t.kind===e:(g.ClassInstance.isInstanceOf(t)||!!E.ClassEnumerationValue.isInstanceOf(t))&&(t.classDefinition.name===e||t.classDefinition.isSubclassOfName(e))}}valueMatchesValidationClass(t,e,r,s=!1){if(O.FunctionValidation.matchesClass(t,e)||this.valueIsRuntimeClass(t,e))return!0;const i=this.context.resolveClassDefinition(e,r);if(!i)return!1;const n=t=>!(!g.ClassInstance.isInstanceOf(t)&&!E.ClassEnumerationValue.isInstanceOf(t))&&(t.classDefinition===i||t.classDefinition.isSubclassOf(i));if(d.MultiArray.isInstanceOf(t)){const e=d.MultiArray.linearize(t);return!(0!==e.length||!s||!d.MultiArray.isEmpty(t))||e.length>0&&e.every(n)}return n(t)}classIntrospectionArgument(t,e){if(!u.CharString.isInstanceOf(e))return e;const r=e.str,s=this.context.resolveClassDefinition(r);if(s)return s;this.context.throwEvalError(`${t}: class '${r}' is not defined.`)}metaclassArgument(t){if(v.ClassMetaClass.isInstanceOf(t))return t;if(f.ClassDefinition.isInstanceOf(t))return this.createClassMetaClass(t);if(g.ClassInstance.isInstanceOf(t)||E.ClassEnumerationValue.isInstanceOf(t))return this.createClassMetaClass(t.classDefinition);if(u.CharString.isInstanceOf(t)){const e=this.context.resolveClassDefinition(t.str);if(e)return this.createClassMetaClass(e);this.context.throwEvalError(`metaclass: class '${t.str}' is not defined.`)}this.context.throwEvalError("metaclass: input must be a class object or class name.")}eventData(t,e){return _.ClassEventData.create(t,e)}propertyEventData(t,e,r=e,s=t){return S.ClassPropertyEvent.create(t,e,r,s)}isEventDataObject(t){return _.ClassEventData.isInstanceOf(t)||g.ClassInstance.isInstanceOf(t)&&t.classDefinition.isSubclassOfName("event.EventData")}prepareEventDataObject(t,e,r){return _.ClassEventData.isInstanceOf(r)?(r.source=t,r.eventName=e):g.ClassInstance.isInstanceOf(r)&&(r.eventDataSource=t,r.eventDataEventName=e),r}propertyEventKey(t,e){return`${t}:${e}`}validateClassEventAccess(t,e,r){const s=t.classDefinition.findEvent(e);if(s){const i="listen"===r?s.listenAccess:s.notifyAccess;return this.context.canAccessClassMember(s.classDefinition,i)||this.context.throwEvalError(`event '${e}' has ${i} ${r} access for class ${t.classDefinition.name}.`),s}const i=t.classDefinition.findProperty(e);i&&(i.isGetObservable||i.isSetObservable)||this.context.throwEvalError(`unknown event '${e}' for class ${t.classDefinition.name}.`)}validatePropertyEventAccess(t,e,r){const s=t.classDefinition.findProperty(e);switch(s||this.context.throwEvalError(`unknown property '${e}' for class ${t.classDefinition.name}.`),r){case"PreGet":case"PostGet":return void(s.isGetObservable||this.context.throwEvalError(`property '${e}' is not GetObservable for class ${t.classDefinition.name}.`));case"PreSet":case"PostSet":return void(s.isSetObservable||this.context.throwEvalError(`property '${e}' is not SetObservable for class ${t.classDefinition.name}.`));default:this.context.throwEvalError(`unknown property event '${r}' for class ${t.classDefinition.name}.`)}}propertyListenerName(t,e,r){if(u.CharString.isInstanceOf(e))return e.str;if(v.ClassMetaProperty.isInstanceOf(e)){const r=t.classDefinition.findProperty(e.property.name);return r&&r===e.property||this.context.throwEvalError(`property '${e.property.name}' is not a property of class ${t.classDefinition.name}.`),e.property.name}this.context.throwEvalError(`${r}: property name must be a string or meta.property.`)}propertyListenerNameList(t,e,r){return d.MultiArray.linearize(e).map((e,s)=>this.propertyListenerName(t,this.expressionValue(e,`property${s+1}`),r))}addClassPropertyListenerArray(t,e,r,s,i){e.classDefinition.isHandleClass()||this.context.throwEvalError(`${t}: source must be a handle object.`),u.CharString.isInstanceOf(s)||this.context.throwEvalError(`${t}: property event name must be a string.`),p.FunctionHandle.isInstanceOf(i)||this.context.throwEvalError(`${t}: callback must be a function handle.`);const n=this.propertyListenerNameList(e,r,t),a=new d.MultiArray(r.dimension);for(let t=0;t<n.length;t++){const r=n[t];this.validatePropertyEventAccess(e,r,s.str);const[o,l]=d.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],t);a.array[o][l]=g.ClassInstance.addListener(e,s.str,i,this.propertyEventKey(r,s.str),"event.proplistener")}return d.MultiArray.setType(a),a}addClassListenerForSource(t,e,r,s,i,n){const a=4===n?i:s;if(e.classDefinition.isHandleClass()||this.context.throwEvalError(`${t}: source must be a handle object.`),p.FunctionHandle.isInstanceOf(a)||this.context.throwEvalError(`${t}: callback must be a function handle.`),4===n){u.CharString.isInstanceOf(s)||this.context.throwEvalError(`${t}: property event name must be a string.`);const i=this.propertyListenerName(e,r,t);return this.validatePropertyEventAccess(e,i,s.str),g.ClassInstance.addListener(e,s.str,a,this.propertyEventKey(i,s.str),"event.proplistener")}u.CharString.isInstanceOf(r)||this.context.throwEvalError(`${t}: event name must be a string.`),this.validateClassEventAccess(e,r.str,"listen");const o=e.classDefinition.findProperty(r.str);return g.ClassInstance.addListener(e,r.str,a,r.str,o?"event.proplistener":"event.listener")}addClassListener(t,...e){const[r,s,i,n]=e;if(d.MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const a=new d.MultiArray(r.dimension),o=d.MultiArray.linearize(r);for(let r=0;r<o.length;r++){const l=this.expressionValue(o[r],`source${r+1}`);g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError(`${t}: source array must contain class instances.`);const[c,u]=d.MultiArray.linearIndexToMultiArrayRowColumn(a.dimension[0],a.dimension[1],r);a.array[c][u]=this.addClassListenerForSource(t,l,s,i,n,e.length)}return d.MultiArray.setType(a),a}return g.ClassInstance.isInstanceOf(r)||this.context.throwEvalError(`${t}: source must be a class instance.`),4===e.length&&d.MultiArray.isInstanceOf(s)?this.addClassPropertyListenerArray(t,r,s,i,n):this.addClassListenerForSource(t,r,s,i,n,e.length)}createClassEventListenerForSource(t,e,r){return g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("event.listener: source must be a class instance."),t.classDefinition.isHandleClass()||this.context.throwEvalError("event.listener: source must be a handle object."),u.CharString.isInstanceOf(e)||this.context.throwEvalError("event.listener: event name must be a string."),p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event.listener: callback must be a function handle."),this.validateClassEventAccess(t,e.str,"listen")||this.context.throwEvalError("event.listener: event name must name a class event."),g.ClassInstance.addListener(t,e.str,r,e.str,"event.listener")}createClassEventListener(...t){const[e,r,s]=t;if(d.MultiArray.isInstanceOf(e)&&this.hasClassInstanceElement(e)){const t=new d.MultiArray(e.dimension),i=d.MultiArray.linearize(e);for(let e=0;e<i.length;e++){const n=this.expressionValue(i[e],`source${e+1}`);g.ClassInstance.isInstanceOf(n)||this.context.throwEvalError("event.listener: source array must contain class instances.");const[a,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);t.array[a][o]=this.createClassEventListenerForSource(n,r,s)}return d.MultiArray.setType(t),t}return g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("event.listener: source must be a class instance."),this.createClassEventListenerForSource(e,r,s)}createClassPropertyListener(...t){return 4!==t.length&&c.AST.throwInvalidCallError("event.proplistener",!0,t=>this.context.throwEvalError(t)),this.addClassListener("listener",...t)}notifyClassEventForSource(t,e,r){t.classDefinition.isHandleClass()||this.context.throwEvalError("notify: source must be a handle object."),this.validateClassEventAccess(t,e,"notify"),this.dispatchClassEvent(t,e,r?this.prepareEventDataObject(t,e,r):this.eventData(t,e))}notifyClassEvent(t,e,r){if(u.CharString.isInstanceOf(e)||this.context.throwEvalError("notify: event name must be a string."),void 0===r||this.isEventDataObject(r)||this.context.throwEvalError("notify: event data must be an event.EventData object."),d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){for(const s of d.MultiArray.linearize(t)){const t=this.expressionValue(s,"source");g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("notify: source array must contain class instances."),this.notifyClassEventForSource(t,e.str,r)}return c.AST.nodeVoid()}return g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("notify: source must be a class instance."),this.notifyClassEventForSource(t,e.str,r),c.AST.nodeVoid()}dispatchClassEvent(t,e,r=this.eventData(t,e)){for(const s of g.ClassInstance.listenersFor(t,e))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"event callback"),this.classMethodArgumentValues([t,r],"event"),c.AST.nodeIdentifier("notify"))}finally{s.notifying=!1}}}dispatchClassPropertyEvent(t,e,r){const s=t.classDefinition.findProperty(e);s||this.context.throwEvalError(`unknown property '${e}' for class ${t.classDefinition.name}.`);const i=this.createClassMetaProperty(s),n=this.propertyEventData(t,e,r,i);for(const s of g.ClassInstance.listenersFor(t,this.propertyEventKey(e,r)))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"property event callback"),this.classMethodArgumentValues([i,n],"property event"),c.AST.nodeIdentifier("addlistener"))}finally{s.notifying=!1}}if("PostGet"===r||"PostSet"===r){const r=this.propertyEventData(t,e,e,i);for(const s of g.ClassInstance.listenersFor(t,e))if(!s.notifying||s.recursive){s.notifying=!0;try{this.context.apply(this.expressionValue(s.callback,"property event callback"),this.classMethodArgumentValues([i,r],"property event"),c.AST.nodeIdentifier("addlistener"))}finally{s.notifying=!1}}}}resolveClassEventDataField(t,e){const r=S.ClassPropertyEvent.isInstanceOf(t)?S.ClassPropertyEvent.getProperty(t,e):_.ClassEventData.getProperty(t,e);return void 0===r&&("Source"!==e&&"EventName"!==e||this.context.throwEvalError(`event data ${e} is not assigned until notify dispatch.`),this.context.throwEvalError(`unknown property '${e}' for ${S.ClassPropertyEvent.isInstanceOf(t)?"event.PropertyEvent":"event.EventData"}.`)),r}setClassEventDataField(t,e){this.context.throwEvalError(`cannot assign to read-only property '${e}' for ${S.ClassPropertyEvent.isInstanceOf(t)?"event.PropertyEvent":"event.EventData"}.`)}resolveClassEventListenerField(t,e){switch(A.ClassEventListener.isValid(t)||this.context.throwEvalError("invalid or deleted event listener."),e){case"Callback":return t.callback;case"Enabled":return t.enabled?h.Complex.true():h.Complex.false();case"EventName":return u.CharString.create(t.eventName);case"Recursive":return t.recursive?h.Complex.true():h.Complex.false();case"Source":case"Object":return t.source;default:this.context.throwEvalError(`unknown property '${e}' for ${t.kind}.`)}}removeClassEventListenerRegistration(t){if(!g.ClassInstance.isInstanceOf(t.source))return;const e=t.source.listeners[t.listenerKey];if(!e)return;const r=e.indexOf(t);r>=0&&e.splice(r,1),0===e.length&&delete t.source.listeners[t.listenerKey]}addClassEventListenerRegistration(t,e){g.ClassInstance.isInstanceOf(t.source)&&(t.source.listeners[e]??=[],t.source.listeners[e].includes(t)||t.source.listeners[e].push(t))}setClassEventListenerEventName(t,e){u.CharString.isInstanceOf(e)||this.context.throwEvalError("event listener EventName must be a string."),g.ClassInstance.isInstanceOf(t.source)||this.context.throwEvalError(`cannot assign EventName for ${t.kind}.`);let r=e.str;if("event.proplistener"===t.kind){const[s,i]=t.listenerKey.split(":");void 0===i&&this.context.throwEvalError(`cannot assign EventName for ${t.kind}.`),this.validatePropertyEventAccess(t.source,s,e.str),r=this.propertyEventKey(s,e.str)}else this.validateClassEventAccess(t.source,e.str,"listen")||this.context.throwEvalError("event listener EventName must name a class event.");this.removeClassEventListenerRegistration(t),t.eventName=e.str,t.listenerKey=r,this.addClassEventListenerRegistration(t,r)}setClassEventListenerSource(t,e){if(g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("event listener Source must be a class instance."),e.classDefinition.isHandleClass()||this.context.throwEvalError("event listener Source must be a handle object."),"event.proplistener"===t.kind){const[r,s]=t.listenerKey.split(":");void 0===s?this.validateClassEventAccess(e,t.eventName,"listen"):this.validatePropertyEventAccess(e,r,t.eventName)}else this.validateClassEventAccess(e,t.eventName,"listen")||this.context.throwEvalError("event listener Source must define the listener EventName as a class event.");this.removeClassEventListenerRegistration(t),t.source=e,this.addClassEventListenerRegistration(t,t.listenerKey)}setClassEventListenerField(t,e,r){switch(A.ClassEventListener.isValid(t)||this.context.throwEvalError("invalid or deleted event listener."),e){case"Callback":return p.FunctionHandle.isInstanceOf(r)||this.context.throwEvalError("event listener Callback must be a function handle."),void(t.callback=r);case"Enabled":return void(t.enabled=this.toBoolean(r));case"EventName":return void this.setClassEventListenerEventName(t,r);case"Recursive":return void(t.recursive=this.toBoolean(r));case"Source":case"Object":return void this.setClassEventListenerSource(t,r);default:this.context.throwEvalError(`cannot assign to read-only property '${e}' for ${t.kind}.`)}}resolveSetGetProperty(t,e,r){t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${r}: first argument must be a matlab.mixin.SetGet object.`);const s=t.classDefinition.allProperties(),i=s.filter(t=>t.name===e);if(1===i.length)return i[0];i.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${e}' for class ${t.classDefinition.name}.`),t.classDefinition.isSetGetExactNamesClass()&&this.context.throwEvalError(`${r}: unknown property '${e}' for class ${t.classDefinition.name}.`);const n=e.toLowerCase(),a=s.filter(t=>t.name.toLowerCase()===n);if(1===a.length)return a[0];a.length>1&&this.context.throwEvalError(`${r}: ambiguous property name '${e}' for class ${t.classDefinition.name}.`);const o=s.filter(t=>t.name.toLowerCase().startsWith(n));0===o.length&&this.context.throwEvalError(`${r}: unknown property '${e}' for class ${t.classDefinition.name}.`);const l=Math.min(...o.map(t=>t.partialMatchPriority)),c=o.filter(t=>t.partialMatchPriority===l);return 1!==c.length&&this.context.throwEvalError(`${r}: ambiguous partial property name '${e}' for class ${t.classDefinition.name}.`),c[0]}isSetGetSettableProperty(t){return!(t.isConstant||"public"!==t.setAccess||t.isDependent&&!t.setMethodName&&!t.classDefinition.findMethod(`set.${t.name}`,t=>!t.isStatic))}assertSetGetSettableProperty(t,e){this.isSetGetSettableProperty(t)||this.context.throwEvalError(`${e}: property '${t.name}' is not publicly settable for class ${t.classDefinition.name}.`)}setGetObject(t,e){if(d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t))return this.setGetArrayRepresentative(t,e),t;g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);try{g.ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}return t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`),t}setGetArrayRepresentative(t,e){const r=d.MultiArray.linearize(t);0===r.length&&this.context.throwEvalError(`${e}: first argument must be a nonempty matlab.mixin.SetGet object array.`);const s=r[0];g.ClassInstance.isInstanceOf(s)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);for(const t of r){g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`);try{g.ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}t.classDefinition.isSetGetClass()||this.context.throwEvalError(`${e}: first argument must be a matlab.mixin.SetGet object.`)}return s}setGetStructure(t){const e={};for(const r of t.classDefinition.allProperties().filter(t=>!t.isHidden&&"public"===t.getAccess))e[r.name]=this.runtimeExpressionValue(this.resolveClassInstanceField(t,r.name,c.AST.nodeIdentifier("get")),`property ${r.name}`);return new m.Structure(e)}setGetStructureArray(t){const e=new d.MultiArray([d.MultiArray.linearLength(t),1]);for(let r=0;r<d.MultiArray.linearLength(t);r++){const[s,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],r),n=t.array[s][i];g.ClassInstance.isInstanceOf(n)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),e.array[r][0]=this.setGetStructure(n)}return d.MultiArray.setType(e),e}setGetPropertyNames(t,e){if(u.CharString.isInstanceOf(t))return[t.str];if(d.MultiArray.isInstanceOf(t)&&t.isCell){const r=d.MultiArray.linearize(t);if(r.every(u.CharString.isInstanceOf))return this.charStringList(r,`${e} property name cell array`).map(t=>t.str)}return c.AST.throwInvalidCallError(e),[]}getSetGetPropertyCell(t,e){const r=g.ClassInstance.isInstanceOf(t)?[t]:d.MultiArray.linearize(t),s=new d.MultiArray([r.length,e.length],void 0,!0);return r.forEach((t,r)=>{g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),e.forEach((e,i)=>{s.array[r][i]=this.resolveClassInstanceField(t,e.name,c.AST.nodeIdentifier("get"))})}),d.MultiArray.setType(s),s}setSetGetPropertyCell(t,e,r){e.isCell&&1===e.dimension[0]||this.context.throwEvalError("set: property name cell array must be 1-by-N."),r.isCell||c.AST.throwInvalidCallError("set");const s=d.MultiArray.linearize(e);s.every(u.CharString.isInstanceOf)||c.AST.throwInvalidCallError("set");const i=g.ClassInstance.isInstanceOf(t)?[t]:d.MultiArray.linearize(t),n=s.length;r.dimension[0]===i.length&&r.dimension[1]===n||this.context.throwEvalError(`set: property value cell array must be ${i.length}-by-${n}.`);const a=g.ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"set"),o=this.charStringList(s,"set property name cell array").map(t=>{const e=this.resolveSetGetProperty(a,t.str,"set");return this.assertSetGetSettableProperty(e,"set"),e});i.forEach((e,s)=>{g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("set: first argument must be a matlab.mixin.SetGet object."),o.forEach((i,n)=>{const a=this.assignClassInstanceField(e,i.name,r.array[s][n],c.AST.nodeIdentifier("set"),this.context.currentScope);if(d.MultiArray.isInstanceOf(t)){const[e,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);t.array[e][r]=a}})}),d.MultiArray.isInstanceOf(t)&&d.MultiArray.setType(t)}assignSetGetProperty(t,e,r){const s=g.ClassInstance.isInstanceOf(t)?t:this.setGetArrayRepresentative(t,"set"),i=this.resolveSetGetProperty(s,e,"set");this.assertSetGetSettableProperty(i,"set"),g.ClassInstance.isInstanceOf(t)?this.assignClassInstanceField(t,i.name,r,c.AST.nodeIdentifier("set"),this.context.currentScope):this.assignClassArrayField(t,i.name,r,c.AST.nodeIdentifier("set"),this.context.currentScope)}setGetSettableStructure(t){const e={};for(const r of t.classDefinition.allProperties().filter(t=>!t.isHidden&&this.isSetGetSettableProperty(t)))e[r.name]=d.MultiArray.emptyArray(!0);return new m.Structure(e)}getSetGetProperty(t){const e=this.setGetObject(t[0],"get");if(1===t.length)return g.ClassInstance.isInstanceOf(e)?this.setGetStructure(e):this.setGetStructureArray(e);2===t.length&&u.CharString.isInstanceOf(t[1])||2===t.length&&d.MultiArray.isInstanceOf(t[1])&&t[1].isCell||c.AST.throwInvalidCallError("get");const r=g.ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"get"),s=this.setGetPropertyNames(t[1],"get").map(t=>this.resolveSetGetProperty(r,t,"get"));if(g.ClassInstance.isInstanceOf(e)&&u.CharString.isInstanceOf(t[1]))return this.resolveClassInstanceField(e,s[0].name,c.AST.nodeIdentifier("get"));if(d.MultiArray.isInstanceOf(e)&&u.CharString.isInstanceOf(t[1])){const t=new d.MultiArray(e.dimension,void 0,!0);for(let r=0;r<d.MultiArray.linearLength(e);r++){const[i,n]=d.MultiArray.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r),a=e.array[i][n];g.ClassInstance.isInstanceOf(a)||this.context.throwEvalError("get: first argument must be a matlab.mixin.SetGet object."),t.array[i][n]=this.resolveClassInstanceField(a,s[0].name,c.AST.nodeIdentifier("get"))}return d.MultiArray.setType(t),t}return this.getSetGetPropertyCell(e,s)}setSetGetProperties(t){const e=this.setGetObject(t[0],"set");if(1===t.length){if(g.ClassInstance.isInstanceOf(e))return this.setGetSettableStructure(e);c.AST.throwInvalidCallError("set")}if(2===t.length){if(u.CharString.isInstanceOf(t[1])){const r=g.ClassInstance.isInstanceOf(e)?e:this.setGetArrayRepresentative(e,"set"),s=this.resolveSetGetProperty(r,t[1].str,"set");return this.assertSetGetSettableProperty(s,"set"),d.MultiArray.emptyArray(!0)}if(m.Structure.isInstanceOf(t[1])){for(const[r,s]of Object.entries(t[1].field))this.assignSetGetProperty(e,r,s);return c.AST.nodeVoid()}c.AST.throwInvalidCallError("set")}if(m.Structure.isInstanceOf(t[1])){(t.length-2)%2!=0&&c.AST.throwInvalidCallError("set");for(const[r,s]of Object.entries(t[1].field))this.assignSetGetProperty(e,r,s);for(let r=2;r<t.length;r+=2){const s=t[r];u.CharString.isInstanceOf(s)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return c.AST.nodeVoid()}if(d.MultiArray.isInstanceOf(t[1])&&t[1].isCell){d.MultiArray.isInstanceOf(t[2])&&t[2].isCell||c.AST.throwInvalidCallError("set"),this.setSetGetPropertyCell(e,t[1],t[2]),(t.length-3)%2!=0&&c.AST.throwInvalidCallError("set");for(let r=3;r<t.length;r+=2){const s=t[r];u.CharString.isInstanceOf(s)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return c.AST.nodeVoid()}t.length%2==0&&c.AST.throwInvalidCallError("set");for(let r=1;r<t.length;r+=2){const s=t[r];u.CharString.isInstanceOf(s)||c.AST.throwInvalidCallError("set"),this.assignSetGetProperty(e,s.str,t[r+1])}return c.AST.nodeVoid()}functions={unparse:{func:t=>new u.CharString(this.Unparse(t)),signature:{inputs:{arity:1},outputs:{arity:1}}},clear:{func:(...t)=>(this.Clear(...t.map(t=>this.charControlArgument(t,"clear name").str)),c.AST.nodeVoid()),signature:{inputs:{arity:-1,min:0,parameters:[{name:"name",classes:["char","string"],variadic:!0}]},outputs:{arity:0}}},who:{func:(...t)=>this.whoResult(t),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},whos:{func:(...t)=>this.whosResult(t),signature:{inputs:{arity:-1,min:0,parameters:[{name:"pattern",classes:["char","string"],variadic:!0}]},outputs:{arity:1}}},iskeyword:{func:(...t)=>this.isKeywordResult(t),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"name",classes:["char","string","cell"],optional:!0}]},outputs:{arity:1}}},isvarname:{func:(...t)=>this.isVarNameResult(t),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},isglobal:{func:(...t)=>this.isGlobalResult(t),signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","cell"]}]},outputs:{arity:1}}},namelengthmax:{func:(...t)=>(c.AST.throwInvalidCallError("namelengthmax",0!==t.length,t=>this.context.throwEvalError(t)),h.Complex.create(W.nameLengthMax)),signature:{inputs:{arity:0},outputs:{arity:1}}},class:{func:(...t)=>new u.CharString(this.getValueClassName(t[0])),signature:{inputs:{arity:1},outputs:{arity:1}}},isa:{func:(...t)=>this.valueIsRuntimeClass(t[0],this.charControlArgument(t[1],"class name").str)?h.Complex.true():h.Complex.false(),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},isclass:{func:(...t)=>this.isClassName(this.charControlArgument(t[0],"class name").str)?h.Complex.true():h.Complex.false(),signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},metaclass:{func:(...t)=>this.metaclassArgument(t[0]),signature:{inputs:{arity:1,parameters:[{name:"object"}]},outputs:{arity:1}}},__meta_class_fromName:{func:(...t)=>{const e=this.context.resolveClassDefinition(this.charControlArgument(t[0],"class name").str);return e?this.createClassMetaClass(e):d.MultiArray.emptyArray()},signature:{inputs:{arity:1,parameters:[{name:"className",classes:["char","string"]}]},outputs:{arity:1}}},properties:{func:(...t)=>N.CoreFunctions.properties(this.classIntrospectionArgument("properties",t[0])),signature:N.CoreFunctions.propertiesSignature},fieldnames:{func:(...t)=>N.CoreFunctions.fieldnames(this.classIntrospectionArgument("fieldnames",t[0])),signature:N.CoreFunctions.fieldnamesSignature},methods:{func:(...t)=>N.CoreFunctions.methods(this.classIntrospectionArgument("methods",t[0])),signature:N.CoreFunctions.methodsSignature},events:{func:(...t)=>N.CoreFunctions.events(this.classIntrospectionArgument("events",t[0])),signature:N.CoreFunctions.eventsSignature},enumeration:{func:(...t)=>N.CoreFunctions.enumeration(this.classIntrospectionArgument("enumeration",t[0])),signature:N.CoreFunctions.enumerationSignature},superclasses:{func:(...t)=>N.CoreFunctions.superclasses(this.classIntrospectionArgument("superclasses",t[0])),signature:N.CoreFunctions.superclassesSignature},isprop:{func:(...t)=>N.CoreFunctions.isprop(this.classIntrospectionArgument("isprop",t[0]),t[1]),signature:N.CoreFunctions.ispropSignature},ismethod:{func:(...t)=>N.CoreFunctions.ismethod(this.classIntrospectionArgument("ismethod",t[0]),t[1]),signature:N.CoreFunctions.ismethodSignature},addlistener:{func:(...t)=>this.addClassListener("addlistener",...t),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},listener:{func:(...t)=>this.addClassListener("listener",...t),signature:{inputs:[{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]}],outputs:{arity:1}}},"event.listener":{func:(...t)=>this.createClassEventListener(...t),signature:{inputs:{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},"event.EventData":{func:()=>_.ClassEventData.create(),signature:{inputs:{arity:0},outputs:{arity:1}}},"event.proplistener":{func:(...t)=>this.createClassPropertyListener(...t),signature:{inputs:{arity:4,parameters:[{name:"source"},{name:"propertyName"},{name:"propertyEventName",classes:["char","string"]},{name:"callback"}]},outputs:{arity:1}}},notify:{func:(...t)=>this.notifyClassEvent(t[0],t[1],t[2]),signature:{inputs:[{arity:2,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]}]},{arity:3,parameters:[{name:"source"},{name:"eventName",classes:["char","string"]},{name:"eventData"}]}],outputs:{arity:0}}},get:{func:(...t)=>this.getSetGetProperty(t),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell"]}]}],outputs:{arity:-1}}},set:{func:(...t)=>this.setSetGetProperties(t),signature:{inputs:[{arity:1,parameters:[{name:"object"}]},{arity:2,parameters:[{name:"object"},{name:"propertyNameOrStruct"}]},{arity:-1,min:3,parameters:[{name:"object"},{name:"propertyName",classes:["char","string","cell","struct"]},{name:"propertyValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},mfilename:{func:(...t)=>{const e=1===t.length?this.charControlArgument(t[0],"mfilename option").str:"";return"class"===e?new u.CharString(this.context.currentClassAccessName()):"fullpath"===e?new u.CharString(this.currentMFilenameFullPath()):new u.CharString(this.currentMFilename())},signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"option",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},dbstack:{func:(...t)=>this.dbstackResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"optionOrCount",optional:!0,variadic:!0,alternatives:[{name:"option",classes:["char","string"],allowedStrings:["-completenames"]},{name:"count",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]}]}]},outputs:{arity:-1}}},lasterror:{func:(...t)=>this.lastErrorResult(t),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"error",optional:!0,alternatives:[{name:"reset",classes:["char","string"],allowedStrings:["reset"]},{name:"errorStruct",classes:["struct"]}]}]},outputs:{arity:-1}}},lasterr:{func:(...t)=>this.lastErrorMessageResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},lastwarn:{func:(...t)=>this.lastWarningResult(t),signature:{inputs:{arity:-2,min:0,max:2,parameters:[{name:"message",classes:["char","string"],optional:!0},{name:"identifier",classes:["char","string"],optional:!0}]},outputs:{arity:-2}}},deal:{func:(...t)=>this.dealResult(t),signature:{inputs:{arity:-1,min:1,parameters:[{name:"value",variadic:!0}]},outputs:{arity:-1}}},subsref:{func:(...t)=>this.subsrefResult(t[0],t[1]),signature:{inputs:{arity:2,parameters:[{name:"value"},{name:"subscript",classes:["struct"]}]},outputs:{arity:-1,min:0}}},subsasgn:{func:(...t)=>this.subsasgnResult(t[0],t[1],t[2]),signature:{inputs:{arity:3,parameters:[{name:"value"},{name:"subscript",classes:["struct"]},{name:"newValue"}]},outputs:{arity:1}}},warning:{func:(...t)=>this.warningResult(t),signature:{inputs:[{arity:0},{arity:1,parameters:[{name:"stateStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:-1,min:0,max:1}}},error:{func:(...t)=>this.errorResult(t),signature:{inputs:[{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},{arity:-1,min:1,parameters:[{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]},{arity:-2,min:2,parameters:[{name:"identifier",classes:["char","string"]},{name:"message",classes:["char","string"]},{name:"formatValue",variadic:!0}]}],outputs:{arity:0}}},assert:{func:(...t)=>this.assertResult(t),signature:{inputs:{arity:-1,min:1,parameters:[{name:"argument",variadic:!0}]},outputs:{arity:0}}},rethrow:{func:(...t)=>this.rethrowResult(t[0]),signature:{inputs:{arity:1,parameters:[{name:"errorStruct",classes:["struct"]}]},outputs:{arity:0}}},exist:{func:(...t)=>h.Complex.create(this.existCode(this.charControlArgument(t[0],"name").str,2===t.length?this.charControlArgument(t[1],"kind").str:void 0)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"name",classes:["char","string"]},{name:"kind",classes:["char","string"],optional:!0}]},outputs:{arity:1}}},which:{func:(...t)=>{if(p.FunctionHandle.isInstanceOf(t[0])){const e=this.functionHandleControlArgument(t[0],"function handle");return this.whichResult(e.id??p.FunctionHandle.unparse(e,this).trim(),e)}return this.whichResult(this.charControlArgument(t[0],"name").str)},signature:{inputs:{arity:1,parameters:[{name:"name",classes:["char","string","function_handle"]}]},outputs:{arity:1}}},validatestring:{func:(...t)=>this.validatestringResult(t),signature:{inputs:{arity:-1,min:2,max:5,parameters:[{name:"string",classes:["char","string"]},{name:"validStrings",classes:["char","string","cell"]},{name:"functionName",classes:["char","string"],optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:1}}},validateattributes:{func:(...t)=>this.validateattributesResult(t),signature:{inputs:{arity:-1,min:3,max:6,parameters:[{name:"value"},{name:"classes",classes:["char","string","cell"]},{name:"attributes",classes:["char","string","cell"]},{name:"functionNameOrArgumentPosition",optional:!0},{name:"variableName",classes:["char","string"],optional:!0},{name:"argumentPosition",optional:!0}]},outputs:{arity:0}}},...this.mustBeFunctionEntries(),func2str:{func:(...t)=>k.FunctionLookup.func2str(this.functionHandleControlArgument(t[0],"function handle"),t=>p.FunctionHandle.unparse(t,this)),signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},str2func:{func:(...t)=>{const e=t.length>1?this.charControlArgument(t[1],"scope").str.trim().toLowerCase():"";return this.functionHandleFromString(this.charControlArgument(t[0],"source"),"global"===e)},signature:{inputs:{arity:-1,min:1,max:2,parameters:[{name:"source",classes:["char","string"]},{name:"scope",classes:["char","string"],allowedStrings:["global"],optional:!0}]},outputs:{arity:1}}},builtin:{func:(...t)=>{const e=this.charControlArgument(t[0],"builtin function").str.trim();0===e.length&&this.context.throwEvalError("builtin: function name cannot be empty.");const r=this.context.aliasNameFunction(e),s=this.context.builtInFunctionTable[r];return s||this.context.throwEvalError(`builtin: '${e}' is not a built-in function.`),this.context.callCallable(H.Callables.builtin(s),this.callArgumentValues(t.slice(1),"builtin"),c.AST.nodeIdentifier("builtin"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},feval:{func:(...t)=>{let e=this.expressionValue(t[0],"feval target");if(u.CharString.isInstanceOf(e)){const r=e.str.trim();0===r.length&&this.context.throwEvalError("feval: function name cannot be empty.");const s=r.startsWith("@")?void 0:this.resolveStaticMethod(r,this.context.currentScope);if(s)return this.context.callClassStaticMethod(s.method,this.callArgumentValues(t.slice(1),"feval"),c.AST.nodeIdentifier("feval"));e=r.startsWith("@")?this.functionHandleFromString(e):this.createResolvedFunctionHandle(r,this.context.currentScope,void 0,!1,!0)}const r=this.context.resolveCallable(e);return r||this.context.throwEvalError("feval: first argument must be a function handle or function name."),this.context.callCallable(r,this.callArgumentValues(t.slice(1),"feval"),c.AST.nodeIdentifier("feval"))},signature:{inputs:{arity:-1,min:1,parameters:[{name:"function",classes:["char","string","function_handle"]},{name:"argument",variadic:!0}]},outputs:{arity:-1}}},spfun:{func:(...t)=>{const e=this.context.resolveCallable(this.expressionValue(t[0],"spfun function"));e||this.context.throwEvalError("spfun: first argument must be a function handle.");const r=d.MultiArray.scalarToMultiArray(this.expressionValue(t[1],"spfun input")),s=new d.MultiArray(r.dimension,h.Complex.zero()),i=d.MultiArray.linearize(r);for(let t=0;t<i.length;t++){if(!N.CoreFunctions.isNonzeroElement(i[t]))continue;const n=this.expressionValue(U.RuntimeValue.copy(i[t]),"spfun value"),a=this.expressionValue(this.context.callCallable(e,[n],c.AST.nodeIdentifier("spfun")),"spfun result"),o=d.MultiArray.MultiArrayToScalar(a);d.MultiArray.isInstanceOf(o)&&this.context.throwEvalError("spfun: function must return a scalar value for each nonzero element.");const[l,u]=d.MultiArray.linearIndexToMultiArrayRowColumn(r.dimension[0],r.dimension[1],t);s.array[l][u]=U.RuntimeValue.copy(o)}return d.MultiArray.setType(s),d.MultiArray.MultiArrayToScalar(s)},signature:{inputs:{arity:2,parameters:[{name:"function",classes:["function_handle"]},{name:"value",alternatives:[{name:"numericValue",classes:["double"]},{name:"logicalValue",classes:["logical"]}]}]},outputs:{arity:1}}},functions:{func:(...t)=>{const e=this.functionHandleControlArgument(t[0],"function handle"),r=e.closure??this.context.currentScope;return k.FunctionLookup.functionsInfo(e,t=>this.context.aliasNameFunction(t),t=>this.context.resolveSymbol(t,r,{variables:!1,classes:!1,loadFunctions:!1})?.functionDefinition,t=>p.FunctionHandle.unparse(t,this),t=>this.functionHandleWorkspaceInfo(t),(t,e)=>this.staticMethodInfo(t,e?.closure??this.context.currentScope))},signature:{inputs:{arity:1,parameters:[{name:"functionHandle",classes:["function_handle"]}]},outputs:{arity:1}}},localfunctions:{func:(...t)=>this.localFunctionHandles(),signature:{inputs:{arity:0},outputs:{arity:1}}},nargin:{func:(...t)=>0===t.length?this.context.currentFunctionArgumentCount("nargin"):h.Complex.create(this.functionArgumentArity(this.functionArityCallable("nargin",t[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},narginchk:{func:(...t)=>this.checkFunctionCount("narginchk",t[0],t[1]),signature:{inputs:{arity:2,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0}]},outputs:{arity:0}}},nargchk:{func:(...t)=>this.nargchkResult(t),signature:{inputs:{arity:-1,min:3,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"inputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nargout:{func:(...t)=>0===t.length?this.context.currentFunctionOutputCount("nargout"):h.Complex.create(this.functionOutputArity(this.functionArityCallable("nargout",t[0]))),signature:{inputs:{arity:-1,min:0,max:1,parameters:[{name:"function",classes:["char","string","function_handle"],optional:!0}]},outputs:{arity:1}}},isargout:{func:(...t)=>this.context.currentFunctionOutputIsRequested(t[0]),signature:{inputs:{arity:1,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]}]},outputs:{arity:1}}},nargoutchk:{func:(...t)=>this.nargoutchkResult(t),signature:{inputs:{arity:-1,min:2,max:4,parameters:[{name:"min",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"]},{name:"max",classes:["double"],validators:["numeric","scalar","real","integer","nonnegative"],allowInfinity:!0},{name:"outputCount",classes:["double"],validators:["numeric","scalar","real","finite","integer","nonnegative"],optional:!0},{name:"outputKind",classes:["char","string"],allowedStrings:["struct","string"],optional:!0}]},outputs:{arity:1}}},nthargout:{func:(...t)=>this.nthargoutResult(t),signature:{inputs:{arity:-2,min:2,parameters:[{name:"outputNumber",classes:["double"],validators:["numeric","real","integer","positive"]},{name:"functionOrTotalOutputCount"},{name:"argument",variadic:!0}]},outputs:{arity:1}}},inputname:{func:(...t)=>{const e=2!==t.length||this.booleanControlArgument(t[1],"inputname onlyVariableNames");return this.context.currentFunctionInputName(t[0],e,t=>this.Unparse(t))},signature:{inputs:[{arity:1,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]}]},{arity:2,parameters:[{name:"argumentNumber",classes:["double"],validators:["numeric","scalar","real","finite","integer","positive"]},{name:"onlyVariableNames",classes:["logical"],validators:["scalar"]}]}],outputs:{arity:1}}},eval:{func:(...t)=>F.FunctionWorkspace.evaluateWithCatch(this.context.currentScope,this.charControlArgument(t[0],"eval code").str,2===t.length?this.charControlArgument(t[1],"eval catch code").str:void 0,(t,e)=>this.evalStringInScope(t,e),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t)),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalc:{func:(...t)=>this.evalcResult(this.charControlArgument(t[0],"evalc code").str,2===t.length?this.charControlArgument(t[1],"evalc catch code").str:void 0),signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},evalin:{func:(...t)=>{const e=this.charControlArgument(t[0],"workspace").str,r=this.context.resolveWorkspace(e,!1,"caller"===e);return F.FunctionWorkspace.evaluateWithCatch(r,this.charControlArgument(t[1],"evalin code").str,3===t.length?this.charControlArgument(t[2],"evalin catch code").str:void 0,(t,r)=>this.evalStringInScope(t,r,{topLevelReturn:"base"===e}),t=>this.isEvalCatchableError(t),t=>this.rememberLastError(t))},signature:{inputs:{arity:-3,min:2,max:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"code",classes:["char","string"]},{name:"catchCode",classes:["char","string"],optional:!0}]},outputs:{arity:-1}}},run:{func:(...t)=>this.RunScriptFile(this.charControlArgument(t[0],"script").str,this.context.currentScope),signature:{inputs:{arity:1,parameters:[{name:"script",classes:["char","string"]}]},outputs:{arity:1}}},source:{func:(...t)=>{const e=2===t.length?this.context.resolveWorkspace(this.charControlArgument(t[1],"workspace").str):this.context.currentScope;return this.RunScriptFile(this.charControlArgument(t[0],"script").str,e)},signature:{inputs:{arity:-2,min:1,max:2,parameters:[{name:"script",classes:["char","string"]},{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"],optional:!0}]},outputs:{arity:1}}},assignin:{func:(...t)=>{const e=this.context.resolveWorkspace(this.charControlArgument(t[0],"workspace").str,!0),r=this.pushDynamicNameCreationGuard(e);try{return F.FunctionWorkspace.assignIn(e,this.charControlArgument(t[1],"name").str,this.runtimeExpressionValue(t[2],"assignin value"))}finally{r()}},signature:{inputs:{arity:3,parameters:[{name:"workspace",classes:["char","string"],allowedStrings:["base","caller"]},{name:"name",classes:["char","string"],identifier:!0},{name:"value"}]},outputs:{arity:0}}}};unparseMathMLFunctions={logb:t=>{let e=this.UnparserMathML(t.args[1]);return this.nodePrecedence(t.args[1])<this.precedenceTable.max&&(e=L.MathML.format["()"]("(",e,")")),L.MathML.format.logb(this.UnparserMathML(t.args[0]),e)},log2:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=L.MathML.format["()"]("(",e,")")),L.MathML.format.log2(e)},log10:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=L.MathML.format["()"]("(",e,")")),L.MathML.format.log10(e)},factorial:t=>{let e=this.UnparserMathML(t.args[0]);return this.nodePrecedence(t.args[0])<this.precedenceTable.max&&(e=L.MathML.format["()"]("(",e,")")),L.MathML.format.factorial(e)}};loadInterpreter(t){this._exitStatus=W.response.OK,this.resetLastError(),this.resetWarningState(),c.AST.reload(),this.context.loadContext(),this.context.nativeNameTable=W.nativeNameTableFactory(),this.context.nativeNameSet=new Set(Object.keys(this.context.nativeNameTable)),this.context.globalScope.defineNameTable(this.context.nativeNameTable);for(const t in this.functions)this.context.defineBuiltInFunction(t,this.functions[t].func,!1,[],this.functions[t].signature);const e={inputs:{arity:1,parameters:[{name:"value",classes:["double"]}]},outputs:{arity:1}};for(const t in h.Complex.mapFunction)this.context.defineBuiltInFunction(t,h.Complex.mapFunction[t],!0,[],e);const r={inputs:{arity:2,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]}]},outputs:{arity:1}},s={logb:{inputs:{arity:2,parameters:[{name:"value",classes:["double"]},{name:"base",classes:["double"]}]},outputs:{arity:1}}};for(const t in h.Complex.twoArgFunction)this.context.defineBuiltInFunction(t,h.Complex.twoArgFunction[t],!1,[],s[t]??r);for(const t in w.Configuration.functions)this.context.defineBuiltInFunction(t,w.Configuration.functions[t].func,!1,[],w.Configuration.functions[t].signature);for(const t in N.CoreFunctions.functions)this.context.defineBuiltInFunction(t,N.CoreFunctions.functions[t].func,!1,[],N.CoreFunctions.functions[t].signature);for(const t of["properties","fieldnames","methods","events","enumeration","superclasses","isprop","ismethod"])this.context.defineBuiltInFunction(t,this.functions[t].func,!1,[],this.functions[t].signature);for(const t in M.LinearAlgebra.functions)this.context.defineBuiltInFunction(t,M.LinearAlgebra.functions[t].func,!1,[],M.LinearAlgebra.functions[t].signature);for(const t in T.MathOperation.leftAssociativeMultipleOperations)this.context.defineLeftAssociativeMultipleOperationFunction(t,T.MathOperation.leftAssociativeMultipleOperations[t]);for(const t in T.MathOperation.binaryOperations)this.context.defineBinaryOperatorFunction(t,T.MathOperation.binaryOperations[t]);for(const t in T.MathOperation.unaryOperations)this.context.defineUnaryOperatorFunction(t,T.MathOperation.unaryOperations[t]);for(const t in this.unparseMathMLFunctions)this.context.builtInFunctionTable[t].UnparserMathML=this.unparseMathMLFunctions[t];t?(this.context.setAliasNameTable(t.aliasNameTable),this.context.assignBuiltInFunctionTable(t.externalFunctionTable),this.sourceResolver=t.sourceResolver??q.TableSourceResolver.create({functionSourceTable:t.functionSourceTable??t.externalFunctionSourceTable??Object.create(null),functionSourceProvider:t.functionSourceProvider,scriptSourceTable:t.scriptSourceTable??t.externalScriptSourceTable??Object.create(null),scriptSourceProvider:t.scriptSourceProvider,classSourceTable:t.classSourceTable??t.externalClassSourceTable??Object.create(null),classSourceProvider:t.classSourceProvider}),this.pathValidationCallbacks={fileExists:t.fileExists,folderExists:t.folderExists},t.externalCmdWListTable&&Object.assign(this.commandWordListTable,t.externalCmdWListTable)):(this.context.aliasNameFunction=t=>t,this.sourceResolver=q.TableSourceResolver.create(),this.pathValidationCallbacks={}),this.refreshCommandWordListNames()}constructor(t,e){this.opTable["**"]=this.opTable["^"],this.opTable[".**"]=this.opTable[".^"],this.opTable["~="]=this.opTable["!="],this.opTable["~"]=this.opTable["!"],this.precedenceTable={},W.precedence.forEach((t,e)=>{t.forEach(t=>{this.precedenceTable[t]=e+1})}),this.precedenceTable["**"]=this.precedenceTable["^"],this.precedenceTable[".**"]=this.precedenceTable[".^"],this.precedenceTable["_**"]=this.precedenceTable["_^"],this.precedenceTable["_.**"]=this.precedenceTable["_.^"],this.precedenceTable["~="]=this.precedenceTable["!="],this.precedenceTable["~"]=this.precedenceTable["!"],e?(this.context=e,this.context.interpreter=this):this.context=j.Context.create(this),this.loadInterpreter(t)}static Create=(t,e)=>new W(t,e);Parse(t){const e=i.CharStreams.fromString(t),r=new n.default(e);r.commandNames=this.commandWordListNameSet,r.assignmentSensitiveCommandNames=this.assignmentSensitiveCommandNameSet;const s=new i.CommonTokenStream(r),u=new a.default(s);return u.buildParseTrees=!0,r.removeErrorListeners(),r.addErrorListener(new o.LexerErrorListener(t)),u.removeErrorListeners(),u.addErrorListener(new l.ParserErrorListener(t)),this._debug,u.input().node??c.AST.nodeVoid()}static nativeNameTableFactory=()=>({false:h.Complex.false(),true:h.Complex.true(),i:h.Complex.onei(),I:h.Complex.onei(),j:h.Complex.onei(),J:h.Complex.onei(),e:h.Complex.e(),pi:h.Complex.pi(),inf:h.Complex.inf_0(),Inf:h.Complex.inf_0(),nan:h.Complex.NaN_0(),NaN:h.Complex.NaN_0()});Restart(){this.loadInterpreter()}Clear(...t){if(0===t.length)this.context.clearCurrentVariables();else{const e=this.clearCommandOptions(t);if(!e)return;this.clearCommandCategory(e)}}clearAllWorkspaceCategories(){this.context.clearCurrentVariables(),this.context.clearGlobalVariables(),this.context.clearClassDefinitions(),this.context.currentScope.clearImports(),this.clearUserFunctions()}clearCommandOptions(t){const e={category:"visible",regexp:!1,exclusive:!1,patterns:[]};for(let r=0;r<t.length;r++)switch(t[r]){case"all":case"-all":case"-a":return void this.clearAllWorkspaceCategories();case"import":return(this.context.isInsideUserFunction()||this.scriptExecutionDepth>0)&&this.context.throwEvalError("clear import is not allowed inside a function or script."),void this.context.currentScope.clearImports();case"variables":case"-variables":case"-v":e.category="variables";break;case"functions":case"-functions":case"-f":e.category="functions";break;case"classes":case"-classes":case"-c":e.category="classes";break;case"global":case"-global":case"-g":e.category="global";break;case"regexp":case"-regexp":case"-r":e.regexp=!0;break;case"-exclusive":case"-x":e.exclusive=!0;break;default:return e.patterns=t.slice(r),e}return e}clearCommandCategory(t){switch(t.category){case"variables":return void this.context.clearCurrentVariables(this.selectClearPatternMatches(t.patterns,this.clearVariableCandidates(),t));case"functions":return void this.clearUserFunctions(this.selectClearPatternMatches(t.patterns,this.clearFunctionCandidates(),t));case"classes":return void this.clearClassDefinitions(this.selectClearPatternMatches(t.patterns,this.clearClassCandidates(),t));case"global":return void this.context.clearGlobalVariables(this.selectClearPatternMatches(t.patterns,[...this.context.globalNameSet],t));case"visible":return void this.clearVisibleSymbols(t)}}clearVisibleSymbols(t){if(0===t.patterns.length){if(t.regexp||t.exclusive)return;return void this.context.clearCurrentVariables()}const e={regexp:t.regexp,exclusive:t.exclusive};if(t.exclusive)this.context.clearCurrentVariables(this.selectClearPatternMatches(t.patterns,this.clearVariableCandidates(),e));else if(t.regexp||t.patterns.some(t=>this.clearPatternHasWildcards(t)))for(const r of this.selectClearPatternMatches(t.patterns,this.clearVisibleCandidates(),e)??[])this.clearNamedSymbol(r);else for(const e of t.patterns)this.clearNamedSymbol(e)}clearPatternHasWildcards(t){return/[*?\[]/.test(t)}clearPatternRegExp(t){let e="^";for(let r=0;r<t.length;r++){const s=t[r];if("*"===s)e+=".*";else if("?"===s)e+=".";else if("["===s){const s=t.indexOf("]",r+1);s>r+1?(e+=`[${t.slice(r+1,s).replace(/\\/g,"\\\\")}]`,r=s):e+="\\["}else e+=s.replace(/[\\^$+?.()|{}]/g,"\\$&")}return new RegExp(e+"$")}clearPatternOptions(t,e={}){let r=e.regexp??!1,s=e.exclusive??!1,i=0;for(;i<t.length;){const e=t[i];if("-regexp"===e||"-r"===e||"regexp"===e)r=!0,i++;else{if("-exclusive"!==e&&"-x"!==e)break;s=!0,i++}}return{patterns:t.slice(i),regexp:r,exclusive:s}}clearPatternMatches(t,e,r){return r?new RegExp(e).test(t):this.clearPatternRegExp(e).test(t)}selectClearPatternMatches(t,e,r={}){if(!t)return;if(0===t.length)return r.regexp||r.exclusive?[]:void 0;const s=this.clearPatternOptions(t,r);if(0===s.patterns.length)return r.regexp||r.exclusive?[]:void 0;if(s.exclusive)return e.filter(t=>!s.patterns.some(e=>this.clearPatternMatches(t,e,s.regexp)));const i=[],n=t=>{i.includes(t)||i.push(t)};for(const t of s.patterns)s.regexp||this.clearPatternHasWildcards(t)?e.filter(e=>this.clearPatternMatches(e,t,s.regexp)).forEach(n):n(t);return i}clearVariableCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(t=>{const e=this.context.currentScope.nameTable[t];return!this.context.nativeNameSet.has(t)&&!f.ClassDefinition.isInstanceOf(e?.node)})}visibleWorkspaceVariableEntries(){return Object.entries(this.context.currentScope.nameTable).filter(([t,e])=>!this.context.nativeNameSet.has(t)&&!f.ClassDefinition.isInstanceOf(e?.node)).sort(([t],[e])=>t.localeCompare(e))}workspaceListingOptions(t,e){const r={globalOnly:!1,regexp:!1,patterns:[]};for(let s=0;s<t.length;s++){const i=t[s],n=i.toLowerCase();"global"===n||"-global"===n?r.globalOnly=!0:"-regexp"===n||"-r"===n||"regexp"===n?r.regexp=!0:"-file"===n||"file"===n?this.context.throwEvalError(`${e}: MAT-file workspace listing is not supported in the browser runtime.`):r.patterns.push(i)}return r}workspaceVariableNamesByPatterns(t,e){const r=this.workspaceListingOptions(t,e),s=this.visibleWorkspaceVariableEntries().filter(([t])=>!r.globalOnly||this.context.globalNameSet.has(t)).map(([t])=>t);if(0===r.patterns.length)return r.regexp?[]:s;const i=[],n=t=>{i.includes(t)||i.push(t)};for(const t of r.patterns){const e=this.clearPatternHasWildcards(t);s.filter(s=>r.regexp||e?this.clearPatternMatches(s,t,r.regexp):s===t).forEach(n)}return i}whoResult(t){const e=t.map(t=>this.charControlArgument(t,"who pattern").str);return this.whoResultFromPatterns(e)}whoResultFromPatterns(t){const e=d.MultiArray.toColumnVector(this.workspaceVariableNamesByPatterns(t,"who").map(t=>u.CharString.create(t,"'")));return e.isCell=!0,e}whosValueSize(t){return d.MultiArray.isInstanceOf(t)?t.dimension:u.CharString.isChar(t)?[1,t.str.length]:[1,1]}whosValueBytes(t){return h.Complex.isInstanceOf(t)?16:u.CharString.isInstanceOf(t)?2*t.str.length:d.MultiArray.isInstanceOf(t)?d.MultiArray.linearize(t).reduce((t,e)=>t+this.whosValueBytes(this.expressionValue(e,"whos element")),0):m.Structure.isInstanceOf(t)?Object.values(t.field).reduce((t,e)=>t+this.whosValueBytes(this.expressionValue(e,"whos field")),0):0}whosValueIsComplex(t){return h.Complex.isInstanceOf(t)?!h.Complex.isRealValue(t):d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearize(t).some(t=>h.Complex.isInstanceOf(t)&&!h.Complex.isRealValue(t))}whosResult(t){const e=t.map(t=>this.charControlArgument(t,"whos pattern").str);return this.whosResultFromPatterns(e)}whosResultFromPatterns(t){const e=new Set(this.workspaceVariableNamesByPatterns(t,"whos")),r=this.visibleWorkspaceVariableEntries().filter(([t])=>e.has(t)),s=d.MultiArray.toColumnVector(r.map(([t,e])=>{const r=this.expressionValue(e.node,`workspace variable ${t}`);return new m.Structure({name:u.CharString.create(t,"'"),size:d.MultiArray.toRowVector(this.whosValueSize(r).map(t=>h.Complex.create(t))),bytes:h.Complex.create(this.whosValueBytes(r)),class:u.CharString.create(this.getValueClassName(r),"'"),global:this.context.globalNameSet.has(t)?h.Complex.true():h.Complex.false(),sparse:h.Complex.false(),complex:this.whosValueIsComplex(r)?h.Complex.true():h.Complex.false(),nesting:new m.Structure({function:u.CharString.create("","'"),level:h.Complex.create(0)}),persistent:h.Complex.false()})}));return d.MultiArray.setType(s),s}keywordListResult(){const t=d.MultiArray.toColumnVector(W.keywordNames.map(t=>u.CharString.create(t,"'")));return t.isCell=!0,t}textNamePredicateResult(t,e,r){if(u.CharString.isInstanceOf(t))return r(t.str)?h.Complex.true():h.Complex.false();d.MultiArray.isInstanceOf(t)||c.AST.throwInvalidCallError(e,!0,t=>this.context.throwEvalError(t));const s=new d.MultiArray(t.dimension);for(let e=0;e<d.MultiArray.linearLength(t);e++){const[i,n]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),a=t.array[i][n];s.array[i][n]=u.CharString.isInstanceOf(a)&&r(a.str)?h.Complex.true():h.Complex.false()}return d.MultiArray.setType(s),d.MultiArray.MultiArrayToScalar(s)}isKeywordResult(t){return c.AST.throwInvalidCallError("iskeyword",t.length>1,t=>this.context.throwEvalError(t)),0===t.length?this.keywordListResult():this.textNamePredicateResult(t[0],"iskeyword",t=>W.keywordNameSet.has(t))}isVarNameResult(t){return c.AST.throwInvalidCallError("isvarname",1!==t.length,t=>this.context.throwEvalError(t)),this.textNamePredicateResult(t[0],"isvarname",t=>/^[A-Za-z][A-Za-z0-9_]*$/.test(t)&&t.length<=W.nameLengthMax&&!W.keywordNameSet.has(t))}isGlobalName(t){return this.context.globalNameSet.has(t)}isGlobalResult(t){return c.AST.throwInvalidCallError("isglobal",1!==t.length,t=>this.context.throwEvalError(t)),this.textNamePredicateResult(t[0],"isglobal",t=>this.isGlobalName(t))}clearFunctionCandidates(){return this.visibleUserFunctionNames()}visibleUserFunctionNames(){const t=[],e=new Set;let r=this.context.currentScope;for(;r;){for(const[s,i]of Object.entries(r.functionTable))e.has(s)||"FCNDEF"!==i?.type||(t.push(s),e.add(s));r=r.parent}return t}hasVisibleUserFunction(t){let e=this.context.currentScope;for(;e;){if("FCNDEF"===e.functionTable[t]?.type)return!0;e=e.parent}return!1}clearVisibleUserFunction(t){return!!this.hasVisibleUserFunction(t)&&(this.context.currentScope.clearFunction(t),!0)}clearClassCandidates(){return Object.keys(this.context.currentScope.nameTable).filter(t=>f.ClassDefinition.isInstanceOf(this.context.currentScope.nameTable[t]?.node))}clearVisibleCandidates(){return[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()]}clearClassDefinitions(t){if(t)for(const e of t)this.clearNamedSymbol(e);else this.context.clearClassDefinitions()}clearNamedPattern(t){if(!this.clearPatternHasWildcards(t))return void this.clearNamedSymbol(t);const e=[...this.clearVariableCandidates(),...this.clearFunctionCandidates(),...this.clearClassCandidates()];for(const r of this.selectClearPatternMatches([t],e)??[])this.clearNamedSymbol(r)}clearNamedSymbol(t){const e=this.resolveRuntimeSymbol(t,this.context.currentScope,{loadClasses:!1,loadFunctions:!1}),r=e?.resolvedName??this.context.aliasNameFunction(t),s=new Set([t,r]);let i=!1;for(const t of s)this.context.currentScope.hasLocalName(t)&&(this.context.currentScope.removeName(t),i=!0,this.context.nativeNameSet.has(t)&&this.context.globalScope.defineName(t,this.context.nativeNameTable[t]));if(!i)for(const t of s)if(this.clearVisibleUserFunction(t))break}clearUserFunctions(t){const e=t||this.clearFunctionCandidates();for(const t of e){const e=this.resolveRuntimeSymbol(t,this.context.currentScope,{variables:!1,classes:!1,loadClasses:!1,loadFunctions:!1}),r=e?.resolvedName??this.context.aliasNameFunction(t);for(const e of new Set([t,r]))this.clearVisibleUserFunction(e)}}validateAssignment(t,e,r=this.context.currentScope){const s="invalid left hand side of assignment",i=(t,e,r,s)=>{const i={done:!1},n=()=>c.AST.nodeList([this.expressionValue(h.Complex.create(r+1),"index")]),a=t=>{if(c.AST.isNodeIdentifier(t)){const r=c.AST.nodeIdentifier(t.id);return"insert-at-identifier"!==s||i.done?r:(i.done=!0,c.AST.nodeIndexExpr(r,n(),e))}if(c.AST.isNodeIgnoredTarget(t))return c.AST.nodeIgnoredTarget();if(c.AST.isNodeIndexExpr(t)){const r=a(t.expr);return"replace-first-index"!==s||i.done?c.AST.nodeIndexExpr(r,c.AST.nodeList(t.args.map(t=>this.cloneAssignmentTarget(t))),t.delim):(i.done=!0,c.AST.nodeIndexExpr(r,n(),e))}if(c.AST.isNodeIndirectRef(t)){const e=t.field[0];let r=c.AST.nodeIndirectRef(a(t.obj),"string"==typeof e?e:this.cloneAssignmentTarget(e));for(let e=1;e<t.field.length;e++){const s=t.field[e];r=c.AST.nodeIndirectRef(r,"string"==typeof s?s:this.cloneAssignmentTarget(s))}return r}return this.cloneAssignmentTarget(t)};return a(t)},n=s=>{if(e||!s.descriptors||0===s.descriptors.length)return[s];const n=r.resolveName(s.id);if(!n||!d.MultiArray.isInstanceOf(n.node))return[s];const a=this.readNativeSubscriptDescriptor(s.descriptors[0],"subsasgn"),o=s.descriptors[1]?this.readNativeSubscriptDescriptor(s.descriptors[1],"subsasgn"):void 0,l=n.node.isCell&&"()"===a.type&&"{}"===o?.type;if(n.node.isCell&&"{}"!==a.type&&!l)return[s];if(!n.node.isCell&&!m.Structure.isStructure(n.node)&&!this.hasClassInstanceElement(n.node))return[s];const c="()"===a.type,u="{}"===a.type,p=c||u?d.MultiArray.resolveLinearIndices(n.node,s.id,this.nativeDescriptorIndexList(a,n.node),this):d.MultiArray.resolveLinearIndices(n.node,s.id,[d.MultiArray.expandColon(d.MultiArray.linearLength(n.node))],this),f=u?"{}":"()";return p.map(e=>{const n=i(t,f,e,c||u?"replace-first-index":"insert-at-identifier");return this.collectSubsasgnAssignmentTarget(n,r)||{id:s.id,index:[this.expressionValue(h.Complex.create(e+1),"index")],delimiter:f,field:[],descriptors:[this.createSubscriptDescriptor(f,[this.expressionValue(h.Complex.create(e+1),"index")],t,r)]}})};if(c.AST.isNodeIdentifier(t))return[{id:t.id,field:[]}];if(c.AST.isNodeIndexExpr(t)&&c.AST.isNodeIdentifier(t.expr)){if(!e&&"{}"===t.delim){const e=r.resolveName(t.expr.id);if(e&&d.MultiArray.isInstanceOf(e.node)&&e.node.isCell){const s=this.evaluatedIndexArguments(t.args,r);return d.MultiArray.resolveLinearIndices(e.node,t.expr.id,s).map(e=>({id:t.expr.id,index:[this.expressionValue(h.Complex.create(e+1),"index")],delimiter:t.delim,field:[]}))}}return[{id:t.expr.id,index:t.args,delimiter:t.delim,field:[]}]}if(c.AST.isNodeIndirectRef(t)){const i=t.field.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,r,`${s}: dynamic structure field names must be strings.`));if(c.AST.isNodeIdentifier(t.obj)){if(!e){const e=r.resolveName(t.obj.id);if(e&&d.MultiArray.isInstanceOf(e.node)&&(m.Structure.isStructure(e.node)||this.hasClassInstanceElement(e.node)))return d.MultiArray.resolveLinearIndices(e.node,t.obj.id,[d.MultiArray.expandColon(d.MultiArray.linearLength(e.node))],this).map(e=>({id:t.obj.id,index:[this.expressionValue(h.Complex.create(e+1),"index")],delimiter:"()",field:i}))}return[{id:t.obj.id,field:i}]}if(c.AST.isNodeIndexExpr(t.obj)&&c.AST.isNodeIdentifier(t.obj.expr)){if(!e&&"{}"===t.obj.delim){const e=r.resolveName(t.obj.expr.id);if(e&&d.MultiArray.isInstanceOf(e.node)&&e.node.isCell){const s=this.evaluatedIndexArguments(t.obj.args,r);return d.MultiArray.resolveLinearIndices(e.node,t.obj.expr.id,s,this).map(e=>({id:t.obj.expr.id,index:[this.expressionValue(h.Complex.create(e+1),"index")],delimiter:t.obj.delim,field:[],descriptors:[this.createSubscriptDescriptor(t.obj.delim,[this.expressionValue(h.Complex.create(e+1),"index")],t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}))}}if(!e&&"()"===t.obj.delim){const e=r.resolveName(t.obj.expr.id);if(e&&d.MultiArray.isInstanceOf(e.node)&&(m.Structure.isStructure(e.node)||this.hasClassInstanceElement(e.node))){const s=this.evaluatedIndexArguments(t.obj.args,r);return d.MultiArray.resolveLinearIndices(e.node,t.obj.expr.id,s,this).map(e=>({id:t.obj.expr.id,index:[this.expressionValue(h.Complex.create(e+1),"index")],delimiter:t.obj.delim,field:i,descriptors:[this.createSubscriptDescriptor(t.obj.delim,[this.expressionValue(h.Complex.create(e+1),"index")],t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}))}}return[{id:t.obj.expr.id,index:t.obj.args,delimiter:t.obj.delim,field:i,descriptors:[this.createSubscriptDescriptor(t.obj.delim,t.obj.args,t.obj,r),...i.map(e=>this.createDotSubscriptDescriptor(e,t,r))]}]}{const e=this.collectSubsasgnAssignmentTarget(t,r);if(e)return n(e);this.context.throwEvalError(`${s}.`)}}else{if(c.AST.isNodeIgnoredTarget(t))return[{id:"~",field:[]}];if(e&&d.MultiArray.isRowVector(t))return t.array[0].flatMap(t=>this.validateAssignment(t,!1,r));{const e=this.collectSubsasgnAssignmentTarget(t,r);if(e)return n(e);this.context.throwEvalError(`${s}.`)}}}toBoolean(t){if(d.MultiArray.isInstanceOf(t)){if(t.isCell&&this.context.throwEvalError("invalid conversion from cell to logical."),this.hasClassInstanceElement(t)){const e=this.classUnaryOperatorArray(t,"logical",c.AST.nodeIdentifier("logical"));if(e)return this.toBoolean(this.expressionValue(e,"logical conversion"));this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(t)} to logical.`)}return this.complexConditionValue(d.MultiArray.toLogical(t))}if(h.Complex.isInstanceOf(t))return this.complexConditionValue(t);if(u.CharString.isInstanceOf(t))return!!t.str;if(g.ClassInstance.isInstanceOf(t)){const e=this.classUnaryOperatorMethod(t,"logical");if(e)return this.toBoolean(this.expressionValue(this.reducedClassMethodResult(e.receiver,e.method,[],c.AST.nodeIdentifier("logical")),"logical conversion"))}this.context.throwEvalError(`invalid conversion from ${this.getValueClassName(t)} to logical.`)}complexConditionValue(t){return Boolean(h.Complex.realToNumber(t)||h.Complex.imagToNumber(t))}evaluatedCondition(t,e,r){return this.toBoolean(this.evaluatedConditionExpression(t,e,r))}evaluatedConditionExpression(t,e,r){return!c.AST.isNodeBinaryOperation(t)||"&"!==t.type&&"|"!==t.type&&"&&"!==t.type&&"||"!==t.type?this.evaluatedExpressionValue(t,e,r):this.evaluateConditionalLogicalOperation(t,e)}evaluateConditionalLogicalOperation(t,e){const r=this.evaluatedCondition(t.left,e,"left condition operand");return"&"===t.type||"&&"===t.type?r&&this.evaluatedCondition(t.right,e,"right condition operand")?h.Complex.true():h.Complex.false():r||this.evaluatedCondition(t.right,e,"right condition operand")?h.Complex.true():h.Complex.false()}switchComparableValue(t){return d.MultiArray.isInstanceOf(t)&&!t.isCell&&2===t.dimension.length&&1===t.dimension[0]&&1===t.dimension[1]?this.expressionValue(t.array[0][0],"switch value"):t}switchCaseMatches(t,e){const r=d.MultiArray.isInstanceOf(e)&&e.isCell?this.expressionList(d.MultiArray.linearize(e),"switch case"):[e];for(const e of r)if(this.switchCandidateMatches(t,e))return!0;return!1}switchCandidateMatches(t,e){const r=this.switchComparableValue(e),s=this.switchComparableValue(t),i=this.classBinaryOperatorMethod(r,s,"eq");return i?this.toBoolean(this.expressionValue(this.reducedClassMethodResult(i.receiver,i.method,i.args,c.AST.nodeIdentifier("switch")),"switch case")):V.RuntimeEquality.valuesEqual(s,r)}classDefinitionForOperatorValue(t){return g.ClassInstance.isInstanceOf(t)?t.classDefinition:void 0}classNameForOperatorValue(t){return g.ClassInstance.isInstanceOf(t)?t.classDefinition.name:this.getValueClassName(t)}classDeclaresInferior(t,e){if(!t)return!1;const r=this.classDefinitionForOperatorValue(e),s=this.classNameForOperatorValue(e);return t.inferiorClasses.some(t=>t===s||!!r&&(r.name===t||r.isSubclassOfName(t)))}classBinaryOperatorMethod(t,e,r){const s=s=>{if(!g.ClassInstance.isInstanceOf(s))return;const i=s.classDefinition.findMethod(r,t=>!t.isStatic);return i?(this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${r}' has ${i.access} access for class ${s.classDefinition.name}.`),{receiver:s,method:i,args:this.classMethodArgumentValues([s===t?e:t],"operator")}):void 0},i=this.classDefinitionForOperatorValue(t),n=this.classDefinitionForOperatorValue(e);return this.classDeclaresInferior(n,t)&&!this.classDeclaresInferior(i,e)?s(e)??s(t):s(t)??s(e)}hasClassInstanceElement(t){return g.ClassInstance.isInstanceOf(t)||d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearize(t).some(t=>g.ClassInstance.isInstanceOf(t))}classBinaryOperatorArray(t,e,r,s){if(!this.hasClassInstanceElement(t)&&!this.hasClassInstanceElement(e))return;const i=d.MultiArray.scalarToMultiArray(t),n=d.MultiArray.scalarToMultiArray(e),a=i.dimension.slice(),o=n.dimension.slice(),l=Math.max(a.length,o.length);for(;a.length<l;)a.push(1);for(;o.length<l;)o.push(1);const c=new Array(l),u=new Array(l),h=new Array(l);for(let t=0;t<l;t++)a[t]===o[t]?(c[t]=a[t],u[t]=h[t]=!1):1===a[t]?(c[t]=o[t],u[t]=!0,h[t]=!1):1===o[t]?(c[t]=a[t],u[t]=!1,h[t]=!0):this.context.throwEvalError(`operator ${r}: nonconformant arguments (op1 is ${a.join("x")}, op2 is ${o.join("x")}).`);const m=i.array[0]?.[0],p=n.array[0]?.[0];if(!this.classBinaryOperatorMethod(m,p,r))return;const f=d.MultiArray.computeStrides(a),g=d.MultiArray.computeStrides(o),y=d.MultiArray.computeStrides(c),x=new d.MultiArray(c),C=c.reduce((t,e)=>t*e,1);for(let t=0;t<C;t++){let e=0,m=0;for(let r=0;r<l;r++){const s=Math.floor(t/y[r])%c[r];e+=(u[r]?0:s)*f[r],m+=(h[r]?0:s)*g[r]}const[p,C]=d.MultiArray.linearIndexToMultiArrayRowColumn(a[0],a[1],e),[E,A]=d.MultiArray.linearIndexToMultiArrayRowColumn(o[0],o[1],m),[_,S]=d.MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],t),v=this.classBinaryOperatorMethod(i.array[p][C],n.array[E][A],r);v||this.context.throwEvalError(`operator ${r} is not defined for class array element.`),x.array[_][S]=this.reducedClassMethodResult(v.receiver,v.method,v.args,s)}return d.MultiArray.setType(x),d.MultiArray.MultiArrayToScalar(x)}evaluateBinaryOperatorWithClassDispatch(t,e,r,s,i){const n=this.classBinaryOperatorArray(t,e,r,i);if(n)return n;const a=this.classBinaryOperatorMethod(t,e,r);return a?this.context.callClassInstanceMethod(a.receiver,a.method,a.args,i):T.MathOperation[s](t,e)}classVariadicOperatorMethod(t,e){for(let r=0;r<t.length;r++){const s=t[r];if(!g.ClassInstance.isInstanceOf(s))continue;const i=s.classDefinition.findMethod(e,t=>!t.isStatic);if(i)return this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${e}' has ${i.access} access for class ${s.classDefinition.name}.`),{receiver:s,method:i,args:this.classMethodArgumentValues(t.filter((t,e)=>e!==r),"operator")}}}evaluateColonWithClassDispatch(t,e){if(!t.some(t=>this.hasClassInstanceElement(t)))return;const r=this.classVariadicOperatorMethod(t,"colon");if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,r.args,e);this.context.throwEvalError("operator colon is not defined for class operands.")}concatenateOverload(t,e,r){const s=e.map((e,r)=>this.expressionValue(e,`${t} argument ${r+1}`));if(!s.some(t=>this.hasClassInstanceElement(t)))return;const i=this.classVariadicOperatorMethod(s,t);return i?this.reducedClassMethodResult(i.receiver,i.method,i.args,r):void 0}callFunctionalOperatorOverload(t,e,r){const s=t.id,i=T.MathOperation.unaryOperations[s],n=T.MathOperation.binaryOperations[s],a=T.MathOperation.leftAssociativeMultipleOperations[s],o="colon"===s,l="cat"===s,u="horzcat"===s||"vertcat"===s;if(!(i||n||a||o||l||u))return;const h=this.context.evaluateBuiltInArgs(t,e,r).map((t,e)=>this.expressionValue(t,`operator argument ${e+1}`));if(this.context.validateBuiltInInputArity(t,h.length),(!h.some(t=>this.hasClassInstanceElement(t))||l||u)&&this.context.validateBuiltInInputParameters(t,h),o)return 2!==h.length&&3!==h.length&&c.AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t)),this.evaluateColonWithClassDispatch(h,r)??N.CoreFunctions.colon(...h);if(l){const t=this.concatenateOverload(s,h,r);if(t)return t;const[e,...i]=h;return N.CoreFunctions.cat(e,...i)}if(u){return this.concatenateOverload(s,h,r)||("horzcat"===s?N.CoreFunctions.horzcat:N.CoreFunctions.vertcat)(...h)}if(i){1!==h.length&&c.AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t));const t=h[0],e=this.classUnaryOperatorArray(t,s,r);if(e)return e;const n=this.classUnaryOperatorMethod(t,s);return n?this.context.callClassInstanceMethod(n.receiver,n.method,[],r):i(t)}if(n)return 2!==h.length&&c.AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t)),this.evaluateBinaryOperatorWithClassDispatch(h[0],h[1],s,s,r);if(a){h.length<2&&c.AST.throwInvalidCallError(s,!1,t=>this.context.throwEvalError(t));let t=this.evaluateBinaryOperatorWithClassDispatch(h[0],h[1],s,s,r);for(let e=2;e<h.length;e++)t=this.evaluateBinaryOperatorWithClassDispatch(t,h[e],s,s,r);return t}}requireBinaryOperation(t){if(c.AST.isNodeBinaryOperation(t))return t;this.context.throwEvalError(`invalid binary operation AST node '${t.type}'.`)}requirePrefixOperation(t){if(c.AST.isNodePrefixOperation(t))return t;this.context.throwEvalError(`invalid prefix operation AST node '${t.type}'.`)}requirePostfixOperation(t){if(c.AST.isNodePostfixOperation(t))return t;this.context.throwEvalError(`invalid postfix operation AST node '${t.type}'.`)}evaluateBinaryOperation(t,e){const r=this.evaluatedExpressionValue(t.left,e,"left operand"),s=this.evaluatedExpressionValue(t.right,e,"right operand"),i=W.binaryOperatorMethodTable[t.type];return i?this.evaluateBinaryOperatorWithClassDispatch(r,s,i,i,t):this.opTable[t.type](r,s)}evaluateShortCircuitOperation(t,e){const r=this.evaluatedExpressionValue(t.left,e,"left operand"),s=this.toBoolean(r);return"&&"===t.type?s&&this.toBoolean(this.evaluatedExpressionValue(t.right,e,"right operand"))?h.Complex.true():h.Complex.false():s||this.toBoolean(this.evaluatedExpressionValue(t.right,e,"right operand"))?h.Complex.true():h.Complex.false()}classUnaryOperatorMethod(t,e){if(!g.ClassInstance.isInstanceOf(t))return;const r=t.classDefinition.findMethod(e,t=>!t.isStatic);return r?(this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method '${e}' has ${r.access} access for class ${t.classDefinition.name}.`),{receiver:t,method:r}):void 0}classUnaryOperatorArray(t,e,r){if(!d.MultiArray.isInstanceOf(t)||!this.hasClassInstanceElement(t))return;const s=t.array[0]?.[0];if(!this.classUnaryOperatorMethod(s,e))return;const i=new d.MultiArray(t.dimension);for(let s=0;s<d.MultiArray.linearLength(t);s++){const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),o=this.classUnaryOperatorMethod(t.array[n][a],e);o||this.context.throwEvalError(`operator ${e} is not defined for class array element.`),i.array[n][a]=this.reducedClassMethodResult(o.receiver,o.method,[],r)}return d.MultiArray.setType(i),d.MultiArray.MultiArrayToScalar(i)}evaluateUnaryOperation(t,e){const r=c.AST.isNodePrefixOperation(t)?t.right:t.left,s=this.evaluatedExpressionValue(r,e,"unary operand"),i=W.unaryOperatorMethodTable[t.type];if(i){const e=this.classUnaryOperatorArray(s,i,t);if(e)return e;const r=this.classUnaryOperatorMethod(s,i);if(r)return this.context.callClassInstanceMethod(r.receiver,r.method,[],t)}return this.opTable[t.type](s)}resolveClassInstanceField(t,e,r){try{g.ClassInstance.throwIfDeleted(t)}catch(t){this.context.throwEvalError(t.message)}if(t.classDefinition.isSubclassOfName("event.EventData")){if("Source"===e)return t.eventDataSource||this.context.throwEvalError("event data Source is not assigned until notify dispatch."),t.eventDataSource;if("EventName"===e)return t.eventDataEventName||this.context.throwEvalError("event data EventName is not assigned until notify dispatch."),u.CharString.create(t.eventDataEventName)}if(!this.context.canAccessClassMember(t.classDefinition,"private")){const s=this.callClassDotSubsref(t,e,r,this.context.currentScope);if(void 0!==s)return s}const s=t.classDefinition.findProperty(e);if(s?.getMethodName){this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PreGet");const i=t.classDefinition.findMethod(s.getMethodName,t=>!t.isStatic);i||this.context.throwEvalError(`GetMethod '${s.getMethodName}' for property '${e}' in class ${t.classDefinition.name} is not defined.`);const n=this.reducedClassMethodResult(t,i,[],r);return s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PostGet"),n}if(s?.isDependent){this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PreGet");const i=t.classDefinition.findMethod(`get.${e}`,t=>!t.isStatic);i||this.context.throwEvalError(`dependent property '${e}' for class ${t.classDefinition.name} has no get accessor.`);const n=this.reducedClassMethodResult(t,i,[],r);return s.isGetObservable&&this.dispatchClassPropertyEvent(t,e,"PostGet"),n}const i=g.ClassInstance.getProperty(t,e);if(void 0!==i)return s&&(this.assertCanReadClassProperty(s,e,t.classDefinition.name),s.isGetObservable&&(this.dispatchClassPropertyEvent(t,e,"PreGet"),this.dispatchClassPropertyEvent(t,e,"PostGet"))),i;const n=t.classDefinition.findMethod(e,t=>!t.isStatic);if(n)return this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method '${e}' has ${n.access} access for class ${t.classDefinition.name}.`),y.ClassBoundMethod.bind(t,n);this.context.throwEvalError(`unknown property or method '${e}' for class ${t.classDefinition.name}.`)}assertCanReadClassProperty(t,e,r){this.context.canAccessClassMember(t.classDefinition,t.getAccess)||this.context.throwEvalError(`property '${e}' has ${t.getAccess} get access for class ${r}.`)}assertCanWriteClassProperty(t,e,r){this.context.canAccessClassMember(t.classDefinition,t.setAccess)||this.context.throwEvalError(`property '${e}' has ${t.setAccess} set access for class ${r}.`)}shouldAbortClassPropertySet(t,e,r){return e.isAbortSet&&!e.isDependent&&g.ClassInstance.hasProperty(t,e.name)&&V.RuntimeEquality.valuesEqual(g.ClassInstance.getProperty(t,e.name),r)}assignClassInstanceField(t,e,r,s,i){if(!this.context.canAccessClassMember(t.classDefinition,"private")){const n=this.callClassDotSubsasgn(t,e,r,s,i);if(n)return n}!t.classDefinition.isSubclassOfName("event.EventData")||"Source"!==e&&"EventName"!==e||this.context.throwEvalError(`cannot assign to read-only property '${e}' for class ${t.classDefinition.name}.`);const n=t.classDefinition.findProperty(e);if(n&&this.assertCanWriteClassProperty(n,e,t.classDefinition.name),n?.isConstant&&this.context.throwEvalError(`cannot assign to constant property '${e}' for class ${t.classDefinition.name}.`),n&&this.shouldAbortClassPropertySet(t,n,r))return t;if(n?.isSetObservable&&this.dispatchClassPropertyEvent(t,e,"PreSet"),n?.setMethodName||n?.isDependent){this.validateClassPropertyValue(n,r,i);const a=n.setMethodName??`set.${e}`,o=t.classDefinition.findMethod(a,t=>!t.isStatic);o||(n.setMethodName&&this.context.throwEvalError(`SetMethod '${n.setMethodName}' for property '${e}' in class ${t.classDefinition.name} is not defined.`),this.context.throwEvalError(`cannot assign to dependent property '${e}' for class ${t.classDefinition.name} without a set accessor.`));const l=this.reducedClassMethodResult(t,o,this.classMethodArgumentValues([r],`set.${e}`),s);return g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError(`set accessor for property '${e}' must return an object of class ${t.classDefinition.name}.`),n.isSetObservable&&this.dispatchClassPropertyEvent(l,e,"PostSet"),l}n&&this.validateClassPropertyValue(n,r,i);try{g.ClassInstance.setProperty(t,e,r)}catch(t){this.context.throwEvalError(t.message)}return n?.isSetObservable&&this.dispatchClassPropertyEvent(t,e,"PostSet"),t}assignNestedClassInstanceField(t,e,r,s,i){if(1===e.length)return this.assignClassInstanceField(t,e[0],r,s,i);const n=e[0],a=e.slice(1);let o,l=this.resolveClassInstanceField(t,n,s);if(d.MultiArray.isEmpty(l)&&(l=new m.Structure({})),m.Structure.isInstanceOf(l)){const t=m.Structure.copy(l);m.Structure.setNewField(t,a,this.runtimeExpressionValue(r,`field ${e.join(".")}`)),o=t}else g.ClassInstance.isInstanceOf(l)?o=this.assignNestedClassInstanceField(l,a,r,s,i):this.context.throwEvalError("value cannot be indexed with .");return this.assignClassInstanceField(t,n,o,s,i)}assignClassArrayField(t,e,r,s,i){const n=d.MultiArray.copy(t),a=this.assignmentValues(r,"assignment"),o=d.MultiArray.linearLength(n);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let t=0;t<o;t++){const[r,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t),l=n.array[r][o];g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),n.array[r][o]=this.assignClassInstanceField(l,e,1===a.length?a[0]:a[t],s,i)}return d.MultiArray.setType(n),n}assignNestedClassArrayField(t,e,r,s,i){if(1===e.length)return this.assignClassArrayField(t,e[0],r,s,i);const n=d.MultiArray.copy(t),a=this.assignmentValues(r,"assignment"),o=d.MultiArray.linearLength(n);1!==a.length&&a.length!==o&&this.context.throwEvalError(`assignment value count ${a.length} does not match object array length ${o}.`);for(let t=0;t<o;t++){const[r,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t),l=n.array[r][o];g.ClassInstance.isInstanceOf(l)||this.context.throwEvalError("object array field assignment requires class instance elements."),n.array[r][o]=this.assignNestedClassInstanceField(l,e,1===a.length?a[0]:a[t],s,i)}return d.MultiArray.setType(n),n}assignClassArrayIndexedField(t,e,r,s,i,n,a){const o=this.evaluatedIndexArguments(r,a),l=d.MultiArray.getElements(e,t,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],t);m.array[r][i]=this.assignClassInstanceField(e,s,1===u.length?u[0]:u[t],n,a)}return d.MultiArray.setType(m),d.MultiArray.setElements(a,t,[],o,m),this.scopedMultiArrayValue(a,t,"object array assignment result")}assignClassArrayIndexedNestedField(t,e,r,s,i,n,a){if(1===s.length)return this.assignClassArrayIndexedField(t,e,r,s[0],i,n,a);const o=this.evaluatedIndexArguments(r,a),l=d.MultiArray.getElements(e,t,[],o),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[r,i]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],t);m.array[r][i]=this.assignNestedClassInstanceField(e,s,1===u.length?u[0]:u[t],n,a)}return d.MultiArray.setType(m),d.MultiArray.setElements(a,t,[],o,m),this.scopedMultiArrayValue(a,t,"object array assignment result")}assignClassArrayDescriptorField(t,e,r,s,i,n){const a=d.MultiArray.copy(t),o=d.MultiArray.getElements(a,"",[],e),l=this.assignmentValues(o,"selection"),c=1===l.length?[s]:this.assignmentValues(s,"assignment");1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=d.MultiArray.isInstanceOf(o)?o:d.MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new d.MultiArray(u.dimension);for(let t=0;t<l.length;t++){const e=l[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[s,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],t);h.array[s][a]=this.assignNestedClassInstanceField(e,r,1===c.length?c[0]:c[t],i,n)}d.MultiArray.setType(h);const m=$.Scope.create();return m.defineName("__object_array_subsasgn__",a),d.MultiArray.setElements(m,"__object_array_subsasgn__",[],e,h,void 0,this),this.scopedMultiArrayValue(m,"__object_array_subsasgn__","object array assignment result")}evaluatedIndexArguments(t,e){return d.MultiArray.indexArguments(t.map((t,r)=>this.convertIndexArgument(this.evaluatedExpressionValue(t,e,`index${r+1}`),t)),"index")}evaluatedDynamicFieldName(t,e,r){const s=this.evaluatedExpressionValue(t,e,"dynamic field name");return u.CharString.isInstanceOf(s)||this.context.throwEvalError(r),s.str}evaluatedCommaSeparatedReceiver(t,e){this.context.pushRequestedOutputCount(1),this.context.pushCommaListExpansion();try{const r=this.Evaluator(t,e);return c.AST.isNodeReturnList(r)&&r.commaSeparated?this.context.expandCommaSeparatedList(r):void 0}finally{this.context.popCommaListExpansion(),this.context.popRequestedOutputCount()}}chainedCommaListResult(t){return 1===t.length?this.returnListValue(t[0],"out1"):this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(t):c.AST.nodeList(this.expressionList(t,"out"))}chainedCommaItemApply(t,e,r){this.context.pushRequestedOutputCount(1);try{const s=this.context.apply(this.expressionValue(t,"indexed expression"),e,r);return this.reducedIndexingResult(s)}finally{this.context.popRequestedOutputCount()}}dottedCommaReceiver(t,e){const r=t=>{try{return this.evaluatedCommaSeparatedReceiver(t,e)}catch{return}};let s=t.obj;for(let e=0;e<t.field.length;e++){const i=r(s);if(i)return{values:i,fields:t.field.slice(e)};s=c.AST.nodeIndirectRef(c.AST.isNodeIndirectRef(s)?{...s,field:[...s.field]}:s,t.field[e])}const i=r(s);return i?{values:i,fields:[]}:void 0}resolveDotFieldChain(t,e,r,s){if(g.ClassInstance.isInstanceOf(t))return this.resolveClassFieldChain(t,e,r);if(d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t))return this.resolveClassFieldChain(t,e,r);if(A.ClassEventListener.isInstanceOf(t)){let s=t;for(const t of e)s=A.ClassEventListener.isInstanceOf(s)?this.resolveClassEventListenerField(s,t):g.ClassInstance.isInstanceOf(s)?this.resolveClassInstanceField(s,t,r):m.Structure.getField(s,[t]);return s}if(_.ClassEventData.isInstanceOf(t)||S.ClassPropertyEvent.isInstanceOf(t)){let s=t;for(const t of e)if(_.ClassEventData.isInstanceOf(s)||S.ClassPropertyEvent.isInstanceOf(s))s=this.resolveClassEventDataField(s,t);else if(g.ClassInstance.isInstanceOf(s))s=this.resolveClassInstanceField(s,t,r);else if(v.ClassMetaObject.isInstanceOf(s)){const e=s.getProperty(t);void 0===e&&this.context.throwEvalError(`unknown property '${t}' for ${s.kind}.`),s=e}else s=m.Structure.getField(s,[t]);return s}if(v.ClassMetaObject.isInstanceOf(t)){let r=t;for(const t of e)if(v.ClassMetaObject.isInstanceOf(r)){const e=r.getProperty(t);void 0===e&&this.context.throwEvalError(`unknown property '${t}' for ${r.kind}.`),r=e}else r=m.Structure.getField(r,[t]);return r}if(f.ClassDefinition.isInstanceOf(t))return this.resolveClassDefinitionMemberChain(t,e,s);const i=m.Structure.getFields(t,e);return 1===i.length?i[0]:this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(i):c.AST.nodeList(i)}resolveClassArrayField(t,e,r,s=!0){const i=new d.MultiArray(t.dimension);for(let s=0;s<d.MultiArray.linearLength(t);s++){const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),o=t.array[n][a];g.ClassInstance.isInstanceOf(o)||this.context.throwEvalError("object array field access requires class instance elements."),i.array[n][a]=this.resolveClassInstanceField(o,e,r)}d.MultiArray.setType(i);const n=d.MultiArray.linearize(i);return s&&(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!n.every(t=>y.ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(n):i}resolveClassFieldChain(t,e,r){let s=t;for(let t=0;t<e.length;t++){const i=e[t],n=t===e.length-1;s=g.ClassInstance.isInstanceOf(s)?this.resolveClassInstanceField(s,i,r):d.MultiArray.isInstanceOf(s)&&this.hasClassInstanceElement(s)?this.resolveClassArrayField(s,i,r,n):this.resolveStructureLikeField(s,i,n)}return s}evaluatedCallArguments(t,e,r){return t.map((t,s)=>this.evaluatedExpressionValue(t,e,`${r}${s+1}`))}isClassInstanceArray(t){return d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearLength(t)>0&&d.MultiArray.linearize(t).every(g.ClassInstance.isInstanceOf)}isClassEventListenerArray(t){return d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearLength(t)>0&&d.MultiArray.linearize(t).every(A.ClassEventListener.isInstanceOf)}inheritedHandleMethodCall(t,e){if("()"!==t.delim||!c.AST.isNodeIndirectRef(t.expr)||this.hasQualifiedNameAccessOperand(t.expr,e))return;const r=t.expr,s=r.field[r.field.length-1];if("string"!=typeof s||!["addlistener","delete","isvalid","notify"].includes(s))return;const i=r.field.slice(0,-1).map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings."));let n=this.evaluatedExpressionValue(r.obj,e,`${s} receiver`);if(i.length>0&&(n=this.resolveDotFieldChain(n,i,r,e)),A.ClassEventListener.isInstanceOf(n))switch(s){case"delete":return c.AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t)),A.ClassEventListener.delete(n),c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),N.CoreFunctions.isvalid(n);default:return}if(this.isClassEventListenerArray(n))switch(s){case"delete":c.AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t));for(const t of d.MultiArray.linearize(n))A.ClassEventListener.isInstanceOf(t)||this.context.throwEvalError("internal error: event listener array contains a non-listener value."),A.ClassEventListener.delete(t);return c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),N.CoreFunctions.isvalid(n);default:return}const a=g.ClassInstance.isInstanceOf(n)?n.classDefinition:this.isClassInstanceArray(n)?d.MultiArray.linearize(n).find(g.ClassInstance.isInstanceOf).classDefinition:void 0;if(!a?.isHandleClass())return;if("delete"!==s&&a.findMethod(s,t=>!t.isStatic))return;const o=()=>this.evaluatedCallArguments(t.args,e,`${s} argument `);if(g.ClassInstance.isInstanceOf(n))switch(s){case"addlistener":return this.addClassListener("addlistener",n,...o());case"delete":return c.AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t)),this.context.deleteClassInstance(n,t);case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),N.CoreFunctions.isvalid(n);case"notify":{const t=o();return c.AST.throwInvalidCallError("notify",t.length<1||t.length>2,t=>this.context.throwEvalError(t)),this.notifyClassEvent(n,t[0],t[1])}default:return}if(this.isClassInstanceArray(n))switch(s){case"addlistener":return this.addClassListener("addlistener",n,...o());case"delete":c.AST.throwInvalidCallError("delete",0!==t.args.length,t=>this.context.throwEvalError(t));for(const e of d.MultiArray.linearize(n))g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("internal error: object array contains a non-object value."),this.context.deleteClassInstance(e,t);return c.AST.nodeVoid();case"isvalid":return c.AST.throwInvalidCallError("isvalid",0!==t.args.length,t=>this.context.throwEvalError(t)),N.CoreFunctions.isvalid(n);case"notify":{const t=o();return c.AST.throwInvalidCallError("notify",t.length<1||t.length>2,t=>this.context.throwEvalError(t)),this.notifyClassEvent(n,t[0],t[1])}default:return}}resolveNestedClassInstanceIndexedField(t,e,r,s){const i=this.resolveClassFieldChain(t,e,s);return this.nativeSubscriptScalar(i,r)}resolveClassArrayDescriptorIndexedField(t,e,r,s,i,n){const a=d.MultiArray.getElements(t,"",[],e,this),o=d.MultiArray.isInstanceOf(a)?a:d.MultiArray.scalarToMultiArray(this.expressionValue(a,"selection")),l=new d.MultiArray(n??o.dimension),c=d.MultiArray.linearize(o);for(let t=0;t<c.length;t++){const e=c[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field access requires class instance elements.");const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[n][a]=this.resolveNestedClassInstanceIndexedField(e,r,s,i)}d.MultiArray.setType(l);const u=d.MultiArray.linearize(l);return 1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(l),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(t=>y.ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(u):l}resolveStructureLikeField(t,e,r){if(d.MultiArray.isInstanceOf(t)&&m.Structure.isStructure(t)){const s=m.Structure.getFields(t,[e]);return r&&s.length>1?c.AST.nodeList(this.expressionList(s,e)):d.MultiArray.MultiArrayToScalar(d.MultiArray.toRowVector(s))}return m.Structure.getField(t,[e])}createSubscriptDescriptor(t,e,r,s){const i=new d.MultiArray([1,e.length]);i.isCell=!0;for(let t=0;t<e.length;t++){const r=e[t];i.array[0][t]=":"===r.type?u.CharString.create(":"):this.evaluatedExpressionValue(r,s,`subscript${t+1}`)}return d.MultiArray.setType(i),new m.Structure({type:u.CharString.create(t),subs:i})}createSubsrefDescriptor(t,e){return this.createSubscriptDescriptor(t.delim,t.args,t,e)}createDotSubscriptDescriptor(t,e,r){return this.expressionValue(u.CharString.create(t),"dot subscript"),new m.Structure({type:u.CharString.create("."),subs:u.CharString.create(t)})}createSubscriptDescriptorArray(t){if(1===t.length)return t[0];const e=new d.MultiArray([1,t.length]);for(let r=0;r<t.length;r++)e.array[0][r]=t[r];return d.MultiArray.setType(e),e}numericScalarToNumber(t,e){const r=d.MultiArray.firstElement(t);return h.Complex.isInstanceOf(r)||this.context.throwEvalError(e),h.Complex.realToNumber(r)}callClassInstanceMethodWithOutputCount(t,e,r,s,i,n){this.context.pushRequestedOutputCount(i),n&&this.context.pushRequestedOutputMask(n);try{return this.context.callClassInstanceMethod(t,e,r,s)}finally{n&&this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount()}}callClassNumArgumentsFromSubscript(t,e,r){const s=t.classDefinition.findMethod("numArgumentsFromSubscript",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'numArgumentsFromSubscript' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.reducedClassMethodResultWithOutputCount(t,s,this.classMethodArgumentValues([e,u.CharString.create("subsref")],"numArgumentsFromSubscript"),r,1),n=this.numericScalarToNumber(i,`numArgumentsFromSubscript for class ${t.classDefinition.name} must return a numeric scalar.`);return(!Number.isFinite(n)||!Number.isInteger(n)||n<0)&&this.context.throwEvalError(`numArgumentsFromSubscript for class ${t.classDefinition.name} must return a nonnegative integer scalar.`),n}callClassSubsrefMethod(t,e,r,s){const i=this.context.requestedOutputCount;if(i<=1)return this.reducedClassMethodResult(t,e,this.classMethodArgumentValues([r],"subsref"),s);const n=this.callClassNumArgumentsFromSubscript(t,r,s)??i;c.AST.throwErrorIfGreaterThanReturnList(n,i,t=>this.context.throwEvalError(t));const a=this.context.requestedOutputMask(i),o=t=>a[t]??!0;return c.AST.nodeReturnList((t,e)=>{const r=t[`out${e}`];return void 0===r&&c.AST.throwErrorIfGreaterThanReturnList(e,e+1,t=>this.context.throwEvalError(t)),r},i=>{c.AST.throwErrorIfGreaterThanReturnList(n,i,t=>this.context.throwEvalError(t));const l=this.callClassInstanceMethodWithOutputCount(t,e,this.classMethodArgumentValues([r],"subsref"),s,i,a.slice(0,i)),u={length:i};if(c.AST.isNodeReturnList(l)){const t=l.handler(i);for(let e=0;e<i;e++)o(e)&&(u[`out${e}`]=l.selector(t,e));return u}return i>1&&c.AST.throwErrorIfGreaterThanReturnList(1,i,t=>this.context.throwEvalError(t)),u.out0=l,u})}callClassSubsref(t,e,r){const s=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsref' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.createSubsrefDescriptor(e,r);return this.callClassSubsrefMethod(t,s,i,e)}callClassSubsrefDescriptors(t,e,r){const s=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!s)return;this.context.canAccessClassMember(s.classDefinition,s.access)||this.context.throwEvalError(`method 'subsref' has ${s.access} access for class ${t.classDefinition.name}.`);const i=this.createSubscriptDescriptorArray(e);return this.callClassSubsrefMethod(t,s,i,r)}callClassDotSubsref(t,e,r,s){const i=t.classDefinition.findMethod("subsref",t=>!t.isStatic);if(!i)return;this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'subsref' has ${i.access} access for class ${t.classDefinition.name}.`);const n=this.createDotSubscriptDescriptor(e,r,s);return this.callClassSubsrefMethod(t,i,n,r)}collectClassSubsrefChain(t,e){if("IDX"===t.type){const r=this.collectClassSubsrefChain(t.expr,e);if(!r){const r=this.evaluatedExpressionValue(t.expr,e,"subsref chain receiver");if(d.MultiArray.isInstanceOf(r)&&this.hasClassInstanceElement(r)){const s=this.reducedIndexingResult(this.context.apply(r,t.args,t));if(g.ClassInstance.isInstanceOf(s))return{instance:s,descriptors:[this.createSubsrefDescriptor(t,e)]}}return}return r.descriptors.push(this.createSubsrefDescriptor(t,e)),r}if("."===t.type){const r=this.collectClassSubsrefChain(t.obj,e);if(!r)return;for(const s of t.field){const i="string"==typeof s?s:this.evaluatedDynamicFieldName(s,e,"Dynamic structure field names must be strings.");r.descriptors.push(this.createDotSubscriptDescriptor(i,t,e))}return r}const r=this.evaluatedExpressionValue(t,e,"subsref chain receiver");return g.ClassInstance.isInstanceOf(r)?{instance:r,descriptors:[]}:void 0}collectSubsasgnAssignmentTarget(t,e){const r=t=>{if(c.AST.isNodeIdentifier(t))return{id:t.id,descriptors:[]};if(c.AST.isNodeIndexExpr(t)){const s=r(t.expr);if(!s)return;return s.descriptors.push(this.createSubscriptDescriptor(t.delim,t.args,t,e)),s}if(c.AST.isNodeIndirectRef(t)){const s=r(t.obj);if(!s)return;for(const r of t.field){const i="string"==typeof r?r:this.evaluatedDynamicFieldName(r,e,"invalid left hand side of assignment: dynamic structure field names must be strings.");s.descriptors.push(this.createDotSubscriptDescriptor(i,t,e))}return s}},s=r(t);return s&&s.descriptors.length>0?{id:s.id,field:[],descriptors:s.descriptors}:void 0}indexedAssignmentRhs(t,e,r,s=!1){return"{}"===t?(void 0!==r&&d.MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("matrix cannot be indexed with {"),d.MultiArray.firstRow([this.runtimeExpressionValue(e,"cell assignment value")],!0)):s?new d.MultiArray([1,1],[[this.runtimeExpressionValue(e,"cell assignment value")]]):!s&&"()"===t&&d.MultiArray.isInstanceOf(e)&&e.isCell?(void 0!==r&&d.MultiArray.isInstanceOf(r)&&!r.isCell&&this.context.throwEvalError("cell array assignment requires a cell array target."),e):"()"===t&&d.MultiArray.isInstanceOf(r)&&r.isCell?(d.MultiArray.isInstanceOf(e)&&!e.isCell&&d.MultiArray.isEmpty(e)||d.MultiArray.isInstanceOf(e)&&e.isCell||this.context.throwEvalError("cell array assignment requires a cell array value."),e):d.MultiArray.scalarToMultiArray(this.runtimeExpressionValue(e,"indexed assignment value"))}readNativeSubscriptDescriptor(t,e="subsasgn"){const r=t.field.type,s=t.field.subs;if((!u.CharString.isInstanceOf(r)||"()"!==r.str&&"{}"!==r.str&&"."!==r.str)&&this.context.throwEvalError(`invalid ${e} descriptor.`),"."===r.str){if(u.CharString.isInstanceOf(s))return{type:".",subs:[s]};if(d.MultiArray.isInstanceOf(s)&&s.isCell){const t=this.descriptorSubscripts(s);if(1===t.length&&u.CharString.isInstanceOf(t[0]))return{type:".",subs:t}}this.context.throwEvalError(`invalid ${e} descriptor.`)}return d.MultiArray.isInstanceOf(s)&&s.isCell||this.context.throwEvalError(`invalid ${e} descriptor.`),{type:r.str,subs:this.descriptorSubscripts(s)}}descriptorSubscripts(t){return d.MultiArray.linearize(t).map((t,e)=>this.expressionValue(t,`subscript${e+1}`))}subscriptDescriptorStructures(t,e){const r=m.Structure.structureElements(t);return 0===r.length&&this.context.throwEvalError(`${e}: subscript argument must be a structure array.`),r.forEach(t=>this.readNativeSubscriptDescriptor(t,e)),r}nativeSubsrefNativeDescriptors(t,e){let r=t;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1,n=t=>{if("()"===s.type&&(y.ClassBoundMethod.isInstanceOf(t)||d.MultiArray.isInstanceOf(t)&&d.MultiArray.linearLength(t)>0&&d.MultiArray.linearize(t).every(y.ClassBoundMethod.isInstanceOf))){const e=s.subs.map((t,e)=>this.expressionValue(t,`subsref method argument ${e+1}`));return this.context.callClassBoundMethodValue(t,e,c.AST.nodeIdentifier("subsref"))}return"."===s.type?this.nativeDotSubsrefResult(t,s):"{}"===s.type?this.nativeBraceSubsrefResult(t,s):i&&"()"===s.type?this.nativeParenSubsrefResult(t,s):this.nativeSubscriptScalar(t,s)};r=c.AST.isNodeReturnList(r)&&r.commaSeparated?this.chainedCommaListResult(this.context.expandCommaSeparatedList(r).map(t=>n(t))):n(r)}return r}nativeSubsrefDescriptors(t,e){return this.nativeSubsrefNativeDescriptors(t,e.map(t=>this.readNativeSubscriptDescriptor(t,"subsref")))}nativeDotSubsrefResult(t,e){const r=e.subs[0];u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsref descriptor.");const s=m.Structure.getFields(t,[r.str]);return s.length>1?this.valueReturnList(s):this.expressionValue(s[0],`field ${r.str}`)}nativeBraceSubsrefResult(t,e){d.MultiArray.isInstanceOf(t)&&t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=d.MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),s=d.MultiArray.linearize(r);return s.length>1?this.valueReturnList(s):this.expressionValue(d.MultiArray.MultiArrayToScalar(r),"indexed value")}nativeParenSubsrefResult(t,e){if(u.CharString.isInstanceOf(t)){const r=d.MultiArray.characterVectorFromCharString(t),s=d.MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(e,r),this);return d.MultiArray.charStringFromCharacterVectorResult(s,t.quote)}d.MultiArray.isInstanceOf(t)||this.context.throwEvalError("matrix cannot be indexed with (");const r=d.MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this);return t.isCell?(d.MultiArray.isInstanceOf(r)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),r.isCell=!0,r):this.expressionValue(d.MultiArray.MultiArrayToScalar(r),"indexed value")}numericCodeToCharString(t,e='"'){return 0!==h.Complex.imagToNumber(t)&&this.context.throwEvalError("character string assignment requires real character codes."),u.CharString.fromNumericCode(h.Complex.realToNumber(t),e)}charStringAssignmentElement(t,e='"'){return u.CharString.isInstanceOf(t)?t:h.Complex.isInstanceOf(t)?this.numericCodeToCharString(t,e):void this.context.throwEvalError("character string assignment requires character or numeric values.")}charStringAssignmentRhs(t,e='"'){if(u.CharString.isInstanceOf(t))return d.MultiArray.characterVectorFromCharString(t);if(d.MultiArray.isInstanceOf(t)&&!t.isCell){const r=new d.MultiArray(t.dimension);for(let s=0;s<d.MultiArray.linearLength(t);s++){const[i,n]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s);r.array[i][n]=this.charStringAssignmentElement(t.array[i][n],e)}return d.MultiArray.setType(r),r}return d.MultiArray.scalarToMultiArray(this.charStringAssignmentElement(t,e))}publicObjectArraySubscriptTarget(t,e){if(!d.MultiArray.isInstanceOf(t)||!this.hasClassInstanceElement(t)||0===e.length)return;const r=this.readNativeSubscriptDescriptor(e[0]);if("."===r.type)return;const s=this.singleOutputNativeSubscriptScalar(t,r);return g.ClassInstance.isInstanceOf(s)?s:void 0}singleOutputNativeSubscriptScalar(t,e){this.context.pushRequestedOutputCount(1);try{return this.reducedIndexingResult(this.nativeSubscriptScalar(t,e))}finally{this.context.popRequestedOutputCount()}}publicCellContentSubscriptSelection(t,e){if(!d.MultiArray.isInstanceOf(t)||!t.isCell||0===e.length)return;const r=this.readNativeSubscriptDescriptor(e[0]);if("{}"===r.type){const s=this.singleOutputNativeSubscriptScalar(t,r);return g.ClassInstance.isInstanceOf(s)?{instance:s,objectDescriptors:e.slice(1),contentDescriptor:r}:void 0}if("()"!==r.type||e.length<2)return;const s=this.readNativeSubscriptDescriptor(e[1]);if("{}"!==s.type)return;const i=this.nativeParenSubsrefResult(t,r);if(!d.MultiArray.isInstanceOf(i)||!i.isCell)return;const n=this.singleOutputNativeSubscriptScalar(i,s);return g.ClassInstance.isInstanceOf(n)?{instance:n,objectDescriptors:e.slice(2),contentDescriptor:s,outerDescriptor:r,selectedCell:i}:void 0}dotDescriptorFieldChain(t,e="subsasgn"){const r=[];for(const s of t){if("."!==s.type)return;const t=s.subs[0];u.CharString.isInstanceOf(t)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.push(t.str)}return r}classPropertyDescriptorChain(t,e){const r={fields:[]};let s=0;if("()"===t[0]?.type)r.leadingIndex=t[0],s=1;else if("{}"===t[0]?.type)return;for(;s<t.length;s++){const i=t[s];if("."!==i.type)break;const n=i.subs[0];u.CharString.isInstanceOf(n)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.fields.push(n.str)}if(0!==r.fields.length){if(s<t.length){if(s!==t.length-1||"."===t[s].type)return;r.finalIndex=t[s]}return r}}classPropertyDescriptorPath(t,e){const r={fields:[]};let s=0;if("()"===t[0]?.type)r.leadingIndex=t[0],s=1;else if("{}"===t[0]?.type)return;for(;s<t.length&&"."===t[s].type;s++){const i=t[s].subs[0];u.CharString.isInstanceOf(i)||this.context.throwEvalError(`invalid ${e} descriptor.`),r.fields.push(i.str)}if(0!==r.fields.length)return r.tailDescriptors=t.slice(s),1===r.tailDescriptors.length&&(r.finalIndex=r.tailDescriptors[0]),r}indexedClassPropertyValue(t,e,r){return d.MultiArray.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${e.type[0]}`),this.setNativeIndexedValue(t,e,r)}assignNestedClassInstanceIndexedField(t,e,r,s,i,n){const a=this.resolveClassFieldChain(t,e,i),o=this.indexedClassPropertyValue(a,r,s);return this.assignNestedClassInstanceField(t,e,o,i,n)}resolveClassSubsrefDescriptors(t,e,r){const s=this.classPropertyDescriptorPath(e,"subsref");if(g.ClassInstance.isInstanceOf(t)){if(!s||s.leadingIndex)return;const e=this.resolveClassFieldChain(t,s.fields,r);return s.tailDescriptors&&s.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,s.tailDescriptors):e}if(s&&d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)&&0!==e.length){if(s.leadingIndex){const e=this.nativeDescriptorIndexList(s.leadingIndex,t);return this.resolveClassArrayPropertyPath(t,e,s,r)}return this.resolveClassArrayPropertyPath(t,[d.MultiArray.expandColon(d.MultiArray.linearLength(t))],s,r,t.dimension)}}assignClassArrayDescriptorIndexedField(t,e,r,s,i,n,a){const o=d.MultiArray.copy(t),l=d.MultiArray.getElements(o,"",[],e),c=this.assignmentValues(l,"selection"),u=1===c.length?[i]:this.assignmentValues(i,"assignment");1!==u.length&&u.length!==c.length&&this.context.throwEvalError(`assignment value count ${u.length} does not match selected object count ${c.length}.`);const h=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),m=new d.MultiArray(h.dimension);for(let t=0;t<c.length;t++){const e=c[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[i,o]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],t);m.array[i][o]=this.assignNestedClassInstanceIndexedField(e,r,s,1===u.length?u[0]:u[t],n,a)}d.MultiArray.setType(m);const p=$.Scope.create();return p.defineName("__object_array_subsasgn__",o),d.MultiArray.setElements(p,"__object_array_subsasgn__",[],e,m,void 0,this),this.scopedMultiArrayValue(p,"__object_array_subsasgn__","object array assignment result")}resolveClassArrayPropertyPath(t,e,r,s,i){const n=d.MultiArray.getElements(t,"",[],e,this),a=d.MultiArray.isInstanceOf(n)?n:d.MultiArray.scalarToMultiArray(this.expressionValue(n,"selection")),o=d.MultiArray.linearize(a),l=(t,e)=>{g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("object array indexed property access requires class instance elements."),e&&this.context.pushRequestedOutputCount(1);try{const e=this.resolveClassFieldChain(t,r.fields,s);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,r.tailDescriptors):e}finally{e&&this.context.popRequestedOutputCount()}};if(1===o.length&&!i)return l(o[0],!1);const c=new d.MultiArray(i??a.dimension);for(let t=0;t<o.length;t++){const[e,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(c.dimension[0],c.dimension[1],t);c.array[e][r]=l(o[t],!0)}d.MultiArray.setType(c);const u=d.MultiArray.linearize(c);return 1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(c),"indexed property"):(this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled)&&!u.every(t=>y.ClassBoundMethod.isInstanceOf(t))?this.valueReturnList(u):c}resolveClassCellContentPropertyPath(t,e,r,s){const i=d.MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),n=d.MultiArray.isInstanceOf(i)?i:d.MultiArray.scalarToMultiArray(this.expressionValue(i,"selection")),a=d.MultiArray.linearize(n),o=(t,e)=>{g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError("cell content property access requires class instance elements."),e&&this.context.pushRequestedOutputCount(1);try{const e=this.resolveClassFieldChain(t,r.fields,s);return r.tailDescriptors&&r.tailDescriptors.length>0?this.nativeSubsrefNativeDescriptors(e,r.tailDescriptors):e}finally{e&&this.context.popRequestedOutputCount()}};if(1===a.length)return o(a[0],!1);const l=new d.MultiArray(n.dimension);for(let t=0;t<a.length;t++){const[e,r]=d.MultiArray.linearIndexToMultiArrayRowColumn(l.dimension[0],l.dimension[1],t);l.array[e][r]=o(a[t],!0)}d.MultiArray.setType(l);const c=d.MultiArray.linearize(l);return this.context.requestedOutputCount>1||this.context.commaListExpansionEnabled?this.valueReturnList(c):l}selectedCellContentsAreClassInstances(t,e){this.context.pushRequestedOutputCount(1);try{const r=d.MultiArray.getElements(t,"",[],this.nativeDescriptorIndexList(e,t),this),s=d.MultiArray.isInstanceOf(r)?r:d.MultiArray.scalarToMultiArray(this.expressionValue(r,"selection"));return d.MultiArray.linearize(s).every(t=>g.ClassInstance.isInstanceOf(t))}finally{this.context.popRequestedOutputCount()}}assignClassInstancePropertyPath(t,e,r,s,i){if(!e.tailDescriptors||0===e.tailDescriptors.length)return this.assignNestedClassInstanceField(t,e.fields,r,s,i);const n=this.resolveClassFieldChain(t,e.fields,s),a=this.assignNativeSubsasgnNativeDescriptors(n,e.tailDescriptors,r);return this.assignNestedClassInstanceField(t,e.fields,a,s,i)}assignClassArrayPropertyPath(t,e,r,s,i,n){const a=d.MultiArray.copy(t),o=d.MultiArray.getElements(a,"",[],e),l=this.assignmentValues(o,"selection"),c=this.classPropertyPathAssignmentValues(s,l.length,r);1!==c.length&&c.length!==l.length&&this.context.throwEvalError(`assignment value count ${c.length} does not match selected object count ${l.length}.`);const u=d.MultiArray.isInstanceOf(o)?o:d.MultiArray.scalarToMultiArray(this.expressionValue(o,"selection")),h=new d.MultiArray(u.dimension);for(let t=0;t<l.length;t++){const e=l[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("object array indexed field assignment requires class instance elements.");const[s,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(h.dimension[0],h.dimension[1],t);h.array[s][a]=this.assignClassInstancePropertyPath(e,r,1===c.length?c[0]:c[t],i,n)}d.MultiArray.setType(h);const m=$.Scope.create();return m.defineName("__object_array_subsasgn__",a),d.MultiArray.setElements(m,"__object_array_subsasgn__",[],e,h,void 0,this),this.scopedMultiArrayValue(m,"__object_array_subsasgn__","object array assignment result")}assignClassCellContentPropertyPath(t,e,r,s,i,n){const a=d.MultiArray.copy(t),o=this.nativeDescriptorIndexList(e,a),l=d.MultiArray.getElements(a,"",[],o),c=d.MultiArray.isInstanceOf(l)?l:d.MultiArray.scalarToMultiArray(this.expressionValue(l,"selection")),u=d.MultiArray.linearize(c).map((t,e)=>this.expressionValue(t,`selection${e+1}`)),h=this.classPropertyPathAssignmentValues(s,u.length,r);1!==h.length&&h.length!==u.length&&this.context.throwEvalError(`assignment value count ${h.length} does not match selected object count ${u.length}.`);const m=new d.MultiArray(c.dimension);for(let t=0;t<u.length;t++){const e=u[t];g.ClassInstance.isInstanceOf(e)||this.context.throwEvalError("cell content property assignment requires class instance elements.");const[s,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(m.dimension[0],m.dimension[1],t);m.array[s][a]=this.assignClassInstancePropertyPath(e,r,1===h.length?h[0]:h[t],i,n)}d.MultiArray.setType(m);const p=1===u.length?this.expressionValue(d.MultiArray.MultiArrayToScalar(m),"cell object assignment value"):m,f=this.setNativeIndexedValue(a,e,p);return d.MultiArray.isInstanceOf(f)||this.context.throwEvalError("internal error: cell object assignment result is not an array."),f}assignClassSubsasgnDescriptors(t,e,r,s){const i=this.context.currentScope;if(d.MultiArray.isInstanceOf(t)&&t.isCell&&"{}"===e[0]?.type){const n=this.classPropertyDescriptorPath(e.slice(1),"subsasgn");if(n&&!n.leadingIndex&&this.selectedCellContentsAreClassInstances(t,e[0]))return this.assignClassCellContentPropertyPath(t,e[0],n,r,s,i)}if(d.MultiArray.isInstanceOf(t)&&t.isCell&&"()"===e[0]?.type&&"{}"===e[1]?.type){const n=this.nativeParenSubsrefResult(t,e[0]);if(d.MultiArray.isInstanceOf(n)&&n.isCell){const a=this.classPropertyDescriptorPath(e.slice(2),"subsasgn");if(a&&!a.leadingIndex&&this.selectedCellContentsAreClassInstances(n,e[1])){const o=this.assignClassCellContentPropertyPath(n,e[1],a,r,s,i);return this.setNativeIndexedValue(t,e[0],o)}}}const n=this.classPropertyDescriptorPath(e,"subsasgn");if(g.ClassInstance.isInstanceOf(t)){if(!n||n.leadingIndex)return;return this.assignClassInstancePropertyPath(g.ClassInstance.copy(t),n,r,s,i)}if(n&&d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){if(n.leadingIndex){const e=this.nativeDescriptorIndexList(n.leadingIndex,t);return this.assignClassArrayPropertyPath(t,e,n,r,s,i)}return this.assignClassArrayPropertyPath(t,[d.MultiArray.expandColon(d.MultiArray.linearLength(t))],n,r,s,i)}}resolveClassCellSubsrefDescriptors(t,e,r){if(!d.MultiArray.isInstanceOf(t)||!t.isCell||"{}"!==e[0]?.type){if(d.MultiArray.isInstanceOf(t)&&t.isCell&&"()"===e[0]?.type&&"{}"===e[1]?.type){const s=this.nativeParenSubsrefResult(t,e[0]);if(d.MultiArray.isInstanceOf(s)&&s.isCell){const t=this.classPropertyDescriptorPath(e.slice(2),"subsref");if(t&&!t.leadingIndex&&this.selectedCellContentsAreClassInstances(s,e[1]))return this.resolveClassCellContentPropertyPath(s,e[1],t,r)}}return}const s=this.classPropertyDescriptorPath(e.slice(1),"subsref");if(s&&!s.leadingIndex&&this.selectedCellContentsAreClassInstances(t,e[0]))return this.resolveClassCellContentPropertyPath(t,e[0],s,r)}subsrefResult(t,e){const r=this.subscriptDescriptorStructures(e,"subsref"),s=r.map(t=>this.readNativeSubscriptDescriptor(t,"subsref"));if(g.ClassInstance.isInstanceOf(t)){const e=this.callClassSubsrefDescriptors(t,r,c.AST.nodeIdentifier("subsref"));if(void 0!==e)return e;const i=this.resolveClassSubsrefDescriptors(t,s,c.AST.nodeIdentifier("subsref"));if(void 0!==i)return i}const i=this.publicObjectArraySubscriptTarget(t,r);if(i){const t=this.callClassSubsrefDescriptors(i,r,c.AST.nodeIdentifier("subsref"));if(void 0!==t)return t}const n=this.publicCellContentSubscriptSelection(t,r);if(n&&n.objectDescriptors.length>0){const t=this.callClassSubsrefDescriptors(n.instance,n.objectDescriptors,c.AST.nodeIdentifier("subsref"));if(void 0!==t)return t}const a=this.resolveClassSubsrefDescriptors(t,s,c.AST.nodeIdentifier("subsref"));if(void 0!==a)return a;const o=this.resolveClassCellSubsrefDescriptors(t,s,c.AST.nodeIdentifier("subsref"));return void 0!==o?o:this.nativeSubsrefDescriptors(t,r)}subsasgnResult(t,e,r){const s=this.subscriptDescriptorStructures(e,"subsasgn"),i=s.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn"));if(g.ClassInstance.isInstanceOf(t)){const e=this.callClassSubsasgnDescriptors(t,s,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==e)return e;const n=this.assignClassSubsasgnDescriptors(t,i,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==n)return n}const n=this.publicObjectArraySubscriptTarget(t,s);if(n){const e=this.callClassSubsasgnDescriptors(n,s,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==e)return d.MultiArray.isInstanceOf(t)||this.context.throwEvalError("internal error: object-array subsasgn target is not an array."),this.setNativeIndexedValue(t,this.readNativeSubscriptDescriptor(s[0]),e)}const a=this.publicCellContentSubscriptSelection(t,s);if(a&&a.objectDescriptors.length>0){const e=this.callClassSubsasgnDescriptors(a.instance,a.objectDescriptors,r,c.AST.nodeIdentifier("subsasgn"));if(void 0!==e){if(d.MultiArray.isInstanceOf(t)||this.context.throwEvalError("internal error: cell-object subsasgn target is not an array."),a.outerDescriptor&&a.selectedCell){const r=this.setNativeIndexedValue(a.selectedCell,a.contentDescriptor,e);return d.MultiArray.isInstanceOf(r)&&r.isCell||this.context.throwEvalError("internal error: selected cell-object subsasgn result is not a cell array."),this.setNativeIndexedValue(t,a.outerDescriptor,r)}return this.setNativeIndexedValue(t,a.contentDescriptor,e)}}const o=this.assignClassSubsasgnDescriptors(t,i,r,c.AST.nodeIdentifier("subsasgn"));return void 0!==o?o:this.assignNativeSubsasgnDescriptors(t,s,r)}nativeDescriptorIndexList(t,e){return t.subs.map((r,s)=>{if(u.CharString.isInstanceOf(r)&&":"===r.str)return 1===t.subs.length?d.MultiArray.expandColon(d.MultiArray.linearLength(e)):d.MultiArray.expandColon(d.MultiArray.getDimension(e,s));const i=this.convertIndexArgument(r,c.AST.nodeIdentifier("subsindex"));return d.MultiArray.isIndexArgument(i)||this.context.throwEvalError(`subscript${s+1}: invalid subscript type.`),i})}nativeSubscriptScalar(t,e){if("."===e.type){const r=e.subs[0];return u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),this.expressionValue(m.Structure.getField(t,[r.str]),`field ${r.str}`)}if(u.CharString.isInstanceOf(t)){"{}"===e.type&&this.context.throwEvalError("matrix cannot be indexed with {");const r=d.MultiArray.characterVectorFromCharString(t),s=d.MultiArray.getElements(r,"",[],this.nativeDescriptorIndexList(e,r),this);return d.MultiArray.charStringFromCharacterVectorResult(s,t.quote)}d.MultiArray.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${e.type[0]}`),"{}"!==e.type||t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const r=this.nativeDescriptorIndexList(e,t),s=d.MultiArray.getElements(t,"",[],r,this);return"()"===e.type&&t.isCell?(d.MultiArray.isInstanceOf(s)||this.context.throwEvalError("internal error: cell parenthesis indexing did not produce a cell array."),s.isCell=!0,s):this.expressionValue(d.MultiArray.MultiArrayToScalar(s),"indexed value")}setNativeIndexedValue(t,e,r){if(u.CharString.isInstanceOf(t)){"{}"===e.type&&this.context.throwEvalError("matrix cannot be indexed with {");const s=d.MultiArray.characterVectorFromCharString(t),i=$.Scope.create();return i.defineName("__subsasgn__",s),d.MultiArray.setElements(i,"__subsasgn__",[],this.nativeDescriptorIndexList(e,s),this.charStringAssignmentRhs(r,t.quote),void 0,this),d.MultiArray.charStringFromCharacterVectorResult(this.scopedExpressionValue(i,"__subsasgn__","character assignment result"),t.quote)}"{}"!==e.type||t.isCell||this.context.throwEvalError("matrix cannot be indexed with {");const s=d.MultiArray.copy(t);let i=this.indexedAssignmentRhs(e.type,r,s);if("{}"===e.type&&d.MultiArray.isInstanceOf(r)&&!r.isCell)try{const t=d.MultiArray.linearize(d.MultiArray.getElements(s,"",[],this.nativeDescriptorIndexList(e,s),this)).length;t>1&&t===d.MultiArray.linearLength(r)&&(i=d.MultiArray.firstRow(d.MultiArray.linearize(r),!0))}catch{i=this.indexedAssignmentRhs(e.type,r,s)}const n=$.Scope.create();return n.defineName("__subsasgn__",s),d.MultiArray.setElements(n,"__subsasgn__",[],this.nativeDescriptorIndexList(e,s),i,void 0,this),this.scopedMultiArrayValue(n,"__subsasgn__","indexed assignment result")}blankNativeSubsasgnValue(t){return t&&"."!==t.type?"()"===t.type&&1===t.subs.length?new d.MultiArray([1,0],void 0,!1):"{}"===t.type&&1===t.subs.length?new d.MultiArray([1,0],void 0,!0):d.MultiArray.emptyArray("{}"===t.type):new m.Structure({})}nativeSubscriptScalarForAssignment(t,e,r){try{return this.nativeSubscriptScalar(t,e)}catch(e){if(d.MultiArray.isInstanceOf(t))return this.blankNativeSubsasgnValue(r);throw e}}assignNativeSubsasgnNativeDescriptors(t,e,r){if(0===e.length)return r;const s=(t,e,r)=>1===e||r&&d.MultiArray.isInstanceOf(t)&&d.MultiArray.isEmpty(t)?[this.expressionValue(t,"assignment")]:this.assignmentValues(t,"assignment"),i=(t,n,a=r)=>{const o=e[n];if(!o)return a;if("."===o.type){const r=o.subs[0];u.CharString.isInstanceOf(r)||this.context.throwEvalError("invalid subsasgn descriptor."),d.MultiArray.isEmpty(t)&&(t=new m.Structure({})),m.Structure.isInstanceOf(t)||m.Structure.isStructure(t)||this.context.throwEvalError("value cannot be indexed with .");const l=m.Structure.isInstanceOf(t)?m.Structure.copy(t):d.MultiArray.isInstanceOf(t)?d.MultiArray.copy(t):void 0;l||this.context.throwEvalError("value cannot be indexed with .");const c=m.Structure.structureElements(l);if(c.length>1&&n<e.length-1){const t=s(a,c.length,!0);return 1!==t.length&&t.length!==c.length&&this.context.throwEvalError(`assignment value count ${t.length} does not match selected structure count ${c.length}.`),c.forEach((s,a)=>{let o;try{o=this.expressionValue(m.Structure.getField(s,[r.str]),`field ${r.str}`)}catch{o=this.blankNativeSubsasgnValue(e[n+1])}const l=i(o,n+1,1===t.length?t[0]:t[a]);m.Structure.setNewField(s,[r.str],this.runtimeExpressionValue(l,`field ${r.str}`))}),l}let h;try{h=this.expressionValue(m.Structure.getField(l,[r.str]),`field ${r.str}`)}catch{h=this.blankNativeSubsasgnValue(e[n+1])}const p=n===e.length-1?a:i(h,n+1,a);return m.Structure.setNewField(l,[r.str],this.runtimeExpressionValue(p,`field ${r.str}`)),l}d.MultiArray.isInstanceOf(t)||u.CharString.isInstanceOf(t)||this.context.throwEvalError(`matrix cannot be indexed with ${o.type[0]}`);const l=n===e.length-1?a:i(this.nativeSubscriptScalarForAssignment(t,o,e[n+1]),n+1,a);return this.setNativeIndexedValue(t,o,l)};return i(t,0)}assignNativeSubsasgnDescriptors(t,e,r){return this.assignNativeSubsasgnNativeDescriptors(t,e.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn")),r)}shouldUseNativeChainedSubsasgn(t){if(t.length>2)return!0;if(t.length<2)return!1;const[e,r]=t.map(t=>this.readNativeSubscriptDescriptor(t).type);return!("()"===e&&"."===r)}callClassSubsasgn(t,e,r,s,i,n){const a=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!a)return;this.context.canAccessClassMember(a.classDefinition,a.access)||this.context.throwEvalError(`method 'subsasgn' has ${a.access} access for class ${t.classDefinition.name}.`);const o=this.createSubsasgnDescriptor(e,r,i,n);return this.classSubsasgnResult(t,a,this.classMethodArgumentValues([o,s],"subsasgn"),i)}callClassSubsasgnDescriptors(t,e,r,s){const i=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!i)return;this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'subsasgn' has ${i.access} access for class ${t.classDefinition.name}.`);const n=this.createSubscriptDescriptorArray(e);return this.classSubsasgnResult(t,i,this.classMethodArgumentValues([n,r],"subsasgn"),s)}createSubsasgnDescriptor(t,e,r,s){return this.createSubscriptDescriptor(e,t,r,s)}callClassDotSubsasgn(t,e,r,s,i){const n=t.classDefinition.findMethod("subsasgn",t=>!t.isStatic);if(!n)return;this.context.canAccessClassMember(n.classDefinition,n.access)||this.context.throwEvalError(`method 'subsasgn' has ${n.access} access for class ${t.classDefinition.name}.`);const a=this.createDotSubscriptDescriptor(e,s,i);return this.classSubsasgnResult(t,n,this.classMethodArgumentValues([a,r],"subsasgn"),s)}callClassEnd(t,e,r,s){const i=t.classDefinition.findMethod("end",t=>!t.isStatic);if(i)return this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method 'end' has ${i.access} access for class ${t.classDefinition.name}.`),this.reducedClassMethodResult(t,i,this.classMethodArgumentValues([h.Complex.create(e),h.Complex.create(r)],"end"),s)}callClassSubsindex(t,e){const r=t.classDefinition.findMethod("subsindex",t=>!t.isStatic);return r||this.context.throwEvalError(`object of class ${t.classDefinition.name} cannot be used as an index without a subsindex method.`),this.context.canAccessClassMember(r.classDefinition,r.access)||this.context.throwEvalError(`method 'subsindex' has ${r.access} access for class ${t.classDefinition.name}.`),this.reducedClassMethodResultWithOutputCount(t,r,[],e,1)}zeroBasedSubsindexValue(t,e,r){const s=(t,e)=>{const r=this.expressionValue(t,e);h.Complex.isInstanceOf(r)&&h.Complex.imagIsZero(r)||this.context.throwEvalError("subsindex must return zero-based real integer indices.");const s=h.Complex.realToNumber(r);return(!Number.isInteger(s)||s<0)&&this.context.throwEvalError("subsindex must return zero-based real integer indices."),h.Complex.create(s+1)},i=this.expressionValue(t,r);if(d.MultiArray.isInstanceOf(i)){const t=new d.MultiArray(i.dimension,void 0,!1);for(let e=0;e<d.MultiArray.linearLength(i);e++){const[n,a]=d.MultiArray.linearIndexToMultiArrayRowColumn(i.dimension[0],i.dimension[1],e);t.array[n][a]=s(this.expressionValue(i.array[n][a],`${r}${e+1}`),`${r}${e+1}`)}return d.MultiArray.setType(t),t.parent=e,t}return s(i,r)}convertIndexArgument(t,e){if(g.ClassInstance.isInstanceOf(t))return this.zeroBasedSubsindexValue(this.callClassSubsindex(t,e),e,"subsindex");if(d.MultiArray.isInstanceOf(t)&&this.hasClassInstanceElement(t)){const r=new d.MultiArray(t.dimension,void 0,!1);for(let s=0;s<d.MultiArray.linearLength(t);s++){const[i,n]=d.MultiArray.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],s),a=t.array[i][n];g.ClassInstance.isInstanceOf(a)||this.context.throwEvalError("object index arrays must contain class instance elements.");const o=this.zeroBasedSubsindexValue(this.callClassSubsindex(a,e),e,`subsindex${s+1}`);h.Complex.isInstanceOf(o)||this.context.throwEvalError("subsindex for object index arrays must return scalar indices."),r.array[i][n]=o}return d.MultiArray.setType(r),r.parent=e,r}return t}solveUndefined(t,e=this.context.currentScope,r=[]){if(this.context.allowForwardReference){const s=r.indexOf(t);s>=0&&this.context.throwCircularReferenceError([...r.slice(s),t]);const i=e.undefinedReferenceTable[t];if(void 0!==i){const s=[...i].filter(t=>t),n=new Set,a=[];s.forEach(t=>{if(void 0!==e.nameTable[t])try{e.nameTable[t].node=this.evaluatedExecutionResult(e.nameTable[t].node,e),delete e.nameTable[t].undefinedReference,a.push(t)}catch(r){r instanceof z.UndefinedReferenceError?(n.add(r.identifier),e.nameTable[t].undefinedReference=r.identifier):n.add(t)}}),e.undefinedReferenceTable[t]=n,a.forEach(s=>this.solveUndefined(s,e,[...r,t]))}}}isLocalUndefinedReference(t){if(!(t instanceof z.UndefinedReferenceError))return!1;const e=this.context.callStack.filter(t=>void 0!==t.func),r=e[e.length-1];return t.stackFrames?.[0]===r}registerFunctionDefinition(t,e,r){this.validateFunctionSignature(t),this.validateDeclarationPlacement(t),r?t.attributes={...t.attributes??{},nested:!0}:t.attributes?.nested&&(t.attributes={...t.attributes},delete t.attributes.nested),this.validateFunctionArgumentsBlocks(t),e.defineFunction(t.id,t),t.definingScope=r?e:e.capture(t=>T.MathOperation.copy(t),this.context.allowForwardReference)}isNodeInsideExecutableBlock(t){const e=t.parent,r=e?.parent;return c.AST.isNodeBase(r)&&("IF"===r.type||"SWITCH"===r.type||"CASE"===r.type||"WHILE"===r.type||"DO_UNTIL"===r.type||"FOR"===r.type||"SPMD"===r.type||"TRY"===r.type||"UNWIND_PROTECT"===r.type)}validateDeclarationPlacement(t){const e=(t,r)=>{if(t)if(c.AST.isNodeList(t))t.list.forEach(t=>e(t,r));else{if(c.AST.isNodeFunctionDefinition(t))return this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError(`function definition '${t.id}' is not allowed inside a control block.`),e(t.arguments,!0),void e(t.statements,!0);if(c.AST.isNodeClassDef(t))return this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError(`class definition '${t.id}' is not allowed inside a control block.`),r&&this.context.throwSyntaxError(`class definition '${t.id}' is not allowed inside a function.`),void t.sections.forEach(t=>e(t,r));switch(c.AST.isNodeImport(t)&&t.imports.length>0&&this.isNodeInsideExecutableBlock(t)&&this.context.throwSyntaxError("import declaration is not allowed inside a control block."),"PERSIST"!==t.type||r||this.context.throwSyntaxError("persistent declaration is only valid inside a function."),t.type){case"IF":t.then.forEach(t=>e(t,r)),e(t.else,r);break;case"SWITCH":t.cases.forEach(t=>e(t,r)),e(t.otherwise,r);break;case"CASE":e(t.then,r);break;case"WHILE":case"DO_UNTIL":case"FOR":case"SPMD":e(t.body,r);break;case"TRY":e(t.body,r),e(t.catchBody,r);break;case"UNWIND_PROTECT":e(t.body,r),e(t.cleanup,r);break;case"CLASS_SECTION":e(t.members,r)}}};e(t,!1)}preregisterScriptLocalFunctions(t,e){if(null!==t.parent)return;if("FCNDEF"===this.context.currentFrame?.func?.type)return;const r=this.scriptSourceNameStack[this.scriptSourceNameStack.length-1];for(const s of t.list)c.AST.isNodeFunctionDefinition(s)&&e.functionTable[s.id]!==s&&(s.sourceName=r,this.registerFunctionDefinition(s,e,!1))}getArgumentValidationName(t){return R.FunctionArguments.validationName(t,t=>this.context.throwSyntaxError(t))}getNameValueArgumentTarget(t){return R.FunctionArguments.nameValueTarget(t,t=>this.context.throwSyntaxError(t))}getArgumentValidationDisplayName(t){return R.FunctionArguments.validationDisplayName(t,t=>this.context.throwSyntaxError(t))}validateFunctionArgumentsBlocks(t){R.FunctionArguments.validateBlocks(t,t=>this.context.throwSyntaxError(t))}validateFunctionSignatureList(t,e,r,s,i){const n=new Set;t.forEach((a,o)=>{if(e(a)||this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),c.AST.isNodeIgnoredTarget(a))return;let l;c.AST.isNodeDefaultedParameter(a)?("parameter"===s&&"anonymous function"!==i||this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),l=a.left.id):c.AST.isNodeIdentifier(a)?l=a.id:this.context.throwSyntaxError(`invalid ${s} list in ${i}.`),n.has(l)&&this.context.throwSyntaxError(`duplicate ${s} name '${l}' in ${i}.`),n.add(l),l===r&&o!==t.length-1&&this.context.throwSyntaxError(`${r} must be the last ${s} in ${i}.`),"="===a.type&&l===r&&this.context.throwSyntaxError(`${r} default value is not supported in ${i}.`)})}validateFunctionSignature(t){const e=`function ${t.id}`;this.validateFunctionSignatureList(t.parameter.list,c.AST.isNodeFunctionParameter,"varargin","parameter",e),this.validateFunctionSignatureList(t.return.list,c.AST.isNodeFunctionReturn,"varargout","return",e),this.validateFunctionDeclarations(t,e)}validateAnonymousFunctionSignature(t){this.validateFunctionSignatureList(t.parameter,c.AST.isNodeFunctionParameter,"varargin","parameter","anonymous function")}declarationName(t,e){const r=c.AST.getDeclarationNode(t);return c.AST.isNodeIdentifier(r)?r.id:c.AST.isNodeDefaultedParameter(r)?r.left.id:void this.context.throwSyntaxError(`invalid ${e} declaration.`)}signatureNameSet(t){const e=new Set;return t.forEach(t=>{c.AST.isNodeDefaultedParameter(t)?e.add(t.left.id):c.AST.isNodeIdentifier(t)&&e.add(t.id)}),e}collectIdentifierReferences(t,e){t&&"object"==typeof t&&(c.AST.isNodeIdentifier(t)?e.add(t.id):c.AST.isNodeFunctionDefinition(t)||c.AST.isNodeClassDef(t)||t instanceof u.CharString||t instanceof h.Complex||t instanceof p.FunctionHandle||(d.MultiArray.isInstanceOf(t)?d.MultiArray.linearize(t).forEach(t=>this.collectIdentifierReferences(t,e)):m.Structure.isInstanceOf(t)?Object.values(t.field).forEach(t=>this.collectIdentifierReferences(t,e)):Object.entries(t).forEach(([t,r])=>{"parent"!==t&&this.collectIdentifierReferences(r,e)})))}validateFunctionDeclarations(t,e){const r=this.signatureNameSet(t.parameter.list),s=this.signatureNameSet(t.return.list),i=new Set,n=new Set,a=new Set,o=t=>{t.list.forEach(o=>{const l=this.declarationName(o,"PERSIST"===t.type?"persistent":"global"),c="PERSIST"===t.type?"persistent":"global",u="PERSIST"===t.type?n:a;(r.has(l)||s.has(l))&&this.context.throwSyntaxError(`can't make function parameter ${l} ${c}.`),!u.has(l)&&i.has(l)&&this.context.throwSyntaxError(`${c} declaration '${l}' must appear before any use in ${e}.`),u.add(l)})},l=t=>{if(c.AST.isNodeDeclaration(t))return o(t),void this.collectIdentifierReferences(t,i);switch(t.type){case"IF":return t.expression.forEach(t=>this.collectIdentifierReferences(t,i)),t.then.forEach(u),void(t.else&&u(t.else));case"SWITCH":return this.collectIdentifierReferences(t.expression,i),t.cases.forEach(t=>{this.collectIdentifierReferences(t.expression,i),u(t.then)}),void(t.otherwise&&u(t.otherwise));case"WHILE":return this.collectIdentifierReferences(t.expression,i),void u(t.body);case"DO_UNTIL":return u(t.body),void this.collectIdentifierReferences(t.expression,i);case"FOR":return this.collectIdentifierReferences(t.target,i),this.collectIdentifierReferences(t.expression,i),this.collectIdentifierReferences(t.workers,i),void u(t.body);case"SPMD":return this.collectIdentifierReferences(t.workers,i),void u(t.body);case"TRY":return u(t.body),this.collectIdentifierReferences(t.catchIdentifier,i),void(t.catchBody&&u(t.catchBody));case"UNWIND_PROTECT":return u(t.body),void u(t.cleanup);case"FCNDEF":case"CLASSDEF":return;default:this.collectIdentifierReferences(t,i)}},u=t=>{t.list.forEach(t=>{l(t)})};u(t.statements)}getValueClassName(t){if(d.MultiArray.isInstanceOf(t)&&!t.isCell){const e=d.MultiArray.linearize(t);if(e.length>0){const t=this.objectArrayClassName(e);if(t)return t}}return O.FunctionValidation.className(t)}objectArrayClassName(t){const e=t.map(t=>g.ClassInstance.isInstanceOf(t)||E.ClassEnumerationValue.isInstanceOf(t)?t.classDefinition.name:v.ClassMetaObject.isInstanceOf(t)?t.kind:void 0);if(!e.every(t=>void 0!==t))return;const r=e[0];return e.every(t=>t===r)?r:void 0}getArgumentValidationEntry(t,e,r){const s=this.getNameValueArgumentTarget(t);if(!s){const s=this.getArgumentValidationName(t);return r?e.nameTable[s]:e.resolveName(s)}const i=r?e.nameTable[s.parameter]:e.resolveName(s.parameter);if(i&&void 0!==i.node)try{return{node:m.Structure.getField(i.node,[s.field])}}catch{return}}validateArgumentValidation(t,e,r,s=!1,i=this.getArgumentValidationDisplayName(t)){R.FunctionArguments.validateArgumentValidation(t,r,{resolveEntry:(t,r)=>this.getArgumentValidationEntry(t,e,r),evaluate:t=>this.evaluatedExpressionValue(t,e,"argument validation expression"),matchesClass:(t,r)=>this.valueMatchesValidationClass(t,r,e),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},s,i)}classPropertyValidationNode(t){return{type:"ARGVALID",name:t.node.name,size:t.size,class:t.class,functions:t.functions,default:t.defaultValue,omitAnswer:!0,omitOutput:!0}}validateClassPropertyValue(t,e,r,s=!1){const i=this.classPropertyValidationNode(t),n=$.Scope.create(r);n.defineName(t.name,e),R.FunctionArguments.validateArgumentValidation(i,new Map,{resolveEntry:()=>({node:e}),evaluate:t=>this.evaluatedExpressionValue(t,n,"property validation expression"),matchesClass:(t,e)=>this.valueMatchesValidationClass(t,e,n,s),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},!1,t.name,"property")}validateClassInstancePropertyDefaults(t,e){for(const r of t.classDefinition.allProperties())!r.isDependent&&g.ClassInstance.hasProperty(t,r.name)&&this.validateClassPropertyValue(r,g.ClassInstance.getProperty(t,r.name),e,!0)}validateFunctionArguments(t,e,r,s,i=!1){R.FunctionArguments.validateFunctionArguments(t,r,{resolveEntry:(t,r)=>this.getArgumentValidationEntry(t,e,r),evaluate:t=>this.evaluatedExpressionValue(t,e,"argument validation expression"),matchesClass:(t,r)=>this.valueMatchesValidationClass(t,r,e),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t)},s,i)}validateFunctionInputArguments(t,e){this.validateFunctionArguments(t,e,"Input")}validateFunctionRepeatingArguments(t,e,r){R.FunctionArguments.validateRepeatingArguments(t,r,{evaluate:t=>this.evaluatedExpressionValue(t,e,"repeating argument validation expression"),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t),validateRepeatingValue:(t,r,s,i,n)=>{const a=$.Scope.create(e);a.defineName(r,s),this.validateArgumentValidation(t,a,n,!0,i)}})}getFunctionNameValueParameters(t){return R.FunctionArguments.nameValueParameters(t,t=>this.context.throwSyntaxError(t))}getFunctionNameValueDeclarations(t){return R.FunctionArguments.nameValueDeclarations(t,t=>this.context.throwSyntaxError(t))}splitFunctionCallNameValueArguments(t,e){return R.FunctionArguments.splitCallNameValueArguments(t,e,t=>this.context.throwEvalError(t),t=>this.context.throwSyntaxError(t))}bindFunctionNameValueArguments(t,e,r){const s=this.getFunctionNameValueDeclarations(t);for(const[t,i]of s){const s=new m.Structure({});for(const[r,n]of i)if(n.default){this.context.pushRequestedOutputCount(1);try{m.Structure.setNewField(s,[r],this.runtimeExpressionValue(this.evaluatedExpressionValue(n.default,e,`name-value default ${t}.${r}`),`name-value default ${t}.${r}`))}finally{this.context.popRequestedOutputCount()}}for(const[t,e]of r)i.has(t)&&m.Structure.setNewField(s,[t],this.runtimeExpressionValue(e,`name-value argument ${t}`));e.defineName(t,s)}}registerNestedFunctions(t,e){for(const r of t.statements.list){if(!c.AST.isNodeFunctionDefinition(r))continue;const s={...r,attributes:{...r.attributes??{},nested:!0}};this.validateFunctionSignature(s),this.validateFunctionArgumentsBlocks(s),s.definingScope=e,s.sourceName=t.sourceName,e.defineFunction(s.id,s)}}configureFunctionWorkspace(t,e){(t.attributes?.nested||this.functionContainsNestedDefinitions(t))&&e.allowStaticWorkspaceNames(this.staticWorkspaceTextNames(t))}functionContainsNestedDefinitions(t){return t.statements.list.some(c.AST.isNodeFunctionDefinition)}staticWorkspaceTextNames(t){const e=new Set,r=t=>{for(const r of t)c.AST.isNodeIdentifier(r)?e.add(r.id):c.AST.isNodeDefaultedParameter(r)&&e.add(r.left.id)};return r(t.parameter.list),r(t.return.list),this.collectStaticWorkspaceTextNames(t.statements,e),e}collectStaticWorkspaceTextNames(t,e){if(!c.AST.isNodeFunctionDefinition(t)){if(c.AST.isNodeIdentifier(t))e.add(t.id);else if(c.AST.isNodeDeclaration(t))for(const r of t.list)c.AST.isNodeIdentifier(r)?e.add(r.id):c.AST.isNodeDefaultedParameter(r)&&e.add(r.left.id);else c.AST.isNodeBinaryOperation(t)&&W.assignmentOperatorNames.has(t.type)&&this.collectStaticAssignmentTargetNames(t.left,e);if(t&&"object"==typeof t)for(const[r,s]of Object.entries(t))if("parent"!==r&&"start"!==r&&"stop"!==r)if(Array.isArray(s))for(const t of s)t&&"object"==typeof t&&this.collectStaticWorkspaceTextNames(t,e);else s&&"object"==typeof s&&this.collectStaticWorkspaceTextNames(s,e)}}collectStaticAssignmentTargetNames(t,e){if(c.AST.isNodeIdentifier(t))e.add(t.id);else if(!c.AST.isNodeIgnoredTarget(t))if(c.AST.isNodeIndexExpr(t))this.collectStaticAssignmentTargetNames(t.expr,e);else if(c.AST.isNodeIndirectRef(t))this.collectStaticAssignmentTargetNames(t.obj,e);else if(d.MultiArray.isInstanceOf(t))for(const r of d.MultiArray.linearize(t))this.collectStaticAssignmentTargetNames(r,e)}applyScopedImports(t,e){const r=c.AST.isNodeList(t)?t.list:[t];for(const t of r)if(c.AST.isNodeImport(t))for(const r of t.imports)this.context.defineImport(r.id,e)}validateFunctionOutputArguments(t,e,r,s=[]){const i=R.FunctionArguments.outputNamesToValidate(t,r,s);i&&this.validateFunctionArguments(t,e,"Output",i,!0);const n=R.FunctionArguments.outputRepeatingInfo(t,t=>this.context.throwSyntaxError(t));if(!n)return;const a=Math.max(r-n.fixedReturnCount,0);if(0===a)return;const o=e.nameTable[n.name];o&&o.node instanceof d.MultiArray&&o.node.isCell||this.context.throwEvalError(`Undefined return variable '${n.name}'`);const l=d.MultiArray.linearize(o.node).slice(0,a).map((t,e)=>(s[n.fixedReturnCount+e]??1)&&void 0!==t?{value:this.expressionValue(t,`${n.name}{${e+1}}`),index:e+1}:void 0).filter(t=>void 0!==t);R.FunctionArguments.validateRepeatingOutputArguments(t,l,{evaluate:t=>this.evaluatedExpressionValue(t,e,"repeating output validation expression"),...this.pathValidationCallbacks,throwEvalError:t=>this.context.throwEvalError(t),throwSyntaxError:t=>this.context.throwSyntaxError(t),validateRepeatingValue:(t,r,s,i,n)=>{const a=$.Scope.create(e);a.defineName(r,s),this.validateArgumentValidation(t,a,n,!0,i)}})}getFunctionInputArgumentDefaults(t){return R.FunctionArguments.inputArgumentDefaults(t,t=>this.context.throwSyntaxError(t))}getFunctionOutputRepeatingName(t){return R.FunctionArguments.outputRepeatingName(t,t=>this.context.throwSyntaxError(t))}Evaluator(t,e=this.context.currentScope){if(this._debug&&console.log(`Interpreter(\ntree:${JSON.stringify(t,(t,e)=>"parent"!==t?e:null!==e||"root",2)},\n);`),!t)return null;if(p.FunctionHandle.isInstanceOf(t)){const r=t.id&&!t.closure?this.resolveRuntimeFunction(t.id,e,{loadFunctions:!1}):void 0,s=!t.id||t.closure||r?.functionDefinition?void 0:this.lookupFunctionSourceResolution(t.id,e);if(r?.functionDefinition){const s=p.FunctionHandle.copy(t);return s.id=t.id.includes(".")?r.resolvedName:this.context.aliasNameFunction(t.id),"FCNDEF"===r.functionDefinition.type&&(s.closure=e.capture(t=>T.MathOperation.copy(t),this.context.allowForwardReference)),s}if(s){const r=p.FunctionHandle.copy(t);return r.id=t.id.includes(".")?s.resolvedName:this.context.aliasNameFunction(t.id),r.sourceName=s.sourceName,"import"===s.source&&(r.closure=e.capture(t=>T.MathOperation.copy(t),this.context.allowForwardReference)),r}if(t.id&&!t.closure&&this.resolveImportedStaticMethod(t.id,e)){const r=p.FunctionHandle.copy(t);return r.closure=e.capture(t=>T.MathOperation.copy(t),this.context.allowForwardReference),r}if(!t.id&&!t.closure){this.validateAnonymousFunctionSignature(t);const r=p.FunctionHandle.copy(t);return r.closure=e.snapshot(t=>T.MathOperation.copy(t)),r.sourceName=this.currentHandleSourceName(),r.className=this.currentHandleClassName(),r}return t}if(h.Complex.isInstanceOf(t)||u.CharString.isInstanceOf(t)||m.Structure.isInstanceOf(t)||f.ClassDefinition.isInstanceOf(t)||g.ClassInstance.isInstanceOf(t)||y.ClassBoundMethod.isInstanceOf(t)||x.ClassStaticMethod.isInstanceOf(t)||C.ClassEmptyMethod.isInstanceOf(t)||E.ClassEnumerationValue.isInstanceOf(t)||A.ClassEventListener.isInstanceOf(t)||_.ClassEventData.isInstanceOf(t)||S.ClassPropertyEvent.isInstanceOf(t)||v.ClassMetaObject.isInstanceOf(t))return t;if(d.MultiArray.isInstanceOf(t))return d.MultiArray.evaluate(t,this,e);switch(t.type){case"VOID":return t;case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":return this.evaluateBinaryOperation(this.requireBinaryOperation(t),e);case"&&":case"||":return this.evaluateShortCircuitOperation(this.requireBinaryOperation(t),e);case"()":return this.evaluatedExpressionValue(this.requirePrefixOperation(t).right,e,"parenthesized expression");case"!":case"~":case"+_":case"-_":return this.evaluateUnaryOperation(this.requirePrefixOperation(t),e);case"++_":case"--_":return this.opTable[t.type](this.requirePrefixOperation(t).right,e);case".'":case"'":return this.evaluateUnaryOperation(this.requirePostfixOperation(t),e);case"_++":case"_--":return this.opTable[t.type](this.requirePostfixOperation(t).left,e);case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const r=this.requireBinaryOperation(t),s=this.validateAssignment(r.left,!0,e),i=r.type,n=i.substring(0,i.length-1);let a,o,l;s.length>1&&n.length>0&&this.context.throwEvalError("computed multiple assignment not allowed."),this.context.pushForwardReferenceTargets(s.map(({id:t})=>t).filter(t=>"~"!==t)),this.context.pushRequestedOutputCount(s.length),this.context.pushRequestedOutputMask(s.map(({id:t})=>"~"!==t));try{a=c.AST.isNodeReturnList(r.right)?r.right:T.MathOperation.copy(this.Evaluator(r.right,e))}catch(t){if(!this.context.allowForwardReference)throw t;if(!this.isLocalUndefinedReference(t))throw t;l=t,a=T.MathOperation.copy(r.right),o=t.identifier}finally{this.context.popRequestedOutputMask(),this.context.popRequestedOutputCount(),this.context.popForwardReferenceTargets()}const h=c.AST.ensureReturnList(a),f=c.AST.nodeListFirst(),y=h.handler(s.length),x=t=>{const e=h.selector(y,t);return void 0===e&&c.AST.throwErrorIfGreaterThanReturnList(t,t+1,t=>this.context.throwEvalError(t)),e};for(let i=0;i<s.length;i++){const{id:a,index:h,delimiter:y,field:C,descriptors:E}=s[i];if("~"!==a){if(E&&E.length>0&&!n){const r=e.resolveName(a),s=this.evaluatedExpressionValue(x(i),e,"assignment value");if(r&&g.ClassInstance.isInstanceOf(r.node)&&!this.context.canAccessClassMember(r.node.classDefinition,"private")){const e=this.callClassSubsasgnDescriptors(r.node,E,s,t);if(e){r.node=e,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(r&&(g.ClassInstance.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node))){const e=this.assignClassSubsasgnDescriptors(r.node,E.map(t=>this.readNativeSubscriptDescriptor(t,"subsasgn")),s,t);if(void 0!==e){r.node=e,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(!r&&this.shouldUseNativeChainedSubsasgn(E)){const t=this.readNativeSubscriptDescriptor(E[0]),r=this.blankNativeSubsasgnValue(t),i=this.assignNativeSubsasgnDescriptors(r,E,s),n=e.defineName(a,i);c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),n.node));continue}if(r&&this.shouldUseNativeChainedSubsasgn(E)&&(d.MultiArray.isInstanceOf(r.node)||m.Structure.isInstanceOf(r.node)||m.Structure.isStructure(r.node))&&(!d.MultiArray.isInstanceOf(r.node)||!this.hasClassInstanceElement(r.node))){r.node=this.assignNativeSubsasgnDescriptors(r.node,E,s),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)));continue}}if(E&&E.length>0&&n){const t=e.resolveName(a);if(t||this.context.throwEvalError(`in computed assignment ${a} OP= X, ${a} must be defined first.`),this.shouldUseNativeChainedSubsasgn(E)&&(d.MultiArray.isInstanceOf(t.node)||m.Structure.isInstanceOf(t.node)||m.Structure.isStructure(t.node))&&(!d.MultiArray.isInstanceOf(t.node)||!this.hasClassInstanceElement(t.node))){const r=this.nativeSubsrefDescriptors(t.node,E),s=this.evaluatedExpressionValue(c.AST.nodeOperation(n,this.compoundAssignmentOperand(r,"compound assignment target value"),this.evaluatedExpressionValue(x(i),e,"assignment value")),e,"compound assignment value");t.node=this.assignNativeSubsasgnDescriptors(t.node,E,s),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(t.node)));continue}}if(h)if(n){const t=e.resolveName(a);if(void 0!==t){if(!p.FunctionHandle.isInstanceOf(t.node)){const s=this.evaluatedIndexArguments(h,e);if(C.length>0&&c.AST.isNodeIndexExpr(r.left)&&c.AST.isNodeIndirectRef(r.left.expr)&&(m.Structure.isInstanceOf(t.node)||d.MultiArray.isInstanceOf(t.node)&&m.Structure.isStructure(t.node))){const r=m.Structure.getField(t.node,C);if(d.MultiArray.isInstanceOf(r)&&!d.MultiArray.isEmpty(r)){const o=this.evaluatedExpressionValue(c.AST.nodeOperation(n,d.MultiArray.getElements(r,"__field_assignment__",[],s,this),d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(x(i),e,"assignment value"))),e,"compound field assignment value"),l=$.Scope.create();l.defineName("__field_assignment__",r),d.MultiArray.setElements(l,"__field_assignment__",[],s,this.indexedAssignmentRhs(y,o,r),void 0,this),m.Structure.setNewField(t.node,C,this.runtimeExpressionValue(this.scopedExpressionValue(l,"__field_assignment__","field assignment result"),"field assignment result")),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(t.node)));continue}}d.MultiArray.setElements(e,a,C,s,d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(c.AST.nodeOperation(n,d.MultiArray.getElements(t.node,a,C,s),d.MultiArray.scalarToMultiArray(this.evaluatedExpressionValue(x(i),e,"assignment value"))),e,"compound assignment value"))),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(t.node)));continue}this.context.throwEvalError("can't perform indexed assignment for function handle type.")}else this.context.throwEvalError(`in computed assignment ${a}(index) OP= X, ${a} must be defined first.`)}else{const s=this.evaluatedExpressionValue(x(i),e,"assignment value"),n=e.resolveName(a);if(n&&g.ClassInstance.isInstanceOf(n.node)&&0===C.length){const r=this.callClassSubsasgn(n.node,h,y??"()",s,t,e);if(r){n.node=r,c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(n.node)));continue}}if(n&&d.MultiArray.isInstanceOf(n.node)&&0===C.length&&this.hasClassInstanceElement(n.node)){const r=this.evaluatedIndexArguments(h,e);try{const i=d.MultiArray.MultiArrayToScalar(this.reducedIndexingResult(d.MultiArray.getElements(n.node,a,[],r)));if(g.ClassInstance.isInstanceOf(i)){const n=this.callClassSubsasgn(i,h,y??"()",s,t,e);if(n){d.MultiArray.setElements(e,a,[],r,d.MultiArray.scalarToMultiArray(n)),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),e.resolveName(a).node));continue}}}catch(t){if(!(t instanceof RangeError))throw t}}if(n&&d.MultiArray.isInstanceOf(n.node)&&C.length>0&&this.hasClassInstanceElement(n.node)){n.node=this.assignClassArrayIndexedNestedField(a,n.node,h,C,s,r.left,e),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(n.node)));continue}if(n&&u.CharString.isInstanceOf(n.node)&&0===C.length){"{}"===y&&this.context.throwEvalError("matrix cannot be indexed with {");const t=d.MultiArray.characterVectorFromCharString(n.node),r=$.Scope.create();r.defineName("__char_assignment__",t),d.MultiArray.setElements(r,"__char_assignment__",[],this.evaluatedIndexArguments(h,e),this.charStringAssignmentRhs(s,n.node.quote),void 0,this),n.node=d.MultiArray.charStringFromCharacterVectorResult(this.scopedMultiArrayValue(r,"__char_assignment__","character assignment result"),n.node.quote),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(n.node)));continue}if(n&&C.length>0&&c.AST.isNodeIndexExpr(r.left)&&c.AST.isNodeIndirectRef(r.left.expr)&&(m.Structure.isInstanceOf(n.node)||d.MultiArray.isInstanceOf(n.node)&&m.Structure.isStructure(n.node))){const t=m.Structure.getField(n.node,C);if(d.MultiArray.isInstanceOf(t)&&!d.MultiArray.isEmpty(t)){const r=$.Scope.create();r.defineName("__field_assignment__",t),d.MultiArray.setElements(r,"__field_assignment__",[],this.evaluatedIndexArguments(h,e),this.indexedAssignmentRhs(y,s,t)),m.Structure.setNewField(n.node,C,this.runtimeExpressionValue(this.scopedExpressionValue(r,"__field_assignment__","field assignment result"),"field assignment result")),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(n.node)));continue}}d.MultiArray.setElements(e,a,C,this.evaluatedIndexArguments(h,e),this.indexedAssignmentRhs(y,s,0===C.length?n?.node:void 0,C.length>0)),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(e.resolveName(a).node)))}else{const s=x(i);s.parent=r.right;let u=s;try{if(C.length>0){let r=e.resolveName(a);n.length&&void 0===r&&this.context.throwEvalError(`in computed assignment ${a}.${C.join(".")} OP= X, ${a}.${C.join(".")} must be defined first.`),void 0===r?r=e.defineName(a,new m.Structure({})):d.MultiArray.isInstanceOf(r.node)&&!r.node.isCell&&d.MultiArray.isEmpty(r.node)&&(r.node=new m.Structure({}));const i=()=>m.Structure.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&m.Structure.isStructure(r.node)?this.expressionValue(m.Structure.getField(r.node,C),`field ${C.join(".")}`):g.ClassInstance.isInstanceOf(r.node)||d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?this.expressionValue(this.resolveClassFieldChain(r.node,C,t),`field ${C.join(".")}`):void this.context.throwEvalError("in indexed assignment."),o=n.length?void 0!==l?c.AST.nodeOperation(n,i(),s):this.Evaluator(c.AST.nodeOperation(n,i(),s)):s;if(u=o,m.Structure.isInstanceOf(r.node))this.assignStructureFieldValue(r.node,C,this.structureAssignmentValue(o,`field ${C.join(".")}`),!1);else if(d.MultiArray.isInstanceOf(r.node)&&m.Structure.isStructure(r.node))this.assignStructureFieldValue(r.node,C,this.structureAssignmentValue(o,`field ${C.join(".")}`),n.length>0);else if(g.ClassInstance.isInstanceOf(r.node)){const s=this.reducedAssignmentValue(o);r.node=this.assignNestedClassInstanceField(r.node,C,s,t,e)}else d.MultiArray.isInstanceOf(r.node)&&this.hasClassInstanceElement(r.node)?r.node=this.assignNestedClassArrayField(r.node,C,this.reducedAssignmentValue(o),t,e):A.ClassEventListener.isInstanceOf(r.node)?(1!==C.length&&this.context.throwEvalError(`cannot assign nested property '${C.join(".")}' for ${r.node.kind}.`),this.setClassEventListenerField(r.node,C[0],this.reducedAssignmentValue(o))):_.ClassEventData.isInstanceOf(r.node)||S.ClassPropertyEvent.isInstanceOf(r.node)?(1!==C.length&&this.context.throwEvalError(`cannot assign nested property '${C.join(".")}' for ${S.ClassPropertyEvent.isInstanceOf(r.node)?"event.PropertyEvent":"event.EventData"}.`),this.setClassEventDataField(r.node,C[0])):this.context.throwEvalError("in indexed assignment.");c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node)))}else{const t=n.length?void 0!==l?c.AST.nodeOperation(n,c.AST.nodeIdentifier(a),s):this.Evaluator(c.AST.nodeOperation(n,c.AST.nodeIdentifier(a),s)):s;let r;if(u=t,o)if(this.context.allowForwardReference)e.defineUndefinedReference(o,a),r=e.assignName(a,this.reducedAssignmentValue(t),o);else{if(l)throw l;this.context.throwUndefinedReferenceError(o)}else r=e.assignName(a,this.reducedAssignmentValue(t));if(this.solveUndefined(a,e),c.AST.appendNodeList(f,c.AST.nodeOperation("=",c.AST.nodeIdentifier(a),U.RuntimeValue.copy(r.node))),l)throw l}}catch(t){throw this.context.allowForwardReference&&this.isLocalUndefinedReference(t)&&e.assignName(a,u,o),t}}}}return t.parent&&t.parent.parent?this.nestedAssignmentValue(f):1===f.list.length?f.list[0]:f}case"IDENT":return this.context.resolveIdentifier(t,e);case"RETURN":throw new j.ReturnSignal;case"BREAK":throw new j.BreakSignal;case"CONTINUE":throw new j.ContinueSignal;case"FCNDEF":{const r=c.AST.isNodeFunctionDefinition(t)?t:this.context.throwEvalError(`invalid function definition AST node '${t.type}'.`);return this.isNodeInsideExecutableBlock(r)&&this.context.throwSyntaxError(`function definition '${r.id}' is not allowed inside a control block.`),"FCNDEF"===this.context.currentFrame?.func?.type&&e.hasLocalFunction(r.id)||e.functionTable[r.id]===r||this.registerFunctionDefinition(r,e,"FCNDEF"===this.context.currentFrame?.func?.type),c.AST.nodeVoid()}case"CLASSDEF":{const r=c.AST.isNodeClassDef(t)?t:this.context.throwEvalError(`invalid class definition AST node '${t.type}'.`);this.isNodeInsideExecutableBlock(r)&&this.context.throwSyntaxError(`class definition '${r.id}' is not allowed inside a control block.`);const s=f.ClassDefinition.create(r);s.resolveSuperclasses(t=>this.context.resolveClassDefinition(t,e),t=>this.context.throwEvalError(t)),this.context.defineClassDefinition(s,e)}return c.AST.nodeVoid();case"GLOBAL":for(const r of t.list){const t=c.AST.getDeclarationNode(r);if(c.AST.isNodeIdentifier(t))this.context.declareGlobal(t.id,void 0,e);else if(c.AST.isNodeDefaultedParameter(t)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(t.right,e,`global ${t.left.id} default`),`global ${t.left.id} default`);this.context.declareGlobal(t.left.id,r,e)}else this.context.throwSyntaxError("invalid global declaration.")}return c.AST.nodeVoid();case"PERSIST":for(const r of t.list){const t=c.AST.getDeclarationNode(r);if(c.AST.isNodeIdentifier(t))this.context.declarePersistent(t.id,void 0,e);else if(c.AST.isNodeDefaultedParameter(t)){const r=this.runtimeExpressionValue(this.evaluatedExpressionValue(t.right,e,`persistent ${t.left.id} default`),`persistent ${t.left.id} default`);this.context.declarePersistent(t.left.id,r,e)}else this.context.throwSyntaxError("invalid persistent declaration.")}return c.AST.nodeVoid();case"IMPORT":if(0===t.imports.length){const t=d.MultiArray.toColumnVector(e.importList().map(t=>u.CharString.create(t)));return t.isCell=!0,t}for(const r of t.imports)this.context.defineImport(r.id,e);return c.AST.nodeVoid();case".":{const r=this.resolveQualifiedNameAccess(t,e);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(t,e)){const r=this.collectClassSubsrefChain(t,e);if(r&&r.descriptors.length>0&&!this.context.canAccessClassMember(r.instance.classDefinition,"private")){const e=this.callClassSubsrefDescriptors(r.instance,r.descriptors,t);if(void 0!==e)return e}}const s=t.field.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings.")),i=this.evaluatedCommaSeparatedReceiver(t.obj,e);if(i)return this.chainedCommaListResult(i.map(r=>this.resolveDotFieldChain(r,s,t,e)));const n=this.evaluatedExpressionValue(t.obj,e,"dot receiver");return this.resolveDotFieldChain(n,s,t,e)}case"SUPERCLASS_CTOR":{const r=t,s="IDENT"===r.instance.type?e.resolveName(r.instance.id)?.node:void 0;if("IDENT"===r.instance.type&&!g.ClassInstance.isInstanceOf(s)){0===r.args.length&&this.context.throwEvalError(`superclass method '${r.instance.id}' requires an object argument.`);const t=this.evaluatedExpressionValue(r.args[0],e,"superclass method receiver");g.ClassInstance.isInstanceOf(t)||this.context.throwEvalError(`superclass method '${r.instance.id}' requires a class instance.`);const s=t.classDefinition.findSuperclass(r.superclass.id);s||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${t.classDefinition.name}.`),this.context.canAccessClassMember(s,"protected")||this.context.throwEvalError(`superclass method '${r.instance.id}' is only accessible from class methods.`);const i=s.findMethod(r.instance.id,t=>!t.isStatic);return i||this.context.throwEvalError(`unknown superclass method '${r.instance.id}' for class ${s.name}.`),this.context.canAccessClassMember(i.classDefinition,i.access)||this.context.throwEvalError(`method '${r.instance.id}' has ${i.access} access for class ${t.classDefinition.name}.`),this.context.callClassInstanceMethod(t,i,r.args.slice(1),r)}const i=g.ClassInstance.isInstanceOf(s)?s:this.evaluatedExpressionValue(r.instance,e,"superclass constructor receiver");g.ClassInstance.isInstanceOf(i)||this.context.throwEvalError("superclass constructor target must be a class instance.");const n=i.classDefinition.findSuperclass(r.superclass.id);return n||this.context.throwEvalError(`class ${r.superclass.id} is not a superclass of class ${i.classDefinition.name}.`),this.context.canAccessClassMember(n,"protected")||this.context.throwEvalError(`superclass constructor '${r.superclass.id}' is only accessible from class methods.`),this.context.constructSuperclassInstance(i,n,r.args,r)}case"METACLASS":return this.resolveMetaclassLiteral(t.className.id,e);case"LIST":{this.preregisterScriptLocalFunctions(t,e);const r={type:"LIST",list:new Array(t.list.length),parent:null===t.parent?null:t};let s=0,i=!1;for(let n=0;n<t.list.length;n++){let a;c.AST.isNodeIdentifier(t.list[n])&&!e.resolveName(t.list[n].id)&&this.commandWordListNameSet.has(t.list[n].id)&&(t.list[n]=c.AST.nodeEmptyCmdWList(t.list[n])),t.list[n].index=n;try{a=this.evaluatedExecutionResult(t.list[n],e)}catch(e){if(e instanceof j.ReturnSignal&&null===t.parent&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth){i=!0;break}throw e}if("LIST"===a.type)for(let i=0;i<a.list.length;i++){const n=a.list[i];"VOID"!==n.type&&(a.list[i].parent=r,a.list[i].index=s,r.list[s]=n,null!==t.parent||n.omitAnswer||e.defineName("ans",n),s++)}else if("VOID"===a.type){const e=t.list[n];e.omitAnswer=!0,e.omitOutput=!0,e.parent=r,e.index=s,r.list[s]=e,s++}else a.parent=r,a.index=s,r.list[s]=a,null!==t.parent||a.omitAnswer||e.defineName("ans",a),s++}if(r.list.length=s,i&&0===s)return c.AST.nodeVoid();const n=r.list.filter(t=>!t.omitOutput);return n.length>0&&n.length<r.list.length&&(r.list=n,r.list.forEach((t,e)=>{t.parent=r,t.index=e})),r}case"RANGE":{const r=this.evaluatedExpressionValue(t.start_,e,"range start"),s=this.evaluatedExpressionValue(t.stop_,e,"range stop"),i=t.stride_?this.evaluatedExpressionValue(t.stride_,e,"range stride"):null;return this.evaluateColonWithClassDispatch(i?[r,i,s]:[r,s],t)||d.MultiArray.expandRange(r,s,i)}case"ENDRANGE":{let r=t.parent,s=t.index;for(;c.AST.isNodeBase(r)&&"IDX"!==r.type;)s=r.index,r=r.parent;if(c.AST.isNodeIndexExpr(r)){const t=this.evaluatedExpressionValue(r.expr,e,"indexed expression");if(g.ClassInstance.isInstanceOf(t)){const e=this.callClassEnd(t,s+1,r.args.length,r);return void 0!==e?e:h.Complex.one()}return d.MultiArray.isInstanceOf(t)?1===r.args.length?h.Complex.create(d.MultiArray.linearLength(t)):h.Complex.create(d.MultiArray.getDimension(t,s)):u.CharString.isInstanceOf(t)?h.Complex.create(t.length):h.Complex.one()}this.context.throwSyntaxError("indeterminate end of range. The word 'end' to refer a value is valid only in indexing.")}case":":if(c.AST.isNodeIndexExpr(t.parent)){const r=this.evaluatedExpressionValue(t.parent.expr,e,"indexed expression");return d.MultiArray.isInstanceOf(r)?1===t.parent.args.length?d.MultiArray.expandColon(d.MultiArray.linearLength(r)):d.MultiArray.expandColon(d.MultiArray.getDimension(r,t.index)):u.CharString.isInstanceOf(r)?d.MultiArray.expandColon(r.length):h.Complex.one()}this.context.throwSyntaxError("indeterminate colon. The colon to refer a range is valid only in indexing.");case"IDX":{t.expr||this.context.throwReferenceError(`'${t.id}' undefined.`);const r=this.inheritedHandleMethodCall(t,e);if(void 0!==r)return r;if(!this.hasQualifiedNameAccessOperand(t,e)&&c.AST.isNodeIndirectRef(t.expr)){const r=this.dottedCommaReceiver(t.expr,e);if(r){const s=r.fields.map(t=>"string"==typeof t?t:this.evaluatedDynamicFieldName(t,e,"Dynamic structure field names must be strings."));return this.chainedCommaListResult(r.values.map(r=>{const i=this.resolveDotFieldChain(r,s,t.expr,e);return this.chainedCommaItemApply(i,t.args,t)}))}}if(!this.hasQualifiedNameAccessOperand(t,e)){const r=this.collectClassSubsrefChain(t,e);if(r&&r.descriptors.length>0){const e=this.callClassSubsrefDescriptors(r.instance,r.descriptors,t);if(void 0!==e)return e}}const s=this.evaluatedCommaSeparatedReceiver(t.expr,e);if(s)return this.chainedCommaListResult(s.map(e=>this.chainedCommaItemApply(e,t.args,t)));const i=this.evaluatedExpressionValue(t.expr,e,"indexed expression");if(g.ClassInstance.isInstanceOf(i)){const r=this.callClassSubsref(i,t,e);if(void 0!==r)return r}return this.context.apply(i,t.args,t)}case"CMDWLIST":{const e=this.commandWordListTable[t.id];e||this.context.throwUndefinedReferenceError(t.id);const r=this.commandWordListResult(e.func(...t.args.map(t=>t.str)));return void 0!==r?r:t}case"IF":for(let r=0;r<t.expression.length;r++)if(this.evaluatedCondition(t.expression[r],e,"if condition"))return this.evaluatedExecutionResult(t.then[r],e);return t.else?this.evaluatedExecutionResult(t.else,e):{type:"LIST",list:[],parent:t};case"SWITCH":{const r=this.evaluatedExpressionValue(t.expression,e,"switch expression");for(const s of t.cases){const t=this.evaluatedExpressionValue(s.expression,e,"switch case");if(this.switchCaseMatches(r,t))return this.evaluatedExecutionResult(s.then,e)}return t.otherwise?this.evaluatedExecutionResult(t.otherwise,e):{type:"LIST",list:[],parent:t}}case"WHILE":{let r={type:"LIST",list:[],parent:t};for(;;){if(!this.evaluatedCondition(t.expression,e,"while condition"))return r;try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof j.ContinueSignal)continue;if(t instanceof j.BreakSignal)return r;throw t}}}case"DO_UNTIL":{let r={type:"LIST",list:[],parent:t};for(;;){try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof j.BreakSignal)return r;if(!(t instanceof j.ContinueSignal))throw t}if(this.evaluatedCondition(t.expression,e,"until condition"))return r}}case"FOR":{let r={type:"LIST",list:[],parent:t};t.workers&&this.workerCountControlArgument(this.evaluatedExpressionValue(t.workers,e,"parfor workers"),"parfor workers");const s=this.evaluatedExpressionValue(t.expression,e,"for expression");t.parallel&&(this.validateParforHeader(t.target,s),this.validateParforBody(t.body,t.target.id));const i=this.forLoopValues(s,t.target);for(const s of i){const i=c.AST.nodeOperation("=",this.cloneAssignmentTarget(t.target),this.forLoopAssignmentValue(t.target,s));this.Evaluator(i,e);try{r=this.evaluatedExecutionResult(t.body,e)}catch(t){if(t instanceof j.ContinueSignal)continue;if(t instanceof j.BreakSignal)return r;throw t}}return r}case"SPMD":if(this.validateSpmdBody(t.body),t.workers){const r=t.workers.list.map((t,r)=>this.workerCountControlArgument(this.evaluatedExpressionValue(this.expressionValue(t,`spmd worker ${r+1}`),e,`spmd worker ${r+1}`),`spmd worker ${r+1}`));2===r.length&&r[0]>r[1]&&this.context.throwEvalError("spmd minimum worker count cannot exceed maximum worker count.")}const r=["spmdIndex","spmdSize"],s=new Map;r.forEach(t=>{s.set(t,e.hasLocalName(t)?{...e.nameTable[t]}:void 0)}),e.defineName("spmdIndex",h.Complex.one()),e.defineName("spmdSize",h.Complex.one());try{return this.evaluatedExecutionResult(t.body,e)}finally{r.forEach(t=>{const r=s.get(t);r?e.nameTable[t]=r:e.removeName(t)})}case"TRY":try{return this.evaluatedExecutionResult(t.body,e)}catch(r){if(r instanceof j.ReturnSignal||r instanceof j.BreakSignal||r instanceof j.ContinueSignal)throw r;const s=this.rememberLastError(r);return t.catchBody?(t.catchIdentifier&&e.defineName(t.catchIdentifier.id,s),this.evaluatedExecutionResult(t.catchBody,e)):{type:"LIST",list:[],parent:t}}case"UNWIND_PROTECT":{let r,s={type:"LIST",list:[],parent:t},i=!1;try{s=this.evaluatedExecutionResult(t.body,e)}catch(t){r=t,i=!0}if(this.evaluatedExecutionResult(t.cleanup,e),i)throw r;return s}default:this.context.throwEvalError(`evaluating undefined type '${t.type}'.`)}}Evaluate(t){try{return this._exitStatus=W.response.OK,t.parent=null,this.validateDeclarationPlacement(t),this.Evaluator(t)}catch(t){if(t instanceof j.ReturnSignal&&!this.context.isInsideUserFunction()&&0===this.scriptExecutionDepth)return c.AST.nodeVoid();if(this._exitStatus=W.response.EVAL_ERROR,t instanceof j.BreakSignal)try{this.context.throwEvalError("break is only valid inside a loop.")}catch(t){throw this.lastError=t,t}if(t instanceof j.ContinueSignal)try{this.context.throwEvalError("continue is only valid inside a loop.")}catch(t){throw this.lastError=t,t}throw this.lastError=t,t}}Execute(t){try{return this.Evaluate(this.Parse(t))}catch(t){throw this.lastError=t,t}}Unparse(t,e=0){const r=(t,e)=>t+" "+e.list.map(t=>this.Unparse(c.AST.getDeclarationNode(t))).join(" "),s=t=>t.map(t=>this.Unparse(t)).join(","),i=t=>!!t&&"LIST"===t.type&&0===t.list.length,n=t=>t.length>0?"("+t.map(t=>this.Unparse(t)).join(",")+")":"",a=t=>{const e=0===t.return.list.length?"":1===t.return.list.length?this.Unparse(t.return.list[0]):"["+s(t.return.list)+"]",r="("+s(t.parameter.list)+")";if(t.attributes?.prototype)return(e?e+"=":"")+t.id+r;const i=t.arguments.list.length>0?"\n"+t.arguments.list.map(t=>this.Unparse(t)).join("\n"):"";return"FUNCTION "+(e?e+"=":"")+t.id+r+i+(t.statements.list.length>0?"\n"+this.Unparse(t.statements).trimEnd():"")+"\nENDFUNCTION"},o=(t,e)=>{const r=this.nodePrecedence(e),s=this.Unparse(e.left,r);return(this.nodePrecedence(e.left)<r?"("+s+")":s)+t},l=(t,e)=>{const r=this.nodePrecedence(e),s=this.Unparse(e.right,r);return t+(this.nodePrecedence(e.right)<r?"("+s+")":s)},T=t=>c.AST.isNodeOperation(t)&&"string"==typeof t.type&&["!","~","+_","-_","++_","--_"].includes(t.type),b=t=>c.AST.isNodeOperation(t)&&"()"===t.type&&T(this.requirePrefixOperation(t).right),N=t=>{const e=this.nodePrecedence(t);return this.nodePrecedence(t.left)<e||("^"===t.type||".^"===t.type||"**"===t.type||".**"===t.type)&&(T(t.left)||b(t.left))};try{if(!t)return"";if(void 0===t)return"<UNDEFINED>";if(h.Complex.isInstanceOf(t))return h.Complex.unparse(t,this,e);if(u.CharString.isInstanceOf(t))return u.CharString.unparse(t,e);if(d.MultiArray.isInstanceOf(t))return d.MultiArray.unparse(t,this,e);if(m.Structure.isInstanceOf(t))return m.Structure.unparse(t,this,e);if(p.FunctionHandle.isInstanceOf(t))return p.FunctionHandle.unparse(t,this,e);if(f.ClassDefinition.isInstanceOf(t))return f.ClassDefinition.unparse(t,this);if(g.ClassInstance.isInstanceOf(t))return g.ClassInstance.unparse(t,this);if(y.ClassBoundMethod.isInstanceOf(t))return y.ClassBoundMethod.unparse(t,this);if(x.ClassStaticMethod.isInstanceOf(t))return x.ClassStaticMethod.unparse(t,this);if(C.ClassEmptyMethod.isInstanceOf(t))return C.ClassEmptyMethod.unparse(t,this);if(E.ClassEnumerationValue.isInstanceOf(t))return E.ClassEnumerationValue.unparse(t,this);if(A.ClassEventListener.isInstanceOf(t))return A.ClassEventListener.unparse(t,this);if(S.ClassPropertyEvent.isInstanceOf(t))return S.ClassPropertyEvent.unparse(t,this);if(_.ClassEventData.isInstanceOf(t))return _.ClassEventData.unparse(t,this);if(v.ClassMetaObject.isInstanceOf(t))return v.ClassMetaObject.unparse(t,this);switch(t.type){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{const e=this.requireBinaryOperation(t),r=this.nodePrecedence(t),s=this.Unparse(e.left,r),i=this.Unparse(e.right,r);return(N(e)?"("+s+")":s)+t.type+(this.nodePrecedence(e.right)<r?"("+i+")":i)}case"()":{const r=this.requirePrefixOperation(t),s=this.nodePrecedence(r.right),i=this.Unparse(r.right,s);return s<e?"("+i+")":i}case"!":case"~":return l(t.type,this.requirePrefixOperation(t));case"+_":return l("+",this.requirePrefixOperation(t));case"-_":return l("-",this.requirePrefixOperation(t));case"++_":return l("++",this.requirePrefixOperation(t));case"--_":return l("--",this.requirePrefixOperation(t));case".'":case"'":return o(t.type,this.requirePostfixOperation(t));case"_++":return o("++",this.requirePostfixOperation(t));case"_--":return o("--",this.requirePostfixOperation(t));case"IDENT":case"CLASS_EVENT":return t.id;case".":return this.Unparse(t.obj)+"."+t.field.map(t=>"string"==typeof t?t:"("+this.Unparse(t)+")").join(".");case"LIST":return t.list.map(t=>this.Unparse(t)).join("\n")+"\n";case"RANGE":return t.start_&&t.stop_?t.stride_?this.Unparse(t.start_)+":"+this.Unparse(t.stride_)+":"+this.Unparse(t.stop_):this.Unparse(t.start_)+":"+this.Unparse(t.stop_):":";case"ENDRANGE":return"end";case":":return":";case"<~>":return"~";case"IDX":return this.Unparse(t.expr)+t.delim[0]+t.args.map(t=>this.Unparse(t)).join(",")+t.delim[1];case"SUPERCLASS_CTOR":return this.Unparse(t.instance)+"@"+this.Unparse(t.superclass)+"("+t.args.map(t=>this.Unparse(t).trimEnd()).join(",")+")";case"METACLASS":return"?"+this.Unparse(t.className);case"RETLIST":return"<RETLIST>";case"CMDWLIST":return(t.id+" "+t.args.map(t=>this.Unparse(t)).join(" ")).trimEnd();case"ARGVALID":{const e=t.size.length>0?"("+s(t.size)+")":"",r=t.class&&!i(t.class)?" "+this.Unparse(t.class).trimEnd():"",n=t.functions.length>0?" {"+s(t.functions)+"}":"",a=t.default?"="+this.Unparse(t.default):"";return this.Unparse(t.name)+e+r+n+a}case"ARGS":return"ARGUMENTS"+(t.attributes.length>0?" ("+t.attributes.map(t=>this.Unparse(t)).join(",")+")":"")+(t.validation.length>0?"\n"+t.validation.map(t=>this.Unparse(t)).join("\n"):"")+"\nENDARGUMENTS";case"GLOBAL":return r("global",t);case"PERSIST":return r("persistent",t);case"IMPORT":return"import"+(t.imports.length>0?" "+t.imports.map(t=>this.Unparse(t)).join(" "):"");case"RETURN":return"return";case"BREAK":return"break";case"CONTINUE":return"continue";case"IF":let c="IF "+this.Unparse(t.expression[0])+"\n";c+=this.Unparse(t.then[0])+"\n";for(let e=1;e<t.expression.length;e++)c+="ELSEIF "+this.Unparse(t.expression[e])+"\n",c+=this.Unparse(t.then[e])+"\n";return t.else&&(c+="ELSE\n"+this.Unparse(t.else)+"\n"),c+="ENDIF",c;case"SWITCH":let u="SWITCH "+this.Unparse(t.expression)+"\n";for(const e of t.cases)u+="CASE "+this.Unparse(e.expression)+"\n",u+=this.Unparse(e.then)+"\n";return t.otherwise&&(u+="OTHERWISE\n"+this.Unparse(t.otherwise)+"\n"),u+="ENDSWITCH",u;case"WHILE":return"WHILE "+this.Unparse(t.expression)+"\n"+this.Unparse(t.body)+"\nENDWHILE";case"DO_UNTIL":return"DO\n"+this.Unparse(t.body)+"\nUNTIL "+this.Unparse(t.expression);case"FOR":return(t.parallel?"PARFOR ":"FOR ")+(t.workers?"(":"")+this.Unparse(t.target)+"="+this.Unparse(t.expression)+(t.workers?","+this.Unparse(t.workers)+")":"")+"\n"+this.Unparse(t.body)+(t.parallel?"\nENDPARFOR":"\nENDFOR");case"SPMD":return"SPMD"+(t.workers?" ("+t.workers.list.map(t=>this.Unparse(t)).join(",")+")":"")+"\n"+this.Unparse(t.body)+"\nENDSPMD";case"TRY":return"TRY\n"+this.Unparse(t.body)+(t.catchBody?"\nCATCH"+(t.catchIdentifier?" "+this.Unparse(t.catchIdentifier):"")+"\n"+this.Unparse(t.catchBody):"")+"\nEND_TRY_CATCH";case"UNWIND_PROTECT":return"UNWIND_PROTECT\n"+this.Unparse(t.body)+"\nUNWIND_PROTECT_CLEANUP\n"+this.Unparse(t.cleanup)+"\nEND_UNWIND_PROTECT";case"CLASSDEF":return"CLASSDEF "+n(t.attributes)+(t.attributes.length>0?" ":"")+t.id+(t.superclasses.length>0?" < "+t.superclasses.map(t=>this.Unparse(t)).join("&"):"")+(t.sections.length>0?"\n"+t.sections.map(t=>this.Unparse(t)).join("\n"):"")+"\nENDCLASSDEF";case"CLASS_SECTION":return t.kind+(t.attributes.length>0?" "+n(t.attributes):"")+(t.members.list.length>0?"\n"+this.Unparse(t.members).trimEnd():"")+"\n"+(t=>{switch(t){case"PROPERTIES":return"ENDPROPERTIES";case"METHODS":return"ENDMETHODS";case"EVENTS":return"ENDEVENTS";case"ENUMERATION":return"ENDENUMERATION";default:return"END"}})(t.kind);case"CLASS_PROPERTY":return t.id+(t.size.length>0?"("+s(t.size)+")":"")+(t.class&&!i(t.class)?" "+this.Unparse(t.class).trimEnd():"")+(t.functions.length>0?" {"+s(t.functions)+"}":"")+(t.defaultValue?"="+this.Unparse(t.defaultValue).trimEnd():"");case"CLASS_ENUMERATION":return t.id+(t.args.length>0?"("+t.args.map(t=>this.Unparse(t).trimEnd()).join(",")+")":"");case"CLASS_ATTRIBUTE":return!t.value||"~"!==t.value.type&&"!"!==t.value.type?t.id+(t.value?"="+this.Unparse(t.value).trimEnd():""):t.value.type+t.id;case"FCNDEF":return a(t);case"VOID":return"";default:return"<INVALID>"}}catch{return"<ERROR>"}}UnparserMathML(t,e=0){const r=(t,e)=>`<mrow><mi>${t}</mi><mspace width="0.4em"/>${e.list.map(t=>this.UnparserMathML(c.AST.getDeclarationNode(t))).join('<mspace width="0.4em"/>')}</mrow>`,s=t=>t.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"),i=(t,e)=>`<mtr><mtd><mo><b>${t}</b></mo></mtd>${void 0===e?"":`<mtd>${e}</mtd>`}</mtr>`,n=t=>`<mtr><mtd></mtd><mtd>${this.UnparserMathML(t)}</mtd></mtr>`,a=(t,e,r,s)=>`<mtable>${i(t,s)}${n(e)}${i(r)}</mtable>`,o=(t,e,r)=>L.MathML.format["()"](t,e,r),l=t=>t.length>0?o("(",s(t),")"):"",f=t=>{const e=t.size.length>0?o("(",s(t.size),")"):"",r=!t.class||(i=t.class)&&"LIST"===i.type&&0===i.list.length?"":'<mspace width="0.33em"/>'+this.UnparserMathML(t.class);var i;const n=t.functions.length>0?'<mspace width="0.33em"/>'+o("{",s(t.functions),"}"):"",a=t.default?"<mo>=</mo>"+this.UnparserMathML(t.default):"";return`<mrow>${this.UnparserMathML(t.name)}${e}${r}${n}${a}</mrow>`},g=t=>{const e=0===t.return.list.length?"":1===t.return.list.length?this.UnparserMathML(t.return.list[0]):o("[",s(t.return.list),"]"),r=o("(",s(t.parameter.list),")");return`${e?e+"<mo>=</mo>":""}${L.MathML.format.IDENT(t.id)}${r}`};try{if(!t)return L.MathML.format.UNDEFINED();if(void 0===t)return L.MathML.format.UNDEFINED();if(h.Complex.isInstanceOf(t))return h.Complex.unparseMathML(t,this,e);if(u.CharString.isInstanceOf(t))return u.CharString.unparseMathML(t,e);if(d.MultiArray.isInstanceOf(t))return d.MultiArray.unparseMathML(t,this,e);if(m.Structure.isInstanceOf(t))return m.Structure.unparseMathML(t,this,e);if(p.FunctionHandle.isInstanceOf(t))return p.FunctionHandle.unparseMathML(t,this,e);switch(t.type){case"()":{const r=this.requirePrefixOperation(t),s=this.nodePrecedence(r.right),i=this.UnparserMathML(r.right,s);return s<e?L.MathML.format["()"]("(",i,")"):i}case"+":case"-":case"*":case".*":case"./":case".\\":case"\\":case".^":case".**":case"<":case">":case"==":case"&":case"|":case"&&":case"||":case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":case"<=":case">=":case"!=":case"~=":{const e=this.requireBinaryOperation(t),r=this.nodePrecedence(t),s=this.UnparserMathML(e.left,r),i=this.UnparserMathML(e.right,r);return L.MathML.formatDynamic(t.type,this.nodePrecedence(e.left)<r?L.MathML.format["()"]("(",s,")"):s,this.nodePrecedence(e.right)<r?L.MathML.format["()"]("(",i,")"):i)}case"/":{const e=this.requireBinaryOperation(t);return L.MathML.formatDynamic(t.type,this.UnparserMathML(e.left),this.UnparserMathML(e.right))}case"**":case"^":{const e=this.requireBinaryOperation(t);return L.MathML.formatDynamic(t.type,this.UnparserMathML(e.left,this.precedenceTable["_"+t.type]),this.UnparserMathML(e.right))}case"!":case"~":case"+_":case"-_":case"++_":case"--_":{const e=this.requirePrefixOperation(t);return L.MathML.formatDynamic(t.type,this.UnparserMathML(e.right))}case"_++":case"_--":case".'":case"'":{const e=this.requirePostfixOperation(t);return L.MathML.formatDynamic(t.type,this.UnparserMathML(e.left,this.precedenceTable["_"+t.type]))}case"IDENT":return L.MathML.format.IDENT((0,b.substSymbol)(t.id));case".":return L.MathML.format["."](this.UnparserMathML(t.obj),t.field.map(t=>"string"==typeof t?L.MathML.format.IDENT(t):L.MathML.format["()"]("(",this.UnparserMathML(t),")")));case"LIST":return L.MathML.format.LIST(t.list.map(t=>this.UnparserMathML(t)));case"RANGE":return t.start_&&t.stop_?t.stride_?L.MathML.format.RANGE(this.UnparserMathML(t.start_),this.UnparserMathML(t.stride_),this.UnparserMathML(t.stop_)):L.MathML.format.RANGE(this.UnparserMathML(t.start_),this.UnparserMathML(t.stop_)):L.MathML.format.RANGE();case"ENDRANGE":case":":case"<~>":return L.MathML.formatDynamic(t.type);case"IDX":if(0===t.args.length)return L.MathML.format.IDX(this.UnparserMathML(t.expr),t.delim[0],[],t.delim[1]);{let r;if("IDENT"===t.expr.type){const e=this.context.aliasNameFunction(t.expr.id);r=e in this.context.builtInFunctionTable&&this.context.builtInFunctionTable[e].UnparserMathML?this.context.builtInFunctionTable[e].UnparserMathML(t):e in this.context.builtInFunctionTable&&L.MathML.formatFunction(e)?L.MathML.formatDynamic(e,...t.args.map(t=>this.UnparserMathML(t))):L.MathML.format.IDX(L.MathML.format.IDENT((0,b.substSymbol)(t.expr.id)),t.delim[0],t.args.map(t=>this.UnparserMathML(t)),t.delim[1])}else r=L.MathML.format.IDX(this.UnparserMathML(t.expr,e),t.delim[0],t.args.map(t=>this.UnparserMathML(t)),t.delim[1]);return this.nodePrecedence(t)>e?r:L.MathML.format["()"]("(",r,")")}case"RETLIST":return L.MathML.format.RETLIST();case"CMDWLIST":return L.MathML.format.CMDWLIST(t.id,t.args.map(t=>this.UnparserMathML(t)));case"ARGVALID":return f(t);case"ARGS":return`<mtable>${i("arguments",t.attributes.length>0?t.attributes.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"):void 0)}${t.validation.map(t=>n(t)).join("")}${i("endarguments")}</mtable>`;case"GLOBAL":return r("global",t);case"PERSIST":return r("persistent",t);case"IMPORT":return"<mrow><mi>import</mi>"+(t.imports.length>0?'<mspace width="0.33em"/>'+t.imports.map(t=>this.UnparserMathML(t)).join("<mo>,</mo>"):"")+"</mrow>";case"RETURN":return"<mi>return</mi>";case"BREAK":return"<mi>break</mi>";case"CONTINUE":return"<mi>continue</mi>";case"IF":const c=t.expression.map((e,r)=>`${i(0===r?"if":"elseif",this.UnparserMathML(e))}${n(t.then[r])}`),u=t.else?`${i("else")}${n(t.else)}`:"";return`<mtable>${c.join("")}${u}${i("endif")}</mtable>`;case"SWITCH":return`<mtable>${i("switch",this.UnparserMathML(t.expression))}${t.cases.map(t=>`${i("case",this.UnparserMathML(t.expression))}${n(t.then)}`).join("")}${t.otherwise?`${i("otherwise")}${n(t.otherwise)}`:""}${i("endswitch")}</mtable>`;case"WHILE":return a("while",t.body,"endwhile",this.UnparserMathML(t.expression));case"DO_UNTIL":return`<mtable>${i("do")}${n(t.body)}${i("until",this.UnparserMathML(t.expression))}</mtable>`;case"FOR":return a(t.parallel?"parfor":"for",t.body,t.parallel?"endparfor":"endfor",this.UnparserMathML(t.target)+'<mo form="infix" stretchy="true">=</mo>'+this.UnparserMathML(t.expression)+(t.workers?"<mo>,</mo>"+this.UnparserMathML(t.workers):""));case"SPMD":return a("spmd",t.body,"endspmd",t.workers?this.UnparserMathML(t.workers):void 0);case"TRY":return`<mtable>${i("try")}${n(t.body)}${t.catchBody?i("catch",t.catchIdentifier?this.UnparserMathML(t.catchIdentifier):void 0)+n(t.catchBody):""}${i("end_try_catch")}</mtable>`;case"UNWIND_PROTECT":return`<mtable>${i("unwind_protect")}${n(t.body)}${i("unwind_protect_cleanup")}${n(t.cleanup)}${i("end_unwind_protect")}</mtable>`;case"CLASSDEF":return`<mtable>${i("classdef",`${l(t.attributes)}${t.attributes.length>0?'<mspace width="0.33em"/>':""}${L.MathML.format.IDENT(t.id)}${t.superclasses.length>0?'<mspace width="0.33em"/><mo><</mo><mspace width="0.33em"/>'+t.superclasses.map(t=>this.UnparserMathML(t)).join("<mo>&</mo>"):""}`)}${t.sections.map(t=>n(t)).join("")}${i("endclassdef")}</mtable>`;case"CLASS_SECTION":return`<mtable>${i(t.kind.toLowerCase(),t.attributes.length>0?l(t.attributes):void 0)}${n(t.members)}${i((t=>{switch(t){case"PROPERTIES":return"endproperties";case"METHODS":return"endmethods";case"EVENTS":return"endevents";case"ENUMERATION":return"endenumeration";default:return"end"}})(t.kind))}</mtable>`;case"CLASS_PROPERTY":return f(t.validation);case"CLASS_EVENT":return L.MathML.format.IDENT(t.id);case"CLASS_ENUMERATION":return`<mrow>${L.MathML.format.IDENT(t.id)}${t.args.length>0?o("(",s(t.args),")"):""}</mrow>`;case"CLASS_ATTRIBUTE":return!t.value||"~"!==t.value.type&&"!"!==t.value.type?`<mrow>${L.MathML.format.IDENT(t.id)}${t.value?"<mo>=</mo>"+this.UnparserMathML(t.value):""}</mrow>`:`<mrow><mo>${t.value.type}</mo>${L.MathML.format.IDENT(t.id)}</mrow>`;case"FCNDEF":return(t=>{if(t.attributes?.prototype)return g(t);const e=t.arguments.list.map(t=>n(t)).join("");return`<mtable>${i("function",g(t))}${e}${n(t.statements)}${i("endfunction")}</mtable>`})(t);case"VOID":return L.MathML.format.VOID();default:return L.MathML.format.INVALID()}}catch(t){if(this._debug)throw t;return L.MathML.format.ERROR()}}UnparseMathML(t,e="block"){let r=this.UnparserMathML(t);return r?L.MathML.format.math(L.MathML.format.errorReplace(r),e):"<b>Unparse error.</b>"}ToMathML(t,e="block"){return this.UnparseMathML(this.Parse(t),e)}Interprets(t,e="none"){const r=this.Parse(t),s=this.Evaluate(r);return{input:t,inputParsed:r,inputUnparsed:this.Unparse(s),inputUnparsedMathML:this.UnparseMathML(s),evaluated:s,evaluatedUnparsed:this.Unparse(s),evaluatedUnparsedMathML:this.UnparseMathML(s,e)}}}e.Interpreter=W;var Q=r(9274);Object.defineProperty(e,"ManifestSourceResolver",{enumerable:!0,get:function(){return Q.ManifestSourceResolver}}),Object.defineProperty(e,"TableSourceResolver",{enumerable:!0,get:function(){return Q.TableSourceResolver}}),e.default={Scope:$.Scope,CallFrame:B.CallFrame,InterpreterError:z.InterpreterError,EvalError:z.EvalError,ReferenceError:z.ReferenceError,UndefinedReferenceError:z.UndefinedReferenceError,CircularReferenceError:z.CircularReferenceError,SyntaxError:z.SyntaxError,Context:j.Context,Interpreter:W}},1201(t,e){"use strict";e.SyntaxError=e.CircularReferenceError=e.UndefinedReferenceError=e.ReferenceError=e.EvalError=e.InterpreterError=void 0;class r extends Error{stackFrames;constructor(t,e){super(t),this.name="InterpreterError",this.stackFrames=e}format(){let t=`Error: ${this.message}`;if(!this.stackFrames||0===this.stackFrames.length)return t;const e=[];for(const t of this.stackFrames){const r=this.getFrameName(t);if(!r||"<anonymous>"===r)continue;let s="";const i=t.callSite;if(i?.start){const{line:t,column:e}=i.start;void 0!==t&&void 0!==e?s=` (line ${t}, column ${e})`:void 0!==t&&(s=` (line ${t})`)}e.push(`Error in ${r}${s}`)}return e.length>0&&(t+="\n"+e.join("\n")),t}getFrameName(t){if(t.name)return t.name;const e=t.func;if(!e)return"";switch(e.type){case"BUILTIN":return e.node.id??"<builtin>";case"LAMBDA":return"<anonymous>";case"FCNDEF":return e.node.id??"<function>";default:return"<unknown>"}}toString(){return this.format()}}e.InterpreterError=r,e.EvalError=class extends r{constructor(t,e){super(t,e),this.name="EvalError"}};class s extends r{constructor(t,e){super(t,e),this.name="ReferenceError"}}e.ReferenceError=s,e.UndefinedReferenceError=class extends s{identifier;constructor(t,e){super(`'${t}' undefined.`,e),this.identifier=t,this.name="UndefinedReferenceError"}},e.CircularReferenceError=class extends r{chain;constructor(t,e){super(`Circular reference detected: ${t.join(" → ")}`,e),this.chain=t,this.name="CircularReferenceError"}},e.SyntaxError=class extends r{constructor(t,e){super(t,e),this.name="SyntaxError"}}},227(t,e,r){"use strict";e.LAPACK=e.ec=void 0;const s=r(845),i=r(7679),n=r(6115);e.ec=["maxIterationFactor"];const a=new Set(e.ec),o={maxIterationFactor:1e3};class l{static defaultSettings=Object.assign({},o);static settings=l.defaultSettings;static mtimes=(t,e)=>{const r=t.dimension[0],a=t.dimension[1],o=e.dimension[1];if(a!==e.dimension[0])throw new Error(`LAPACK.mtimes: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);const l=new i.MultiArray([r,o]);return n.BLAS.gemm(s.Complex.one(),t.array,r,a,e.array,o,s.Complex.zero(),l.array),i.MultiArray.setType(l),l};static set=t=>{Object.entries(t).forEach(t=>{if(!a.has(t[0]))throw new Error(`LAPACK.set: invalid configuration parameter: ${t[0]}`);l.settings[t[0]]=t[1]})};static is_hermitian=t=>{const e=t.length;if(0===e)return!0;if(t[0].length!==e)return!1;for(let r=0;r<e;r++){const i=t[r][r];if(Math.abs((0,s.toNumber)(i.im))>1e-14)return!1;for(let i=r+1;i<e;i++){const e=t[r][i],n=t[i][r],a=(0,s.toNumber)(e.re)-(0,s.toNumber)(n.re),o=(0,s.toNumber)(e.im)+(0,s.toNumber)(n.im);if(Math.hypot(a,o)>1e-14)return!1}}return!0};static is_positive_definite=t=>{const e=t.length;if(0===e)return!0;if(t[0].length!==e)return!1;if(!l.is_hermitian(t))return!1;const r=Array.from({length:e},(r,i)=>Array.from({length:e},(e,r)=>s.Complex.copy(t[i][r])));for(let t=0;t<e;t++){let i=r[t][t];for(let e=0;e<t;e++){const n=r[t][e];i=s.Complex.sub(i,s.Complex.mul(n,s.Complex.conj(n)))}if(Math.abs((0,s.toNumber)(i.im))>1e-14)return!1;if((0,s.toNumber)(i.re)<=1e-14)return!1;const n=s.Complex.create(Math.sqrt((0,s.toNumber)(i.re)),0);r[t][t]=n;for(let i=t+1;i<e;i++){let e=r[i][t];for(let n=0;n<t;n++)e=s.Complex.sub(e,s.Complex.mul(r[i][n],s.Complex.conj(r[t][n])));r[i][t]=s.Complex.rdiv(e,n)}}return!0};static laswp=(t,e,r,s,i,n,a,o)=>{const l=e[0],c=e[1],u=2===e.length?1:e.slice(2).reduce((t,e)=>t*e,1),h=void 0===a?0:a,d=void 0===o?c-1:o;if(!i||0===i.length)return;const m=0===Math.min(...i);if(n>0)for(let e=r;e<=s;e+=n){const r=e-1,s=i[e-1],n=m?s:s-1;if(n!==r)for(let e=0;e<u;e++){const s=e*l+r,i=e*l+n;for(let e=h;e<=d;e++){const r=t[s][e];t[s][e]=t[i][e],t[i][e]=r}}}else for(let e=r;e>=s;e+=n){const r=e-1,s=i[e-1],n=m?s:s-1;if(n!==r)for(let e=0;e<u;e++){const s=e*l+r,i=e*l+n;for(let e=h;e<=d;e++){const r=t[s][e];t[s][e]=t[i][e],t[i][e]=r}}}};static laswp_rows=(t,e,r,s)=>{const i=r+1,n=i,a=[];a[i-1]=s+1,l.laswp(t,e,i,n,a,1)};static laswp_cols=(t,e,r,s)=>{const i=e[0]*(2===e.length?1:e.slice(2).reduce((t,e)=>t*e,1));for(let e=0;e<i;e++){const i=t[e][r];t[e][r]=t[e][s],t[e][s]=i}};static eye=(...t)=>{const e=t.flat(),r=e[0],i=e[1];if(2===e.length)return Array.from({length:r},(t,e)=>Array.from({length:i},(t,r)=>e===r?s.Complex.one():s.Complex.zero()));{const t=e.slice(2).reduce((t,e)=>t*e,1);return Array.from({length:r*t},(t,e)=>{const n=e%r;return Array.from({length:i},(t,e)=>n===e?s.Complex.one():s.Complex.zero())})}};static fillFactory=t=>(...e)=>{const r=e.flat();return Array.from({length:r[0]*r.slice(2).reduce((t,e)=>t*e,1)},()=>Array.from({length:r[1]},t))};static zeros=l.fillFactory(()=>s.Complex.zero());static ones=l.fillFactory(()=>s.Complex.one());static diag=(t,e=0,...r)=>{const i=r.length>0?r.flat():[t.length,t.length],n=i[0],a=i[1];if(2===i.length)return Array.from({length:n},(r,i)=>Array.from({length:a},(r,n)=>i+e===n?t[i]:s.Complex.zero()));{const r=i.slice(2).reduce((t,e)=>t*e,1);return Array.from({length:n*r},(r,i)=>{const o=i%n;return Array.from({length:a},(r,i)=>o+e===i?t[o]:s.Complex.zero())})}};static from_diag=(t,e=0)=>{const r=[];for(let s=0;s<t.length-Math.abs(e);s++)r[s]=e>0?t[s][s+e]:t[s-e][s];return r};static lassq=t=>{const e=t.dimension[0],r=t.dimension[1];let i=s.Complex.zero(),n=s.Complex.one();for(let a=0;a<e;a++)for(let e=0;e<r;e++){const r=t.array[a][e];if(!s.Complex.realIsZero(r)){const t=s.Complex.abs(r);if(s.Complex.lt(i,t)){if(!s.Complex.realIsZero(i)){const e=s.Complex.rdiv(i,t);s.Complex.mulAndSumTo(n,n,s.Complex.mul(e,e))}i=t}else{const e=s.Complex.rdiv(t,i);s.Complex.mulAndSumTo(n,e,e)}}}return{scale:i,sumsq:n}};static lange=(t,e)=>{const r=e.dimension[0],i=e.dimension[1];switch(t){case"F":{const{scale:t,sumsq:r}=l.lassq(e);return s.Complex.realIsZero(t)?s.Complex.zero():s.Complex.mul(t,s.Complex.sqrt(r))}case"M":{let t=s.Complex.zero();for(let n=0;n<r;n++)for(let r=0;r<i;r++){const i=s.Complex.abs(e.array[n][r]);s.Complex.lt(t,i)&&(t=i)}return t}default:throw new Error(`lange: norm '${t}' not implemented`)}};static triu_inplace=t=>{const e=t.dimension.length>2?t.dimension.slice(2).reduce((t,e)=>t*e,1):1,r=t.dimension[0];for(let i=0;i<e;i++){const e=i*r;for(let r=0;r<t.dimension[0];r++){const i=t.array[e+r];for(let e=0;e<Math.min(r,t.dimension[1]);e++)i[e]=s.Complex.zero()}}i.MultiArray.setType(t)};static tril_inplace=t=>{const e=t.dimension.length>2?t.dimension.slice(2).reduce((t,e)=>t*e,1):1,r=t.dimension[0];for(let i=0;i<e;i++){const e=i*r;for(let r=0;r<t.dimension[0];r++){const i=t.array[e+r];for(let e=r+1;e<t.dimension[1];e++)i[e]=s.Complex.zero()}}i.MultiArray.setType(t)};static trsm_left_upper_block=(t,e,r)=>{const i=t[0].length;for(let n=e+r;n<i;n++)for(let i=r-1;i>=0;i--){const a=e+i;let o=t[a][n];for(let l=i+1;l<r;l++){const r=t[a][e+l],i=t[e+l][n];o=s.Complex.sub(o,s.Complex.mul(r,i))}const l=t[a][e+i];t[a][n]=s.Complex.rdiv(o,l)}};static lapmt_matrix=t=>{const e=t.length,r=new i.MultiArray([e,e]);for(let i=0;i<e;i++){const e=t[i];r.array[e][i]=s.Complex.one()}return i.MultiArray.setType(r),r};static lapmt_apply=(t,e)=>{const r=t.dimension[0],s=t.dimension[1];if(e.length!==s)throw new EvalError(`lapmt_apply: jpvt length (${e.length}) must match number of columns (${s}).`);const n=new Array(r);for(let e=0;e<r;e++)n[e]=t.array[e].slice();for(let i=0;i<s;i++){const s=e[i];for(let e=0;e<r;e++)t.array[e][i]=n[e][s]}i.MultiArray.setType(t)};static dotc_col=(t,e,r)=>{const i=t.dimension[0];if(r+1>=i)return s.Complex.zero();{const s=t.array.slice(r+1,i).map(t=>t[e]);return n.BLAS.dotc(s,s)}};static dotc_row=(t,e,r)=>{const i=t.dimension[1];if(r+1>=i)return s.Complex.zero();{const s=t.array[e].slice(r+1,i);return n.BLAS.dotc(s,s)}};static larfg=(t,e,r,i)=>{const n=r-i,a=new Array(n);if(a[0]=e.array[i][i],"L"===t)for(let t=1;t<n;t++)a[t]=e.array[i+t][i];else for(let t=1;t<n;t++)a[t]=e.array[i][i+t];const o=a[0],l=s.Complex.abs(o),c=s.Complex.realIsZero(l)?s.Complex.one():s.Complex.rdiv(o,l);let u=s.Complex.zero();for(let t=1;t<n;t++)u=s.Complex.add(u,s.Complex.mul(a[t],s.Complex.conj(a[t])));if(1===n||s.Complex.realIsZero(s.Complex.abs(u))){const t=s.Complex.zero(),e=new Array(n).fill(s.Complex.zero());return e[0]=s.Complex.one(),{tau:t,v:e,phi:c,alpha:o}}const h=s.Complex.sqrt(s.Complex.add(s.Complex.mul(o,s.Complex.conj(o)),u)),d=s.Complex.mul(s.Complex.neg(c),h),m=s.Complex.rdiv(s.Complex.sub(d,o),d),p=s.Complex.sub(o,d),f=new Array(n);f[0]=s.Complex.one();for(let t=1;t<n;t++)f[t]=s.Complex.rdiv(a[t],p);return{tau:m,v:f,phi:c,alpha:d}};static larfg_novo=(t,e,r,i)=>{const n=r-i,a=new Array(n);if(a[0]=e.array[i][i],"L"===t)for(let t=1;t<n;t++)a[t]=e.array[i+t][i];else for(let t=1;t<n;t++)a[t]=e.array[i][i+t];const o=a[0],l=s.Complex.abs(o),c=s.Complex.realIsZero(l)?s.Complex.one():s.Complex.rdiv(o,l);let u=s.Complex.zero();for(let t=1;t<n;t++)u=s.Complex.add(u,s.Complex.mul(a[t],s.Complex.conj(a[t])));if(1===n||s.Complex.realIsZero(s.Complex.abs(u))){const t=s.Complex.zero(),e=new Array(n).fill(s.Complex.zero());return e[0]=s.Complex.one(),{tau:t,v:e,phi:c,alpha:o}}const h=s.Complex.sqrt(s.Complex.add(s.Complex.mul(o,s.Complex.conj(o)),u)),d=s.Complex.mul(s.Complex.neg(c),h),m=s.Complex.rdiv(s.Complex.sub(d,o),d),p=s.Complex.sub(o,d),f=new Array(n);f[0]=s.Complex.one();for(let t=1;t<n;t++)f[t]=s.Complex.rdiv(a[t],p);return{tau:m,v:f,phi:c,alpha:d}};static larf_left=(t,e,r,i,n)=>{if(s.Complex.realIsZero(s.Complex.abs(r)))return;const a=e.length;for(let o=n;o<t.dimension[1];o++){let n=s.Complex.zero();for(let r=0;r<a;r++)s.Complex.mulAndSumTo(n,s.Complex.conj(e[r]),t.array[i+r][o]);if(n=s.Complex.mul(r,n),!s.Complex.realIsZero(s.Complex.abs(n)))for(let r=0;r<a;r++)t.array[i+r][o]=s.Complex.sub(t.array[i+r][o],s.Complex.mul(e[r],n))}};static larf=(t,e,r,i,n,a)=>{if(s.Complex.realIsZero(s.Complex.abs(i)))return;const o=e.dimension[0],l=e.dimension[1],c=r.length;if("L"===t){const t=new Array(l-a).fill(s.Complex.zero());for(let i=0;i<l-a;i++){let o=s.Complex.zero();for(let t=0;t<c;t++){const l=e.array[n+t][a+i];s.Complex.mulAndSumTo(o,s.Complex.conj(r[t]),l)}t[i]=o}for(let o=0;o<c;o++){const c=r[o],u=e.array[n+o];for(let e=0;e<l-a;e++)u[a+e]=s.Complex.sub(u[a+e],s.Complex.mul(i,s.Complex.mul(c,t[e])))}}else{const t=o-n,l=r.length,c=new Array(t);for(let i=0;i<t;i++){let t=s.Complex.zero();const o=e.array[n+i];for(let e=0;e<l;e++)s.Complex.mulAndSumTo(t,o[a+e],s.Complex.conj(r[e]));c[i]=t}for(let o=0;o<t;o++){const t=c[o];if(s.Complex.realIsZero(s.Complex.abs(t)))continue;const u=e.array[n+o];for(let e=0;e<l;e++)u[a+e]=s.Complex.sub(u[a+e],s.Complex.mul(i,s.Complex.mul(t,r[e])))}}};static larf_right_adjoint=(t,e,r,i,n)=>{if(s.Complex.realIsZero(s.Complex.abs(r)))return;const a=t.dimension[0],o=e.length,l=new Array(a-i).fill(s.Complex.zero());for(let r=i;r<a;r++){let a=s.Complex.zero();for(let i=0;i<o;i++)a=s.Complex.add(a,s.Complex.mul(t.array[r][n+i],e[i]));l[r-i]=a}const c=s.Complex.conj(r);for(let r=i;r<a;r++)for(let a=0;a<o;a++){const o=s.Complex.mul(c,s.Complex.mul(l[r-i],s.Complex.conj(e[a])));t.array[r][n+a]=s.Complex.sub(t.array[r][n+a],o)}};static larf_left_block=(t,e,r,a,o,l)=>{if(s.Complex.realIsZero(s.Complex.abs(r)))return;const c=t.dimension[0],u=t.dimension[1],h=e.length;if(a<0||a>=c)throw new Error("larf_left_block: invalid rowStart");if(o<0||o>=u)throw new Error("larf_left_block: invalid colStart");if(h!==c-a)throw new Error("larf_left_block: v length must equal m - rowStart");const d=Math.max(1,Math.floor(l??n.BLAS.settings.blockSize)),m=new i.MultiArray([h,1]);for(let t=0;t<h;t++)m.array[t][0]=e[t];const p=new i.MultiArray([1,h]);for(let t=0;t<h;t++)p.array[0][t]=s.Complex.conj(e[t]);for(let e=o;e<u;e+=d){const o=Math.min(e+d,u)-e,l=new i.MultiArray([h,o]);for(let r=0;r<h;r++)for(let s=0;s<o;s++)l.array[r][s]=t.array[a+r][e+s];const c=new i.MultiArray([1,o]);n.BLAS.gemm_block(p.array,l.array,c.array,s.Complex.one(),s.Complex.zero(),d);for(let t=0;t<o;t++)c.array[0][t]=s.Complex.mul(r,c.array[0][t]);for(let t=0;t<h;t++){const e=m.array[t][0];if(!s.Complex.realIsZero(s.Complex.abs(e)))for(let r=0;r<o;r++){const i=s.Complex.mul(e,c.array[0][r]);l.array[t][r]=s.Complex.sub(l.array[t][r],i)}}for(let r=0;r<h;r++)for(let s=0;s<o;s++)t.array[a+r][e+s]=l.array[r][s]}};static geqr2=t=>{const e=i.MultiArray.copy(t),r=e.dimension[0],n=e.dimension[1],a=Math.min(r,n),o=new Array(a),c=new Array(a);for(let t=0;t<a;t++){const{tau:i,v:a,phi:u,alpha:h}=l.larfg("L",e,r,t);e.array[t][t]=h;for(let r=1;r<a.length;r++)e.array[t+r][t]=s.Complex.mul(i,a[r]);t+1<n&&l.larf("L",e,a,i,t,t+1),o[t]=i,c[t]=u}return i.MultiArray.setType(e),{R:e,taus:o,phis:c}};static geqp2=t=>{const e=t.dimension[0],r=t.dimension[1],a=new Array(Math.min(e,r)),o=new Array(Math.min(e,r)),c=new Array(r);for(let t=0;t<r;t++)c[t]=t;const u=new Array(r),h=new Array(r);for(let e=0;e<r;e++){const r=n.BLAS.nrm2(t.array.map(t=>t[e]));u[e]=r,h[e]=r}const d=Math.min(e,r);for(let i=0;i<d;i++){let d=i,m=u[i];for(let t=i+1;t<r;t++)s.Complex.toBoolean(s.Complex.gt(u[t],m))&&(m=u[t],d=t);if(d!==i){for(let r=0;r<e;r++){const e=t.array[r][i];t.array[r][i]=t.array[r][d],t.array[r][d]=e}const r=u[i];u[i]=u[d],u[d]=r;const s=h[i];h[i]=h[d],h[d]=s;const n=c[i];c[i]=c[d],c[d]=n}const{tau:p,v:f,alpha:g,phi:y}=l.larfg("L",t,e,i);a[i]=p,o[i]=y,t.array[i][i]=g;for(let e=1;e<f.length;e++)t.array[i+e][i]=s.Complex.mul(p,f[e]);i+1<r&&l.larf("L",t,f,p,i,i+1);for(let a=i+1;a<r;a++){if(s.Complex.toBoolean(s.Complex.eq(u[a],s.Complex.zero())))continue;const r=s.Complex.abs(t.array[i][a]),o=s.Complex.rdiv(r,u[a]),l=s.Complex.sub(s.Complex.one(),s.Complex.mul(o,o)),c=s.Complex.toBoolean(s.Complex.gt(l,s.Complex.zero()))?l:s.Complex.zero();if(u[a]=s.Complex.mul(u[a],s.Complex.sqrt(c)),s.Complex.toBoolean(s.Complex.le(u[a],s.Complex.mul(s.Complex.onediv2(),h[a])))){const r=n.BLAS.nrm2(t.array.slice(i+1,e).map(t=>t[a]));u[a]=r,h[a]=r}}}return i.MultiArray.setType(t),{R:t,taus:a,phis:o,jpvt:c}};static geqp3=t=>{const e=i.MultiArray.copy(t),r=e.dimension[0],n=e.dimension[1],a=Math.min(r,n),o=new Array(a),c=new Array(a),u=new Array(n);for(let t=0;t<n;t++)u[t]=t;const h=new Array(n),d=new Array(n);for(let t=0;t<n;t++){let i=s.Complex.zero();for(let n=0;n<r;n++){const r=e.array[n][t],a=s.Complex.abs(r);s.Complex.mulAndSumTo(i,a,a)}const n=s.Complex.sqrt(i);h[t]=n,d[t]=n}for(let t=0;t<a;t++){let i=t,a=h[t];for(let e=t+1;e<n;e++)s.Complex.toBoolean(s.Complex.gt(h[e],a))&&(a=h[e],i=e);if(i!==t){for(let s=0;s<r;s++){const r=e.array[s][t];e.array[s][t]=e.array[s][i],e.array[s][i]=r}const s=u[t];u[t]=u[i],u[i]=s;const n=h[t];h[t]=h[i],h[i]=n;const a=d[t];d[t]=d[i],d[i]=a}const{tau:m,v:p,phi:f,alpha:g}=l.larfg("L",e,r,t);if(e.array[t][t]=g,s.Complex.realIsZero(s.Complex.abs(m)))for(let r=1;r<p.length;r++)e.array[t+r][t]=s.Complex.zero();else for(let r=1;r<p.length;r++)e.array[t+r][t]=s.Complex.mul(m,p[r]);t+1<n&&!s.Complex.realIsZero(s.Complex.abs(m))&&l.larf("L",e,p,m,t,t+1),o[t]=m,c[t]=f;for(let i=t;i>=0;i--){const t=r-i,n=new Array(t);n[0]=s.Complex.one();const a=o[i];if(s.Complex.realIsZero(s.Complex.abs(a)))for(let e=1;e<t;e++)n[e]=s.Complex.zero();else for(let r=1;r<t;r++)n[r]=s.Complex.rdiv(e.array[i+r][i],a)}for(let i=t+1;i<n;i++)if(s.Complex.toBoolean(s.Complex.ne(h[i],s.Complex.zero()))){const n=e.array[t][i],a=s.Complex.abs(n),o=s.Complex.sub(s.Complex.one(),s.Complex.rdiv(s.Complex.mul(a,a),s.Complex.mul(h[i],h[i]))),l=s.Complex.toBoolean(s.Complex.gt(o,s.Complex.zero()))?s.Complex.sqrt(o):s.Complex.zero(),c=s.Complex.mul(h[i],l),u=s.Complex.onediv2();if(s.Complex.toBoolean(s.Complex.le(c,s.Complex.mul(u,d[i])))){let n=s.Complex.zero();for(let a=t+1;a<r;a++){const t=e.array[a][i],r=s.Complex.abs(t);s.Complex.mulAndSumTo(n,r,r)}const a=s.Complex.sqrt(n);h[i]=a,d[i]=a}else h[i]=c}}return i.MultiArray.setType(e),{R:e,taus:o,phis:c,jpvt:u}};static gelq2=t=>{const e=t.dimension[0],r=t.dimension[1],n=Math.min(e,r),a=new Array(n),o=new Array(n);for(let i=0;i<n;i++){const{tau:n,v:c,alpha:u,phi:h}=l.larfg("R",t,r,i);a[i]=n,o[i]=h,t.array[i][i]=u;for(let e=1;e<c.length;e++)t.array[i][i+e]=c[e];i+1<e&&!s.Complex.realIsZero(s.Complex.abs(n))&&l.larf("R",t,c,n,i+1,i)}return i.MultiArray.setType(t),{L:t,taus:a,phis:o}};static orgqr=(t,e)=>{const r=t.dimension[0],n=t.dimension[1],a=Math.min(r,n),o=new i.MultiArray([r,r]);o.array=l.eye(r,r);for(let i=a-1;i>=0;i--){const n=r-i,a=[s.Complex.one()],c=e[i];if(s.Complex.realIsZero(s.Complex.abs(c)))for(let t=1;t<n;t++)a[t]=s.Complex.zero();else for(let e=1;e<n;e++)a[e]=s.Complex.rdiv(t.array[i+e][i],c);l.larf("L",o,a,c,i,0)}return i.MultiArray.setType(o),o};static orglq=(t,e)=>{const r=t.dimension[1],n=e.length,a=new i.MultiArray([r,r]);a.array=l.eye(r,r);for(let i=n-1;i>=0;i--){const n=e[i];if(s.Complex.realIsZero(s.Complex.abs(n)))continue;const o=r-i,c=new Array(o);c[0]=s.Complex.one();for(let e=1;e<o;e++)c[e]=t.array[i][i+e];l.larf("R",a,c,n,0,i)}return i.MultiArray.setType(a),a};static getf2=(t,e,r,i,n,a)=>{const o=[t.length,t[0].length],[c,u]=o,h=Math.min(e+r,Math.min(c,u));for(let r=e;r<h;r++){let e=r,h=s.Complex.abs(t[r][r]);for(let i=r+1;i<c;i++){const n=s.Complex.abs(t[i][r]);s.Complex.toBoolean(s.Complex.gt(n,h))&&(h=n,e=i)}i[r]=e,e!==r&&(l.laswp_rows(t,o,r,e),void 0!==n&&n.swaps++);const d=t[r][r];if(s.Complex.toBoolean(s.Complex.eq(s.Complex.abs(d),s.Complex.zero())))void 0!==a&&0===a.info&&(a.info=r+1);else{for(let e=r+1;e<c;e++)t[e][r]=s.Complex.rdiv(t[e][r],d);for(let e=r+1;e<c;e++){const i=t[e][r];if(s.Complex.toBoolean(s.Complex.eq(s.Complex.abs(i),s.Complex.zero())))continue;const n=t[e],a=t[r];for(let t=r+1;t<u;t++)n[t]=s.Complex.sub(n[t],s.Complex.mul(i,a[t]))}}}};static getrf=(t,e)=>{const r=t.length,i=t[0].length,a=Math.min(r,i),o=new Array(a);for(let t=0;t<a;t++)o[t]=t;const c={swaps:0},u={info:0};for(let h=0;h<a;h+=e??n.BLAS.settings.blockSize){const d=Math.min(e??n.BLAS.settings.blockSize,a-h);l.getf2(t,h,d,o,c,u);for(let e=h;e<h+d&&e<a;e++){const r=o[e];if(r!==e&&c.swaps++,r!==e&&h>0)for(let s=0;s<h;s++){const i=t[e][s];t[e][s]=t[r][s],t[r][s]=i}}const m=d,p=r-(h+m),f=i-(h+m);if(h+m<i){const e=t,r=[];for(let t=0;t<p;t++){const s=h+m+t,i=new Array(m);for(let t=0;t<m;t++)i[t]=e[s][h+t];r.push(i)}const i=[];for(let t=0;t<m;t++){const r=h+t,s=new Array(f);for(let t=0;t<f;t++)s[t]=e[r][h+m+t];i.push(s)}const a=[];for(let t=0;t<p;t++){const r=h+m+t,s=new Array(f);for(let t=0;t<f;t++)s[t]=e[r][h+m+t];a.push(s)}n.BLAS.gemm(s.Complex.neg(s.Complex.one()),r,p,m,i,f,s.Complex.one(),a);for(let t=0;t<p;t++){const r=h+m+t;for(let s=0;s<f;s++)e[r][h+m+s]=a[t][s]}for(let t=0;t<m;t++){const r=h+t;for(let s=0;s<f;s++)e[r][h+m+s]=i[t][s]}for(let t=0;t<p;t++){const s=h+m+t;for(let i=0;i<m;i++)e[s][h+i]=r[t][i]}}}return{LU:t,piv:o,swaps:c.swaps,info:u.info}};static getrf_blocked=(t,e)=>{const r=t.length,s=t[0].length,i=Math.min(r,s),a=new Array(i);for(let t=0;t<i;t++)a[t]=t;const o={swaps:0},c={info:0};for(let u=0;u<i;u+=e??n.BLAS.settings.blockSize){const h=Math.min(e??n.BLAS.settings.blockSize,i-u);l.getf2(t,u,h,a,o,c),u+h<s&&l.trsm_left_upper_block(t,u,h),u+h<r&&u+h<s&&l.gemm_blocked(t,u,h)}return{LU:t,piv:a,info:c.info,swaps:o.swaps}};static gemm_blocked=(t,e,r,i=64)=>{const n=e+r,a=e+r,o=t.length-(e+r),l=t[0].length-(e+r);if(o<=0||l<=0)return;const c=r,u=i;for(let r=0;r<o;r+=u){const i=Math.min(r+u,o);for(let o=0;o<l;o+=u){const h=Math.min(o+u,l);for(let l=r;l<i;l++){const r=t[n+l];for(let i=o;i<h;i++){let o=s.Complex.zero();for(let r=0;r<c;r++){const c=t[n+l][e+r],u=t[e+r][a+i];o=s.Complex.add(o,s.Complex.mul(c,u))}r[a+i]=s.Complex.sub(r[a+i],o)}}}}};static getrs=(t,e,r)=>{const i=t.length,a=t[0].length,o=r[0].length??1,l=n.BLAS.copy(r);for(let t=0;t<e.length;t++){const r=e[t];if(r!==t){const e=l[t];l[t]=l[r],l[r]=e}}for(let e=0;e<o;e++)for(let r=0;r<i;r++){let i=l[r][e];for(let n=0;n<r&&n<a;n++)i=s.Complex.sub(i,s.Complex.mul(t[r][n],l[n][e]));l[r][e]=i}for(let e=0;e<o;e++)for(let r=Math.min(a,i)-1;r>=0;r--){let i=l[r][e];for(let n=r+1;n<a;n++)i=s.Complex.sub(i,s.Complex.mul(t[r][n],l[n][e]));const n=t[r][r];l[r][e]=s.Complex.rdiv(i,n)}return l};static gesv=(t,e)=>{const r=n.BLAS.copy(t),s=n.BLAS.copy(e),{LU:i,piv:a,info:o}=l.getrf(r);return 0!==o?{X:s,info:o}:{X:l.getrs(i,a,s),info:0}};static posv=(t,e)=>{const r=n.BLAS.copy(t),s=n.BLAS.copy(e),{LU:i,piv:a,info:o}=l.getrf(r);if(0!==o)throw new Error(`posv: matrix is singular or not positive definite (info = ${o})`);return l.getrs(i,a,s)};static potrf=(t,e)=>{const r=e?.uplo??"lower",n=t.dimension[0];if(t.dimension[0]!==t.dimension[1])throw new Error("LAPACK.potrf: A must be square");const a=i.MultiArray.copy(t);if("lower"===r){for(let t=0;t<n;t++){let e=s.Complex.realToNumber(a.array[t][t]);for(let r=0;r<t;r++){const i=a.array[t][r];e-=s.Complex.realToNumber(s.Complex.mul(i,s.Complex.conj(i)))}if(e<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");a.array[t][t]=s.Complex.create(Math.sqrt(e));for(let e=t+1;e<n;e++){let r=a.array[e][t];for(let i=0;i<t;i++)r=s.Complex.sub(r,s.Complex.mul(a.array[e][i],s.Complex.conj(a.array[t][i])));a.array[e][t]=s.Complex.rdiv(r,a.array[t][t])}}for(let t=0;t<n;t++)for(let e=t+1;e<n;e++)a.array[t][e]=s.Complex.zero()}else{for(let t=0;t<n;t++){let e=s.Complex.realToNumber(a.array[t][t]);for(let r=0;r<t;r++){const i=a.array[r][t];e-=s.Complex.realToNumber(s.Complex.mul(i,s.Complex.conj(i)))}if(e<=0)throw new Error("LAPACK.potrf: matrix is not positive definite");a.array[t][t]=s.Complex.create(Math.sqrt(e));for(let e=t+1;e<n;e++){let r=a.array[t][e];for(let i=0;i<t;i++)r=s.Complex.sub(r,s.Complex.mul(s.Complex.conj(a.array[i][t]),a.array[i][e]));a.array[t][e]=s.Complex.rdiv(r,a.array[t][t])}}for(let t=1;t<n;t++)for(let e=0;e<t;e++)a.array[t][e]=s.Complex.zero()}return i.MultiArray.setType(a),a};static sysv=(t,e)=>{const r=n.BLAS.copy(t),s=n.BLAS.copy(e),{LU:i,piv:a,info:o}=l.getrf(r);if(0!==o)throw new Error(`sysv: matrix is singular (info = ${o})`);return l.getrs(i,a,s)};static mldivide=(t,e)=>{const[r,s]=t.dimension,[n,a]=e.dimension;if(s!==n)throw new EvalError(`operator \\: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);let o,c,u;if(l.is_hermitian(t.array))if(l.is_positive_definite(t.array)){const r=l.posv(t.array,e.array);o=new i.MultiArray([r.length,r[0].length]),o.array=r,c=0,u="posv"}else{const r=l.sysv(t.array,e.array);o=new i.MultiArray([r.length,r[0].length]),o.array=r,c=0,u="sysv"}else{const r=l.gesv(t.array,e.array);o=new i.MultiArray([r.X.length,r.X[0].length]),o.array=r.X,c=r.info,u="gesv"}return{X:o,info:c,solver:u}};static larfg_original=t=>{const e=t.length;if(0===e)return{tau:s.Complex.zero(),v:[],phi:s.Complex.one(),alpha:s.Complex.zero()};const r=t[0];let i=s.Complex.zero();for(let r=1;r<e;r++){const e=s.Complex.abs(t[r]);s.Complex.mulAndSumTo(i,e,e)}const n=s.Complex.abs(r),a=s.Complex.realIsZero(n)?s.Complex.one():s.Complex.rdiv(r,n);if(1===e||s.Complex.realIsZero(s.Complex.abs(i))){const t=s.Complex.zero(),i=new Array(e);i[0]=s.Complex.one();for(let t=1;t<e;t++)i[t]=s.Complex.zero();return{tau:t,v:i,phi:a,alpha:r}}{const n=s.Complex.sqrt(s.Complex.add(s.Complex.mul(r,s.Complex.conj(r)),i)),o=s.Complex.mul(s.Complex.neg(a),n),l=s.Complex.rdiv(s.Complex.sub(o,r),o),c=s.Complex.sub(r,o),u=new Array(e);u[0]=s.Complex.one();for(let r=1;r<e;r++)u[r]=s.Complex.rdiv(t[r],c);return{tau:l,v:u,phi:a,alpha:o}}};static sytrd=(t,e)=>{const r=t.dimension[0],i=new Array(r),n=new Array(r-1),a=new Array(r-1);for(let o=0;o<r-1;o++){const c=r-o-1,u=new Array(c);for(let e=0;e<c;e++)u[e]=s.Complex.copy(t.array[o+1+e][o]);const{alpha:h,v:d,tau:m}=l.larfg_original(u);a[o]=m,n[o]=h,t.array[o+1][o]=h;for(let e=1;e<c;e++)t.array[o+1+e][o]=d[e];s.Complex.realIsZero(s.Complex.abs(m))||e(t,d,s.Complex.conj(m),o+1,o+1),i[o]=s.Complex.copy(t.array[o][o])}return i[r-1]=s.Complex.copy(t.array[r-1][r-1]),{diag:i,offdiag:n,taus:a}};static her2_zhtrd_update=(t,e,r,i,n)=>{if(s.Complex.realIsZero(s.Complex.abs(r)))return;const a=e.length,o=new Array(a);for(let l=0;l<a;l++){let c=s.Complex.zero();for(let r=0;r<a;r++)s.Complex.mulAndSumTo(c,t.array[i+l][n+r],e[r]);o[l]=s.Complex.mul(r,c)}let l=s.Complex.zero();for(let t=0;t<a;t++)s.Complex.mulAndSumTo(l,s.Complex.conj(e[t]),o[t]);const c=s.Complex.mul(s.Complex.minusonediv2(),s.Complex.mul(r,l));for(let t=0;t<a;t++)s.Complex.mulAndSumTo(o[t],c,e[t]);for(let r=0;r<a;r++)for(let l=r;l<a;l++){const a=s.Complex.add(s.Complex.mul(e[r],s.Complex.conj(o[l])),s.Complex.mul(o[r],s.Complex.conj(e[l]))),c=i+r,u=n+l;t.array[c][u]=s.Complex.sub(t.array[c][u],a),r!==l&&(t.array[u][c]=s.Complex.conj(t.array[c][u]))}};static hetrd=t=>l.sytrd(t,l.her2_zhtrd_update);static ungtr=(t,e)=>{const r=t.dimension[0],n=new i.MultiArray([r,r]);n.array=l.eye([r,r]);for(let i=r-2;i>=0;i--){const a=e[i];if(!a||s.Complex.realIsZero(s.Complex.abs(a)))continue;const o=r-i-1,l=new Array(o);l[0]=s.Complex.one();for(let e=1;e<o;e++)l[e]=s.Complex.copy(t.array[i+1+e][i]);const c=new Array(r);for(let t=0;t<r;t++){let e=s.Complex.zero();for(let r=0;r<o;r++)s.Complex.mulAndSumTo(e,s.Complex.conj(l[r]),n.array[i+1+r][t]);c[t]=e}for(let t=0;t<o;t++){const e=s.Complex.mul(a,l[t]);for(let a=0;a<r;a++)n.array[i+1+t][a]=s.Complex.sub(n.array[i+1+t][a],s.Complex.mul(e,c[a]))}}return n};static sytrd_blocked_w=(t,e)=>{const r=t.dimension[0];if(r!==t.dimension[1])throw new Error("sytrd_blocked_w: A must be square");const i=new Array(r),a=new Array(r),o=new Array(r);if(0===r)return{diag:i,offdiag:a,taus:o};if(1===r)return i[0]=t.array[0][0],a[0]=s.Complex.zero(),o[0]=s.Complex.zero(),{diag:i,offdiag:a,taus:o};const c=Math.max(1,Math.floor(e??n.BLAS.settings.blockSize));for(let e=0;e<r-1;e+=c){const n=Math.min(c,r-1-e),u=new Array(r-e-1),h=new Array(r-e-1);for(let t=0;t<r-e-1;t++)u[t]=new Array(n).fill(s.Complex.zero()),h[t]=new Array(n).fill(s.Complex.zero());for(let c=0;c<n;c++){const n=e+c,d=r-n-1,m=new Array(d);for(let e=0;e<d;e++)m[e]=t.array[n+1+e][n];const p=l.larfg_original(m),f=p.v,g=p.tau,y=p.alpha;o[n]=g,i[n]=t.array[n][n],a[n]=y;for(let e=0;e<d;e++)t.array[n+1+e][n]=f[e],u[e][c]=f[e];if(!s.Complex.realIsZero(s.Complex.abs(g)))for(let e=0;e<d;e++){let r=s.Complex.zero();for(let i=0;i<=e;i++)r=s.Complex.add(r,s.Complex.mul(u[i][c],s.Complex.conj(t.array[n+1+i][n+1+e])));h[e][c]=s.Complex.mul(g,r)}}for(let i=0;i<r-e-1;i++)for(let a=i;a<r-e-1;a++){let r=s.Complex.zero(),o=s.Complex.zero();for(let t=0;t<n;t++)r=s.Complex.add(r,s.Complex.mul(u[i][t],s.Complex.conj(h[a][t]))),o=s.Complex.add(o,s.Complex.mul(h[i][t],s.Complex.conj(u[a][t])));t.array[e+1+i][e+1+a]=s.Complex.sub(t.array[e+1+i][e+1+a],s.Complex.add(r,o)),i!==a&&(t.array[e+1+a][e+1+i]=s.Complex.conj(t.array[e+1+i][e+1+a]))}}return i[r-1]=t.array[r-1][r-1],a[r-1]=s.Complex.zero(),o[r-1]=s.Complex.zero(),{diag:i,offdiag:a,taus:o}};static tridiagonal_hermitian_to_dense=(t,e)=>{const r=t.length,i=Array.from({length:r},()=>Array.from({length:r},()=>s.Complex.zero()));for(let n=0;n<r;n++)i[n][n]=s.Complex.copy(t[n]),n<r-1&&(i[n][n+1]=s.Complex.copy(e[n]),i[n+1][n]=s.Complex.conj(e[n]));return i};static hermitian_to_real2n=t=>{const e=t.length,r=Array.from({length:2*e},t=>Array.from({length:2*e}));for(let i=0;i<e;i++)for(let n=0;n<e;n++){const a=t[i][n];r[i][n]=s.Complex.real(a),r[i][n+e]=s.Complex.neg(s.Complex.imag(a)),r[i+e][n]=s.Complex.imag(a),r[i+e][n+e]=s.Complex.real(a)}return r};static real2n_to_complex_eigenvectors=t=>{const e=t.length/2,r=Array.from({length:e},t=>Array.from({length:e}));for(let i=0;i<e;i++)for(let n=0;n<e;n++){const a=t[n][i],o=t[n+e][i];r[n][i]=s.Complex.create(a.re,o.re)}return r};static real2n_to_complex_eigenvalues=t=>{const e=t.length/2,r=new Array(e);for(let i=0;i<e;i++){const n=t[i].re,a=t[i+e].re;r[i]=s.Complex.create(n,a)}return r};static jacobi_real_symmetric_dense=(t,e=1e3,r=1e-14)=>{const i=t.length;if(0===i)return{D:[],V:[]};if(1===i)return{D:[t[0][0]],V:[[s.Complex.one()]]};const n=l.eye([i,i]);for(let a=0;a<(0,s.toNumber)(e);a++){let e=s.Complex.zero();for(let a=0;a<i-1;a++)for(let o=a+1;o<i;o++){const l=t[a][o];if(e=s.Complex.max(e,s.Complex.abs(l)),s.Complex.realLessThan(s.Complex.abs(l),r))continue;const c=t[a][a],u=t[o][o],h=s.Complex.mul(s.Complex.two(),l);if(s.Complex.toBoolean(s.Complex.eq(h,s.Complex.zero())))continue;const d=s.Complex.rdiv(s.Complex.sub(u,c),h),m=s.Complex.toBoolean(s.Complex.ge(d,s.Complex.zero()))?s.Complex.one():s.Complex.minusone(),p=s.Complex.rdiv(m,s.Complex.add(s.Complex.abs(d),s.Complex.sqrt(s.Complex.add(s.Complex.one(),s.Complex.mul(d,d))))),f=s.Complex.rdiv(s.Complex.one(),s.Complex.sqrt(s.Complex.add(s.Complex.one(),s.Complex.mul(p,p)))),g=s.Complex.mul(p,f);for(let e=0;e<i;e++)if(e!==a&&e!==o){const r=t[e][a],i=t[e][o];t[e][a]=s.Complex.sub(s.Complex.mul(f,r),s.Complex.mul(g,i)),t[a][e]=t[e][a],t[e][o]=s.Complex.add(s.Complex.mul(g,r),s.Complex.mul(f,i)),t[o][e]=t[e][o]}t[a][a]=s.Complex.add(s.Complex.sub(s.Complex.mul(s.Complex.mul(f,f),c),s.Complex.mul(s.Complex.mul(s.Complex.mul(s.Complex.two(),g),f),l)),s.Complex.mul(s.Complex.mul(g,g),u)),t[o][o]=s.Complex.add(s.Complex.add(s.Complex.mul(s.Complex.mul(g,g),c),s.Complex.mul(s.Complex.mul(s.Complex.mul(s.Complex.two(),g),f),l)),s.Complex.mul(s.Complex.mul(f,f),u)),t[a][o]=s.Complex.zero(),t[o][a]=s.Complex.zero();for(let t=0;t<i;t++){const e=n[t][a],r=n[t][o];n[t][a]=s.Complex.sub(s.Complex.mul(f,e),s.Complex.mul(g,r)),n[t][o]=s.Complex.add(s.Complex.mul(g,e),s.Complex.mul(f,r))}}if(s.Complex.realLessThan(e,r))break}return{D:l.from_diag(t),V:n}};static jacobi_symmetric_hermitian=(t,e,r)=>{const i=t.length,n=Array.from({length:i},(t,e)=>Array.from({length:i},(t,r)=>e===r?s.Complex.create(1):s.Complex.zero())),a=r??1e-12,o=e??Math.max(50,Math.floor(1e3/Math.max(1,i))),l=t=>{let e=0;for(let r=0;r<i;r++)for(let n=r+1;n<i;n++){const i=s.Complex.abs(t[r][n]),a=s.Complex.realToNumber(i);e+=a*a}return Math.sqrt(e)};for(let e=0;e<o;e++){let e=!1;for(let r=0;r<i-1;r++)for(let o=r+1;o<i;o++){const l=t[r][o];if(s.Complex.realToNumber(s.Complex.le(s.Complex.abs(l),s.Complex.create(a))))continue;const c=t[r][r],u=t[o][o],h=s.Complex.realToNumber(s.Complex.real(l)),d=s.Complex.realToNumber(s.Complex.real(c)),m=s.Complex.realToNumber(s.Complex.real(u)),p=.5*Math.atan2(2*h,m-d),f=Math.cos(p),g=Math.sin(p);for(let e=0;e<i;e++){if(e===r||e===o)continue;const i=t[e][r],n=t[e][o];t[e][r]=s.Complex.sub(s.Complex.mul(s.Complex.create(f),i),s.Complex.mul(s.Complex.create(g),n)),t[r][e]=s.Complex.conj(t[e][r]),t[e][o]=s.Complex.add(s.Complex.mul(s.Complex.create(g),i),s.Complex.mul(s.Complex.create(f),n)),t[o][e]=s.Complex.conj(t[e][o])}const y=s.Complex.add(s.Complex.sub(s.Complex.mul(s.Complex.create(f*f),c),s.Complex.mul(s.Complex.create(2*g*f),l)),s.Complex.mul(s.Complex.create(g*g),u)),x=s.Complex.add(s.Complex.add(s.Complex.mul(s.Complex.create(g*g),c),s.Complex.mul(s.Complex.create(2*g*f),l)),s.Complex.mul(s.Complex.create(f*f),u));t[r][r]=y,t[o][o]=x,t[r][o]=s.Complex.zero(),t[o][r]=s.Complex.zero();for(let t=0;t<i;t++){const e=n[t][r],i=n[t][o];n[t][r]=s.Complex.sub(s.Complex.mul(s.Complex.create(f),e),s.Complex.mul(s.Complex.create(g),i)),n[t][o]=s.Complex.add(s.Complex.mul(s.Complex.create(g),e),s.Complex.mul(s.Complex.create(f),i))}e=!0}if(!e)break;if(l(t)<=a)break}const c=new Array(i);for(let e=0;e<i;e++)c[e]=t[e][e];return{D:c,V:n}};static column_pivot=(t,e,r=0,i=t.length)=>{const n=t.slice(r,i).map(t=>s.Complex.abs(t[e])),a=n.reduce((t,e,r,i)=>s.Complex.toBoolean(s.Complex.gt(e,i[t]))?r:t,0);return{pivotRow:a,pivotAbs:n[a],pivotIsZero:s.Complex.realIsZero(n[a])}};static normalize_eigenvector_phases=(t,e=!0)=>{const r=t.length,i=t[0].length;for(let n=0;n<i;n++){const{pivotRow:i,pivotAbs:a,pivotIsZero:o}=l.column_pivot(t,n);if(o)continue;const c=t[i][n];let u=s.Complex.rdiv(s.Complex.conj(c),a);e&&s.Complex.realLessThan(s.Complex.mul(c,u),0)&&(u=s.Complex.neg(u));for(let e=0;e<r;e++)t[e][n]=s.Complex.mul(t[e][n],u)}};static steqr_vectors=(t,e,r=1e3*t.length)=>{const i=t.length,n=t.map(t=>s.Complex.copy(t)),a=e.map(t=>s.Complex.copy(t));a[i-1]=s.Complex.zero();let o=!1;for(let t=0;t<i;t++)if(s.Complex.isComplexValue(n[t])||t<i-1&&s.Complex.isComplexValue(a[t])){o=!0;break}const c=new Array(i);let u=n.slice(),h=new Array(i);if(o){c[0]=s.Complex.one();for(let t=0;t<i-1;t++){const e=a[t],r=s.Complex.abs(e);if(s.Complex.realIsZero(r))c[t+1]=s.Complex.copy(c[t]);else{const i=s.Complex.rdiv(s.Complex.conj(e),r);c[t+1]=s.Complex.mul(c[t],i)}}for(let t=0;t<i-1;t++){const e=s.Complex.mul(s.Complex.conj(c[t]),s.Complex.mul(a[t],c[t+1]));h[t]=s.Complex.abs(e)}}else for(let t=0;t<i-1;t++)h[t]=s.Complex.copy(a[t]);h[i-1]=s.Complex.zero();const d=l.tridiagonal_hermitian_to_dense(u,h),m=l.jacobi_real_symmetric_dense(d,r);let p=m.D.map(t=>s.Complex.copy(t)),f=m.V.map(t=>t.map(t=>s.Complex.copy(t)));if(o)for(let t=0;t<i;t++)for(let e=0;e<i;e++)f[t][e]=s.Complex.mul(c[t],f[t][e]);const g=p.map((t,e)=>({v:t,i:e})).sort((t,e)=>s.Complex.realToNumber(t.v)-s.Complex.realToNumber(e.v)),y=Array.from({length:i},()=>Array(i)),x=g.map(t=>t.v);for(let t=0;t<i;t++){const e=g[t].i;for(let r=0;r<i;r++)y[r][t]=s.Complex.copy(f[r][e])}return l.normalize_eigenvector_phases(y),{D:x,V:y,complex:o}};static steqr_vectors_tridiagonal=(t,e,r=1e3)=>{const i=t.length;if(0===i)return{D:[],V:[]};if(1===i)return{D:[s.Complex.copy(t[0])],V:[[s.Complex.one()]]};const n=t.map(t=>s.Complex.copy(t)),a=e.map(t=>s.Complex.copy(t)),o=Array.from({length:i},(t,e)=>Array.from({length:i},(t,r)=>e===r?s.Complex.one():s.Complex.zero())),l=Number.EPSILON||2220446049250313e-31;let c=0;for(;c<r;){let t=0;for(;t<i-1&&s.Complex.realLessThanOrEqualTo(s.Complex.abs(a[t]),l);)t++;if(t>=i-1)break;let e=t;for(;e<i-2&&s.Complex.realGreaterThan(s.Complex.abs(a[e]),l);)e++;const r=n[e],u=n[e+1],h=a[e],d=s.Complex.mul(s.Complex.sub(r,u),s.Complex.create(.5)),m=s.Complex.abs(d),p=s.Complex.power(s.Complex.abs(h),s.Complex.two()),f=s.Complex.add(m,s.Complex.sqrt(s.Complex.add(s.Complex.mul(m,m),p))),g=s.Complex.realGreaterThanOrEqualTo(d,0)?s.Complex.one():s.Complex.minusone(),y=s.Complex.sub(u,s.Complex.rdiv(s.Complex.mul(g,p),f));let x=s.Complex.sub(n[t],y),C=a[t];for(let r=t;r<=e;r++){const t=s.Complex.sqrt(s.Complex.add(s.Complex.power(s.Complex.abs(x),s.Complex.two()),s.Complex.power(s.Complex.abs(C),s.Complex.two())));if(s.Complex.realEquals(t,0))continue;const l=s.Complex.rdiv(x,t),c=s.Complex.rdiv(C,t),u=n[r],h=n[r+1];n[r]=s.Complex.add(s.Complex.mul(s.Complex.conj(l),s.Complex.mul(l,u)),s.Complex.mul(s.Complex.conj(c),s.Complex.mul(c,h))),n[r+1]=s.Complex.add(s.Complex.mul(s.Complex.conj(c),s.Complex.mul(c,u)),s.Complex.mul(s.Complex.conj(l),s.Complex.mul(l,h))),a[r]=s.Complex.zero(),r<e&&(x=a[r],C=a[r+1]);for(let t=0;t<i;t++){const e=o[t][r],i=o[t][r+1];o[t][r]=s.Complex.sub(s.Complex.mul(l,e),s.Complex.mul(c,i)),o[t][r+1]=s.Complex.add(s.Complex.mul(s.Complex.conj(c),e),s.Complex.mul(l,i))}}c++}return{D:n,V:o}};static steqr_values=(t,e,r)=>l.steqr_vectors(t,e,r).D;static orgtr=(t,e)=>{const r=t.dimension[0];if(r!==t.dimension[1])throw new Error("orgtr: A must be square");const n=new i.MultiArray([r,r]);n.array=l.eye(r,r);for(let i=r-2;i>=0;i--){const a=r-i-1,o=new Array(a);for(let e=0;e<a;e++)o[e]=t.array[i+1+e][i];const c=e[i];s.Complex.realIsZero(s.Complex.abs(c))||l.larf_left(n,o,c,i+1,0)}return i.MultiArray.setType(n),n};static orgtr_blocked=(t,e,r)=>{const a=t.dimension[0];if(a!==t.dimension[1])throw new Error("orgtr_blocked: A must be square");const o=new i.MultiArray([a,a]);o.array=l.eye(a,a);const c=Math.max(1,Math.floor(r??n.BLAS.settings.blockSize));for(let r=a-2-(a-2)%c;r>=0;r-=c){for(let i=Math.min(c,a-1-r)-1;i>=0;i--){const n=r+i,u=a-n-1;if(u<=0)continue;const h=new Array(u);for(let e=0;e<u;e++)h[e]=t.array[n+1+e][n];const d=e[n];s.Complex.realIsZero(s.Complex.abs(d))||l.larf_left_block(o,h,d,n+1,0,c)}if(0===r)break}return i.MultiArray.setType(o),o};static orgtr_blocked_w=(t,e,r)=>{const a=t.dimension[0];if(a!==t.dimension[1])throw new Error("orgtr_blocked_w: A must be square");const o=new i.MultiArray([a,a]);o.array=l.eye(a,a);const c=Math.max(1,Math.floor(r??n.BLAS.settings.blockSize));for(let r=a-2;r>=0;r-=c){const i=Math.min(c,r+1),n=new Array(a-r-1),l=new Array(a-r-1);for(let t=0;t<a-r-1;t++)n[t]=new Array(i).fill(s.Complex.zero()),l[t]=new Array(i).fill(s.Complex.zero());for(let e=0;e<i;e++){const s=r-i+1+e,o=a-s-1;for(let r=0;r<o;r++)n[r][e]=t.array[s+1+r][s]}for(let t=0;t<i;t++){const c=r-i+1+t,u=e[c],h=a-c-1;if(!s.Complex.realIsZero(s.Complex.abs(u)))for(let e=0;e<h;e++){let r=s.Complex.zero();for(let i=0;i<=e;i++)r=s.Complex.add(r,s.Complex.mul(n[i][t],s.Complex.conj(o.array[c+1+i][c+1+e])));l[e][t]=s.Complex.mul(u,r)}}for(let t=0;t<a-r-1;t++)for(let e=0;e<a;e++){let a=s.Complex.zero(),c=s.Complex.zero();for(let o=0;o<i;o++)a=s.Complex.add(a,s.Complex.mul(n[t][o],s.Complex.conj(l[e-r-1+t]?.[o]??s.Complex.zero()))),c=s.Complex.add(c,s.Complex.mul(l[t][o],s.Complex.conj(n[e-r-1+t]?.[o]??s.Complex.zero())));o.array[r+1+t][e]=s.Complex.sub(o.array[r+1+t][e],s.Complex.add(a,c))}}return o};static eig_symmetric=(t,e=!1)=>{t.dimension[0];const r=i.MultiArray.copy(t),{diag:s,offdiag:n,taus:a}=l.hetrd(r);if(e){let t=l.ungtr(r,a);const{D:e,V:o}=l.steqr_vectors(s,n),c=new i.MultiArray([o.length,o[0].length]);return c.array=o,t=l.mtimes(t,c),{D:i.MultiArray.toDiagonalMatrix(e),V:t}}return{D:i.MultiArray.toColumnVector(l.steqr_vectors(s,n).D)}};static eig_hermitian=(t,e=!1)=>{const r=t.dimension[0],n=i.MultiArray.copy(t);let a=!1;for(let t=0;t<r&&!a;t++)for(let e=0;e<r;e++){const r=n.array[t][e];if(!s.Complex.imagIsZero(r)){a=!0;break}}if(a){const{diag:t,offdiag:s,taus:a}=l.hetrd(n);if(!e){const{D:e}=l.steqr_vectors(t,s);return{D:i.MultiArray.toColumnVector(e)}}let o=l.ungtr(n,a);console.log("Q =",o);const{D:c,V:u}=l.steqr_vectors(t,s),h=new i.MultiArray([r,r]);return h.array=u,o=l.mtimes(o,h),{D:i.MultiArray.toDiagonalMatrix(c),V:o}}{const{diag:t,offdiag:s,taus:a}=l.hetrd(n);if(!e){const{D:e}=l.steqr_vectors(t,s);return{D:i.MultiArray.toColumnVector(e)}}let o=l.ungtr(n,a);const{D:c,V:u}=l.steqr_vectors(t,s),h=new i.MultiArray([r,r]);return h.array=u,o=l.mtimes(o,h),{D:i.MultiArray.toDiagonalMatrix(c),V:o}}};static functions={is_hermitian:l.is_hermitian,is_positive_definite:l.is_positive_definite,laswp:l.laswp,laswp_rows:l.laswp_rows,laswp_cols:l.laswp_cols,eye:l.eye,fillFactory:l.fillFactory,zeros:l.zeros,ones:l.ones,diag:l.diag,from_diag:l.from_diag,lassq:l.lassq,lange:l.lange,triu_inplace:l.triu_inplace,tril_inplace:l.tril_inplace,trsm_left_upper_block:l.trsm_left_upper_block,lapmt_matrix:l.lapmt_matrix,lapmt_apply:l.lapmt_apply,dotc_col:l.dotc_col,dotc_row:l.dotc_row,larfg:l.larfg,larf:l.larf,geqr2:l.geqr2,geqp2:l.geqp2,geqp3:l.geqp3,gelq2:l.gelq2,orgqr:l.orgqr,orglq:l.orglq,getf2:l.getf2,getrf:l.getrf,getrf_blocked:l.getrf_blocked,gemm_blocked:l.gemm_blocked,getrs:l.getrs,gesv:l.gesv,posv:l.posv,potrf:l.potrf,sysv:l.sysv,mldivide:l.mldivide,sytrd:l.sytrd,her2_zhtrd_update:l.her2_zhtrd_update,hetrd:l.hetrd,ungtr:l.ungtr,sytrd_blocked_w:l.sytrd_blocked_w,tridiagonal_hermitian_to_dense:l.tridiagonal_hermitian_to_dense,hermitian_to_real2n:l.hermitian_to_real2n,real2n_to_complex_eigenvectors:l.real2n_to_complex_eigenvectors,real2n_to_complex_eigenvalues:l.real2n_to_complex_eigenvalues,jacobi_real_symmetric_dense:l.jacobi_real_symmetric_dense,jacobi_symmetric_hermitian:l.jacobi_symmetric_hermitian,column_pivot:l.column_pivot,normalize_eigenvector_phases:l.normalize_eigenvector_phases,steqr_vectors:l.steqr_vectors,steqr_vectors_tridiagonal:l.steqr_vectors_tridiagonal,steqr_values:l.steqr_values,orgtr:l.orgtr,orgtr_blocked:l.orgtr_blocked,orgtr_blocked_w:l.orgtr_blocked_w,eig_symmetric:l.eig_symmetric,eig_hermitian:l.eig_hermitian}}e.LAPACK=l},7645(t,e,r){"use strict";e.LexerErrorListener=void 0;const s=r(3222),i=r(2697);class n extends s.ErrorListener{source;constructor(t=""){super(),this.source=t}syntaxError(t,e,r,s,n,a){if(!i.SyntaxDiagnostic.isBenignEndOfInput(n))throw i.SyntaxDiagnostic.error(n,r,s,this.source)}}e.LexerErrorListener=n},4610(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LinearAlgebra=e.LinearAlgebraConfigKeyTable=void 0;const s=r(845),i=r(5956),n=r(7679),a=r(6115),o=r(227),l=r(6109);e.LinearAlgebraConfigKeyTable=["wasteLU","qrPhaseEpsilon"];const c=new Set(e.LinearAlgebraConfigKeyTable),u={wasteLU:1e-15,qrPhaseEpsilon:1e-300};class h{static defaultSettings=Object.assign({},u);static settings=h.defaultSettings;static set=t=>{Object.entries(t).forEach(t=>{if(!c.has(t[0]))throw new Error(`LinearAlgebra.set: invalid configuration parameter: ${t[0]}`);h.settings[t[0]]=t[1]})};static eyeSignature={inputs:[{arity:0},{arity:1,parameters:[{name:"dimensions",classes:["double"],validators:["dimension"],alternatives:[{name:"dimensions",validators:["dimensionVector","oneOrTwoElement"]}]}]},{arity:2,parameters:[{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}};static eye=(...t)=>{let e=0,r=0;if(0===t.length)return s.Complex.one();if(1===t.length)if(n.MultiArray.isInstanceOf(t[0])){const s=n.MultiArray.linearize(t[0]);if(0===s.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");if(1===s.length)e=n.MultiArray.testIndex(s[0]),r=e;else{if(2!==s.length)throw new SyntaxError("eye (A): use eye (size (A)) instead");e=n.MultiArray.testIndex(s[0]),r=n.MultiArray.testIndex(s[1])}}else e=n.MultiArray.testIndex(t[0]),r=e;else 2===t.length&&s.Complex.isInstanceOf(t[0])&&s.Complex.isInstanceOf(t[1])?(e=n.MultiArray.testIndex(t[0]),r=n.MultiArray.testIndex(t[1])):l.AST.throwInvalidCallError("eye");const i=new n.MultiArray([e,r],s.Complex.zero());for(let t=0;t<Math.min(i.dimension[0],i.dimension[1]);t++)i.array[t][t]=s.Complex.one();return i};static diagSignature={inputs:[{arity:1,parameters:[{name:"value",classes:["double"]}]},{arity:2,parameters:[{name:"value",classes:["double"]},{name:"offset",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},{arity:3,parameters:[{name:"value",classes:["double"],validators:["vector"]},{name:"rows",classes:["double"],validators:["dimension"]},{name:"columns",classes:["double"],validators:["dimension"]}]}],outputs:{arity:1}};static diag=(...t)=>{let e;if(t.length>0&&t.length<=3)if(n.MultiArray.isInstanceOf(t[0])){if(2!==t[0].dimension.length)throw new Error("Matrix must be 2-dimensional");if(1===t.length)if(1===t[0].dimension[0]&&t[0].dimension[1]>1){const r=t[0].dimension[1];e=new n.MultiArray([r,r]),e.array=o.LAPACK.diag(t[0].array[0])}else if(1===t[0].dimension[1]&&t[0].dimension[0]>1){const r=t[0].dimension[0];e=new n.MultiArray([r,r]),e.array=o.LAPACK.diag(t[0].array.map(t=>t[0]))}else e=n.MultiArray.toColumnVector(o.LAPACK.from_diag(t[0].array));else if(2===t.length){const r=Math.floor(s.Complex.realToNumber(n.MultiArray.firstElement(t[1])));if(1===t[0].dimension[0]&&t[0].dimension[1]>1){const s=t[0].dimension[1];e=new n.MultiArray([s,s]),e.array=o.LAPACK.diag(t[0].array[0],r)}else if(1===t[0].dimension[1]&&t[0].dimension[0]>1){const s=t[0].dimension[0];e=new n.MultiArray([s,s]),e.array=o.LAPACK.diag(t[0].array.map(t=>t[0]),r)}else e=n.MultiArray.toColumnVector(o.LAPACK.from_diag(t[0].array,r))}else{const r=Math.floor(s.Complex.realToNumber(n.MultiArray.firstElement(t[1]))),i=Math.floor(s.Complex.realToNumber(n.MultiArray.firstElement(t[2])));if(e=new n.MultiArray([r,i]),e.array=o.LAPACK.diag(t[0].array[0],0,[r,i]),1===t[0].dimension[0]&&t[0].dimension[1]>1)e.array=o.LAPACK.diag(t[0].array[0],0,r,i);else{if(!(1===t[0].dimension[1]&&t[0].dimension[0]>1))throw new Error("diag: V must be a vector");e.array=o.LAPACK.diag(t[0].array.map(t=>t[0]),0,r,i)}}}else e=new n.MultiArray([1,1],t[0].copy());else l.AST.throwInvalidCallError("diag");return e};static traceSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static trace=t=>{if(2===t.dimension.length)return t.array.map((t,e)=>t[e]?t[e]:s.Complex.zero()).reduce((t,e)=>s.Complex.add(t,e),s.Complex.zero());throw new Error("trace: only valid on 2-D objects")};static applyTranspose=(t,e=t=>t)=>{if(2===t.dimension.length){const r=new n.MultiArray([t.dimension[1],t.dimension[0]],void 0,t.isCell);for(let s=0;s<t.dimension[1];s++){r.array[s]=new Array(t.dimension[0]);for(let i=0;i<t.dimension[0];i++)r.array[s][i]=e(t.array[i][s]).copy()}return r.type=t.type,r.isCell=t.isCell,r}throw new Error("transpose not defined for N-D objects")};static transposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static transpose=t=>{const e=i.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):t;return s.Complex.isInstanceOf(e)?s.Complex.copy(e):h.applyTranspose(e)};static ctransposeSignature={inputs:{arity:1,parameters:[{name:"value"}]},outputs:{arity:1}};static ctranspose=t=>{const e=i.CharString.isInstanceOf(t)?n.MultiArray.characterVectorFromCharString(t):t;return s.Complex.isInstanceOf(e)?s.Complex.conj(e):h.applyTranspose(e,t=>e.isCell||!s.Complex.isInstanceOf(t)?t:s.Complex.conj(t))};static mulSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static mul(t,e){if(t.dimension[1]!==e.dimension[0]||2!==t.dimension.length||2!==e.dimension.length)throw new EvalError(`operator *: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is ${e.dimension.join("x")}).`);{const r=new n.MultiArray([t.dimension[0],e.dimension[1]]);return a.BLAS.gemm(s.Complex.one(),t.array,t.dimension[0],t.dimension[1],e.array,e.dimension[1],s.Complex.zero(),r.array),n.MultiArray.setType(r),r}}static powerSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"exponent",classes:["double"],validators:["numeric","scalar","real","finite","integer"]}]},outputs:{arity:1}};static multiplyMatrices=(t,e)=>{const r=new n.MultiArray([t.dimension[0],e.dimension[1]]);return a.BLAS.gemm(s.Complex.one(),t.array,t.dimension[0],t.dimension[1],e.array,e.dimension[1],s.Complex.zero(),r.array),n.MultiArray.setType(r),r};static formatDimensions=t=>t.dimension.join("x");static hermitianEigenExpansion=(t,e)=>{if(!o.LAPACK.is_hermitian(t.array))throw new Error("invalid exponent in '^'.");const r=o.LAPACK.jacobi_symmetric_hermitian(a.BLAS.copy(t.array),1e3,1e-14),s=new n.MultiArray([t.dimension[0],t.dimension[1]]);s.array=r.V;const i=n.MultiArray.toDiagonalMatrix(r.D.map(e)),l=h.multiplyMatrices(s,i);return h.multiplyMatrices(l,h.ctranspose(s))};static power=(t,e)=>{if(2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new EvalError("operator ^: only square matrices can be raised to scalar powers.");if(s.Complex.realIsInteger(e)&&s.Complex.imagEquals(e,0)){let r=Math.abs(s.Complex.realToNumber(e)),i=h.eye(s.Complex.create(t.dimension[0],0)),a=s.Complex.realGreaterThan(e,0)||s.Complex.realEquals(e,0)?n.MultiArray.copy(t):h.inv(t);for(;r>0;)r%2==1&&(i=h.multiplyMatrices(i,a)),r=Math.floor(r/2),r>0&&(a=h.multiplyMatrices(a,a));return i}return h.hermitianEigenExpansion(t,t=>s.Complex.power(t,e))};static scalarPower=(t,e)=>{if(2!==e.dimension.length||e.dimension[0]!==e.dimension[1])throw new EvalError("operator ^: matrix exponent must be square when base is scalar.");return h.hermitianEigenExpansion(e,e=>s.Complex.power(t,e))};static detSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}};static det=t=>{if(2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new EvalError("det: matrix must be square.");const e=t.dimension[0];if(0===e)return s.Complex.create(1,0);if(1===e)return t.array[0][0];if(2===e)return s.Complex.sub(s.Complex.mul(t.array[0][0],t.array[1][1]),s.Complex.mul(t.array[0][1],t.array[1][0]));const{U:r,swaps:i}=h.luDecomposition(t);let n=s.Complex.one();for(let t=0;t<e;t++){const e=r.array[t][t];if(s.Complex.realIsZero(s.Complex.abs(e)))return s.Complex.zero();n=s.Complex.mul(n,e)}return i%2==1&&(n=s.Complex.neg(n)),n};static luDecomposition=t=>{const e=n.MultiArray.copy(t),{LU:r,piv:i,swaps:a}=o.LAPACK.getrf_blocked(e.array),l=e.dimension[0],c=e.dimension[1],u=Math.min(l,c),d=h.eye(s.Complex.create(l));for(let t=0;t<u;t++)i[t]!==t&&o.LAPACK.laswp_rows(d.array,d.dimension,t,i[t]);const m=new n.MultiArray([l,l]),p=new n.MultiArray([l,c]);for(let t=0;t<l;t++)for(let r=0;r<c;r++)t>r?(m.array[t][r]=e.array[t][r],p.array[t][r]=s.Complex.zero()):t===r?(m.array[t][r]=s.Complex.one(),p.array[t][r]=e.array[t][r]):(m.array[t][r]=s.Complex.zero(),p.array[t][r]=e.array[t][r]);return{L:m,U:p,P:d,swaps:a}};static luSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static lu=t=>{if(!t||2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new Error("PLU decomposition can only be applied to square matrices.");return l.AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length)return t.U;switch(e){case 0:return t.L;case 1:return t.U;case 2:return t.P}},e=>{const{L:r,U:s,P:i}=h.luDecomposition(t);return{length:e,L:r,U:s,P:i}})};static invSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:1}};static inv=t=>{if(!t||2!==t.dimension.length||t.dimension[0]!==t.dimension[1])throw new Error("inv: matrix must be square.");const e=n.MultiArray.copy(t),{LU:r,piv:i,info:a,swaps:l}=o.LAPACK.getrf_blocked(e.array);if(0!==a){const e=t.dimension[0],r=new n.MultiArray([e,e]);for(let t=0;t<e;t++)for(let i=0;i<e;i++)r.array[t][i]=s.Complex.inf_0();return n.MultiArray.setType(r),r}{const e=t.dimension[0],s=o.LAPACK.eye([e,e]),a=o.LAPACK.getrs(r,i,s),l=new n.MultiArray([a.length,a[0].length]);return l.array=a,n.MultiArray.setType(l),l}};static condSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"normType",alternatives:[{name:"numericNormType",classes:["double"],validators:["numeric","scalar","real"]},{name:"frobeniusNormType",classes:["char","string"],allowedStrings:["fro"]}]}]}],outputs:{arity:1}};static cond=(t,e=s.Complex.create(2))=>{if(t&&2===t.dimension.length||l.AST.throwInvalidCallError("cond"),0===t.dimension[0]||0===t.dimension[1])return s.Complex.zero();if(i.CharString.isInstanceOf(e))return"fro"!==e.str&&l.AST.throwInvalidCallError("cond"),h.squareMatrixNormCondition(t,"fro");const r=s.Complex.realToNumber(n.MultiArray.firstElement(e));if(2===r){const e=h.singularValuesSquared(t);if(0===e.length)return s.Complex.zero();const r=e[e.length-1],i=e[0];return i<=Math.max(1e-14*r,0)?s.Complex.inf_0():s.Complex.create(Math.sqrt(r/i))}if(1===r||r===1/0)return h.squareMatrixNormCondition(t,r);throw l.AST.throwInvalidCallError("cond"),new EvalError("Invalid call to cond.")};static rankSignature={inputs:[{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]},{name:"tolerance",classes:["double"],validators:["numeric","scalar","real","finite","nonnegative"]}]}],outputs:{arity:1}};static rank=(t,e)=>{t&&2===t.dimension.length||l.AST.throwInvalidCallError("rank");const r=h.singularValues(t);if(0===r.length)return s.Complex.zero();const i=void 0===e?Math.max(t.dimension[0],t.dimension[1])*Number.EPSILON*r[r.length-1]:s.Complex.realToNumber(e);return(!Number.isFinite(i)||i<0||void 0!==e&&!s.Complex.imagIsZero(e))&&l.AST.throwInvalidCallError("rank"),s.Complex.create(h.rankByElimination(t,i))};static squareMatrixNormCondition=(t,e)=>(t.dimension[0]!==t.dimension[1]&&l.AST.throwInvalidCallError("cond"),s.Complex.mul(h.matrixNorm(t,e),h.matrixNorm(h.inv(t),e)));static matrixNorm=(t,e)=>{if(1===e){let e=0;for(let r=0;r<t.dimension[1];r++){let i=0;for(let e=0;e<t.dimension[0];e++)i+=s.Complex.realToNumber(s.Complex.abs(t.array[e][r]));e=Math.max(e,i)}return s.Complex.create(e)}if(e===1/0){let e=0;for(let r=0;r<t.dimension[0];r++){let i=0;for(let e=0;e<t.dimension[1];e++)i+=s.Complex.realToNumber(s.Complex.abs(t.array[r][e]));e=Math.max(e,i)}return s.Complex.create(e)}let r=s.Complex.zero();for(const e of n.MultiArray.linearize(t)){const t=s.Complex.abs(e);r=s.Complex.add(r,s.Complex.mul(t,t))}return s.Complex.sqrt(r)};static singularValuesSquared=t=>{const e=t.dimension[0],r=t.dimension[1],i=Math.min(e,r);if(0===i)return[];const n=Array.from({length:i},()=>Array.from({length:i},()=>s.Complex.zero()));if(e>=r)for(let i=0;i<r;i++)for(let a=i;a<r;a++){let r=s.Complex.zero();for(let n=0;n<e;n++)r=s.Complex.add(r,s.Complex.mul(s.Complex.conj(t.array[n][i]),t.array[n][a]));n[i][a]=r,n[a][i]=i===a?r:s.Complex.conj(r)}else for(let i=0;i<e;i++)for(let a=i;a<e;a++){let e=s.Complex.zero();for(let n=0;n<r;n++)e=s.Complex.add(e,s.Complex.mul(t.array[i][n],s.Complex.conj(t.array[a][n])));n[i][a]=e,n[a][i]=i===a?e:s.Complex.conj(e)}const{D:a}=o.LAPACK.jacobi_symmetric_hermitian(n,1e3,1e-14);return a.map(t=>Math.max(0,s.Complex.realToNumber(t))).sort((t,e)=>t-e)};static singularValues=t=>h.singularValuesSquared(t).map(t=>Math.sqrt(t));static rankByElimination=(t,e)=>{const r=t.array.map(t=>t.map(t=>s.Complex.create(s.Complex.realToNumber(t),s.Complex.imagToNumber(t)))),i=t.dimension[0],n=t.dimension[1];let a=0;for(let t=0;t<n&&a<i;t++){let o=a,l=s.Complex.realToNumber(s.Complex.abs(r[o][t]));for(let e=a+1;e<i;e++){const i=s.Complex.realToNumber(s.Complex.abs(r[e][t]));i>l&&(l=i,o=e)}if(l<=e)continue;if(o!==a){const t=r[a];r[a]=r[o],r[o]=t}const c=r[a][t];for(let e=a+1;e<i;e++){const i=s.Complex.rdiv(r[e][t],c);if(!s.Complex.realIsZero(s.Complex.abs(i)))for(let o=t;o<n;o++)r[e][o]=s.Complex.sub(r[e][o],s.Complex.mul(i,r[a][o]))}a++}return a};static mldivide=(t,e)=>{if(2!==t.dimension.length||2!==e.dimension.length||t.dimension[0]!==t.dimension[1]||t.dimension[0]!==e.dimension[0])throw new EvalError(`operator \\: nonconformant arguments (op1 is ${h.formatDimensions(t)}, op2 is ${h.formatDimensions(e)}).`);return o.LAPACK.mldivide(t,e).X};static mrdivide=(t,e)=>{if(2!==t.dimension.length||2!==e.dimension.length||e.dimension[0]!==e.dimension[1]||t.dimension[1]!==e.dimension[1])throw new EvalError(`operator /: nonconformant arguments (op1 is ${h.formatDimensions(t)}, op2 is ${h.formatDimensions(e)}).`);return h.ctranspose(h.mldivide(h.ctranspose(e),h.ctranspose(t)))};static gaussSignature={inputs:{arity:2,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]},{name:"rightHandSide",classes:["double"]}]},outputs:{arity:1}};static gauss=(t,e)=>{if(t.dimension.length>2||t.dimension[0]!==t.dimension[1])throw new Error("invalid dimensions in function gauss.");const r=n.MultiArray.copy(t);let i,a,o;for(Math.min(e.dimension[0],e.dimension[1])===e.dimension[1]&&(e=h.transpose(e)),i=0;i<r.dimension[0];i++)r.array[i].push(e.array[0][i]);const l=r.dimension[0];for(i=0;i<l;i++){let t=s.Complex.abs(r.array[i][i]),e=i;for(a=i+1;a<l;a++)s.Complex.realGreaterThan(s.Complex.abs(r.array[a][i]),t.re)&&(t=s.Complex.abs(r.array[a][i]),e=a);for(a=i;a<l+1;a++){const t=r.array[e][a];r.array[e][a]=r.array[i][a],r.array[i][a]=t}for(a=i+1;a<l;a++){const t=s.Complex.rdiv(s.Complex.neg(r.array[a][i]),r.array[i][i]);for(o=i;o<l+1;o++)r.array[a][o]=i===o?s.Complex.zero():s.Complex.add(r.array[a][o],s.Complex.mul(t,r.array[i][o]))}}const c=new n.MultiArray([1,l],s.Complex.zero());for(i=l-1;i>-1;i--)for(c.array[0][i]=s.Complex.rdiv(r.array[i][l],r.array[i][i]),a=i-1;a>-1;a--)r.array[a][l]=s.Complex.sub(r.array[a][l],s.Complex.mul(r.array[a][i],c.array[0][i]));return n.MultiArray.setType(c),c};static dotSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static dot=(t,e,r)=>{if(!n.MultiArray.arrayEquals(t.dimension,e.dimension))throw new Error("dot: A and B must have the same size.");let i;if(i=void 0!==r?n.MultiArray.testIndex(r,"dot")-1:n.MultiArray.firstNonSingleDimension(t),i<0||i>=t.dimension.length)throw new Error("dot: dimension argument out of range.");const a=t.dimension,o=a.length,l=a.reduce((t,e)=>t*e,1),c=new Array(o);c[0]=1;for(let t=1;t<o;t++)c[t]=c[t-1]*a[t-1];const u=[...a];u[i]=1;const h=u.reduce((t,e)=>t*e,1),d=new Array(o);d[0]=1;for(let t=1;t<o;t++)d[t]=d[t-1]*u[t-1];const m=new n.MultiArray(u),p=u.slice(2).reduce((t,e)=>t*e,1),f=u[0]*Math.max(1,p),g=u[1]??1;m.array=new Array(f);for(let t=0;t<f;t++)m.array[t]=new Array(g);const y=a[0]*a[1],x=u[0]*u[1];for(let r=0;r<l;r++){let n=0;for(let t=0;t<o;t++){const e=Math.floor(r/c[t])%a[t];t!==i&&(n+=e*d[t])}const l=Math.floor(r/y),h=r-l*y,p=l*a[0]+h%a[0],f=Math.floor(h/a[0]);if(!t.array[p]||void 0===t.array[p][f])throw new Error(`dot_fast: invalid access to A at physical [${p},${f}] (linIdx=${r}).`);if(!e.array[p]||void 0===e.array[p][f])throw new Error(`dot_fast: invalid access to B at physical [${p},${f}] (linIdx=${r}).`);const g=t.array[p][f],C=e.array[p][f],E=s.Complex.mul(s.Complex.conj(g),C),A=Math.floor(n/x),_=n-A*x,S=A*u[0]+_%u[0],v=Math.floor(_/u[0]);void 0===m.array[S][v]||null===m.array[S][v]?m.array[S][v]=s.Complex.copy(E):m.array[S][v]=s.Complex.add(m.array[S][v],E)}return n.MultiArray.setType(m),1===h?m.array[0][0]:m};static crossSignature={inputs:{arity:-3,min:2,max:3,parameters:[{name:"left",classes:["double"]},{name:"right",classes:["double"]},{name:"dimension",classes:["double"],validators:["dimension","positive"],optional:!0}]},outputs:{arity:1}};static dimensionArgumentToNumber=t=>{if("number"==typeof t)return t;if(n.MultiArray.isInstanceOf(t)){const e=n.MultiArray.linearize(t);return e.length>0?h.dimensionArgumentToNumber(e[0]):void 0}return s.Complex.isInstanceOf(t)?s.Complex.realToNumber(t):void 0};static cross=(t,e,r)=>{const i=t.dimension.slice(),a=e.dimension.slice();let o;if(void 0!==r){const t=h.dimensionArgumentToNumber(r);if(void 0===t||!Number.isFinite(t))throw new EvalError(`cross: invalid dimension ${String(r)}.`);const e=Math.floor(t);if(e<1)throw new EvalError(`cross: invalid dimension ${String(r)}.`);o=e-1}const l=Math.max(i.length,a.length,void 0!==o?o+1:0),c=i.slice(),u=a.slice();for(;c.length<l;)c.push(1);for(;u.length<l;)u.push(1);if(void 0===o&&(o=c.findIndex(t=>3===t),-1===o))throw new EvalError("cross: no dimension of length 3 found and dim not specified.");for(let t=0;t<l;t++)if(t!==o&&c[t]!==u[t])throw new EvalError("cross: A and B must have the same size, except along the operation dimension.");const d=c[o]??1,m=u[o]??1;if(3!==d||3!==m)throw new EvalError(`cross: inputs must have length 3 along the operation dimension (got ${d} and ${m}).`);const p=n.MultiArray.linearize(t),f=n.MultiArray.linearize(e),g=p.length,y=new Array(g),x=c.slice(0,o).reduce((t,e)=>t*e,1),C=c[o],E=x*C,A=Math.floor(g/E);if(3!==C)throw new EvalError(`cross: internal error, block length along dim ${o+1} must be 3.`);for(let t=0;t<A;t++){const e=t*E;for(let t=0;t<x;t++){const r=e+0*x+t,i=e+1*x+t,n=e+2*x+t;y[r]=s.Complex.sub(s.Complex.mul(p[i],f[n]),s.Complex.mul(p[n],f[i])),y[i]=s.Complex.sub(s.Complex.mul(p[n],f[r]),s.Complex.mul(p[r],f[n])),y[n]=s.Complex.sub(s.Complex.mul(p[r],f[i]),s.Complex.mul(p[i],f[r]))}}const _=new n.MultiArray(i);1===_.dimension.length&&_.dimension.push(1);for(let t=0;t<p.length;t++){const[e,r]=n.MultiArray.linearIndexToMultiArrayRowColumn(_.dimension[0],_.dimension[1],t);_.array[e][r]=y[t]??s.Complex.zero()}return n.MultiArray.setType(_),_};static kronSignature={inputs:{arity:2,parameters:[{name:"left",classes:["double"],validators:["matrix2d"]},{name:"right",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:1}};static kron=(t,e)=>{const r=n.MultiArray.scalarToMultiArray(t),i=n.MultiArray.scalarToMultiArray(e);if(!r||r.dimension.length<2||!i||i.dimension.length<2)throw new Error("kron: inputs must be at least 2-D arrays");const a=r.dimension[0],o=r.dimension[1],l=i.dimension[0],c=i.dimension[1],u=[a*l,o*c],h=new n.MultiArray(u);for(let t=0;t<a;t++)for(let e=0;e<o;e++){const n=r.array[t][e];for(let r=0;r<l;r++)for(let a=0;a<c;a++){const o=i.array[r][a],u=s.Complex.mul(n,o);h.array[t*l+r][e*c+a]=u}}return n.MultiArray.setType(h),h};static qrPhaseNormalize=(t,e,r)=>{const i=Math.min(e.dimension[0],e.dimension[1]);for(let n=0;n<i;n++){if(s.Complex.realIsZero(s.Complex.abs(e.array[n][n])))continue;const i=s.Complex.neg(t[n]);for(let t=n;t<e.dimension[1];t++)e.array[n][t]=s.Complex.rdiv(e.array[n][t],i);if(void 0!==r)for(let t=0;t<r.dimension[0];t++)r.array[t][n]=s.Complex.mul(r.array[t][n],i)}if(s.Complex.imagGreaterThan(s.Complex.abs(e.array[0][0]),h.settings.qrPhaseEpsilon))throw new Error("Phase normalization error: R(1,1) should be real.");if(s.Complex.realGreaterThan(e.array[0][0],0)){for(let t=0;t<e.dimension[1];t++)e.array[0][t]=s.Complex.neg(e.array[0][t]);if(void 0!==r)for(let t=0;t<r.dimension[0];t++)r.array[t][0]=s.Complex.neg(r.array[t][0])}};static lqPhaseNormalize=(t,e,r)=>{const i=Math.min(e.dimension[0],e.dimension[1]);for(let n=0;n<i;n++){const i=t[n];if(!s.Complex.realIsZero(s.Complex.abs(i))){for(let t=n;t<e.dimension[1];t++)e.array[n][t]=s.Complex.mul(e.array[n][t],i);if(r){const t=s.Complex.conj(i);for(let e=0;e<r.dimension[0];e++)r.array[e][n]=s.Complex.mul(r.array[e][n],t)}}}};static qrDecomposition=(t,e)=>{switch(e){case 1:{const{R:e,phis:r}=o.LAPACK.geqr2(t);return n.MultiArray.haveAnyComplex(e)&&h.qrPhaseNormalize(r,e),{R:e}}case 2:{const{R:e,taus:r,phis:s}=o.LAPACK.geqr2(t),i=o.LAPACK.orgqr(e,r);return o.LAPACK.triu_inplace(e),n.MultiArray.haveAnyComplex(e)&&h.qrPhaseNormalize(s,e,i),{Q:i,R:e}}case 3:{const{R:e,taus:r,phis:s,jpvt:i}=o.LAPACK.geqp3(t),a=o.LAPACK.orgqr(e,r);o.LAPACK.triu_inplace(e);const l=o.LAPACK.lapmt_matrix(i);return n.MultiArray.haveAnyComplex(e)&&h.qrPhaseNormalize(s,e,a),{Q:a,R:e,P:l}}}};static qrSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["matrix2d"]}]},outputs:{arity:-3}};static qr=t=>{if(!t||2!==t.dimension.length)throw new Error("QR decomposition can only be applied to 2D matrices.");return l.AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return t.R}else if(2===t.length){if(0===e)return t.Q;if(1===e)return t.R}else if(3===t.length){if(0===e)return t.Q;if(1===e)return t.R;if(2===e)return t.P}},e=>{if(1===e){const{R:r}=h.qrDecomposition(t,1);return{length:e,R:r}}if(2===e){const{Q:r,R:s}=h.qrDecomposition(t,2);return{length:e,R:s,Q:r}}{const{Q:r,R:s,P:i}=h.qrDecomposition(t,3);return{length:e,R:s,Q:r,P:i}}})};static eigDecomposition_original=(t,e,r=32,i="asc")=>{if(!t||!t.dimension||2!==t.dimension.length)throw new Error("eigDecomposition: A must be a 2D MultiArray");const l=t.dimension[0];if(l!==t.dimension[1])throw new Error("eigDecomposition: A must be square");const c=n.MultiArray.copy(t),{diag:u,offdiag:h,taus:d}=o.LAPACK.sytrd_blocked_w(c,r);if(!Array.isArray(u)||!Array.isArray(h))throw new Error("eigDecomposition: sytrd_blocked_w did not return diag/offdiag arrays");if(1===e){const t=n.MultiArray.toColumnVector(o.LAPACK.steqr_values(u,h));if(!t||!t.array||t.dimension[0]!==l)throw new Error("eigDecomposition: steqr_values returned invalid MultiArray");if("none"===i)return n.MultiArray.setType(t),{values:t};const e=new Array(l);for(let r=0;r<l;r++)e[r]=t.array[r][0];const r=Array.from({length:l},(t,e)=>e).sort((t,r)=>{const n=s.Complex.realToNumber(e[t]),a=s.Complex.realToNumber(e[r]);return"asc"===i?n-a:a-n}).map(t=>e[t]),a=n.MultiArray.toColumnVector(r);return n.MultiArray.setType(a),{values:a}}{const t=o.LAPACK.steqr_vectors(u,h);if(!t||!t.D||!t.V)throw new Error("eigDecomposition: steqr_vectors returned invalid result");const m=n.MultiArray.toDiagonalMatrix(t.D),p=new n.MultiArray([t.V.length,t.V[0].length]);if(p.array=t.V,m.dimension[0]!==l)throw new Error("eigDecomposition: steqr_vectors returned D of unexpected size");if(p.dimension[0]!==l||p.dimension[1]!==l)throw new Error("eigDecomposition: steqr_vectors returned V of unexpected shape");const f=o.LAPACK.orgtr_blocked_w(c,d,r),g=new n.MultiArray([l,l]);for(let t=0;t<l;t++)for(let e=0;e<l;e++)g.array[t][e]=s.Complex.zero();a.BLAS.gemm_block(f.array,p.array,g.array,s.Complex.one(),s.Complex.zero(),r),n.MultiArray.setType(g);const y=new Array(l);for(let t=0;t<l;t++)y[t]=m.array[t][0];const x="none"===i?Array.from({length:l},(t,e)=>e):Array.from({length:l},(t,e)=>e).sort((t,e)=>{const r=s.Complex.realToNumber(y[t]),n=s.Complex.realToNumber(y[e]);return"asc"===i?r-n:n-r}),C=x.map(t=>y[t]),E=n.MultiArray.toColumnVector(C),A=new n.MultiArray([l,l]);for(let t=0;t<l;t++){const e=x[t];for(let r=0;r<l;r++)A.array[r][t]=g.array[r][e]}if(n.MultiArray.setType(E),n.MultiArray.setType(A),2===e)return{values:E,vectors:A};{const t=new n.MultiArray([l,l]);for(let e=0;e<l;e++)for(let r=0;r<l;r++)t.array[e][r]=s.Complex.zero();for(let e=0;e<l;e++)t.array[e][e]=u[e],e<l-1&&(t.array[e][e+1]=h[e],t.array[e+1][e]=s.Complex.conj(h[e]));return n.MultiArray.setType(t),{values:E,vectors:A,T:t}}}};static eigDecomposition=(t,e,r="asc",i)=>{const a=t.dimension[0],l=n.MultiArray.copy(t),{diag:c,offdiag:u,taus:h}=o.LAPACK.sytrd(l,o.LAPACK.larf_left);if(1===e){const{D:t}=o.LAPACK.steqr_vectors(c,u,1e4),e=Array.from({length:a},(t,e)=>e).sort((e,i)=>{const n=s.Complex.realToNumber(t[e]),a=s.Complex.realToNumber(t[i]);return"asc"===r?n-a:a-n}).map(e=>t[e]),i=n.MultiArray.toColumnVector(e);return n.MultiArray.setType(i),{values:i}}{const{D:t,V:e}=o.LAPACK.steqr_vectors_tridiagonal(c,u,1e4),r=new n.MultiArray([e.length,e[0].length]);return r.array=e,{values:n.MultiArray.toDiagonalMatrix(t),vectors:r}}};static eigSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static eig=t=>l.AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return t.values}else if(2===t.length){if(0===e)return t.vectors;if(1===e)return t.values}else if(3===t.length){if(0===e)return t.vectors;if(1===e)return t.values;if(2===e)return t.T}},e=>{if(1===e){const{D:r}=o.LAPACK.eig_hermitian(t);return{length:e,values:r}}if(2===e){const{D:r,V:s}=o.LAPACK.eig_hermitian(t,!0);return{length:e,values:r,vectors:s}}{const{values:r,vectors:s,T:i}=h.eigDecomposition(t,3);return{length:e,values:r,vectors:s,T:i}}});static testSignature={inputs:{arity:1,parameters:[{name:"matrix",classes:["double"],validators:["squareMatrix"]}]},outputs:{arity:-3}};static test(t){return l.AST.nodeBoundedReturnList(3,(t,e)=>{if(1===t.length){if(0===e)return s.Complex.zero()}else if(2===t.length){if(0===e)return s.Complex.zero();if(1===e)return s.Complex.one()}else if(3===t.length){if(0===e)return s.Complex.zero();if(1===e)return s.Complex.one();if(2===e)return s.Complex.two()}},t=>({length:t}))}static functions={eye:{func:h.eye,signature:h.eyeSignature},transpose:{func:h.transpose,signature:h.transposeSignature},ctranspose:{func:h.ctranspose,signature:h.ctransposeSignature},diag:{func:h.diag,signature:h.diagSignature},trace:{func:h.trace,signature:h.traceSignature},det:{func:h.det,signature:h.detSignature},inv:{func:h.inv,signature:h.invSignature},cond:{func:h.cond,signature:h.condSignature},rank:{func:h.rank,signature:h.rankSignature},gauss:{func:h.gauss,signature:h.gaussSignature},lu:{func:h.lu,signature:h.luSignature},dot:{func:h.dot,signature:h.dotSignature},cross:{func:h.cross,signature:h.crossSignature},kron:{func:h.kron,signature:h.kronSignature},qr:{func:h.qr,signature:h.qrSignature},eig:{func:h.eig,signature:h.eigSignature},test:{func:h.test,signature:h.testSignature}}}e.LinearAlgebra=h,e.default={LinearAlgebra:h}},2207(__unused_webpack_module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const antlr4_1=__webpack_require__(3222);class MathJSLabLexer extends antlr4_1.Lexer{static GLOBAL=1;static PERSISTENT=2;static IMPORT=3;static IF=4;static ENDIF=5;static END=6;static ENDRANGE=7;static ELSEIF=8;static ELSE=9;static SWITCH=10;static ENDSWITCH=11;static CASE=12;static OTHERWISE=13;static WHILE=14;static ENDWHILE=15;static DO=16;static UNTIL=17;static FOR=18;static ENDFOR=19;static PARFOR=20;static ENDPARFOR=21;static SPMD=22;static ENDSPMD=23;static BREAK=24;static CONTINUE=25;static RETURN=26;static FUNCTION=27;static ENDFUNCTION=28;static TRY=29;static CATCH=30;static END_TRY_CATCH=31;static UNWIND_PROTECT=32;static UNWIND_PROTECT_CLEANUP=33;static END_UNWIND_PROTECT=34;static CLASSDEF=35;static ENDCLASSDEF=36;static ENUMERATION=37;static ENDENUMERATION=38;static PROPERTIES=39;static ENDPROPERTIES=40;static EVENTS=41;static ENDEVENTS=42;static METHODS=43;static ENDMETHODS=44;static WSPACE=45;static STRING=46;static ARGUMENTS=47;static ENDARGUMENTS=48;static PLUS=49;static MINUS=50;static MUL=51;static DIV=52;static EQ=53;static COLON=54;static SEMICOLON=55;static COMMA=56;static DOT=57;static TILDE=58;static EXCLAMATION=59;static COMMAT=60;static QUESTION=61;static LPAREN=62;static RPAREN=63;static LBRACKET=64;static RBRACKET=65;static LCURLYBR=66;static RCURLYBR=67;static LEFTDIV=68;static ADD_EQ=69;static SUB_EQ=70;static MUL_EQ=71;static DIV_EQ=72;static LEFTDIV_EQ=73;static POW_EQ=74;static EMUL_EQ=75;static EDIV_EQ=76;static ELEFTDIV_EQ=77;static EPOW_EQ=78;static AND_EQ=79;static OR_EQ=80;static EXPR_AND_AND=81;static EXPR_OR_OR=82;static EXPR_AND=83;static EXPR_OR=84;static EXPR_LT=85;static EXPR_LE=86;static EXPR_EQ=87;static EXPR_NE=88;static EXPR_GE=89;static EXPR_GT=90;static EMUL=91;static EDIV=92;static ELEFTDIV=93;static PLUS_PLUS=94;static MINUS_MINUS=95;static POW=96;static EPOW=97;static TRANSPOSE=98;static HERMITIAN=99;static DQSTRING=100;static IDENTIFIER=101;static FLOAT_NUMBER=102;static NUMBER_DOT_OP=103;static LINE_CONTINUATION=104;static SPACE_OR_CONTINUATION=105;static NEWLINE=106;static BLOCK_COMMENT_START=107;static COMMENT_LINE=108;static INVALID=109;static SINGLEQ_STRING=110;static SINGLEQ_NL=111;static SINGLEQ_SINGLEQ=112;static SINGLEQ_END=113;static DOUBLEQ_STRING=114;static DOUBLEQ_NL=115;static DOUBLEQ_DOUBLEQ=116;static DOUBLEQ_ESCAPE=117;static DOUBLEQ_ESCAPE_OTHER=118;static DOUBLEQ_ESCAPE_OCT=119;static DOUBLEQ_ESCAPE_HEX=120;static DOUBLEQ_ESCAPE_UNICODE=121;static DOUBLEQ_END=122;static BLOCK_COMMENT_START_AGAIN=123;static BLOCK_COMMENT_END=124;static BLOCK_COMMENT_LINE=125;static BLOCK_COMMENT_EOF=126;static COMMAND_LINE_CONTINUATION=127;static COMMAND_CONTINUED_BLOCK_COMMENT_START=128;static COMMAND_CONTINUED_COMMENT_LINE=129;static COMMAND_CONTINUED_NEWLINE=130;static SKIP_SPACE=131;static COMMAND_LONE_DQUOTE=132;static COMMAND_LONE_SQUOTE=133;static COMMAND_UNCLOSED_DQUOTE=134;static COMMAND_UNCLOSED_SQUOTE=135;static COMMAND_DQSTRING=136;static COMMAND_SQSTRING=137;static SKIP_COMMENT_LINE=138;static COMMAND_SEPARATOR=139;static EXIT_AT_NEWLINE=140;static EXIT_AT_EOF=141;static UNQUOTED_STRING=142;static EOF=antlr4_1.Token.EOF;static SQ_STRING=1;static DQ_STRING=2;static BLOCK_COMMENT=3;static ANY_AS_STRING_UNTIL_END_OF_LINE=4;static channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'?'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static modeNames=["DEFAULT_MODE","SQ_STRING","DQ_STRING","BLOCK_COMMENT","ANY_AS_STRING_UNTIL_END_OF_LINE"];static ruleNames=["PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING","CCHAR","NL","SPACE","IDENT","FQIDENT","REAL_NUMBER","INTEGER_NUMBER","INTEGER_DIGITS","DECIMAL_DIGITS","BINARY_DIGITS","OCTAL_DIGITS","HEXADECIMAL_DIGITS","EXPONENT"];static keywordNames=[null,"global","persistent","import","if","endif","end","elseif","else","switch","endswitch","case","otherwise","while","endwhile","do","until","for","endfor","parfor","endparfor","spmd","endspmd","break","continue","return","function","endfunction","try","catch","end_try_catch","unwind_protect","unwind_protect_cleanup","end_unwind_protect","classdef","endclassdef","enumeration","endenumeration","properties","endproperties","events","endevents","methods","endmethods","arguments","endarguments"];static keywordTypes=[NaN,MathJSLabLexer.GLOBAL,MathJSLabLexer.PERSISTENT,MathJSLabLexer.IMPORT,MathJSLabLexer.IF,MathJSLabLexer.ENDIF,MathJSLabLexer.END,MathJSLabLexer.ELSEIF,MathJSLabLexer.ELSE,MathJSLabLexer.SWITCH,MathJSLabLexer.ENDSWITCH,MathJSLabLexer.CASE,MathJSLabLexer.OTHERWISE,MathJSLabLexer.WHILE,MathJSLabLexer.ENDWHILE,MathJSLabLexer.DO,MathJSLabLexer.UNTIL,MathJSLabLexer.FOR,MathJSLabLexer.ENDFOR,MathJSLabLexer.PARFOR,MathJSLabLexer.ENDPARFOR,MathJSLabLexer.SPMD,MathJSLabLexer.ENDSPMD,MathJSLabLexer.BREAK,MathJSLabLexer.CONTINUE,MathJSLabLexer.RETURN,MathJSLabLexer.FUNCTION,MathJSLabLexer.ENDFUNCTION,MathJSLabLexer.TRY,MathJSLabLexer.CATCH,MathJSLabLexer.END_TRY_CATCH,MathJSLabLexer.UNWIND_PROTECT,MathJSLabLexer.UNWIND_PROTECT_CLEANUP,MathJSLabLexer.END_UNWIND_PROTECT,MathJSLabLexer.CLASSDEF,MathJSLabLexer.ENDCLASSDEF,MathJSLabLexer.ENUMERATION,MathJSLabLexer.ENDENUMERATION,MathJSLabLexer.PROPERTIES,MathJSLabLexer.ENDPROPERTIES,MathJSLabLexer.EVENTS,MathJSLabLexer.ENDEVENTS,MathJSLabLexer.METHODS,MathJSLabLexer.ENDMETHODS,MathJSLabLexer.ARGUMENTS,MathJSLabLexer.ENDARGUMENTS];static keywordTypeByName=new Map(MathJSLabLexer.keywordNames.map((t,e)=>t?[t,MathJSLabLexer.keywordTypes[e]]:void 0).filter(t=>void 0!==t));commandNames=new Set;assignmentSensitiveCommandNames=new Set;static nonTerminalSign=new Set([MathJSLabLexer.PLUS,MathJSLabLexer.MINUS,MathJSLabLexer.MUL,MathJSLabLexer.DIV,MathJSLabLexer.EQ,MathJSLabLexer.COLON,MathJSLabLexer.DOT,MathJSLabLexer.TILDE,MathJSLabLexer.EXCLAMATION,MathJSLabLexer.COMMAT,MathJSLabLexer.QUESTION,MathJSLabLexer.LPAREN,MathJSLabLexer.LBRACKET,MathJSLabLexer.LCURLYBR,MathJSLabLexer.LEFTDIV,MathJSLabLexer.ADD_EQ,MathJSLabLexer.SUB_EQ,MathJSLabLexer.MUL_EQ,MathJSLabLexer.DIV_EQ,MathJSLabLexer.LEFTDIV_EQ,MathJSLabLexer.POW_EQ,MathJSLabLexer.EMUL_EQ,MathJSLabLexer.EDIV_EQ,MathJSLabLexer.ELEFTDIV_EQ,MathJSLabLexer.EPOW_EQ,MathJSLabLexer.AND_EQ,MathJSLabLexer.OR_EQ,MathJSLabLexer.EXPR_AND_AND,MathJSLabLexer.EXPR_OR_OR,MathJSLabLexer.EXPR_AND,MathJSLabLexer.EXPR_OR,MathJSLabLexer.EXPR_LT,MathJSLabLexer.EXPR_LE,MathJSLabLexer.EXPR_EQ,MathJSLabLexer.EXPR_NE,MathJSLabLexer.EXPR_GE,MathJSLabLexer.EXPR_GT,MathJSLabLexer.EMUL,MathJSLabLexer.EDIV,MathJSLabLexer.ELEFTDIV,MathJSLabLexer.PLUS_PLUS,MathJSLabLexer.MINUS_MINUS,MathJSLabLexer.POW,MathJSLabLexer.EPOW]);previousTokenType=antlr4_1.Token.EOF;parenthesisCount=0;continuedTokenType=null;commandContinued=!1;matrixContext=[];curlyBraceIsMatrixContext=[];indexingBraceCount=0;quotedString="";commandQuoteIsClosed(t){let e=1,r=this._input.LA(e);for(;r!==antlr4_1.Token.EOF&&10!==r&&13!==r;){if(r===t){if(this._input.LA(e+1)===t){e+=2,r=this._input.LA(e);continue}return!0}e++,r=this._input.LA(e)}return!1}commandIsFollowedByAssignment(t){const e=this._input.LA(t);if(61===e)return!0;const r=this._input.LA(t+1);return!(![43,45,42,47,92,94,38,124].includes(e)||61!==r)||46===e&&[42,47,92,94].includes(r)&&61===this._input.LA(t+2)}matrixWhitespaceIsSeparator(t=!1){let e=1;if(t)for(;9===this._input.LA(e)||32===this._input.LA(e);)e++;const r=this._input.LA(e);if(43!==r&&45!==r)return!this.matrixWhitespaceBeforeBinaryOperator(e);const s=this._input.LA(e+1);return 9!==s&&32!==s}matrixWhitespaceBeforeBinaryOperator(t){const e=this._input.LA(t),r=this._input.LA(t+1);return!![38,42,47,58,60,62,92,94,124].includes(e)||(46===e?[42,47,92,94].includes(r):61===e&&61===r||126===e&&61===r)}emit(){const t=super.emit();return null!==this.continuedTokenType&&t.type!==antlr4_1.Token.EOF&&t.type!==MathJSLabLexer.NEWLINE&&t.type!==MathJSLabLexer.WSPACE&&(this.continuedTokenType=null),t}constructor(t){super(t),this._interp=new antlr4_1.LexerATNSimulator(this,MathJSLabLexer._ATN,MathJSLabLexer.DecisionsToDFA,new antlr4_1.PredictionContextCache)}get grammarFileName(){return"MathJSLabLexer.g4"}get literalNames(){return MathJSLabLexer.literalNames}get symbolicNames(){return MathJSLabLexer.symbolicNames}get ruleNames(){return MathJSLabLexer.ruleNames}get serializedATN(){return MathJSLabLexer._serializedATN}get channelNames(){return MathJSLabLexer.channelNames}get modeNames(){return MathJSLabLexer.modeNames}action(t,e,r){switch(e){case 0:this.PLUS_action(t,r);break;case 1:this.MINUS_action(t,r);break;case 2:this.MUL_action(t,r);break;case 3:this.DIV_action(t,r);break;case 4:this.EQ_action(t,r);break;case 5:this.COLON_action(t,r);break;case 6:this.SEMICOLON_action(t,r);break;case 7:this.COMMA_action(t,r);break;case 8:this.DOT_action(t,r);break;case 9:this.TILDE_action(t,r);break;case 10:this.EXCLAMATION_action(t,r);break;case 11:this.COMMAT_action(t,r);break;case 12:this.QUESTION_action(t,r);break;case 13:this.LPAREN_action(t,r);break;case 14:this.RPAREN_action(t,r);break;case 15:this.LBRACKET_action(t,r);break;case 16:this.RBRACKET_action(t,r);break;case 17:this.LCURLYBR_action(t,r);break;case 18:this.RCURLYBR_action(t,r);break;case 19:this.LEFTDIV_action(t,r);break;case 20:this.ADD_EQ_action(t,r);break;case 21:this.SUB_EQ_action(t,r);break;case 22:this.MUL_EQ_action(t,r);break;case 23:this.DIV_EQ_action(t,r);break;case 24:this.LEFTDIV_EQ_action(t,r);break;case 25:this.POW_EQ_action(t,r);break;case 26:this.EMUL_EQ_action(t,r);break;case 27:this.EDIV_EQ_action(t,r);break;case 28:this.ELEFTDIV_EQ_action(t,r);break;case 29:this.EPOW_EQ_action(t,r);break;case 30:this.AND_EQ_action(t,r);break;case 31:this.OR_EQ_action(t,r);break;case 32:this.EXPR_AND_AND_action(t,r);break;case 33:this.EXPR_OR_OR_action(t,r);break;case 34:this.EXPR_AND_action(t,r);break;case 35:this.EXPR_OR_action(t,r);break;case 36:this.EXPR_LT_action(t,r);break;case 37:this.EXPR_LE_action(t,r);break;case 38:this.EXPR_EQ_action(t,r);break;case 39:this.EXPR_NE_action(t,r);break;case 40:this.EXPR_GE_action(t,r);break;case 41:this.EXPR_GT_action(t,r);break;case 42:this.EMUL_action(t,r);break;case 43:this.EDIV_action(t,r);break;case 44:this.ELEFTDIV_action(t,r);break;case 45:this.PLUS_PLUS_action(t,r);break;case 46:this.MINUS_MINUS_action(t,r);break;case 47:this.POW_action(t,r);break;case 48:this.EPOW_action(t,r);break;case 49:this.TRANSPOSE_action(t,r);break;case 50:this.HERMITIAN_action(t,r);break;case 51:this.DQSTRING_action(t,r);break;case 52:this.IDENTIFIER_action(t,r);break;case 53:this.FLOAT_NUMBER_action(t,r);break;case 54:this.NUMBER_DOT_OP_action(t,r);break;case 55:this.LINE_CONTINUATION_action(t,r);break;case 56:this.SPACE_OR_CONTINUATION_action(t,r);break;case 57:this.NEWLINE_action(t,r);break;case 58:this.BLOCK_COMMENT_START_action(t,r);break;case 59:this.COMMENT_LINE_action(t,r);break;case 61:this.SINGLEQ_STRING_action(t,r);break;case 62:this.SINGLEQ_NL_action(t,r);break;case 63:this.SINGLEQ_SINGLEQ_action(t,r);break;case 64:this.SINGLEQ_END_action(t,r);break;case 65:this.DOUBLEQ_STRING_action(t,r);break;case 66:this.DOUBLEQ_NL_action(t,r);break;case 67:this.DOUBLEQ_DOUBLEQ_action(t,r);break;case 68:this.DOUBLEQ_ESCAPE_action(t,r);break;case 69:this.DOUBLEQ_ESCAPE_OTHER_action(t,r);break;case 70:this.DOUBLEQ_ESCAPE_OCT_action(t,r);break;case 71:this.DOUBLEQ_ESCAPE_HEX_action(t,r);break;case 72:this.DOUBLEQ_ESCAPE_UNICODE_action(t,r);break;case 73:this.DOUBLEQ_END_action(t,r);break;case 74:this.BLOCK_COMMENT_START_AGAIN_action(t,r);break;case 75:this.BLOCK_COMMENT_END_action(t,r);break;case 77:this.BLOCK_COMMENT_EOF_action(t,r);break;case 78:this.COMMAND_LINE_CONTINUATION_action(t,r);break;case 79:this.COMMAND_CONTINUED_BLOCK_COMMENT_START_action(t,r);break;case 83:this.COMMAND_LONE_DQUOTE_action(t,r);break;case 84:this.COMMAND_LONE_SQUOTE_action(t,r);break;case 85:this.COMMAND_UNCLOSED_DQUOTE_action(t,r);break;case 86:this.COMMAND_UNCLOSED_SQUOTE_action(t,r);break;case 87:this.COMMAND_DQSTRING_action(t,r);break;case 88:this.COMMAND_SQSTRING_action(t,r);break;case 90:this.COMMAND_SEPARATOR_action(t,r);break;case 91:this.EXIT_AT_NEWLINE_action(t,r);break;case 92:this.EXIT_AT_EOF_action(t,r);break;case 93:this.UNQUOTED_STRING_action(t,r)}}PLUS_action(t,e){0===e&&(this.previousTokenType=MathJSLabLexer.PLUS)}MINUS_action(t,e){1===e&&(this.previousTokenType=MathJSLabLexer.MINUS)}MUL_action(t,e){2===e&&(this.previousTokenType=MathJSLabLexer.MUL)}DIV_action(t,e){3===e&&(this.previousTokenType=MathJSLabLexer.DIV)}EQ_action(t,e){4===e&&(this.previousTokenType=MathJSLabLexer.EQ)}COLON_action(t,e){5===e&&(this.previousTokenType=MathJSLabLexer.COLON)}SEMICOLON_action(t,e){6===e&&(this.previousTokenType=MathJSLabLexer.SEMICOLON)}COMMA_action(t,e){7===e&&(this.previousTokenType=MathJSLabLexer.COMMA)}DOT_action(t,e){8===e&&(this.previousTokenType=MathJSLabLexer.DOT)}TILDE_action(t,e){9===e&&(this.previousTokenType=MathJSLabLexer.TILDE)}EXCLAMATION_action(t,e){10===e&&(this.previousTokenType=MathJSLabLexer.EXCLAMATION)}COMMAT_action(t,e){11===e&&(this.previousTokenType=MathJSLabLexer.COMMAT)}QUESTION_action(t,e){12===e&&(this.previousTokenType=MathJSLabLexer.QUESTION)}LPAREN_action(t,e){13===e&&(this.matrixContext.length>0&&this.matrixContext.push(MathJSLabLexer.LPAREN),this.parenthesisCount++,this.previousTokenType=MathJSLabLexer.LPAREN)}RPAREN_action(t,e){14===e&&(this.matrixContext.length>0&&this.matrixContext.pop(),this.parenthesisCount=Math.max(0,this.parenthesisCount-1),this.previousTokenType=MathJSLabLexer.RPAREN)}LBRACKET_action(t,e){15===e&&(this.matrixContext.push(MathJSLabLexer.LBRACKET),this.previousTokenType=MathJSLabLexer.LBRACKET)}RBRACKET_action(t,e){16===e&&(this.matrixContext.pop(),this.previousTokenType=MathJSLabLexer.RBRACKET)}LCURLYBR_action(t,e){if(17===e){const t=this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER||this.previousTokenType===MathJSLabLexer.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE;this.curlyBraceIsMatrixContext.push(!t),t?this.indexingBraceCount++:this.matrixContext.push(MathJSLabLexer.LCURLYBR),this.previousTokenType=MathJSLabLexer.LCURLYBR}}RCURLYBR_action(t,e){18===e&&(this.curlyBraceIsMatrixContext.pop()??1?this.matrixContext.pop():this.indexingBraceCount=Math.max(0,this.indexingBraceCount-1),this.previousTokenType=MathJSLabLexer.RCURLYBR)}LEFTDIV_action(t,e){19===e&&(this.previousTokenType=MathJSLabLexer.LEFTDIV)}ADD_EQ_action(t,e){20===e&&(this.previousTokenType=MathJSLabLexer.ADD_EQ)}SUB_EQ_action(t,e){21===e&&(this.previousTokenType=MathJSLabLexer.SUB_EQ)}MUL_EQ_action(t,e){22===e&&(this.previousTokenType=MathJSLabLexer.MUL_EQ)}DIV_EQ_action(t,e){23===e&&(this.previousTokenType=MathJSLabLexer.DIV_EQ)}LEFTDIV_EQ_action(t,e){24===e&&(this.previousTokenType=MathJSLabLexer.LEFTDIV_EQ)}POW_EQ_action(t,e){25===e&&(this.previousTokenType=MathJSLabLexer.POW_EQ)}EMUL_EQ_action(t,e){26===e&&(this.previousTokenType=MathJSLabLexer.EMUL_EQ)}EDIV_EQ_action(t,e){27===e&&(this.previousTokenType=MathJSLabLexer.EDIV_EQ)}ELEFTDIV_EQ_action(t,e){28===e&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV_EQ)}EPOW_EQ_action(t,e){29===e&&(this.previousTokenType=MathJSLabLexer.EPOW_EQ)}AND_EQ_action(t,e){30===e&&(this.previousTokenType=MathJSLabLexer.AND_EQ)}OR_EQ_action(t,e){31===e&&(this.previousTokenType=MathJSLabLexer.OR_EQ)}EXPR_AND_AND_action(t,e){32===e&&(this.previousTokenType=MathJSLabLexer.EXPR_AND_AND)}EXPR_OR_OR_action(t,e){33===e&&(this.previousTokenType=MathJSLabLexer.EXPR_OR_OR)}EXPR_AND_action(t,e){34===e&&(this.previousTokenType=MathJSLabLexer.EXPR_AND)}EXPR_OR_action(t,e){35===e&&(this.previousTokenType=MathJSLabLexer.EXPR_OR)}EXPR_LT_action(t,e){36===e&&(this.previousTokenType=MathJSLabLexer.EXPR_LT)}EXPR_LE_action(t,e){37===e&&(this.previousTokenType=MathJSLabLexer.EXPR_LE)}EXPR_EQ_action(t,e){38===e&&(this.previousTokenType=MathJSLabLexer.EXPR_EQ)}EXPR_NE_action(t,e){39===e&&(this.previousTokenType=MathJSLabLexer.EXPR_NE)}EXPR_GE_action(t,e){40===e&&(this.previousTokenType=MathJSLabLexer.EXPR_GE)}EXPR_GT_action(t,e){41===e&&(this.previousTokenType=MathJSLabLexer.EXPR_GT)}EMUL_action(t,e){42===e&&(this.previousTokenType=MathJSLabLexer.EMUL)}EDIV_action(t,e){43===e&&(this.previousTokenType=MathJSLabLexer.EDIV)}ELEFTDIV_action(t,e){44===e&&(this.previousTokenType=MathJSLabLexer.ELEFTDIV)}PLUS_PLUS_action(t,e){45===e&&(this.previousTokenType=MathJSLabLexer.PLUS_PLUS)}MINUS_MINUS_action(t,e){46===e&&(this.previousTokenType=MathJSLabLexer.MINUS_MINUS)}POW_action(t,e){47===e&&(this.previousTokenType=MathJSLabLexer.POW)}EPOW_action(t,e){48===e&&(this.previousTokenType=MathJSLabLexer.EPOW)}TRANSPOSE_action(t,e){49===e&&(this.previousTokenType=MathJSLabLexer.TRANSPOSE)}HERMITIAN_action(t,e){50===e&&(this.previousTokenType===MathJSLabLexer.RPAREN||this.previousTokenType===MathJSLabLexer.RBRACKET||this.previousTokenType===MathJSLabLexer.RCURLYBR||this.previousTokenType===MathJSLabLexer.IDENTIFIER||this.previousTokenType===MathJSLabLexer.FLOAT_NUMBER||this.previousTokenType===MathJSLabLexer.STRING||this.previousTokenType===MathJSLabLexer.ENDRANGE?this.previousTokenType=MathJSLabLexer.HERMITIAN:(this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip()))}DQSTRING_action(t,e){51===e&&(this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}IDENTIFIER_action(t,e){if(52===e)if(this.previousTokenType===MathJSLabLexer.DOT)this.previousTokenType=MathJSLabLexer.IDENTIFIER;else{const t=MathJSLabLexer.keywordTypeByName.get(this.text);if(void 0!==t)t===MathJSLabLexer.END?this._type=this.previousTokenType=this.parenthesisCount>0||this.matrixContext.length>0||this.indexingBraceCount>0?MathJSLabLexer.ENDRANGE:MathJSLabLexer.END:this._type=this.previousTokenType=t;else{const t=this.commandNames.has(this.text),e=this.previousTokenType===antlr4_1.Token.EOF||this.previousTokenType===MathJSLabLexer.NEWLINE||this.previousTokenType===MathJSLabLexer.SEMICOLON||this.previousTokenType===MathJSLabLexer.COMMA&&0===this.parenthesisCount&&0===this.matrixContext.length;let r=1,s=this._input.LA(r);for(;9===s||32===s;)s=this._input.LA(++r);const i=this.assignmentSensitiveCommandNames.has(this.text)&&this.commandIsFollowedByAssignment(r);t&&e&&(40!==s||r>1)&&!i&&this.pushMode(MathJSLabLexer.ANY_AS_STRING_UNTIL_END_OF_LINE),this.previousTokenType=MathJSLabLexer.IDENTIFIER}}}FLOAT_NUMBER_action(t,e){53===e&&(this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}NUMBER_DOT_OP_action(t,e){54===e&&(this._input.seek(this._input.index-2),this._type=this.previousTokenType=MathJSLabLexer.FLOAT_NUMBER)}LINE_CONTINUATION_action(t,e){55===e&&(this.continuedTokenType=this.previousTokenType,this.skip())}SPACE_OR_CONTINUATION_action(t,e){56===e&&(this.text.includes("...")&&(this.continuedTokenType=this.previousTokenType),this.matrixContext.length>0&&this.previousTokenType!==MathJSLabLexer.LBRACKET&&this.previousTokenType!==MathJSLabLexer.COMMA&&this.previousTokenType!==MathJSLabLexer.SEMICOLON&&this.matrixContext[this.matrixContext.length-1]!==MathJSLabLexer.LPAREN&&!MathJSLabLexer.nonTerminalSign.has(this.previousTokenType)&&this.matrixWhitespaceIsSeparator(this.text.includes("..."))?this._type=this.previousTokenType=MathJSLabLexer.WSPACE:this.skip())}NEWLINE_action(t,e){57===e&&(this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.indexingBraceCount>0||this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this.previousTokenType=MathJSLabLexer.NEWLINE)}BLOCK_COMMENT_START_action(t,e){58===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0||this.matrixContext.length>0&&(this.previousTokenType===MathJSLabLexer.LBRACKET||this.previousTokenType===MathJSLabLexer.COMMA||this.previousTokenType===MathJSLabLexer.SEMICOLON)?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}COMMENT_LINE_action(t,e){switch(e){case 59:this.continuedTokenType===this.previousTokenType||this.parenthesisCount>0?this.skip():this._type=this.previousTokenType=MathJSLabLexer.NEWLINE;break;case 60:this._type=this.previousTokenType=MathJSLabLexer.EOF}}SINGLEQ_STRING_action(t,e){61===e&&(this.quotedString+=this.text,this.skip())}SINGLEQ_NL_action(t,e){62===e&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}SINGLEQ_SINGLEQ_action(t,e){63===e&&(this.quotedString+="'",this.skip())}SINGLEQ_END_action(t,e){64===e&&(this.text=`'${this.quotedString}'`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}DOUBLEQ_STRING_action(t,e){65===e&&(this.quotedString+=this.text,this.skip())}DOUBLEQ_NL_action(t,e){66===e&&(this._type=this.previousTokenType=MathJSLabLexer.INVALID)}DOUBLEQ_DOUBLEQ_action(t,e){67===e&&(this.quotedString+='"',this.skip())}DOUBLEQ_ESCAPE_action(t,e){68===e&&(this.quotedString+=JSON.parse(`"${this.text}"`),this.skip())}DOUBLEQ_ESCAPE_OTHER_action(t,e){69===e&&(this.quotedString+=this.text.substring(1),this.skip())}DOUBLEQ_ESCAPE_OCT_action(t,e){70===e&&(this.quotedString+=JSON.parse(`"\\u${parseInt(this.text.substring(1),8).toString(16).padStart(4,"0")}"`),this.skip())}DOUBLEQ_ESCAPE_HEX_action(localctx,actionIndex){71===actionIndex&&(this.quotedString+=eval(`"\\x${this.text.substring(2)}"`),this.skip())}DOUBLEQ_ESCAPE_UNICODE_action(t,e){72===e&&(this.quotedString+=JSON.parse(`"\\u${this.text.substring(2).padStart(4,"0")}"`),this.skip())}DOUBLEQ_END_action(t,e){73===e&&(this.text=`"${this.quotedString}"`,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.STRING)}BLOCK_COMMENT_START_AGAIN_action(t,e){74===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}BLOCK_COMMENT_END_action(t,e){75===e&&(this.popMode(),this.skip())}BLOCK_COMMENT_EOF_action(t,e){if(76===e)throw new SyntaxError("Block comment open at end of input.")}COMMAND_LINE_CONTINUATION_action(t,e){77===e&&(this.commandContinued=!0,this.skip())}COMMAND_CONTINUED_BLOCK_COMMENT_START_action(t,e){78===e&&(this.pushMode(MathJSLabLexer.BLOCK_COMMENT),this.skip())}COMMAND_LONE_DQUOTE_action(t,e){79===e&&(this.commandContinued=!1,this.text='"',this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_LONE_SQUOTE_action(t,e){80===e&&(this.commandContinued=!1,this.text="'",this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_DQUOTE_action(t,e){81===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_UNCLOSED_SQUOTE_action(t,e){82===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING,this._type=MathJSLabLexer.UNQUOTED_STRING)}COMMAND_DQSTRING_action(t,e){83===e&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.DQ_STRING),this.quotedString="",this.skip())}COMMAND_SQSTRING_action(t,e){84===e&&(this.commandContinued=!1,this.pushMode(MathJSLabLexer.SQ_STRING),this.quotedString="",this.skip())}COMMAND_SEPARATOR_action(t,e){85===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=","===this.text?MathJSLabLexer.COMMA:MathJSLabLexer.SEMICOLON)}EXIT_AT_NEWLINE_action(t,e){86===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.NEWLINE)}EXIT_AT_EOF_action(t,e){87===e&&(this.commandContinued=!1,this.popMode(),this._type=this.previousTokenType=MathJSLabLexer.EOF)}UNQUOTED_STRING_action(t,e){88===e&&(this.commandContinued=!1,this.previousTokenType=MathJSLabLexer.UNQUOTED_STRING)}sempred(t,e,r){switch(e){case 58:return this.BLOCK_COMMENT_START_sempred(t,r);case 74:return this.BLOCK_COMMENT_START_AGAIN_sempred(t,r);case 75:return this.BLOCK_COMMENT_END_sempred(t,r);case 79:return this.COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(t,r);case 80:return this.COMMAND_CONTINUED_COMMENT_LINE_sempred(t,r);case 81:return this.COMMAND_CONTINUED_NEWLINE_sempred(t,r);case 83:return this.COMMAND_LONE_DQUOTE_sempred(t,r);case 84:return this.COMMAND_LONE_SQUOTE_sempred(t,r);case 85:return this.COMMAND_UNCLOSED_DQUOTE_sempred(t,r);case 86:return this.COMMAND_UNCLOSED_SQUOTE_sempred(t,r);case 87:return this.COMMAND_DQSTRING_sempred(t,r);case 88:return this.COMMAND_SQSTRING_sempred(t,r)}return!0}BLOCK_COMMENT_START_sempred(t,e){return 0!==e||0===this.column}BLOCK_COMMENT_START_AGAIN_sempred(t,e){return 1!==e||0===this.column}BLOCK_COMMENT_END_sempred(t,e){return 2!==e||0===this.column}COMMAND_CONTINUED_BLOCK_COMMENT_START_sempred(t,e){return 3!==e||this.commandContinued}COMMAND_CONTINUED_COMMENT_LINE_sempred(t,e){return 4!==e||this.commandContinued}COMMAND_CONTINUED_NEWLINE_sempred(t,e){return 5!==e||this.commandContinued}COMMAND_LONE_DQUOTE_sempred(t,e){return 6!==e||[antlr4_1.Token.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_LONE_SQUOTE_sempred(t,e){return 7!==e||[antlr4_1.Token.EOF,9,10,13,32].includes(this._input.LA(1))}COMMAND_UNCLOSED_DQUOTE_sempred(t,e){return 8!==e||!this.commandQuoteIsClosed(34)}COMMAND_UNCLOSED_SQUOTE_sempred(t,e){return 9!==e||!this.commandQuoteIsClosed(39)}COMMAND_DQSTRING_sempred(t,e){return 10!==e||this.commandQuoteIsClosed(34)}COMMAND_SQSTRING_sempred(t,e){return 11!==e||this.commandQuoteIsClosed(39)}static _serializedATN=[4,0,142,927,6,-1,6,-1,6,-1,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,7,91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,98,7,98,2,99,7,99,2,100,7,100,2,101,7,101,2,102,7,102,2,103,7,103,2,104,7,104,2,105,7,105,2,106,7,106,1,0,1,0,1,0,1,1,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,14,1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,25,3,25,310,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,29,3,29,339,8,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,35,1,35,1,35,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,3,39,386,8,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,1,47,1,47,1,47,3,47,426,8,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,3,48,435,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,52,1,52,1,52,1,53,1,53,3,53,455,8,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,5,55,469,8,55,10,55,12,55,472,9,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,5,56,483,8,56,10,56,12,56,486,9,56,1,56,1,56,3,56,490,8,56,3,56,492,8,56,1,56,1,56,1,57,1,57,1,57,1,58,1,58,3,58,501,8,58,1,58,1,58,1,58,3,58,506,8,58,1,58,1,58,1,58,1,59,1,59,5,59,513,8,59,10,59,12,59,516,9,59,1,59,1,59,1,59,1,59,1,59,3,59,523,8,59,1,60,1,60,1,61,4,61,528,8,61,11,61,12,61,529,1,61,1,61,1,62,1,62,1,62,1,63,1,63,1,63,1,63,1,63,1,64,1,64,1,64,1,65,4,65,546,8,65,11,65,12,65,547,1,65,1,65,1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,67,1,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,70,1,70,1,70,3,70,571,8,70,1,70,3,70,574,8,70,1,70,1,70,1,71,1,71,1,71,1,71,3,71,582,8,71,1,71,1,71,1,72,1,72,1,72,1,72,3,72,590,8,72,1,72,3,72,593,8,72,1,72,3,72,596,8,72,1,72,1,72,1,73,1,73,1,73,1,74,1,74,3,74,605,8,74,1,74,1,74,1,74,3,74,610,8,74,1,74,1,74,1,74,1,75,1,75,3,75,617,8,75,1,75,1,75,1,75,3,75,622,8,75,1,75,3,75,625,8,75,1,75,1,75,1,76,5,76,630,8,76,10,76,12,76,633,9,76,1,76,1,76,1,76,1,76,1,77,5,77,640,8,77,10,77,12,77,643,9,77,1,77,1,77,1,77,1,78,1,78,1,78,1,78,1,78,5,78,653,8,78,10,78,12,78,656,9,78,1,78,1,78,1,78,1,79,1,79,3,79,663,8,79,1,79,1,79,1,79,3,79,668,8,79,1,79,1,79,1,79,1,80,1,80,1,80,5,80,676,8,80,10,80,12,80,679,9,80,1,80,1,80,1,80,1,80,1,81,1,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,83,1,83,1,83,1,83,1,84,1,84,1,84,1,84,1,85,1,85,1,85,5,85,705,8,85,10,85,12,85,708,9,85,1,85,1,85,1,86,1,86,1,86,5,86,715,8,86,10,86,12,86,718,9,86,1,86,1,86,1,87,1,87,1,87,1,87,1,88,1,88,1,88,1,88,1,89,1,89,5,89,732,8,89,10,89,12,89,735,9,89,1,89,1,89,1,90,1,90,1,90,1,91,1,91,1,91,1,92,1,92,1,92,1,93,1,93,5,93,750,8,93,10,93,12,93,753,9,93,1,93,1,93,1,94,1,94,1,95,1,95,3,95,761,8,95,1,95,3,95,764,8,95,1,96,4,96,767,8,96,11,96,12,96,768,1,97,1,97,5,97,773,8,97,10,97,12,97,776,9,97,1,98,1,98,3,98,780,8,98,1,98,1,98,3,98,784,8,98,1,98,5,98,787,8,98,10,98,12,98,790,9,98,1,99,1,99,3,99,794,8,99,1,99,3,99,797,8,99,1,99,1,99,3,99,801,8,99,1,99,1,99,3,99,805,8,99,1,99,1,99,1,99,1,99,3,99,811,8,99,1,99,3,99,814,8,99,1,99,1,99,3,99,818,8,99,1,99,1,99,3,99,822,8,99,1,99,1,99,1,99,1,99,3,99,828,8,99,1,99,3,99,831,8,99,1,99,1,99,3,99,835,8,99,1,99,1,99,3,99,839,8,99,1,99,1,99,1,99,1,99,3,99,845,8,99,1,99,3,99,848,8,99,1,99,1,99,3,99,852,8,99,1,99,1,99,3,99,856,8,99,3,99,858,8,99,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,3,100,869,8,100,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101,3,101,879,8,101,3,101,881,8,101,1,102,1,102,3,102,885,8,102,1,102,5,102,888,8,102,10,102,12,102,891,9,102,1,103,1,103,3,103,895,8,103,1,103,5,103,898,8,103,10,103,12,103,901,9,103,1,104,1,104,3,104,905,8,104,1,104,5,104,908,8,104,10,104,12,104,911,9,104,1,105,1,105,3,105,915,8,105,1,105,5,105,918,8,105,10,105,12,105,921,9,105,1,106,3,106,924,8,106,1,106,1,106,1,631,0,107,5,49,7,50,9,51,11,52,13,53,15,54,17,55,19,56,21,57,23,58,25,59,27,60,29,61,31,62,33,63,35,64,37,65,39,66,41,67,43,68,45,69,47,70,49,71,51,72,53,73,55,74,57,75,59,76,61,77,63,78,65,79,67,80,69,81,71,82,73,83,75,84,77,85,79,86,81,87,83,88,85,89,87,90,89,91,91,92,93,93,95,94,97,95,99,96,101,97,103,98,105,99,107,100,109,101,111,102,113,103,115,104,117,105,119,106,121,107,123,108,125,109,127,110,129,111,131,112,133,113,135,114,137,115,139,116,141,117,143,118,145,119,147,120,149,121,151,122,153,123,155,124,157,125,159,126,161,127,163,128,165,129,167,130,169,131,171,132,173,133,175,134,177,135,179,136,181,137,183,138,185,139,187,140,189,141,191,142,193,0,195,0,197,0,199,0,201,0,203,0,205,0,207,0,209,0,211,0,213,0,215,0,217,0,5,0,1,2,3,4,25,2,0,73,74,105,106,5,0,39,39,42,42,47,47,92,92,94,94,2,0,10,10,13,13,3,0,10,10,13,13,39,39,4,0,10,10,13,13,34,34,92,92,8,0,34,34,39,39,92,92,98,98,102,102,110,110,114,114,116,116,1,0,48,55,3,0,48,57,65,70,97,102,3,0,9,10,13,13,32,32,2,0,44,44,59,59,7,0,9,10,13,13,32,32,34,34,39,39,44,44,59,59,5,0,9,10,13,13,32,32,44,44,59,59,2,0,35,35,37,37,2,0,9,9,32,32,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,68,69,100,101,2,0,66,66,98,98,2,0,80,80,112,112,2,0,79,79,111,111,2,0,88,88,120,120,2,0,115,115,117,117,1,0,48,57,1,0,48,49,2,0,43,43,45,45,987,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,1,127,1,0,0,0,1,129,1,0,0,0,1,131,1,0,0,0,1,133,1,0,0,0,2,135,1,0,0,0,2,137,1,0,0,0,2,139,1,0,0,0,2,141,1,0,0,0,2,143,1,0,0,0,2,145,1,0,0,0,2,147,1,0,0,0,2,149,1,0,0,0,2,151,1,0,0,0,3,153,1,0,0,0,3,155,1,0,0,0,3,157,1,0,0,0,3,159,1,0,0,0,4,161,1,0,0,0,4,163,1,0,0,0,4,165,1,0,0,0,4,167,1,0,0,0,4,169,1,0,0,0,4,171,1,0,0,0,4,173,1,0,0,0,4,175,1,0,0,0,4,177,1,0,0,0,4,179,1,0,0,0,4,181,1,0,0,0,4,183,1,0,0,0,4,185,1,0,0,0,4,187,1,0,0,0,4,189,1,0,0,0,4,191,1,0,0,0,5,219,1,0,0,0,7,222,1,0,0,0,9,225,1,0,0,0,11,228,1,0,0,0,13,231,1,0,0,0,15,234,1,0,0,0,17,237,1,0,0,0,19,240,1,0,0,0,21,243,1,0,0,0,23,246,1,0,0,0,25,249,1,0,0,0,27,252,1,0,0,0,29,255,1,0,0,0,31,258,1,0,0,0,33,261,1,0,0,0,35,264,1,0,0,0,37,267,1,0,0,0,39,270,1,0,0,0,41,273,1,0,0,0,43,276,1,0,0,0,45,279,1,0,0,0,47,284,1,0,0,0,49,289,1,0,0,0,51,294,1,0,0,0,53,299,1,0,0,0,55,309,1,0,0,0,57,313,1,0,0,0,59,319,1,0,0,0,61,325,1,0,0,0,63,338,1,0,0,0,65,342,1,0,0,0,67,347,1,0,0,0,69,352,1,0,0,0,71,357,1,0,0,0,73,362,1,0,0,0,75,365,1,0,0,0,77,368,1,0,0,0,79,371,1,0,0,0,81,376,1,0,0,0,83,385,1,0,0,0,85,389,1,0,0,0,87,394,1,0,0,0,89,397,1,0,0,0,91,402,1,0,0,0,93,407,1,0,0,0,95,412,1,0,0,0,97,417,1,0,0,0,99,425,1,0,0,0,101,434,1,0,0,0,103,438,1,0,0,0,105,443,1,0,0,0,107,446,1,0,0,0,109,449,1,0,0,0,111,452,1,0,0,0,113,458,1,0,0,0,115,463,1,0,0,0,117,476,1,0,0,0,119,495,1,0,0,0,121,498,1,0,0,0,123,510,1,0,0,0,125,524,1,0,0,0,127,527,1,0,0,0,129,533,1,0,0,0,131,536,1,0,0,0,133,541,1,0,0,0,135,545,1,0,0,0,137,551,1,0,0,0,139,554,1,0,0,0,141,559,1,0,0,0,143,563,1,0,0,0,145,567,1,0,0,0,147,577,1,0,0,0,149,585,1,0,0,0,151,599,1,0,0,0,153,602,1,0,0,0,155,614,1,0,0,0,157,631,1,0,0,0,159,641,1,0,0,0,161,647,1,0,0,0,163,660,1,0,0,0,165,672,1,0,0,0,167,684,1,0,0,0,169,689,1,0,0,0,171,693,1,0,0,0,173,697,1,0,0,0,175,701,1,0,0,0,177,711,1,0,0,0,179,721,1,0,0,0,181,725,1,0,0,0,183,729,1,0,0,0,185,738,1,0,0,0,187,741,1,0,0,0,189,744,1,0,0,0,191,747,1,0,0,0,193,756,1,0,0,0,195,763,1,0,0,0,197,766,1,0,0,0,199,770,1,0,0,0,201,777,1,0,0,0,203,857,1,0,0,0,205,859,1,0,0,0,207,880,1,0,0,0,209,882,1,0,0,0,211,892,1,0,0,0,213,902,1,0,0,0,215,912,1,0,0,0,217,923,1,0,0,0,219,220,5,43,0,0,220,221,6,0,0,0,221,6,1,0,0,0,222,223,5,45,0,0,223,224,6,1,1,0,224,8,1,0,0,0,225,226,5,42,0,0,226,227,6,2,2,0,227,10,1,0,0,0,228,229,5,47,0,0,229,230,6,3,3,0,230,12,1,0,0,0,231,232,5,61,0,0,232,233,6,4,4,0,233,14,1,0,0,0,234,235,5,58,0,0,235,236,6,5,5,0,236,16,1,0,0,0,237,238,5,59,0,0,238,239,6,6,6,0,239,18,1,0,0,0,240,241,5,44,0,0,241,242,6,7,7,0,242,20,1,0,0,0,243,244,5,46,0,0,244,245,6,8,8,0,245,22,1,0,0,0,246,247,5,126,0,0,247,248,6,9,9,0,248,24,1,0,0,0,249,250,5,33,0,0,250,251,6,10,10,0,251,26,1,0,0,0,252,253,5,64,0,0,253,254,6,11,11,0,254,28,1,0,0,0,255,256,5,63,0,0,256,257,6,12,12,0,257,30,1,0,0,0,258,259,5,40,0,0,259,260,6,13,13,0,260,32,1,0,0,0,261,262,5,41,0,0,262,263,6,14,14,0,263,34,1,0,0,0,264,265,5,91,0,0,265,266,6,15,15,0,266,36,1,0,0,0,267,268,5,93,0,0,268,269,6,16,16,0,269,38,1,0,0,0,270,271,5,123,0,0,271,272,6,17,17,0,272,40,1,0,0,0,273,274,5,125,0,0,274,275,6,18,18,0,275,42,1,0,0,0,276,277,5,92,0,0,277,278,6,19,19,0,278,44,1,0,0,0,279,280,5,43,0,0,280,281,5,61,0,0,281,282,1,0,0,0,282,283,6,20,20,0,283,46,1,0,0,0,284,285,5,45,0,0,285,286,5,61,0,0,286,287,1,0,0,0,287,288,6,21,21,0,288,48,1,0,0,0,289,290,5,42,0,0,290,291,5,61,0,0,291,292,1,0,0,0,292,293,6,22,22,0,293,50,1,0,0,0,294,295,5,47,0,0,295,296,5,61,0,0,296,297,1,0,0,0,297,298,6,23,23,0,298,52,1,0,0,0,299,300,5,92,0,0,300,301,5,61,0,0,301,302,1,0,0,0,302,303,6,24,24,0,303,54,1,0,0,0,304,305,5,94,0,0,305,310,5,61,0,0,306,307,5,42,0,0,307,308,5,42,0,0,308,310,5,61,0,0,309,304,1,0,0,0,309,306,1,0,0,0,310,311,1,0,0,0,311,312,6,25,25,0,312,56,1,0,0,0,313,314,5,46,0,0,314,315,5,42,0,0,315,316,5,61,0,0,316,317,1,0,0,0,317,318,6,26,26,0,318,58,1,0,0,0,319,320,5,46,0,0,320,321,5,47,0,0,321,322,5,61,0,0,322,323,1,0,0,0,323,324,6,27,27,0,324,60,1,0,0,0,325,326,5,46,0,0,326,327,5,92,0,0,327,328,5,61,0,0,328,329,1,0,0,0,329,330,6,28,28,0,330,62,1,0,0,0,331,332,5,46,0,0,332,333,5,94,0,0,333,339,5,61,0,0,334,335,5,46,0,0,335,336,5,42,0,0,336,337,5,42,0,0,337,339,5,61,0,0,338,331,1,0,0,0,338,334,1,0,0,0,339,340,1,0,0,0,340,341,6,29,29,0,341,64,1,0,0,0,342,343,5,38,0,0,343,344,5,61,0,0,344,345,1,0,0,0,345,346,6,30,30,0,346,66,1,0,0,0,347,348,5,124,0,0,348,349,5,61,0,0,349,350,1,0,0,0,350,351,6,31,31,0,351,68,1,0,0,0,352,353,5,38,0,0,353,354,5,38,0,0,354,355,1,0,0,0,355,356,6,32,32,0,356,70,1,0,0,0,357,358,5,124,0,0,358,359,5,124,0,0,359,360,1,0,0,0,360,361,6,33,33,0,361,72,1,0,0,0,362,363,5,38,0,0,363,364,6,34,34,0,364,74,1,0,0,0,365,366,5,124,0,0,366,367,6,35,35,0,367,76,1,0,0,0,368,369,5,60,0,0,369,370,6,36,36,0,370,78,1,0,0,0,371,372,5,60,0,0,372,373,5,61,0,0,373,374,1,0,0,0,374,375,6,37,37,0,375,80,1,0,0,0,376,377,5,61,0,0,377,378,5,61,0,0,378,379,1,0,0,0,379,380,6,38,38,0,380,82,1,0,0,0,381,382,5,33,0,0,382,386,5,61,0,0,383,384,5,126,0,0,384,386,5,61,0,0,385,381,1,0,0,0,385,383,1,0,0,0,386,387,1,0,0,0,387,388,6,39,39,0,388,84,1,0,0,0,389,390,5,62,0,0,390,391,5,61,0,0,391,392,1,0,0,0,392,393,6,40,40,0,393,86,1,0,0,0,394,395,5,62,0,0,395,396,6,41,41,0,396,88,1,0,0,0,397,398,5,46,0,0,398,399,5,42,0,0,399,400,1,0,0,0,400,401,6,42,42,0,401,90,1,0,0,0,402,403,5,46,0,0,403,404,5,47,0,0,404,405,1,0,0,0,405,406,6,43,43,0,406,92,1,0,0,0,407,408,5,46,0,0,408,409,5,92,0,0,409,410,1,0,0,0,410,411,6,44,44,0,411,94,1,0,0,0,412,413,5,43,0,0,413,414,5,43,0,0,414,415,1,0,0,0,415,416,6,45,45,0,416,96,1,0,0,0,417,418,5,45,0,0,418,419,5,45,0,0,419,420,1,0,0,0,420,421,6,46,46,0,421,98,1,0,0,0,422,426,5,94,0,0,423,424,5,42,0,0,424,426,5,42,0,0,425,422,1,0,0,0,425,423,1,0,0,0,426,427,1,0,0,0,427,428,6,47,47,0,428,100,1,0,0,0,429,430,5,46,0,0,430,435,5,94,0,0,431,432,5,46,0,0,432,433,5,42,0,0,433,435,5,42,0,0,434,429,1,0,0,0,434,431,1,0,0,0,435,436,1,0,0,0,436,437,6,48,48,0,437,102,1,0,0,0,438,439,5,46,0,0,439,440,5,39,0,0,440,441,1,0,0,0,441,442,6,49,49,0,442,104,1,0,0,0,443,444,5,39,0,0,444,445,6,50,50,0,445,106,1,0,0,0,446,447,5,34,0,0,447,448,6,51,51,0,448,108,1,0,0,0,449,450,3,199,97,0,450,451,6,52,52,0,451,110,1,0,0,0,452,454,3,203,99,0,453,455,7,0,0,0,454,453,1,0,0,0,454,455,1,0,0,0,455,456,1,0,0,0,456,457,6,53,53,0,457,112,1,0,0,0,458,459,3,207,101,0,459,460,5,46,0,0,460,461,7,1,0,0,461,462,6,54,54,0,462,114,1,0,0,0,463,464,5,46,0,0,464,465,5,46,0,0,465,466,5,46,0,0,466,470,1,0,0,0,467,469,8,2,0,0,468,467,1,0,0,0,469,472,1,0,0,0,470,468,1,0,0,0,470,471,1,0,0,0,471,473,1,0,0,0,472,470,1,0,0,0,473,474,3,195,95,0,474,475,6,55,55,0,475,116,1,0,0,0,476,491,3,197,96,0,477,478,5,46,0,0,478,479,5,46,0,0,479,480,5,46,0,0,480,484,1,0,0,0,481,483,8,2,0,0,482,481,1,0,0,0,483,486,1,0,0,0,484,482,1,0,0,0,484,485,1,0,0,0,485,487,1,0,0,0,486,484,1,0,0,0,487,489,3,195,95,0,488,490,3,197,96,0,489,488,1,0,0,0,489,490,1,0,0,0,490,492,1,0,0,0,491,477,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,6,56,56,0,494,118,1,0,0,0,495,496,3,195,95,0,496,497,6,57,57,0,497,120,1,0,0,0,498,500,4,58,0,0,499,501,3,197,96,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,3,193,94,0,503,505,5,123,0,0,504,506,3,197,96,0,505,504,1,0,0,0,505,506,1,0,0,0,506,507,1,0,0,0,507,508,3,195,95,0,508,509,6,58,58,0,509,122,1,0,0,0,510,514,3,193,94,0,511,513,8,2,0,0,512,511,1,0,0,0,513,516,1,0,0,0,514,512,1,0,0,0,514,515,1,0,0,0,515,522,1,0,0,0,516,514,1,0,0,0,517,518,3,195,95,0,518,519,6,59,59,0,519,523,1,0,0,0,520,521,5,0,0,1,521,523,6,59,60,0,522,517,1,0,0,0,522,520,1,0,0,0,523,124,1,0,0,0,524,525,9,0,0,0,525,126,1,0,0,0,526,528,8,3,0,0,527,526,1,0,0,0,528,529,1,0,0,0,529,527,1,0,0,0,529,530,1,0,0,0,530,531,1,0,0,0,531,532,6,61,61,0,532,128,1,0,0,0,533,534,3,195,95,0,534,535,6,62,62,0,535,130,1,0,0,0,536,537,5,39,0,0,537,538,5,39,0,0,538,539,1,0,0,0,539,540,6,63,63,0,540,132,1,0,0,0,541,542,5,39,0,0,542,543,6,64,64,0,543,134,1,0,0,0,544,546,8,4,0,0,545,544,1,0,0,0,546,547,1,0,0,0,547,545,1,0,0,0,547,548,1,0,0,0,548,549,1,0,0,0,549,550,6,65,65,0,550,136,1,0,0,0,551,552,3,195,95,0,552,553,6,66,66,0,553,138,1,0,0,0,554,555,5,34,0,0,555,556,5,34,0,0,556,557,1,0,0,0,557,558,6,67,67,0,558,140,1,0,0,0,559,560,5,92,0,0,560,561,7,5,0,0,561,562,6,68,68,0,562,142,1,0,0,0,563,564,5,92,0,0,564,565,9,0,0,0,565,566,6,69,69,0,566,144,1,0,0,0,567,568,5,92,0,0,568,570,7,6,0,0,569,571,7,6,0,0,570,569,1,0,0,0,570,571,1,0,0,0,571,573,1,0,0,0,572,574,7,6,0,0,573,572,1,0,0,0,573,574,1,0,0,0,574,575,1,0,0,0,575,576,6,70,70,0,576,146,1,0,0,0,577,578,5,92,0,0,578,579,5,120,0,0,579,581,7,7,0,0,580,582,7,7,0,0,581,580,1,0,0,0,581,582,1,0,0,0,582,583,1,0,0,0,583,584,6,71,71,0,584,148,1,0,0,0,585,586,5,92,0,0,586,587,5,117,0,0,587,589,7,7,0,0,588,590,7,7,0,0,589,588,1,0,0,0,589,590,1,0,0,0,590,592,1,0,0,0,591,593,7,7,0,0,592,591,1,0,0,0,592,593,1,0,0,0,593,595,1,0,0,0,594,596,7,7,0,0,595,594,1,0,0,0,595,596,1,0,0,0,596,597,1,0,0,0,597,598,6,72,72,0,598,150,1,0,0,0,599,600,5,34,0,0,600,601,6,73,73,0,601,152,1,0,0,0,602,604,4,74,1,0,603,605,3,197,96,0,604,603,1,0,0,0,604,605,1,0,0,0,605,606,1,0,0,0,606,607,3,193,94,0,607,609,5,123,0,0,608,610,3,197,96,0,609,608,1,0,0,0,609,610,1,0,0,0,610,611,1,0,0,0,611,612,3,195,95,0,612,613,6,74,74,0,613,154,1,0,0,0,614,616,4,75,2,0,615,617,3,197,96,0,616,615,1,0,0,0,616,617,1,0,0,0,617,618,1,0,0,0,618,619,3,193,94,0,619,621,5,125,0,0,620,622,3,197,96,0,621,620,1,0,0,0,621,622,1,0,0,0,622,624,1,0,0,0,623,625,3,195,95,0,624,623,1,0,0,0,624,625,1,0,0,0,625,626,1,0,0,0,626,627,6,75,75,0,627,156,1,0,0,0,628,630,9,0,0,0,629,628,1,0,0,0,630,633,1,0,0,0,631,632,1,0,0,0,631,629,1,0,0,0,632,634,1,0,0,0,633,631,1,0,0,0,634,635,3,195,95,0,635,636,1,0,0,0,636,637,6,76,76,0,637,158,1,0,0,0,638,640,8,2,0,0,639,638,1,0,0,0,640,643,1,0,0,0,641,639,1,0,0,0,641,642,1,0,0,0,642,644,1,0,0,0,643,641,1,0,0,0,644,645,5,0,0,1,645,646,6,77,77,0,646,160,1,0,0,0,647,648,5,46,0,0,648,649,5,46,0,0,649,650,5,46,0,0,650,654,1,0,0,0,651,653,8,2,0,0,652,651,1,0,0,0,653,656,1,0,0,0,654,652,1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656,654,1,0,0,0,657,658,3,195,95,0,658,659,6,78,78,0,659,162,1,0,0,0,660,662,4,79,3,0,661,663,3,197,96,0,662,661,1,0,0,0,662,663,1,0,0,0,663,664,1,0,0,0,664,665,3,193,94,0,665,667,5,123,0,0,666,668,3,197,96,0,667,666,1,0,0,0,667,668,1,0,0,0,668,669,1,0,0,0,669,670,3,195,95,0,670,671,6,79,79,0,671,164,1,0,0,0,672,673,4,80,4,0,673,677,3,193,94,0,674,676,8,2,0,0,675,674,1,0,0,0,676,679,1,0,0,0,677,675,1,0,0,0,677,678,1,0,0,0,678,680,1,0,0,0,679,677,1,0,0,0,680,681,3,195,95,0,681,682,1,0,0,0,682,683,6,80,76,0,683,166,1,0,0,0,684,685,4,81,5,0,685,686,3,195,95,0,686,687,1,0,0,0,687,688,6,81,76,0,688,168,1,0,0,0,689,690,3,197,96,0,690,691,1,0,0,0,691,692,6,82,76,0,692,170,1,0,0,0,693,694,5,34,0,0,694,695,4,83,6,0,695,696,6,83,80,0,696,172,1,0,0,0,697,698,5,39,0,0,698,699,4,84,7,0,699,700,6,84,81,0,700,174,1,0,0,0,701,702,5,34,0,0,702,706,4,85,8,0,703,705,8,8,0,0,704,703,1,0,0,0,705,708,1,0,0,0,706,704,1,0,0,0,706,707,1,0,0,0,707,709,1,0,0,0,708,706,1,0,0,0,709,710,6,85,82,0,710,176,1,0,0,0,711,712,5,39,0,0,712,716,4,86,9,0,713,715,8,8,0,0,714,713,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,719,1,0,0,0,718,716,1,0,0,0,719,720,6,86,83,0,720,178,1,0,0,0,721,722,5,34,0,0,722,723,4,87,10,0,723,724,6,87,84,0,724,180,1,0,0,0,725,726,5,39,0,0,726,727,4,88,11,0,727,728,6,88,85,0,728,182,1,0,0,0,729,733,3,193,94,0,730,732,8,2,0,0,731,730,1,0,0,0,732,735,1,0,0,0,733,731,1,0,0,0,733,734,1,0,0,0,734,736,1,0,0,0,735,733,1,0,0,0,736,737,6,89,76,0,737,184,1,0,0,0,738,739,7,9,0,0,739,740,6,90,86,0,740,186,1,0,0,0,741,742,3,195,95,0,742,743,6,91,87,0,743,188,1,0,0,0,744,745,5,0,0,1,745,746,6,92,88,0,746,190,1,0,0,0,747,751,8,10,0,0,748,750,8,11,0,0,749,748,1,0,0,0,750,753,1,0,0,0,751,749,1,0,0,0,751,752,1,0,0,0,752,754,1,0,0,0,753,751,1,0,0,0,754,755,6,93,89,0,755,192,1,0,0,0,756,757,7,12,0,0,757,194,1,0,0,0,758,764,5,13,0,0,759,761,5,13,0,0,760,759,1,0,0,0,760,761,1,0,0,0,761,762,1,0,0,0,762,764,5,10,0,0,763,758,1,0,0,0,763,760,1,0,0,0,764,196,1,0,0,0,765,767,7,13,0,0,766,765,1,0,0,0,767,768,1,0,0,0,768,766,1,0,0,0,768,769,1,0,0,0,769,198,1,0,0,0,770,774,7,14,0,0,771,773,7,15,0,0,772,771,1,0,0,0,773,776,1,0,0,0,774,772,1,0,0,0,774,775,1,0,0,0,775,200,1,0,0,0,776,774,1,0,0,0,777,788,3,199,97,0,778,780,3,197,96,0,779,778,1,0,0,0,779,780,1,0,0,0,780,781,1,0,0,0,781,783,5,46,0,0,782,784,3,197,96,0,783,782,1,0,0,0,783,784,1,0,0,0,784,785,1,0,0,0,785,787,3,199,97,0,786,779,1,0,0,0,787,790,1,0,0,0,788,786,1,0,0,0,788,789,1,0,0,0,789,202,1,0,0,0,790,788,1,0,0,0,791,793,3,209,102,0,792,794,5,46,0,0,793,792,1,0,0,0,793,794,1,0,0,0,794,801,1,0,0,0,795,797,3,209,102,0,796,795,1,0,0,0,796,797,1,0,0,0,797,798,1,0,0,0,798,799,5,46,0,0,799,801,3,209,102,0,800,791,1,0,0,0,800,796,1,0,0,0,801,804,1,0,0,0,802,803,7,16,0,0,803,805,3,217,106,0,804,802,1,0,0,0,804,805,1,0,0,0,805,858,1,0,0,0,806,807,5,48,0,0,807,817,7,17,0,0,808,810,3,211,103,0,809,811,5,46,0,0,810,809,1,0,0,0,810,811,1,0,0,0,811,818,1,0,0,0,812,814,3,211,103,0,813,812,1,0,0,0,813,814,1,0,0,0,814,815,1,0,0,0,815,816,5,46,0,0,816,818,3,211,103,0,817,808,1,0,0,0,817,813,1,0,0,0,818,821,1,0,0,0,819,820,7,18,0,0,820,822,3,217,106,0,821,819,1,0,0,0,821,822,1,0,0,0,822,858,1,0,0,0,823,824,5,48,0,0,824,834,7,19,0,0,825,827,3,213,104,0,826,828,5,46,0,0,827,826,1,0,0,0,827,828,1,0,0,0,828,835,1,0,0,0,829,831,3,213,104,0,830,829,1,0,0,0,830,831,1,0,0,0,831,832,1,0,0,0,832,833,5,46,0,0,833,835,3,213,104,0,834,825,1,0,0,0,834,830,1,0,0,0,835,838,1,0,0,0,836,837,7,18,0,0,837,839,3,217,106,0,838,836,1,0,0,0,838,839,1,0,0,0,839,858,1,0,0,0,840,841,5,48,0,0,841,851,7,20,0,0,842,844,3,215,105,0,843,845,5,46,0,0,844,843,1,0,0,0,844,845,1,0,0,0,845,852,1,0,0,0,846,848,3,215,105,0,847,846,1,0,0,0,847,848,1,0,0,0,848,849,1,0,0,0,849,850,5,46,0,0,850,852,3,215,105,0,851,842,1,0,0,0,851,847,1,0,0,0,852,855,1,0,0,0,853,854,7,18,0,0,854,856,3,217,106,0,855,853,1,0,0,0,855,856,1,0,0,0,856,858,1,0,0,0,857,800,1,0,0,0,857,806,1,0,0,0,857,823,1,0,0,0,857,840,1,0,0,0,858,204,1,0,0,0,859,860,3,207,101,0,860,868,7,21,0,0,861,869,5,56,0,0,862,863,5,49,0,0,863,869,5,54,0,0,864,865,5,51,0,0,865,869,5,50,0,0,866,867,5,54,0,0,867,869,5,52,0,0,868,861,1,0,0,0,868,862,1,0,0,0,868,864,1,0,0,0,868,866,1,0,0,0,869,206,1,0,0,0,870,881,3,209,102,0,871,878,5,48,0,0,872,873,7,17,0,0,873,879,3,211,103,0,874,875,7,19,0,0,875,879,3,213,104,0,876,877,7,20,0,0,877,879,3,215,105,0,878,872,1,0,0,0,878,874,1,0,0,0,878,876,1,0,0,0,879,881,1,0,0,0,880,870,1,0,0,0,880,871,1,0,0,0,881,208,1,0,0,0,882,889,7,22,0,0,883,885,5,95,0,0,884,883,1,0,0,0,884,885,1,0,0,0,885,886,1,0,0,0,886,888,7,22,0,0,887,884,1,0,0,0,888,891,1,0,0,0,889,887,1,0,0,0,889,890,1,0,0,0,890,210,1,0,0,0,891,889,1,0,0,0,892,899,7,23,0,0,893,895,5,95,0,0,894,893,1,0,0,0,894,895,1,0,0,0,895,896,1,0,0,0,896,898,7,23,0,0,897,894,1,0,0,0,898,901,1,0,0,0,899,897,1,0,0,0,899,900,1,0,0,0,900,212,1,0,0,0,901,899,1,0,0,0,902,909,7,6,0,0,903,905,5,95,0,0,904,903,1,0,0,0,904,905,1,0,0,0,905,906,1,0,0,0,906,908,7,6,0,0,907,904,1,0,0,0,908,911,1,0,0,0,909,907,1,0,0,0,909,910,1,0,0,0,910,214,1,0,0,0,911,909,1,0,0,0,912,919,7,7,0,0,913,915,5,95,0,0,914,913,1,0,0,0,914,915,1,0,0,0,915,916,1,0,0,0,916,918,7,7,0,0,917,914,1,0,0,0,918,921,1,0,0,0,919,917,1,0,0,0,919,920,1,0,0,0,920,216,1,0,0,0,921,919,1,0,0,0,922,924,7,24,0,0,923,922,1,0,0,0,923,924,1,0,0,0,924,925,1,0,0,0,925,926,3,209,102,0,926,218,1,0,0,0,78,0,1,2,3,4,309,338,385,425,434,454,470,484,489,491,500,505,514,522,529,547,570,573,581,589,592,595,604,609,616,621,624,631,641,654,662,667,677,706,716,733,751,760,763,768,774,779,783,788,793,796,800,804,810,813,817,821,827,830,834,838,844,847,851,855,857,868,878,880,884,889,894,899,904,909,914,919,923,90,1,0,0,1,1,1,1,2,2,1,3,3,1,4,4,1,5,5,1,6,6,1,7,7,1,8,8,1,9,9,1,10,10,1,11,11,1,12,12,1,13,13,1,14,14,1,15,15,1,16,16,1,17,17,1,18,18,1,19,19,1,20,20,1,21,21,1,22,22,1,23,23,1,24,24,1,25,25,1,26,26,1,27,27,1,28,28,1,29,29,1,30,30,1,31,31,1,32,32,1,33,33,1,34,34,1,35,35,1,36,36,1,37,37,1,38,38,1,39,39,1,40,40,1,41,41,1,42,42,1,43,43,1,44,44,1,45,45,1,46,46,1,47,47,1,48,48,1,49,49,1,50,50,1,51,51,1,52,52,1,53,53,1,54,54,1,55,55,1,56,56,1,57,57,1,58,58,1,59,59,1,59,60,1,61,61,1,62,62,1,63,63,1,64,64,1,65,65,1,66,66,1,67,67,1,68,68,1,69,69,1,70,70,1,71,71,1,72,72,1,73,73,1,74,74,1,75,75,6,0,0,1,77,76,1,78,77,1,79,78,1,83,79,1,84,80,1,85,81,1,86,82,1,87,83,1,88,84,1,90,85,1,91,86,1,92,87,1,93,88];static __ATN;static get _ATN(){return MathJSLabLexer.__ATN||(MathJSLabLexer.__ATN=(new antlr4_1.ATNDeserializer).deserialize(MathJSLabLexer._serializedATN)),MathJSLabLexer.__ATN}static DecisionsToDFA=MathJSLabLexer._ATN.decisionToState.map((t,e)=>new antlr4_1.DFA(t,e))}exports.default=MathJSLabLexer},6770(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Jump_commandContext=e.Spmd_worker_specContext=e.Spmd_commandContext=e.For_commandContext=e.Do_until_commandContext=e.While_commandContext=e.Loop_commandContext=e.Otherwise_caseContext=e.Switch_caseContext=e.Switch_case_listContext=e.Switch_commandContext=e.Else_clauseContext=e.Elseif_clauseContext=e.If_commandContext=e.Select_commandContext=e.Import_nameContext=e.Import_commandContext=e.Declaration_elementContext=e.DeclarationContext=e.CommandContext=e.Assign_listContext=e.Assign_lhsContext=e.ExpressionContext=e.Simple_exprContext=e.Colon_exprContext=e.Power_exprContext=e.Oper_exprContext=e.Arg_listContext=e.List_elementContext=e.Magic_tildeContext=e.Magic_colonContext=e.Primary_exprContext=e.Anon_fcn_handleContext=e.Meta_classContext=e.Fcn_handleContext=e.Matrix_rowContext=e.MatrixContext=e.ConstantContext=e.End_rangeContext=e.NumberContext=e.StringContext=e.Qualified_identifierContext=e.Qualified_identifier_partContext=e.IdentifierContext=e.Command_wordContext=e.Word_list_cmdContext=e.StatementContext=e.ListContext=e.Global_listContext=e.InputContext=void 0,e.SepContext=e.NlContext=e.Sep_no_nlContext=e.Arg_validation_nameContext=e.Arg_validationContext=e.Args_validation_listContext=e.Arguments_attribute_listContext=e.Arguments_blockContext=e.Arguments_block_listContext=e.Class_enumerationContext=e.Class_enumeration_listContext=e.Enumeration_sectionContext=e.Class_eventContext=e.Class_event_listContext=e.Events_sectionContext=e.Class_method_listContext=e.Class_methodContext=e.Methods_sectionContext=e.Class_propertyContext=e.Class_property_listContext=e.Properties_sectionContext=e.Class_sectionContext=e.Class_section_listContext=e.Class_superclass_listContext=e.Class_method_nameContext=e.Class_attributeContext=e.Class_attribute_listContext=e.Classdef_commandContext=e.Function_nameContext=e.FunctionContext=e.Return_listContext=e.Return_list_eltContext=e.Param_list_eltContext=e.Param_listContext=e.Unwind_cleanup_clauseContext=e.Unwind_commandContext=e.Catch_clauseContext=e.Try_commandContext=e.Except_commandContext=void 0;const s=r(3222),i=r(6109);class n extends s.Parser{static GLOBAL=1;static PERSISTENT=2;static IMPORT=3;static IF=4;static ENDIF=5;static END=6;static ENDRANGE=7;static ELSEIF=8;static ELSE=9;static SWITCH=10;static ENDSWITCH=11;static CASE=12;static OTHERWISE=13;static WHILE=14;static ENDWHILE=15;static DO=16;static UNTIL=17;static FOR=18;static ENDFOR=19;static PARFOR=20;static ENDPARFOR=21;static SPMD=22;static ENDSPMD=23;static BREAK=24;static CONTINUE=25;static RETURN=26;static FUNCTION=27;static ENDFUNCTION=28;static TRY=29;static CATCH=30;static END_TRY_CATCH=31;static UNWIND_PROTECT=32;static UNWIND_PROTECT_CLEANUP=33;static END_UNWIND_PROTECT=34;static CLASSDEF=35;static ENDCLASSDEF=36;static ENUMERATION=37;static ENDENUMERATION=38;static PROPERTIES=39;static ENDPROPERTIES=40;static EVENTS=41;static ENDEVENTS=42;static METHODS=43;static ENDMETHODS=44;static WSPACE=45;static STRING=46;static ARGUMENTS=47;static ENDARGUMENTS=48;static PLUS=49;static MINUS=50;static MUL=51;static DIV=52;static EQ=53;static COLON=54;static SEMICOLON=55;static COMMA=56;static DOT=57;static TILDE=58;static EXCLAMATION=59;static COMMAT=60;static QUESTION=61;static LPAREN=62;static RPAREN=63;static LBRACKET=64;static RBRACKET=65;static LCURLYBR=66;static RCURLYBR=67;static LEFTDIV=68;static ADD_EQ=69;static SUB_EQ=70;static MUL_EQ=71;static DIV_EQ=72;static LEFTDIV_EQ=73;static POW_EQ=74;static EMUL_EQ=75;static EDIV_EQ=76;static ELEFTDIV_EQ=77;static EPOW_EQ=78;static AND_EQ=79;static OR_EQ=80;static EXPR_AND_AND=81;static EXPR_OR_OR=82;static EXPR_AND=83;static EXPR_OR=84;static EXPR_LT=85;static EXPR_LE=86;static EXPR_EQ=87;static EXPR_NE=88;static EXPR_GE=89;static EXPR_GT=90;static EMUL=91;static EDIV=92;static ELEFTDIV=93;static PLUS_PLUS=94;static MINUS_MINUS=95;static POW=96;static EPOW=97;static TRANSPOSE=98;static HERMITIAN=99;static DQSTRING=100;static IDENTIFIER=101;static FLOAT_NUMBER=102;static NUMBER_DOT_OP=103;static LINE_CONTINUATION=104;static SPACE_OR_CONTINUATION=105;static NEWLINE=106;static BLOCK_COMMENT_START=107;static COMMENT_LINE=108;static INVALID=109;static SINGLEQ_STRING=110;static SINGLEQ_NL=111;static SINGLEQ_SINGLEQ=112;static SINGLEQ_END=113;static DOUBLEQ_STRING=114;static DOUBLEQ_NL=115;static DOUBLEQ_DOUBLEQ=116;static DOUBLEQ_ESCAPE=117;static DOUBLEQ_ESCAPE_OTHER=118;static DOUBLEQ_ESCAPE_OCT=119;static DOUBLEQ_ESCAPE_HEX=120;static DOUBLEQ_ESCAPE_UNICODE=121;static DOUBLEQ_END=122;static BLOCK_COMMENT_START_AGAIN=123;static BLOCK_COMMENT_END=124;static BLOCK_COMMENT_LINE=125;static BLOCK_COMMENT_EOF=126;static COMMAND_LINE_CONTINUATION=127;static COMMAND_CONTINUED_BLOCK_COMMENT_START=128;static COMMAND_CONTINUED_COMMENT_LINE=129;static COMMAND_CONTINUED_NEWLINE=130;static SKIP_SPACE=131;static COMMAND_LONE_DQUOTE=132;static COMMAND_LONE_SQUOTE=133;static COMMAND_UNCLOSED_DQUOTE=134;static COMMAND_UNCLOSED_SQUOTE=135;static COMMAND_DQSTRING=136;static COMMAND_SQSTRING=137;static SKIP_COMMENT_LINE=138;static COMMAND_SEPARATOR=139;static EXIT_AT_NEWLINE=140;static EXIT_AT_EOF=141;static UNQUOTED_STRING=142;static EOF=s.Token.EOF;static RULE_input=0;static RULE_global_list=1;static RULE_list=2;static RULE_statement=3;static RULE_word_list_cmd=4;static RULE_command_word=5;static RULE_identifier=6;static RULE_qualified_identifier_part=7;static RULE_qualified_identifier=8;static RULE_string=9;static RULE_number=10;static RULE_end_range=11;static RULE_constant=12;static RULE_matrix=13;static RULE_matrix_row=14;static RULE_fcn_handle=15;static RULE_meta_class=16;static RULE_anon_fcn_handle=17;static RULE_primary_expr=18;static RULE_magic_colon=19;static RULE_magic_tilde=20;static RULE_list_element=21;static RULE_arg_list=22;static RULE_oper_expr=23;static RULE_power_expr=24;static RULE_colon_expr=25;static RULE_simple_expr=26;static RULE_expression=27;static RULE_assign_lhs=28;static RULE_assign_list=29;static RULE_command=30;static RULE_declaration=31;static RULE_declaration_element=32;static RULE_import_command=33;static RULE_import_name=34;static RULE_select_command=35;static RULE_if_command=36;static RULE_elseif_clause=37;static RULE_else_clause=38;static RULE_switch_command=39;static RULE_switch_case_list=40;static RULE_switch_case=41;static RULE_otherwise_case=42;static RULE_loop_command=43;static RULE_while_command=44;static RULE_do_until_command=45;static RULE_for_command=46;static RULE_spmd_command=47;static RULE_spmd_worker_spec=48;static RULE_jump_command=49;static RULE_except_command=50;static RULE_try_command=51;static RULE_catch_clause=52;static RULE_unwind_command=53;static RULE_unwind_cleanup_clause=54;static RULE_param_list=55;static RULE_param_list_elt=56;static RULE_return_list_elt=57;static RULE_return_list=58;static RULE_function=59;static RULE_function_name=60;static RULE_classdef_command=61;static RULE_class_attribute_list=62;static RULE_class_attribute=63;static RULE_class_method_name=64;static RULE_class_superclass_list=65;static RULE_class_section_list=66;static RULE_class_section=67;static RULE_properties_section=68;static RULE_class_property_list=69;static RULE_class_property=70;static RULE_methods_section=71;static RULE_class_method=72;static RULE_class_method_list=73;static RULE_events_section=74;static RULE_class_event_list=75;static RULE_class_event=76;static RULE_enumeration_section=77;static RULE_class_enumeration_list=78;static RULE_class_enumeration=79;static RULE_arguments_block_list=80;static RULE_arguments_block=81;static RULE_arguments_attribute_list=82;static RULE_args_validation_list=83;static RULE_arg_validation=84;static RULE_arg_validation_name=85;static RULE_sep_no_nl=86;static RULE_nl=87;static RULE_sep=88;static literalNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"'+'","'-'","'*'","'/'","'='","':'","';'","','","'.'","'~'","'!'","'@'","'?'","'('","')'","'['","']'","'{'","'}'","'\\'","'+='","'-='","'*='","'/='","'\\='",null,"'.*='","'./='","'.\\='",null,"'&='","'|='","'&&'","'||'","'&'","'|'","'<'","'<='","'=='",null,"'>='","'>'","'.*'","'./'","'.\\'","'++'","'--'",null,null,"'.''",null,null,null,null,null,null,null,null,null,null,null,null,null,"''''",null,null,null,"'\"\"'"];static symbolicNames=[null,"GLOBAL","PERSISTENT","IMPORT","IF","ENDIF","END","ENDRANGE","ELSEIF","ELSE","SWITCH","ENDSWITCH","CASE","OTHERWISE","WHILE","ENDWHILE","DO","UNTIL","FOR","ENDFOR","PARFOR","ENDPARFOR","SPMD","ENDSPMD","BREAK","CONTINUE","RETURN","FUNCTION","ENDFUNCTION","TRY","CATCH","END_TRY_CATCH","UNWIND_PROTECT","UNWIND_PROTECT_CLEANUP","END_UNWIND_PROTECT","CLASSDEF","ENDCLASSDEF","ENUMERATION","ENDENUMERATION","PROPERTIES","ENDPROPERTIES","EVENTS","ENDEVENTS","METHODS","ENDMETHODS","WSPACE","STRING","ARGUMENTS","ENDARGUMENTS","PLUS","MINUS","MUL","DIV","EQ","COLON","SEMICOLON","COMMA","DOT","TILDE","EXCLAMATION","COMMAT","QUESTION","LPAREN","RPAREN","LBRACKET","RBRACKET","LCURLYBR","RCURLYBR","LEFTDIV","ADD_EQ","SUB_EQ","MUL_EQ","DIV_EQ","LEFTDIV_EQ","POW_EQ","EMUL_EQ","EDIV_EQ","ELEFTDIV_EQ","EPOW_EQ","AND_EQ","OR_EQ","EXPR_AND_AND","EXPR_OR_OR","EXPR_AND","EXPR_OR","EXPR_LT","EXPR_LE","EXPR_EQ","EXPR_NE","EXPR_GE","EXPR_GT","EMUL","EDIV","ELEFTDIV","PLUS_PLUS","MINUS_MINUS","POW","EPOW","TRANSPOSE","HERMITIAN","DQSTRING","IDENTIFIER","FLOAT_NUMBER","NUMBER_DOT_OP","LINE_CONTINUATION","SPACE_OR_CONTINUATION","NEWLINE","BLOCK_COMMENT_START","COMMENT_LINE","INVALID","SINGLEQ_STRING","SINGLEQ_NL","SINGLEQ_SINGLEQ","SINGLEQ_END","DOUBLEQ_STRING","DOUBLEQ_NL","DOUBLEQ_DOUBLEQ","DOUBLEQ_ESCAPE","DOUBLEQ_ESCAPE_OTHER","DOUBLEQ_ESCAPE_OCT","DOUBLEQ_ESCAPE_HEX","DOUBLEQ_ESCAPE_UNICODE","DOUBLEQ_END","BLOCK_COMMENT_START_AGAIN","BLOCK_COMMENT_END","BLOCK_COMMENT_LINE","BLOCK_COMMENT_EOF","COMMAND_LINE_CONTINUATION","COMMAND_CONTINUED_BLOCK_COMMENT_START","COMMAND_CONTINUED_COMMENT_LINE","COMMAND_CONTINUED_NEWLINE","SKIP_SPACE","COMMAND_LONE_DQUOTE","COMMAND_LONE_SQUOTE","COMMAND_UNCLOSED_DQUOTE","COMMAND_UNCLOSED_SQUOTE","COMMAND_DQSTRING","COMMAND_SQSTRING","SKIP_COMMENT_LINE","COMMAND_SEPARATOR","EXIT_AT_NEWLINE","EXIT_AT_EOF","UNQUOTED_STRING"];static ruleNames=["input","global_list","list","statement","word_list_cmd","command_word","identifier","qualified_identifier_part","qualified_identifier","string","number","end_range","constant","matrix","matrix_row","fcn_handle","meta_class","anon_fcn_handle","primary_expr","magic_colon","magic_tilde","list_element","arg_list","oper_expr","power_expr","colon_expr","simple_expr","expression","assign_lhs","assign_list","command","declaration","declaration_element","import_command","import_name","select_command","if_command","elseif_clause","else_clause","switch_command","switch_case_list","switch_case","otherwise_case","loop_command","while_command","do_until_command","for_command","spmd_command","spmd_worker_spec","jump_command","except_command","try_command","catch_clause","unwind_command","unwind_cleanup_clause","param_list","param_list_elt","return_list_elt","return_list","function","function_name","classdef_command","class_attribute_list","class_attribute","class_method_name","class_superclass_list","class_section_list","class_section","properties_section","class_property_list","class_property","methods_section","class_method","class_method_list","events_section","class_event_list","class_event","enumeration_section","class_enumeration_list","class_enumeration","arguments_block_list","arguments_block","arguments_attribute_list","args_validation_list","arg_validation","arg_validation_name","sep_no_nl","nl","sep"];get grammarFileName(){return"MathJSLabParser.g4"}get literalNames(){return n.literalNames}get symbolicNames(){return n.symbolicNames}get ruleNames(){return n.ruleNames}get serializedATN(){return n._serializedATN}createFailedPredicateException(t,e){return new s.FailedPredicateException(this,t,e)}markStatementRange(t,e){t.start={line:e.line,column:e.column},t.stop={line:this._input.LT(1).column>0?this._input.LT(1).line:this._input.LT(1).line-1,column:this._input.LT(1).column>0?this._input.LT(1).column-1:1/0}}markPreviousStatementOmitOutput(t,e){";"===e?.[0]&&(t.list[t.list.length-1].omitOutput=!0)}constructor(t){super(t),this._interp=new s.ParserATNSimulator(this,n._ATN,n.DecisionsToDFA,new s.PredictionContextCache)}input(){let t,e=new a(this,this._ctx,this.state);this.enterRule(e,0,n.RULE_input);try{switch(this.state=190,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,2,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=179,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=178,this.sep()),this.state=181,this.match(n.EOF),e.node=null;break;case 2:this.enterOuterAlt(e,2),this.state=184,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=183,this.sep()),this.state=186,this.global_list(),this.state=187,this.match(n.EOF),e.node=e.global_list().node}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}global_list(){let t,e=new o(this,this._ctx,this.state);this.enterRule(e,2,n.RULE_global_list);try{let r;for(this.enterOuterAlt(e,1),this.state=192,this.statement(),this.markStatementRange(e.statement(e.i).node,e.statement(e.i).start),e.node=i.AST.nodeListFirst(e.statement(e.i++).node),this.state=200,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=194,this.sep(),this.state=195,this.statement(),this.markStatementRange(e.statement(e.i).node,e.statement(e.i).start),this.markPreviousStatementOmitOutput(e.node,e.sep(e.i-1).getText()),e.node=i.AST.appendNodeList(e.node,e.statement(e.i++).node)),this.state=202,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,3,this._ctx);this.state=204,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=203,this.sep()),this.markPreviousStatementOmitOutput(e.node,e.sep(e.i-1)?.getText())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}list(){let t=new l(this,this._ctx,this.state);this.enterRule(t,4,n.RULE_list);try{let e;for(this.enterOuterAlt(t,1),this.state=208,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),t.node=i.AST.nodeListFirst(t.statement(t.i++).node),this.state=216,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,5,this._ctx);2!==e&&e!==s.ATN.INVALID_ALT_NUMBER;)1===e&&(this.state=210,this.sep(),this.state=211,this.statement(),this.markStatementRange(t.statement(t.i).node,t.statement(t.i).start),this.markPreviousStatementOmitOutput(t.node,t.sep(t.i-1).getText()),t.node=i.AST.appendNodeList(t.node,t.statement(t.i++).node)),this.state=218,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,5,this._ctx);this.state=220,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,6,this._ctx)&&(this.state=219,this.sep()),this.markPreviousStatementOmitOutput(t.node,t.sep(t.i-1)?.getText())}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}statement(){let t=new c(this,this._ctx,this.state);this.enterRule(t,6,n.RULE_statement);try{switch(this.state=233,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,7,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=224,this.command(),t.node=t.command().node;break;case 2:this.enterOuterAlt(t,2),this.state=227,this.word_list_cmd(),t.node=t.word_list_cmd().node;break;case 3:this.enterOuterAlt(t,3),this.state=230,this.expression(),t.node=t.expression().node}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}word_list_cmd(){let t,e=new u(this,this._ctx,this.state);this.enterRule(e,8,n.RULE_word_list_cmd);try{for(this.enterOuterAlt(e,1),this.state=235,this.identifier(),this.state=236,this.command_word(),e.node=i.AST.nodeListFirst(e.command_word(e.i++).node),this.state=243,this._errHandler.sync(this),t=this._input.LA(1);46===t||142===t;)this.state=238,this.command_word(),i.AST.appendNodeList(e.node,e.command_word(e.i++).node),this.state=245,this._errHandler.sync(this),t=this._input.LA(1);e.node=i.AST.nodeCmdWList(e.identifier().node,e.node)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}command_word(){let t=new h(this,this._ctx,this.state);this.enterRule(t,10,n.RULE_command_word);try{this.enterOuterAlt(t,1),this.state=248,this.string_(),t.node=t.string_().node}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}identifier(){let t=new d(this,this._ctx,this.state);this.enterRule(t,12,n.RULE_identifier);try{switch(this.state=261,this._errHandler.sync(this),this._input.LA(1)){case 101:this.enterOuterAlt(t,1),this.state=251,this.match(n.IDENTIFIER),t.node=i.AST.nodeIdentifier(t.IDENTIFIER().getText());break;case 39:this.enterOuterAlt(t,2),this.state=253,this.match(n.PROPERTIES),t.node=i.AST.nodeIdentifier("properties");break;case 43:this.enterOuterAlt(t,3),this.state=255,this.match(n.METHODS),t.node=i.AST.nodeIdentifier("methods");break;case 41:this.enterOuterAlt(t,4),this.state=257,this.match(n.EVENTS),t.node=i.AST.nodeIdentifier("events");break;case 37:this.enterOuterAlt(t,5),this.state=259,this.match(n.ENUMERATION),t.node=i.AST.nodeIdentifier("enumeration");break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}qualified_identifier_part(){let t=new m(this,this._ctx,this.state);this.enterRule(t,14,n.RULE_qualified_identifier_part);try{switch(this.state=268,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=263,this.identifier(),t.text=t.identifier().node.id;break;case 6:this.enterOuterAlt(t,2),this.state=266,this.match(n.END),t.text="end";break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}qualified_identifier(){let t=new p(this,this._ctx,this.state);this.enterRule(t,16,n.RULE_qualified_identifier);try{let e;for(this.enterOuterAlt(t,1),this.state=270,this.qualified_identifier_part(),t.node=i.AST.nodeIdentifier(t.qualified_identifier_part(0).text),this.state=278,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,11,this._ctx);2!==e&&e!==s.ATN.INVALID_ALT_NUMBER;)1===e&&(this.state=272,this.match(n.DOT),this.state=273,this.qualified_identifier_part(),t.node=i.AST.nodeIdentifier(t.node.id+"."+t.qualified_identifier_part(t.i++).text)),this.state=280,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,11,this._ctx)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}string_(){let t=new f(this,this._ctx,this.state);this.enterRule(t,18,n.RULE_string);try{switch(this.state=285,this._errHandler.sync(this),this._input.LA(1)){case 46:this.enterOuterAlt(t,1);{this.state=281,this.match(n.STRING);const e=t.STRING().getText();t.node=i.AST.nodeString(e.substring(1,e.length-1),e[0])}break;case 142:this.enterOuterAlt(t,2),this.state=283,this.match(n.UNQUOTED_STRING),t.node=i.AST.nodeString(t.UNQUOTED_STRING().getText());break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}number_(){let t=new g(this,this._ctx,this.state);this.enterRule(t,20,n.RULE_number);try{this.enterOuterAlt(t,1),this.state=287,this.match(n.FLOAT_NUMBER),t.node=i.AST.nodeNumber(t.FLOAT_NUMBER().getText())}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}end_range(){let t=new y(this,this._ctx,this.state);this.enterRule(t,22,n.RULE_end_range);try{this.enterOuterAlt(t,1),this.state=290,this.match(n.ENDRANGE),t.node=i.AST.nodeEndRange()}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}constant(){let t=new x(this,this._ctx,this.state);this.enterRule(t,24,n.RULE_constant);try{switch(this.state=302,this._errHandler.sync(this),this._input.LA(1)){case 102:this.enterOuterAlt(t,1),this.state=293,this.number_(),t.node=t.number_().node;break;case 46:case 142:this.enterOuterAlt(t,2),this.state=296,this.string_(),t.node=t.string_().node;break;case 7:this.enterOuterAlt(t,3),this.state=299,this.end_range(),t.node=t.end_range().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}matrix(){let t,e=new C(this,this._ctx,this.state);this.enterRule(e,26,n.RULE_matrix);try{let r;switch(this.state=366,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,28,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=304,this.match(n.LBRACKET),this.state=305,this.match(n.RBRACKET),e.node=i.AST.emptyArray();break;case 2:for(this.enterOuterAlt(e,2),this.state=307,this.match(n.LBRACKET),this.state=312,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=310,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=308,this.match(n.SEMICOLON);break;case 106:this.state=309,this.nl();break;default:throw new s.NoViableAltException(this)}this.state=314,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,15,this._ctx)}for(this.state=316,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=315,this.matrix_row()),e.node=i.AST.nodeFirstRow(e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=331,this._errHandler.sync(this),t=this._input.LA(1);55===t||106===t;){this.state=321,this._errHandler.sync(this),r=1;do{if(1!==r)throw new s.NoViableAltException(this);switch(this.state=321,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=319,this.match(n.SEMICOLON);break;case 106:this.state=320,this.nl();break;default:throw new s.NoViableAltException(this)}this.state=323,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,18,this._ctx)}while(2!==r&&r!==s.ATN.INVALID_ALT_NUMBER);this.state=326,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=325,this.matrix_row()),e.node=i.AST.nodeAppendRow(e.node,e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=333,this._errHandler.sync(this),t=this._input.LA(1)}this.state=334,this.match(n.RBRACKET);break;case 3:this.enterOuterAlt(e,3),this.state=335,this.match(n.LCURLYBR),this.state=336,this.match(n.RCURLYBR),e.node=i.AST.emptyArray(!0);break;case 4:for(this.enterOuterAlt(e,4),this.state=338,this.match(n.LCURLYBR),this.state=343,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;){if(1===r)switch(this.state=341,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=339,this.match(n.SEMICOLON);break;case 106:this.state=340,this.nl();break;default:throw new s.NoViableAltException(this)}this.state=345,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,22,this._ctx)}for(this.state=347,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=346,this.matrix_row()),e.node=i.AST.nodeFirstRow(e.matrix_row(e.i)?e.matrix_row(e.i++).node:null,!0),this.state=362,this._errHandler.sync(this),t=this._input.LA(1);55===t||106===t;){this.state=352,this._errHandler.sync(this),r=1;do{if(1!==r)throw new s.NoViableAltException(this);switch(this.state=352,this._errHandler.sync(this),this._input.LA(1)){case 55:this.state=350,this.match(n.SEMICOLON);break;case 106:this.state=351,this.nl();break;default:throw new s.NoViableAltException(this)}this.state=354,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,25,this._ctx)}while(2!==r&&r!==s.ATN.INVALID_ALT_NUMBER);this.state=357,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736768853||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=356,this.matrix_row()),e.node=i.AST.nodeAppendRow(e.node,e.matrix_row(e.i)?e.matrix_row(e.i++).node:null),this.state=364,this._errHandler.sync(this),t=this._input.LA(1)}this.state=365,this.match(n.RCURLYBR)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}matrix_row(){let t,e=new E(this,this._ctx,this.state);this.enterRule(e,28,n.RULE_matrix_row);try{let r;switch(this.state=387,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,32,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=368,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=null;break;case 2:for(this.enterOuterAlt(e,2),this.state=371,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=370,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())),this.state=373,this.list_element(),e.node=i.AST.nodeListFirst(e.list_element(e.i++).node),this.state=381,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=375,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=376,this.list_element(),e.node=i.AST.appendNodeList(e.node,e.list_element(e.i++).node)),this.state=383,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,30,this._ctx);this.state=385,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=384,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}fcn_handle(){let t=new A(this,this._ctx,this.state);this.enterRule(t,30,n.RULE_fcn_handle);try{this.enterOuterAlt(t,1),this.state=389,this.match(n.COMMAT),this.state=390,this.qualified_identifier(),t.node=i.AST.nodeFunctionHandle(t.qualified_identifier().node)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}meta_class(){let t=new _(this,this._ctx,this.state);this.enterRule(t,32,n.RULE_meta_class);try{this.enterOuterAlt(t,1),this.state=393,this.match(n.QUESTION),this.state=394,this.qualified_identifier(),t.node=i.AST.nodeMetaClass(t.qualified_identifier().node)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}anon_fcn_handle(){let t=new S(this,this._ctx,this.state);this.enterRule(t,34,n.RULE_anon_fcn_handle);try{this.enterOuterAlt(t,1),this.state=397,this.match(n.COMMAT),this.state=398,this.param_list(),this.state=399,this.expression(),t.node=i.AST.nodeFunctionHandle(null,t.param_list().node,t.expression().node)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}primary_expr(){let t=new v(this,this._ctx,this.state);this.enterRule(t,36,n.RULE_primary_expr);try{switch(this.state=424,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=402,this.identifier(),t.node=t.identifier().node;break;case 3:this.enterOuterAlt(t,2),this.state=405,this.match(n.IMPORT),t.node=i.AST.nodeImport();break;case 7:case 46:case 102:case 142:this.enterOuterAlt(t,3),this.state=407,this.constant(),t.node=t.constant().node;break;case 60:this.enterOuterAlt(t,4),this.state=410,this.fcn_handle(),t.node=t.fcn_handle().node;break;case 61:this.enterOuterAlt(t,5),this.state=413,this.meta_class(),t.node=t.meta_class().node;break;case 64:case 66:this.enterOuterAlt(t,6),this.state=416,this.matrix(),t.node=t.matrix().node;break;case 62:this.enterOuterAlt(t,7),this.state=419,this.match(n.LPAREN),this.state=420,this.expression(),this.state=421,this.match(n.RPAREN),t.node=i.AST.nodeOperation("()",t.expression().node);break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}magic_colon(){let t=new T(this,this._ctx,this.state);this.enterRule(t,38,n.RULE_magic_colon);try{this.enterOuterAlt(t,1),this.state=426,this.match(n.COLON),t.node=i.AST.nodeColon()}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}magic_tilde(){let t=new b(this,this._ctx,this.state);this.enterRule(t,40,n.RULE_magic_tilde);try{this.enterOuterAlt(t,1),this.state=429,this.match(n.TILDE),t.node=i.AST.nodeIgnoredTarget()}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}list_element(){let t=new N(this,this._ctx,this.state);this.enterRule(t,42,n.RULE_list_element);try{switch(this.state=441,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,34,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=432,this.expression(),t.node=t.expression().node;break;case 2:this.enterOuterAlt(t,2),this.state=435,this.magic_colon(),t.node=t.magic_colon().node;break;case 3:this.enterOuterAlt(t,3),this.state=438,this.magic_tilde(),t.node=t.magic_tilde().node}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arg_list(){let t,e=new I(this,this._ctx,this.state);this.enterRule(e,44,n.RULE_arg_list);try{for(this.enterOuterAlt(e,1),this.state=443,this.list_element(),e.node=i.AST.nodeListFirst(e.list_element(e.i++).node),this.state=451,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=445,this.match(n.COMMA),this.state=446,this.list_element(),e.node=i.AST.appendNodeList(e.node,e.list_element(e.i++).node),this.state=453,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}oper_expr(t){void 0===t&&(t=0);let e,r=this._ctx,a=this.state,o=new M(this,this._ctx,a),l=o,c=46;this.enterRecursionRule(o,46,n.RULE_oper_expr,t);try{let t;switch(this.enterOuterAlt(o,1),this.state=466,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=455,this.primary_expr(),o.node=o.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=458,o._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e&&94!==e&&95!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=459,this.oper_expr(4),o.node=i.AST.nodeOperation(o._op.text+"_",o.oper_expr(0).node);break;case 58:case 59:this.state=462,o._op=this._input.LT(1),e=this._input.LA(1),58!==e&&59!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=463,this.oper_expr(3),o.node=i.AST.nodeOperation(o._op.text,o.oper_expr(0).node);break;default:throw new s.NoViableAltException(this)}for(this._ctx.stop=this._input.LT(-1),this.state=527,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,41,this._ctx);2!==t&&t!==s.ATN.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=525,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,40,this._ctx)){case 1:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=468,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=469,o._op=this._input.LT(1),e=this._input.LA(1),!(e-51&-32)&&1<<e-51&131075||!(e-91&-32)&&1<<e-91&7?(this._errHandler.reportMatch(this),this.consume()):o._op=this._errHandler.recoverInline(this),this.state=470,this.oper_expr(3),o.node=i.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.oper_expr(1).node);break;case 2:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=473,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=474,o._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=475,this.oper_expr(2),o.node=i.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.oper_expr(1).node);break;case 3:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=478,!this.precpred(this._ctx,12))throw this.createFailedPredicateException("this.precpred(this._ctx, 12)");this.state=479,o._op=this._input.LT(1),e=this._input.LA(1),94!==e&&95!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=i.AST.nodeOperation("_"+o._op.text,o.oper_expr(0).node);break;case 4:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=481,!this.precpred(this._ctx,11))throw this.createFailedPredicateException("this.precpred(this._ctx, 11)");this.state=482,this.match(n.LPAREN),this.state=484,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=483,this.arg_list()),this.state=486,this.match(n.RPAREN),o.node=i.AST.nodeIndexExpr(o.oper_expr(0).node,o.arg_list()?o.arg_list().node:null,"()");break;case 5:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=488,!this.precpred(this._ctx,10))throw this.createFailedPredicateException("this.precpred(this._ctx, 10)");this.state=489,this.match(n.LCURLYBR),this.state=491,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=490,this.arg_list()),this.state=493,this.match(n.RCURLYBR),o.node=i.AST.nodeIndexExpr(o.oper_expr(0).node,o.arg_list()?o.arg_list().node:null,"{}");break;case 6:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=495,!this.precpred(this._ctx,9))throw this.createFailedPredicateException("this.precpred(this._ctx, 9)");this.state=496,this.match(n.COMMAT),this.state=497,this.qualified_identifier(),this.state=498,this.match(n.LPAREN),this.state=500,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=499,this.arg_list()),this.state=502,this.match(n.RPAREN),o.node=i.AST.nodeSuperclassConstructor(o.oper_expr(0).node,o.qualified_identifier().node,o.arg_list()?o.arg_list().node:null);break;case 7:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=505,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=506,o._op=this._input.LT(1),e=this._input.LA(1),98!==e&&99!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=i.AST.nodeOperation(o._op.text,o.oper_expr(0).node);break;case 8:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=508,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=509,this.match(n.DOT),this.state=510,this.qualified_identifier_part(),o.node=i.AST.nodeIndirectRef(o.oper_expr(0).node,o.qualified_identifier_part().text);break;case 9:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=513,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=514,this.match(n.DOT),this.state=515,this.match(n.LPAREN),this.state=516,this.expression(),this.state=517,this.match(n.RPAREN),o.node=i.AST.nodeIndirectRef(o.oper_expr(0).node,o.expression().node);break;case 10:if(o=new M(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_oper_expr),this.state=520,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=521,o._op=this._input.LT(1),e=this._input.LA(1),96!==e&&97!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=522,this.power_expr(0),o.node=i.AST.nodeOperation(o._op.text,o.oper_expr(0).node,o.power_expr().node)}this.state=529,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,41,this._ctx)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;o.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return o}power_expr(t){void 0===t&&(t=0);let e,r=this._ctx,a=this.state,o=new w(this,this._ctx,a),l=o,c=48;this.enterRecursionRule(o,48,n.RULE_power_expr,t);try{let t;switch(this.enterOuterAlt(o,1),this.state=542,this._errHandler.sync(this),this._input.LA(1)){case 3:case 7:case 37:case 39:case 41:case 43:case 46:case 60:case 61:case 62:case 64:case 66:case 101:case 102:case 142:this.state=531,this.primary_expr(),o.node=o.primary_expr().node;break;case 49:case 50:case 94:case 95:this.state=534,o._op=this._input.LT(1),e=this._input.LA(1),49!==e&&50!==e&&94!==e&&95!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=535,this.power_expr(2),o.node=i.AST.nodeOperation(o._op.text+"_",o.power_expr().node);break;case 58:case 59:this.state=538,o._op=this._input.LT(1),e=this._input.LA(1),58!==e&&59!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=539,this.power_expr(1),o.node=i.AST.nodeOperation(o._op.text,o.power_expr().node);break;default:throw new s.NoViableAltException(this)}for(this._ctx.stop=this._input.LT(-1),this.state=585,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,47,this._ctx);2!==t&&t!==s.ATN.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=583,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,46,this._ctx)){case 1:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=544,!this.precpred(this._ctx,8))throw this.createFailedPredicateException("this.precpred(this._ctx, 8)");this.state=545,o._op=this._input.LT(1),e=this._input.LA(1),94!==e&&95!==e?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),o.node=i.AST.nodeOperation("_"+o._op.text,o.power_expr().node);break;case 2:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=547,!this.precpred(this._ctx,7))throw this.createFailedPredicateException("this.precpred(this._ctx, 7)");this.state=548,this.match(n.LPAREN),this.state=550,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=549,this.arg_list()),this.state=552,this.match(n.RPAREN),o.node=i.AST.nodeIndexExpr(o.power_expr().node,o.arg_list()?o.arg_list().node:null,"()");break;case 3:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=554,!this.precpred(this._ctx,6))throw this.createFailedPredicateException("this.precpred(this._ctx, 6)");this.state=555,this.match(n.LCURLYBR),this.state=557,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=556,this.arg_list()),this.state=559,this.match(n.RCURLYBR),o.node=i.AST.nodeIndexExpr(o.power_expr().node,o.arg_list()?o.arg_list().node:null,"{}");break;case 4:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=561,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=562,this.match(n.COMMAT),this.state=563,this.qualified_identifier(),this.state=564,this.match(n.LPAREN),this.state=566,this._errHandler.sync(this),e=this._input.LA(1),(3===e||7===e||!(e-37&-32)&&1<<e-37&736244309||!(e-94&-32)&&1<<e-94&387||142===e)&&(this.state=565,this.arg_list()),this.state=568,this.match(n.RPAREN),o.node=i.AST.nodeSuperclassConstructor(o.power_expr().node,o.qualified_identifier().node,o.arg_list()?o.arg_list().node:null);break;case 5:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=571,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=572,this.match(n.DOT),this.state=573,this.qualified_identifier_part(),o.node=i.AST.nodeIndirectRef(o.power_expr().node,o.qualified_identifier_part().text);break;case 6:if(o=new w(this,r,a),this.pushNewRecursionContext(o,c,n.RULE_power_expr),this.state=576,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=577,this.match(n.DOT),this.state=578,this.match(n.LPAREN),this.state=579,this.expression(),this.state=580,this.match(n.RPAREN),o.node=i.AST.nodeIndirectRef(o.power_expr().node,o.expression().node)}this.state=587,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,47,this._ctx)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;o.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return o}colon_expr(){let t=new L(this,this._ctx,this.state);this.enterRule(t,50,n.RULE_colon_expr);try{this.enterOuterAlt(t,1),this.state=588,this.oper_expr(0),this.state=589,this.match(n.COLON),this.state=590,this.oper_expr(0),this.state=593,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,48,this._ctx)&&(this.state=591,this.match(n.COLON),this.state=592,this.oper_expr(0)),t.oper_expr(2)?t.node=i.AST.nodeRange(t.oper_expr(0).node,t.oper_expr(2).node,t.oper_expr(1).node):t.node=i.AST.nodeRange(t.oper_expr(0).node,t.oper_expr(1).node)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}simple_expr(t){void 0===t&&(t=0);let e,r=this._ctx,a=this.state,o=new O(this,this._ctx,a),l=o;this.enterRecursionRule(o,52,n.RULE_simple_expr,t);try{let t;switch(this.enterOuterAlt(o,1),this.state=604,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,49,this._ctx)){case 1:this.state=598,this.oper_expr(0),o.node=o.oper_expr().node;break;case 2:this.state=601,this.colon_expr(),o.node=o.colon_expr().node}for(this._ctx.stop=this._input.LT(-1),this.state=633,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,51,this._ctx);2!==t&&t!==s.ATN.INVALID_ALT_NUMBER;){if(1===t)switch(null!=this._parseListeners&&this.triggerExitRuleEvent(),l=o,this.state=631,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,50,this._ctx)){case 1:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,n.RULE_simple_expr),this.state=606,!this.precpred(this._ctx,5))throw this.createFailedPredicateException("this.precpred(this._ctx, 5)");this.state=607,o._op=this._input.LT(1),e=this._input.LA(1),e-85&-32||!(1<<e-85&63)?o._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=608,this.simple_expr(6),o.node=i.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 2:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,n.RULE_simple_expr),this.state=611,!this.precpred(this._ctx,4))throw this.createFailedPredicateException("this.precpred(this._ctx, 4)");this.state=612,o._op=this.match(n.EXPR_AND),this.state=613,this.simple_expr(5),o.node=i.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 3:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,n.RULE_simple_expr),this.state=616,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=617,o._op=this.match(n.EXPR_OR),this.state=618,this.simple_expr(4),o.node=i.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 4:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,n.RULE_simple_expr),this.state=621,!this.precpred(this._ctx,2))throw this.createFailedPredicateException("this.precpred(this._ctx, 2)");this.state=622,o._op=this.match(n.EXPR_AND_AND),this.state=623,this.simple_expr(3),o.node=i.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node);break;case 5:if(o=new O(this,r,a),this.pushNewRecursionContext(o,52,n.RULE_simple_expr),this.state=626,!this.precpred(this._ctx,1))throw this.createFailedPredicateException("this.precpred(this._ctx, 1)");this.state=627,o._op=this.match(n.EXPR_OR_OR),this.state=628,this.simple_expr(2),o.node=i.AST.nodeOperation(o._op.text,o.simple_expr(0).node,o.simple_expr(1).node)}this.state=635,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,51,this._ctx)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;o.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.unrollRecursionContexts(r)}return o}expression(){let t,e=new R(this,this._ctx,this.state);this.enterRule(e,54,n.RULE_expression);try{switch(this.state=647,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,52,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=636,this.simple_expr(0),e.node=e.simple_expr().node;break;case 2:this.enterOuterAlt(e,2),this.state=639,this.simple_expr(0),this.state=640,e._op=this._input.LT(1),t=this._input.LA(1),t-53&-32||!(1<<t-53&268369921)?e._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=641,this.expression(),e.node=i.AST.nodeOperation(e._op.text,e.simple_expr().node,e.expression().node);break;case 3:this.enterOuterAlt(e,3),this.state=644,this.anon_fcn_handle(),e.node=e.anon_fcn_handle().node}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}assign_lhs(){let t,e=new D(this,this._ctx,this.state);this.enterRule(e,56,n.RULE_assign_lhs);try{switch(this.state=658,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,54,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=649,this.simple_expr(0),e.node=e.simple_expr().node;break;case 2:this.enterOuterAlt(e,2),this.state=652,this.match(n.LBRACKET),this.state=654,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=653,this.assign_list()),this.state=656,this.match(n.RBRACKET),e.node=i.AST.nodeFirstRow(e.assign_list()?e.assign_list().node:i.AST.nodeListFirst())}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}assign_list(){let t,e=new F(this,this._ctx,this.state);this.enterRule(e,58,n.RULE_assign_list);try{let r;for(this.enterOuterAlt(e,1),this.state=660,this.list_element(),e.node=i.AST.nodeListFirst(e.list_element(e.i++).node),this.state=668,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=662,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=663,this.list_element(),e.node=i.AST.appendNodeList(e.node,e.list_element(e.i++).node)),this.state=670,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,55,this._ctx);this.state=672,this._errHandler.sync(this),t=this._input.LA(1),45!==t&&56!==t||(this.state=671,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()))}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}command(){let t=new P(this,this._ctx,this.state);this.enterRule(t,60,n.RULE_command);try{switch(this.state=698,this._errHandler.sync(this),this._input.LA(1)){case 1:case 2:this.enterOuterAlt(t,1),this.state=674,this.declaration(),t.node=t.declaration().node;break;case 3:this.enterOuterAlt(t,2),this.state=677,this.import_command(),t.node=t.import_command().node;break;case 4:case 10:this.enterOuterAlt(t,3),this.state=680,this.select_command(),t.node=t.select_command().node;break;case 14:case 16:case 18:case 20:case 22:this.enterOuterAlt(t,4),this.state=683,this.loop_command(),t.node=t.loop_command().node;break;case 24:case 25:case 26:this.enterOuterAlt(t,5),this.state=686,this.jump_command(),t.node=t.jump_command().node;break;case 29:case 32:this.enterOuterAlt(t,6),this.state=689,this.except_command(),t.node=t.except_command().node;break;case 27:this.enterOuterAlt(t,7),this.state=692,this.function_(),t.node=t.function_().node;break;case 35:this.enterOuterAlt(t,8),this.state=695,this.classdef_command(),t.node=t.classdef_command().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}declaration(){let t,e=new k(this,this._ctx,this.state);this.enterRule(e,62,n.RULE_declaration);try{let r;switch(this.enterOuterAlt(e,1),this.state=704,this._errHandler.sync(this),this._input.LA(1)){case 1:this.state=700,this.match(n.GLOBAL),e.node=i.AST.nodeDeclarationFirst("GLOBAL");break;case 2:this.state=702,this.match(n.PERSISTENT),e.node=i.AST.nodeDeclarationFirst("PERSIST");break;default:throw new s.NoViableAltException(this)}for(this.state=706,this.declaration_element(),e.node=i.AST.nodeAppendDeclaration(e.node,e.declaration_element(e.i++).node),this.state=716,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=709,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=708,this.match(n.COMMA)),this.state=711,this.declaration_element(),e.node=i.AST.nodeAppendDeclaration(e.node,e.declaration_element(e.i++).node)),this.state=718,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,60,this._ctx)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}declaration_element(){let t=new V(this,this._ctx,this.state);this.enterRule(t,64,n.RULE_declaration_element);try{switch(this.state=727,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,61,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=719,this.identifier(),t.node=t.identifier().node;break;case 2:this.enterOuterAlt(t,2),this.state=722,this.identifier(),this.state=723,this.match(n.EQ),this.state=724,this.expression(),t.node=i.AST.nodeDefaultedParameter(t.identifier().node,t.expression().node)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}import_command(){let t,e=new U(this,this._ctx,this.state);this.enterRule(e,66,n.RULE_import_command);try{let r;if(this.enterOuterAlt(e,1),this.state=729,this.match(n.IMPORT),e.node=i.AST.nodeImport(),this.state=744,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,64,this._ctx))for(this.state=731,this.import_name(),e.node=i.AST.nodeImportFirst(e.import_name(e.i++).node),this.state=741,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=734,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=733,this.match(n.COMMA)),this.state=736,this.import_name(),e.node=i.AST.nodeAppendImport(e.node,e.import_name(e.i++).node)),this.state=743,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,63,this._ctx)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}import_name(){let t=new $(this,this._ctx,this.state);this.enterRule(t,68,n.RULE_import_name);try{switch(this.state=757,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,66,this._ctx)){case 1:this.enterOuterAlt(t,1),this.state=746,this.qualified_identifier(),t.node=t.qualified_identifier().node;break;case 2:switch(this.enterOuterAlt(t,2),this.state=749,this.qualified_identifier(),this.state=753,this._errHandler.sync(this),this._input.LA(1)){case 57:this.state=750,this.match(n.DOT),this.state=751,this.match(n.MUL);break;case 91:this.state=752,this.match(n.EMUL);break;default:throw new s.NoViableAltException(this)}t.node=i.AST.nodeIdentifier(t.qualified_identifier().node.id+".*")}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}select_command(){let t=new B(this,this._ctx,this.state);this.enterRule(t,70,n.RULE_select_command);try{switch(this.state=765,this._errHandler.sync(this),this._input.LA(1)){case 4:this.enterOuterAlt(t,1),this.state=759,this.if_command(),t.node=t.if_command().node;break;case 10:this.enterOuterAlt(t,2),this.state=762,this.switch_command(),t.node=t.switch_command().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}if_command(){let t,e=new H(this,this._ctx,this.state);this.enterRule(e,72,n.RULE_if_command);try{for(this.enterOuterAlt(e,1),this.state=767,this.match(n.IF),this.state=768,this.expression(),this.state=770,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=769,this.sep()),this.state=773,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=772,this.list()),e.node=i.AST.nodeIfBegin(e.expression().node,e.list()?e.list().node:i.AST.nodeListFirst()),this.state=781,this._errHandler.sync(this),t=this._input.LA(1);8===t;)this.state=776,this.elseif_clause(),e.node=i.AST.nodeIfAppendElseIf(e.node,e.elseif_clause(e.i++).node),this.state=783,this._errHandler.sync(this),t=this._input.LA(1);this.state=785,this._errHandler.sync(this),t=this._input.LA(1),9===t&&(this.state=784,this.else_clause()),e.else_clause()&&(e.node=i.AST.nodeIfAppendElse(e.node,e.else_clause().node)),this.state=788,t=this._input.LA(1),5!==t&&6!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}elseif_clause(){let t,e=new q(this,this._ctx,this.state);this.enterRule(e,74,n.RULE_elseif_clause);try{this.enterOuterAlt(e,1),this.state=790,this.match(n.ELSEIF),this.state=792,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=791,this.sep()),this.state=794,this.expression(),this.state=796,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=795,this.sep()),this.state=799,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=798,this.list()),e.node=i.AST.nodeElseIf(e.expression().node,e.list()?e.list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}else_clause(){let t,e=new j(this,this._ctx,this.state);this.enterRule(e,76,n.RULE_else_clause);try{this.enterOuterAlt(e,1),this.state=803,this.match(n.ELSE),this.state=805,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=804,this.sep()),this.state=808,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=807,this.list()),e.node=i.AST.nodeElse(e.list()?e.list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_command(){let t,e=new z(this,this._ctx,this.state);this.enterRule(e,78,n.RULE_switch_command);try{this.enterOuterAlt(e,1),this.state=812,this.match(n.SWITCH),this.state=813,this.expression(),this.state=815,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=814,this.sep()),this.state=818,this._errHandler.sync(this),t=this._input.LA(1),12===t&&(this.state=817,this.switch_case_list()),this.state=821,this._errHandler.sync(this),t=this._input.LA(1),13===t&&(this.state=820,this.otherwise_case()),this.state=823,t=this._input.LA(1),6!==t&&11!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeSwitch(e.expression().node,e.switch_case_list()?e.switch_case_list().node:i.AST.nodeListFirst(),e.otherwise_case()?e.otherwise_case().node:null)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_case_list(){let t,e=new G(this,this._ctx,this.state);this.enterRule(e,80,n.RULE_switch_case_list);try{let r;for(this.enterOuterAlt(e,1),this.state=826,this.switch_case(),e.node=i.AST.nodeListFirst(e.switch_case(e.i++).node),this.state=836,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=829,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=828,this.sep()),this.state=831,this.switch_case(),e.node=i.AST.appendNodeList(e.node,e.switch_case(e.i++).node)),this.state=838,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,81,this._ctx);this.state=840,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=839,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}switch_case(){let t,e=new W(this,this._ctx,this.state);this.enterRule(e,82,n.RULE_switch_case);try{this.enterOuterAlt(e,1),this.state=842,this.match(n.CASE),this.state=844,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=843,this.sep()),this.state=846,this.expression(),this.state=848,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,84,this._ctx)&&(this.state=847,this.sep()),this.state=851,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=850,this.list()),e.node=i.AST.nodeSwitchCase(e.expression().node,e.list()?e.list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}otherwise_case(){let t,e=new Q(this,this._ctx,this.state);this.enterRule(e,84,n.RULE_otherwise_case);try{this.enterOuterAlt(e,1),this.state=855,this.match(n.OTHERWISE),this.state=857,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,86,this._ctx)&&(this.state=856,this.sep()),this.state=860,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=859,this.list()),this.state=863,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=862,this.sep()),e.node=e.list()?e.list().node:i.AST.nodeListFirst()}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}loop_command(){let t=new K(this,this._ctx,this.state);this.enterRule(t,86,n.RULE_loop_command);try{switch(this.state=879,this._errHandler.sync(this),this._input.LA(1)){case 14:this.enterOuterAlt(t,1),this.state=867,this.while_command(),t.node=t.while_command().node;break;case 16:this.enterOuterAlt(t,2),this.state=870,this.do_until_command(),t.node=t.do_until_command().node;break;case 18:case 20:this.enterOuterAlt(t,3),this.state=873,this.for_command(),t.node=t.for_command().node;break;case 22:this.enterOuterAlt(t,4),this.state=876,this.spmd_command(),t.node=t.spmd_command().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}while_command(){let t,e=new J(this,this._ctx,this.state);this.enterRule(e,88,n.RULE_while_command);try{this.enterOuterAlt(e,1),this.state=881,this.match(n.WHILE),this.state=882,this.expression(),this.state=884,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=883,this.sep()),this.state=887,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=886,this.list()),this.state=889,t=this._input.LA(1),6!==t&&15!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeWhile(e.expression().node,e.list()?e.list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}do_until_command(){let t,e=new Z(this,this._ctx,this.state);this.enterRule(e,90,n.RULE_do_until_command);try{this.enterOuterAlt(e,1),this.state=892,this.match(n.DO),this.state=894,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=893,this.sep()),this.state=897,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=896,this.list()),this.state=899,this.match(n.UNTIL),this.state=900,this.expression(),e.node=i.AST.nodeDoUntil(e.list()?e.list().node:i.AST.nodeListFirst(),e.expression().node)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}for_command(){let t,e=new X(this,this._ctx,this.state);this.enterRule(e,92,n.RULE_for_command);try{switch(this.state=963,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,103,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=903,this.match(n.FOR),this.state=904,this.assign_lhs(),this.state=905,this.match(n.EQ),this.state=906,this.expression(),this.state=908,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=907,this.sep()),this.state=911,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=910,this.list()),this.state=913,t=this._input.LA(1),6!==t&&19!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:i.AST.nodeListFirst());break;case 2:this.enterOuterAlt(e,2),this.state=916,this.match(n.FOR),this.state=917,this.match(n.LPAREN),this.state=918,this.assign_lhs(),this.state=919,this.match(n.EQ),this.state=920,this.expression(),this.state=921,this.match(n.RPAREN),this.state=923,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=922,this.sep()),this.state=926,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=925,this.list()),this.state=928,t=this._input.LA(1),6!==t&&19!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:i.AST.nodeListFirst());break;case 3:this.enterOuterAlt(e,3),this.state=931,this.match(n.PARFOR),this.state=932,this.assign_lhs(),this.state=933,this.match(n.EQ),this.state=934,this.expression(),this.state=936,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=935,this.sep()),this.state=939,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=938,this.list()),this.state=941,t=this._input.LA(1),6!==t&&21!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:i.AST.nodeListFirst(),!0);break;case 4:this.enterOuterAlt(e,4),this.state=944,this.match(n.PARFOR),this.state=945,this.match(n.LPAREN),this.state=946,this.assign_lhs(),this.state=947,this.match(n.EQ),this.state=948,this.expression(),this.state=951,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=949,this.match(n.COMMA),this.state=950,this.expression()),this.state=953,this.match(n.RPAREN),this.state=955,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=954,this.sep()),this.state=958,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=957,this.list()),this.state=960,t=this._input.LA(1),6!==t&&21!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeFor(e.assign_lhs().node,e.expression(0).node,e.list()?e.list().node:i.AST.nodeListFirst(),!0,e.expression(1)?e.expression(1).node:null)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}spmd_command(){let t,e=new Y(this,this._ctx,this.state);this.enterRule(e,94,n.RULE_spmd_command);try{this.enterOuterAlt(e,1),this.state=965,this.match(n.SPMD),this.state=967,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,104,this._ctx)&&(this.state=966,this.spmd_worker_spec()),this.state=970,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=969,this.sep()),this.state=973,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=972,this.list()),this.state=975,t=this._input.LA(1),6!==t&&23!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeSpmd(e.list()?e.list().node:i.AST.nodeListFirst(),e.spmd_worker_spec()?e.spmd_worker_spec().node:null)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}spmd_worker_spec(){let t,e=new tt(this,this._ctx,this.state);this.enterRule(e,96,n.RULE_spmd_worker_spec);try{this.enterOuterAlt(e,1),this.state=978,this.match(n.LPAREN),this.state=979,this.expression(),e.node=i.AST.nodeListFirst(e.expression(e.i++).node),this.state=985,this._errHandler.sync(this),t=this._input.LA(1),56===t&&(this.state=981,this.match(n.COMMA),this.state=982,this.expression(),e.node=i.AST.appendNodeList(e.node,e.expression(e.i++).node)),this.state=987,this.match(n.RPAREN)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}jump_command(){let t=new et(this,this._ctx,this.state);this.enterRule(t,98,n.RULE_jump_command);try{switch(this.state=995,this._errHandler.sync(this),this._input.LA(1)){case 24:this.enterOuterAlt(t,1),this.state=989,this.match(n.BREAK),t.node=i.AST.nodeBreak();break;case 25:this.enterOuterAlt(t,2),this.state=991,this.match(n.CONTINUE),t.node=i.AST.nodeContinue();break;case 26:this.enterOuterAlt(t,3),this.state=993,this.match(n.RETURN),t.node=i.AST.nodeReturn();break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}except_command(){let t=new rt(this,this._ctx,this.state);this.enterRule(t,100,n.RULE_except_command);try{switch(this.state=1003,this._errHandler.sync(this),this._input.LA(1)){case 29:this.enterOuterAlt(t,1),this.state=997,this.try_command(),t.node=t.try_command().node;break;case 32:this.enterOuterAlt(t,2),this.state=1e3,this.unwind_command(),t.node=t.unwind_command().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}try_command(){let t,e=new st(this,this._ctx,this.state);this.enterRule(e,102,n.RULE_try_command);try{switch(this.state=1025,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,114,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=1005,this.match(n.TRY),this.state=1007,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1006,this.sep()),this.state=1010,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1009,this.list()),this.state=1012,this.catch_clause(),this.state=1013,t=this._input.LA(1),6!==t&&31!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeTry(e.list()?e.list().node:i.AST.nodeListFirst(),e.catch_clause().body,e.catch_clause().identifierNode);break;case 2:this.enterOuterAlt(e,2),this.state=1016,this.match(n.TRY),this.state=1018,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1017,this.sep()),this.state=1021,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1020,this.list()),this.state=1023,t=this._input.LA(1),6!==t&&31!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeTry(e.list()?e.list().node:i.AST.nodeListFirst())}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}catch_clause(){let t,e=new it(this,this._ctx,this.state);this.enterRule(e,104,n.RULE_catch_clause);try{this.enterOuterAlt(e,1),this.state=1027,this.match(n.CATCH),this.state=1029,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1028,this.sep()),this.state=1032,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1031,this.list()),e.identifierNode=null,e.body=e.list()?e.list().node:i.AST.nodeListFirst(),!e.sep()&&e.body.list.length>0&&i.AST.isNodeIdentifier(e.body.list[0])&&(e.identifierNode=e.body.list.shift(),e.body.list.forEach((t,e)=>{t.index=e}))}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}unwind_command(){let t,e=new nt(this,this._ctx,this.state);this.enterRule(e,106,n.RULE_unwind_command);try{this.enterOuterAlt(e,1),this.state=1036,this.match(n.UNWIND_PROTECT),this.state=1038,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1037,this.sep()),this.state=1041,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1040,this.list()),this.state=1043,this.unwind_cleanup_clause(),this.state=1044,t=this._input.LA(1),6!==t&&34!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeUnwindProtect(e.list()?e.list().node:i.AST.nodeListFirst(),e.unwind_cleanup_clause().node)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}unwind_cleanup_clause(){let t,e=new at(this,this._ctx,this.state);this.enterRule(e,108,n.RULE_unwind_cleanup_clause);try{this.enterOuterAlt(e,1),this.state=1047,this.match(n.UNWIND_PROTECT_CLEANUP),this.state=1049,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1048,this.sep()),this.state=1052,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1051,this.list()),e.node=e.list()?e.list().node:i.AST.nodeListFirst()}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}param_list(){let t,e=new ot(this,this._ctx,this.state);this.enterRule(e,110,n.RULE_param_list);try{if(this.enterOuterAlt(e,1),this.state=1056,this.match(n.LPAREN),e.node=i.AST.nodeListFirst(),this.state=1069,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&2097237||101===t)for(this.state=1058,this.param_list_elt(),e.node=i.AST.appendNodeList(e.node,e.param_list_elt(e.i++).node),this.state=1066,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1060,this.match(n.COMMA),this.state=1061,this.param_list_elt(),e.node=i.AST.appendNodeList(e.node,e.param_list_elt(e.i++).node),this.state=1068,this._errHandler.sync(this),t=this._input.LA(1);this.state=1071,this.match(n.RPAREN)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}param_list_elt(){let t=new lt(this,this._ctx,this.state);this.enterRule(t,112,n.RULE_param_list_elt);try{switch(this.state=1079,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=1073,this.declaration_element(),t.node=t.declaration_element().node;break;case 58:this.enterOuterAlt(t,2),this.state=1076,this.magic_tilde(),t.node=t.magic_tilde().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}return_list_elt(){let t=new ct(this,this._ctx,this.state);this.enterRule(t,114,n.RULE_return_list_elt);try{switch(this.state=1087,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(t,1),this.state=1081,this.identifier(),t.node=t.identifier().node;break;case 58:this.enterOuterAlt(t,2),this.state=1084,this.magic_tilde(),t.node=t.magic_tilde().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}return_list(){let t,e=new ut(this,this._ctx,this.state);this.enterRule(e,116,n.RULE_return_list);try{switch(this.state=1108,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 58:case 101:this.enterOuterAlt(e,1),this.state=1089,this.return_list_elt(),e.node=i.AST.nodeListFirst(e.return_list_elt(0).node);break;case 64:if(this.enterOuterAlt(e,2),this.state=1092,this.match(n.LBRACKET),e.node=i.AST.nodeListFirst(),this.state=1105,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&2097237||101===t)for(this.state=1094,this.return_list_elt(),e.node=i.AST.appendNodeList(e.node,e.return_list_elt(e.i++).node),this.state=1102,this._errHandler.sync(this),t=this._input.LA(1);45===t||56===t;)this.state=1096,t=this._input.LA(1),45!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1097,this.return_list_elt(),e.node=i.AST.appendNodeList(e.node,e.return_list_elt(e.i++).node),this.state=1104,this._errHandler.sync(this),t=this._input.LA(1);this.state=1107,this.match(n.RBRACKET);break;default:throw new s.NoViableAltException(this)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}function_(){let t,e=new ht(this,this._ctx,this.state);this.enterRule(e,118,n.RULE_function);try{this.enterOuterAlt(e,1),this.state=1110,this.match(n.FUNCTION),this.state=1114,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,128,this._ctx)&&(this.state=1111,this.return_list(),this.state=1112,this.match(n.EQ)),this.state=1116,this.function_name(),this.state=1118,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,129,this._ctx)&&(this.state=1117,this.param_list()),this.state=1121,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1120,this.sep()),this.state=1124,this._errHandler.sync(this),t=this._input.LA(1),47===t&&(this.state=1123,this.arguments_block_list()),this.state=1127,this._errHandler.sync(this),t=this._input.LA(1),(!(t-1&-32)&&1<<t-1&2544542287||!(t-35&-32)&&1<<t-35&2944452949||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1126,this.list()),this.state=1129,t=this._input.LA(1),t- -1&-32||!(1<<t- -1&536871041)?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeFunctionDefinition(e.function_name().node,e.return_list()?e.return_list().node:i.AST.nodeListFirst(),e.param_list()?e.param_list().node:i.AST.nodeListFirst(),e.arguments_block_list()?e.arguments_block_list().node:i.AST.nodeListFirst(),e.list()?e.list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}function_name(){let t=new dt(this,this._ctx,this.state);this.enterRule(t,120,n.RULE_function_name);try{this.enterOuterAlt(t,1),this.state=1132,this.qualified_identifier(),t.node=t.qualified_identifier().node}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}classdef_command(){let t,e=new mt(this,this._ctx,this.state);this.enterRule(e,122,n.RULE_classdef_command);try{this.enterOuterAlt(e,1),this.state=1135,this.match(n.CLASSDEF),this.state=1137,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1136,this.class_attribute_list()),this.state=1139,this.qualified_identifier(),this.state=1141,this._errHandler.sync(this),t=this._input.LA(1),85===t&&(this.state=1140,this.class_superclass_list()),this.state=1144,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1143,this.sep()),this.state=1147,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&85&&(this.state=1146,this.class_section_list()),this.state=1149,t=this._input.LA(1),-1!==t&&6!==t&&36!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeClassDef(e.qualified_identifier().node,e.class_section_list()?e.class_section_list().node:i.AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:i.AST.nodeListFirst(),e.class_superclass_list()?e.class_superclass_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_attribute_list(){let t,e=new pt(this,this._ctx,this.state);this.enterRule(e,124,n.RULE_class_attribute_list);try{if(this.enterOuterAlt(e,1),this.state=1152,this.match(n.LPAREN),e.node=i.AST.nodeListFirst(),this.state=1165,this._errHandler.sync(this),t=this._input.LA(1),!(t-37&-32)&&1<<t-37&6291541||101===t)for(this.state=1154,this.class_attribute(),e.node=i.AST.appendNodeList(e.node,e.class_attribute(e.i++).node),this.state=1162,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1156,this.match(n.COMMA),this.state=1157,this.class_attribute(),e.node=i.AST.appendNodeList(e.node,e.class_attribute(e.i++).node),this.state=1164,this._errHandler.sync(this),t=this._input.LA(1);this.state=1167,this.match(n.RPAREN),this.state=1169,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,139,this._ctx)&&(this.state=1168,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_attribute(){let t,e=new ft(this,this._ctx,this.state);this.enterRule(e,126,n.RULE_class_attribute);try{switch(this.state=1182,this._errHandler.sync(this),this._input.LA(1)){case 37:case 39:case 41:case 43:case 101:this.enterOuterAlt(e,1),this.state=1171,this.identifier(),this.state=1174,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1172,this.match(n.EQ),this.state=1173,this.expression()),e.node=i.AST.nodeClassAttribute(e.identifier().node,e.expression()?e.expression().node:null);break;case 58:case 59:this.enterOuterAlt(e,2),this.state=1178,e._op=this._input.LT(1),t=this._input.LA(1),58!==t&&59!==t?e._op=this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1179,this.identifier(),e.node=i.AST.nodeClassAttribute(e.identifier().node,i.AST.nodeOperation(e._op.text,e.identifier().node));break;default:throw new s.NoViableAltException(this)}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method_name(){let t,e=new gt(this,this._ctx,this.state);this.enterRule(e,128,n.RULE_class_method_name);try{for(this.enterOuterAlt(e,1),this.state=1184,this.identifier(),e.node=i.AST.nodeIdentifier(e.identifier(0).node.id),this.state=1192,this._errHandler.sync(this),t=this._input.LA(1);57===t;)this.state=1186,this.match(n.DOT),this.state=1187,this.identifier(),e.node=i.AST.nodeIdentifier(e.node.id+"."+e.identifier(e.i++).node.id),this.state=1194,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_superclass_list(){let t,e=new yt(this,this._ctx,this.state);this.enterRule(e,130,n.RULE_class_superclass_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1195,this.match(n.EXPR_LT),this.state=1196,this.qualified_identifier(),e.node=i.AST.nodeListFirst(e.qualified_identifier(e.i++).node),this.state=1204,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1198,t=this._input.LA(1),56!==t&&83!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1199,this.qualified_identifier(),e.node=i.AST.appendNodeList(e.node,e.qualified_identifier(e.i++).node)),this.state=1206,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,143,this._ctx)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_section_list(){let t,e=new xt(this,this._ctx,this.state);this.enterRule(e,132,n.RULE_class_section_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1207,this.class_section(),e.node=i.AST.nodeListFirst(e.class_section(e.i++).node),this.state=1217,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1210,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1209,this.sep()),this.state=1212,this.class_section(),e.node=i.AST.appendNodeList(e.node,e.class_section(e.i++).node)),this.state=1219,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,145,this._ctx);this.state=1221,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1220,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_section(){let t=new Ct(this,this._ctx,this.state);this.enterRule(t,134,n.RULE_class_section);try{switch(this.state=1235,this._errHandler.sync(this),this._input.LA(1)){case 39:this.enterOuterAlt(t,1),this.state=1223,this.properties_section(),t.node=t.properties_section().node;break;case 43:this.enterOuterAlt(t,2),this.state=1226,this.methods_section(),t.node=t.methods_section().node;break;case 41:this.enterOuterAlt(t,3),this.state=1229,this.events_section(),t.node=t.events_section().node;break;case 37:this.enterOuterAlt(t,4),this.state=1232,this.enumeration_section(),t.node=t.enumeration_section().node;break;default:throw new s.NoViableAltException(this)}}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}properties_section(){let t,e=new Et(this,this._ctx,this.state);this.enterRule(e,136,n.RULE_properties_section);try{this.enterOuterAlt(e,1),this.state=1237,this.match(n.PROPERTIES),this.state=1239,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1238,this.class_attribute_list()),this.state=1242,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1241,this.sep()),this.state=1245,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1244,this.class_property_list()),this.state=1247,t=this._input.LA(1),6!==t&&40!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeClassSection("PROPERTIES",e.class_property_list()?e.class_property_list().node:i.AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_property_list(){let t,e=new At(this,this._ctx,this.state);this.enterRule(e,138,n.RULE_class_property_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1250,this.class_property(),e.node=i.AST.nodeListFirst(e.class_property(e.i++).node),this.state=1258,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1252,this.sep(),this.state=1253,this.class_property(),e.node=i.AST.appendNodeList(e.node,e.class_property(e.i++).node)),this.state=1260,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,151,this._ctx);this.state=1262,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1261,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_property(){let t,e=new _t(this,this._ctx,this.state);this.enterRule(e,140,n.RULE_class_property);try{this.enterOuterAlt(e,1),this.state=1264,this.identifier(),this.state=1269,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1265,this.match(n.LPAREN),this.state=1266,this.arg_list(),this.state=1267,this.match(n.RPAREN)),this.state=1272,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,154,this._ctx)&&(this.state=1271,this.qualified_identifier()),this.state=1278,this._errHandler.sync(this),t=this._input.LA(1),66===t&&(this.state=1274,this.match(n.LCURLYBR),this.state=1275,this.arg_list(),this.state=1276,this.match(n.RCURLYBR)),this.state=1282,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1280,this.match(n.EQ),this.state=1281,this.expression()),e.node=i.AST.nodeClassProperty(e.identifier().node,e.LPAREN()?e.arg_list(0).node:i.AST.nodeListFirst(),e.qualified_identifier()?e.qualified_identifier().node:null,e.LCURLYBR()?e.arg_list(e.LPAREN()?1:0).node:i.AST.nodeListFirst(),e.expression()?e.expression().node:null)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}methods_section(){let t,e=new St(this,this._ctx,this.state);this.enterRule(e,142,n.RULE_methods_section);try{this.enterOuterAlt(e,1),this.state=1286,this.match(n.METHODS),this.state=1288,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1287,this.class_attribute_list()),this.state=1291,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1290,this.sep()),this.state=1294,this._errHandler.sync(this),t=this._input.LA(1),(27===t||!(t-37&-32)&&1<<t-37&136314965||101===t)&&(this.state=1293,this.class_method_list()),this.state=1296,t=this._input.LA(1),6!==t&&44!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeClassSection("METHODS",e.class_method_list()?e.class_method_list().node:i.AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method(){let t,e=new vt(this,this._ctx,this.state);this.enterRule(e,144,n.RULE_class_method);try{switch(this.state=1316,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,162,this._ctx)){case 1:this.enterOuterAlt(e,1),this.state=1299,this.function_(),e.node=e.function_().node;break;case 2:this.enterOuterAlt(e,2),this.state=1302,this.class_method_name(),this.state=1304,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1303,this.param_list()),e.node=i.AST.nodeFunctionDefinition(e.class_method_name().node,i.AST.nodeListFirst(),e.param_list()?e.param_list().node:i.AST.nodeListFirst(),i.AST.nodeListFirst(),i.AST.nodeListFirst()),e.node.attributes={...e.node.attributes??{},prototype:!0};break;case 3:this.enterOuterAlt(e,3),this.state=1308,this.return_list(),this.state=1309,this.match(n.EQ),this.state=1310,this.class_method_name(),this.state=1312,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1311,this.param_list()),e.node=i.AST.nodeFunctionDefinition(e.class_method_name().node,e.return_list().node,e.param_list()?e.param_list().node:i.AST.nodeListFirst(),i.AST.nodeListFirst(),i.AST.nodeListFirst()),e.node.attributes={...e.node.attributes??{},prototype:!0}}}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_method_list(){let t,e=new Tt(this,this._ctx,this.state);this.enterRule(e,146,n.RULE_class_method_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1318,this.class_method(),e.node=i.AST.nodeListFirst(e.class_method(e.i++).node),this.state=1328,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1321,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1320,this.sep()),this.state=1323,this.class_method(),e.node=i.AST.appendNodeList(e.node,e.class_method(e.i++).node)),this.state=1330,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,164,this._ctx);this.state=1332,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1331,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}events_section(){let t,e=new bt(this,this._ctx,this.state);this.enterRule(e,148,n.RULE_events_section);try{this.enterOuterAlt(e,1),this.state=1334,this.match(n.EVENTS),this.state=1336,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1335,this.class_attribute_list()),this.state=1339,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1338,this.sep()),this.state=1342,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1341,this.class_event_list()),this.state=1344,t=this._input.LA(1),6!==t&&42!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeClassSection("EVENTS",e.class_event_list()?e.class_event_list().node:i.AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_event_list(){let t,e=new Nt(this,this._ctx,this.state);this.enterRule(e,150,n.RULE_class_event_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1347,this.class_event(),e.node=i.AST.nodeListFirst(e.class_event(e.i++).node),this.state=1357,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1350,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1349,this.sep()),this.state=1352,this.class_event(),e.node=i.AST.appendNodeList(e.node,e.class_event(e.i++).node)),this.state=1359,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,170,this._ctx);this.state=1361,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1360,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_event(){let t=new It(this,this._ctx,this.state);this.enterRule(t,152,n.RULE_class_event);try{this.enterOuterAlt(t,1),this.state=1363,this.identifier(),t.node=i.AST.nodeClassEvent(t.identifier().node)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}enumeration_section(){let t,e=new Mt(this,this._ctx,this.state);this.enterRule(e,154,n.RULE_enumeration_section);try{this.enterOuterAlt(e,1),this.state=1366,this.match(n.ENUMERATION),this.state=1368,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1367,this.class_attribute_list()),this.state=1371,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1370,this.sep()),this.state=1374,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1373,this.class_enumeration_list()),this.state=1376,t=this._input.LA(1),6!==t&&38!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeClassSection("ENUMERATION",e.class_enumeration_list()?e.class_enumeration_list().node:i.AST.nodeListFirst(),e.class_attribute_list()?e.class_attribute_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_enumeration_list(){let t,e=new wt(this,this._ctx,this.state);this.enterRule(e,156,n.RULE_class_enumeration_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1379,this.class_enumeration(),e.node=i.AST.nodeListFirst(e.class_enumeration(e.i++).node),this.state=1389,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1382,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1381,this.sep()),this.state=1384,this.class_enumeration(),e.node=i.AST.appendNodeList(e.node,e.class_enumeration(e.i++).node)),this.state=1391,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,176,this._ctx);this.state=1393,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1392,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}class_enumeration(){let t,e=new Lt(this,this._ctx,this.state);this.enterRule(e,158,n.RULE_class_enumeration);try{this.enterOuterAlt(e,1),this.state=1395,this.identifier(),this.state=1401,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1396,this.match(n.LPAREN),this.state=1398,this._errHandler.sync(this),t=this._input.LA(1),(3===t||7===t||!(t-37&-32)&&1<<t-37&736244309||!(t-94&-32)&&1<<t-94&387||142===t)&&(this.state=1397,this.arg_list()),this.state=1400,this.match(n.RPAREN)),e.node=i.AST.nodeClassEnumeration(e.identifier().node,e.arg_list()?e.arg_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_block_list(){let t,e=new Ot(this,this._ctx,this.state);this.enterRule(e,160,n.RULE_arguments_block_list);try{let r;for(this.enterOuterAlt(e,1),this.state=1405,this.arguments_block(),e.node=i.AST.nodeListFirst(e.arguments_block(e.i++).node),this.state=1415,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);2!==r&&r!==s.ATN.INVALID_ALT_NUMBER;)1===r&&(this.state=1408,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1407,this.sep()),this.state=1410,this.arguments_block(),e.node=i.AST.appendNodeList(e.node,e.arguments_block(e.i++).node)),this.state=1417,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,181,this._ctx);this.state=1419,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1418,this.sep())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_block(){let t,e=new Rt(this,this._ctx,this.state);this.enterRule(e,162,n.RULE_arguments_block);try{this.enterOuterAlt(e,1),this.state=1421,this.match(n.ARGUMENTS),this.state=1423,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,183,this._ctx)&&(this.state=1422,this.sep()),this.state=1431,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1425,this.match(n.LPAREN),this.state=1426,this.arguments_attribute_list(),this.state=1427,this.match(n.RPAREN),this.state=1429,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,184,this._ctx))&&(this.state=1428,this.sep()),this.state=1434,this._errHandler.sync(this),t=this._input.LA(1),(!(t-37&-32)&&1<<t-37&85||101===t)&&(this.state=1433,this.args_validation_list()),this.state=1437,this._errHandler.sync(this),t=this._input.LA(1),55!==t&&56!==t&&106!==t||(this.state=1436,this.sep()),this.state=1439,t=this._input.LA(1),6!==t&&48!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),e.node=i.AST.nodeArguments(e.arguments_attribute_list()?e.arguments_attribute_list().node:null,e.args_validation_list()?e.args_validation_list().node:i.AST.nodeListFirst())}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arguments_attribute_list(){let t,e=new Dt(this,this._ctx,this.state);this.enterRule(e,164,n.RULE_arguments_attribute_list);try{for(this.enterOuterAlt(e,1),this.state=1442,this.identifier(),e.node=i.AST.nodeListFirst(e.identifier(e.i++).node),this.state=1450,this._errHandler.sync(this),t=this._input.LA(1);56===t;)this.state=1444,this.match(n.COMMA),this.state=1445,this.identifier(),e.node=i.AST.appendNodeList(e.node,e.identifier(e.i++).node),this.state=1452,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}args_validation_list(){let t=new Ft(this,this._ctx,this.state);this.enterRule(t,166,n.RULE_args_validation_list);try{let e;for(this.enterOuterAlt(t,1),this.state=1453,this.arg_validation(),t.node=i.AST.nodeListFirst(t.arg_validation(t.i++).node),this.state=1461,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,189,this._ctx);2!==e&&e!==s.ATN.INVALID_ALT_NUMBER;)1===e&&(this.state=1455,this.sep(),this.state=1456,this.arg_validation(),t.node=i.AST.appendNodeList(t.node,t.arg_validation(t.i++).node)),this.state=1463,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,189,this._ctx)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}arg_validation(){let t,e=new Pt(this,this._ctx,this.state);this.enterRule(e,168,n.RULE_arg_validation);try{this.enterOuterAlt(e,1),this.state=1464,this.arg_validation_name(),this.state=1469,this._errHandler.sync(this),t=this._input.LA(1),62===t&&(this.state=1465,this.match(n.LPAREN),this.state=1466,this.arg_list(),this.state=1467,this.match(n.RPAREN)),this.state=1472,this._errHandler.sync(this),1===this._interp.adaptivePredict(this._input,191,this._ctx)&&(this.state=1471,this.qualified_identifier()),this.state=1478,this._errHandler.sync(this),t=this._input.LA(1),66===t&&(this.state=1474,this.match(n.LCURLYBR),this.state=1475,this.arg_list(),this.state=1476,this.match(n.RCURLYBR)),this.state=1482,this._errHandler.sync(this),t=this._input.LA(1),53===t&&(this.state=1480,this.match(n.EQ),this.state=1481,this.expression()),e.node=i.AST.nodeArgumentValidation(e.arg_validation_name().node,e.LPAREN()?e.arg_list(0).node:i.AST.nodeListFirst(),e.qualified_identifier()?e.qualified_identifier().node:i.AST.nodeListFirst(),e.LCURLYBR()?e.LPAREN()?e.arg_list(1).node:e.arg_list(0).node:i.AST.nodeListFirst(),e.expression()?e.expression().node:null)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}arg_validation_name(){let t,e=new kt(this,this._ctx,this.state);this.enterRule(e,170,n.RULE_arg_validation_name);try{for(this.enterOuterAlt(e,1),this.state=1486,this.identifier(),e.node=e.identifier(0).node,this.state=1494,this._errHandler.sync(this),t=this._input.LA(1);57===t;)this.state=1488,this.match(n.DOT),this.state=1489,this.identifier(),e.node=i.AST.nodeIndirectRef(e.node,e.identifier(e.i++).node.id),this.state=1496,this._errHandler.sync(this),t=this._input.LA(1)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}sep_no_nl(){let t,e=new Vt(this,this._ctx,this.state);this.enterRule(e,172,n.RULE_sep_no_nl);try{this.enterOuterAlt(e,1),this.state=1498,this._errHandler.sync(this),t=this._input.LA(1);do{this.state=1497,t=this._input.LA(1),55!==t&&56!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1500,this._errHandler.sync(this),t=this._input.LA(1)}while(55===t||56===t)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}nl(){let t=new Ut(this,this._ctx,this.state);this.enterRule(t,174,n.RULE_nl);try{let e;this.enterOuterAlt(t,1),this.state=1503,this._errHandler.sync(this),e=1;do{if(1!==e)throw new s.NoViableAltException(this);this.state=1502,this.match(n.NEWLINE),this.state=1505,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,196,this._ctx)}while(2!==e&&e!==s.ATN.INVALID_ALT_NUMBER)}catch(e){if(!(e instanceof s.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t}sep(){let t,e=new $t(this,this._ctx,this.state);this.enterRule(e,176,n.RULE_sep);try{let r;this.enterOuterAlt(e,1),this.state=1508,this._errHandler.sync(this),r=1;do{if(1!==r)throw new s.NoViableAltException(this);this.state=1507,t=this._input.LA(1),55!==t&&56!==t&&106!==t?this._errHandler.recoverInline(this):(this._errHandler.reportMatch(this),this.consume()),this.state=1510,this._errHandler.sync(this),r=this._interp.adaptivePredict(this._input,197,this._ctx)}while(2!==r&&r!==s.ATN.INVALID_ALT_NUMBER)}catch(t){if(!(t instanceof s.RecognitionException))throw t;e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t)}finally{this.exitRule()}return e}sempred(t,e,r){switch(e){case 23:return this.oper_expr_sempred(t,r);case 24:return this.power_expr_sempred(t,r);case 26:return this.simple_expr_sempred(t,r)}return!0}oper_expr_sempred(t,e){switch(e){case 0:return this.precpred(this._ctx,2);case 1:return this.precpred(this._ctx,1);case 2:return this.precpred(this._ctx,12);case 3:return this.precpred(this._ctx,11);case 4:return this.precpred(this._ctx,10);case 5:return this.precpred(this._ctx,9);case 6:return this.precpred(this._ctx,8);case 7:return this.precpred(this._ctx,7);case 8:return this.precpred(this._ctx,6);case 9:return this.precpred(this._ctx,5)}return!0}power_expr_sempred(t,e){switch(e){case 10:return this.precpred(this._ctx,8);case 11:return this.precpred(this._ctx,7);case 12:return this.precpred(this._ctx,6);case 13:return this.precpred(this._ctx,5);case 14:return this.precpred(this._ctx,4);case 15:return this.precpred(this._ctx,3)}return!0}simple_expr_sempred(t,e){switch(e){case 16:return this.precpred(this._ctx,5);case 17:return this.precpred(this._ctx,4);case 18:return this.precpred(this._ctx,3);case 19:return this.precpred(this._ctx,2);case 20:return this.precpred(this._ctx,1)}return!0}static _serializedATN=[4,1,142,1513,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,1,0,3,0,180,8,0,1,0,1,0,1,0,3,0,185,8,0,1,0,1,0,1,0,1,0,3,0,191,8,0,1,1,1,1,1,1,1,1,1,1,1,1,5,1,199,8,1,10,1,12,1,202,9,1,1,1,3,1,205,8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,5,2,215,8,2,10,2,12,2,218,9,2,1,2,3,2,221,8,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,234,8,3,1,4,1,4,1,4,1,4,1,4,1,4,5,4,242,8,4,10,4,12,4,245,9,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,262,8,6,1,7,1,7,1,7,1,7,1,7,3,7,269,8,7,1,8,1,8,1,8,1,8,1,8,1,8,5,8,277,8,8,10,8,12,8,280,9,8,1,9,1,9,1,9,1,9,3,9,286,8,9,1,10,1,10,1,10,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,3,12,303,8,12,1,13,1,13,1,13,1,13,1,13,1,13,5,13,311,8,13,10,13,12,13,314,9,13,1,13,3,13,317,8,13,1,13,1,13,1,13,4,13,322,8,13,11,13,12,13,323,1,13,3,13,327,8,13,1,13,5,13,330,8,13,10,13,12,13,333,9,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,5,13,342,8,13,10,13,12,13,345,9,13,1,13,3,13,348,8,13,1,13,1,13,1,13,4,13,353,8,13,11,13,12,13,354,1,13,3,13,358,8,13,1,13,5,13,361,8,13,10,13,12,13,364,9,13,1,13,3,13,367,8,13,1,14,1,14,1,14,3,14,372,8,14,1,14,1,14,1,14,1,14,1,14,1,14,5,14,380,8,14,10,14,12,14,383,9,14,1,14,3,14,386,8,14,3,14,388,8,14,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,425,8,18,1,19,1,19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,3,21,442,8,21,1,22,1,22,1,22,1,22,1,22,1,22,5,22,450,8,22,10,22,12,22,453,9,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,467,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,485,8,23,1,23,1,23,1,23,1,23,1,23,3,23,492,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,501,8,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,5,23,526,8,23,10,23,12,23,529,9,23,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,543,8,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,551,8,24,1,24,1,24,1,24,1,24,1,24,3,24,558,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,3,24,567,8,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,1,24,5,24,584,8,24,10,24,12,24,587,9,24,1,25,1,25,1,25,1,25,1,25,3,25,594,8,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,605,8,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,5,26,632,8,26,10,26,12,26,635,9,26,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,3,27,648,8,27,1,28,1,28,1,28,1,28,1,28,3,28,655,8,28,1,28,1,28,3,28,659,8,28,1,29,1,29,1,29,1,29,1,29,1,29,5,29,667,8,29,10,29,12,29,670,9,29,1,29,3,29,673,8,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,699,8,30,1,31,1,31,1,31,1,31,3,31,705,8,31,1,31,1,31,1,31,3,31,710,8,31,1,31,1,31,1,31,5,31,715,8,31,10,31,12,31,718,9,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,728,8,32,1,33,1,33,1,33,1,33,1,33,3,33,735,8,33,1,33,1,33,1,33,5,33,740,8,33,10,33,12,33,743,9,33,3,33,745,8,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,3,34,754,8,34,1,34,1,34,3,34,758,8,34,1,35,1,35,1,35,1,35,1,35,1,35,3,35,766,8,35,1,36,1,36,1,36,3,36,771,8,36,1,36,3,36,774,8,36,1,36,1,36,1,36,1,36,5,36,780,8,36,10,36,12,36,783,9,36,1,36,3,36,786,8,36,1,36,1,36,1,36,1,37,1,37,3,37,793,8,37,1,37,1,37,3,37,797,8,37,1,37,3,37,800,8,37,1,37,1,37,1,38,1,38,3,38,806,8,38,1,38,3,38,809,8,38,1,38,1,38,1,39,1,39,1,39,3,39,816,8,39,1,39,3,39,819,8,39,1,39,3,39,822,8,39,1,39,1,39,1,39,1,40,1,40,1,40,3,40,830,8,40,1,40,1,40,1,40,5,40,835,8,40,10,40,12,40,838,9,40,1,40,3,40,841,8,40,1,41,1,41,3,41,845,8,41,1,41,1,41,3,41,849,8,41,1,41,3,41,852,8,41,1,41,1,41,1,42,1,42,3,42,858,8,42,1,42,3,42,861,8,42,1,42,3,42,864,8,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,3,43,880,8,43,1,44,1,44,1,44,3,44,885,8,44,1,44,3,44,888,8,44,1,44,1,44,1,44,1,45,1,45,3,45,895,8,45,1,45,3,45,898,8,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,3,46,909,8,46,1,46,3,46,912,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,924,8,46,1,46,3,46,927,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,937,8,46,1,46,3,46,940,8,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,952,8,46,1,46,1,46,3,46,956,8,46,1,46,3,46,959,8,46,1,46,1,46,1,46,3,46,964,8,46,1,47,1,47,3,47,968,8,47,1,47,3,47,971,8,47,1,47,3,47,974,8,47,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,48,1,48,3,48,986,8,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,49,3,49,996,8,49,1,50,1,50,1,50,1,50,1,50,1,50,3,50,1004,8,50,1,51,1,51,3,51,1008,8,51,1,51,3,51,1011,8,51,1,51,1,51,1,51,1,51,1,51,1,51,3,51,1019,8,51,1,51,3,51,1022,8,51,1,51,1,51,3,51,1026,8,51,1,52,1,52,3,52,1030,8,52,1,52,3,52,1033,8,52,1,52,1,52,1,53,1,53,3,53,1039,8,53,1,53,3,53,1042,8,53,1,53,1,53,1,53,1,53,1,54,1,54,3,54,1050,8,54,1,54,3,54,1053,8,54,1,54,1,54,1,55,1,55,1,55,1,55,1,55,1,55,1,55,1,55,5,55,1065,8,55,10,55,12,55,1068,9,55,3,55,1070,8,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,3,56,1080,8,56,1,57,1,57,1,57,1,57,1,57,1,57,3,57,1088,8,57,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,1,58,5,58,1101,8,58,10,58,12,58,1104,9,58,3,58,1106,8,58,1,58,3,58,1109,8,58,1,59,1,59,1,59,1,59,3,59,1115,8,59,1,59,1,59,3,59,1119,8,59,1,59,3,59,1122,8,59,1,59,3,59,1125,8,59,1,59,3,59,1128,8,59,1,59,1,59,1,59,1,60,1,60,1,60,1,61,1,61,3,61,1138,8,61,1,61,1,61,3,61,1142,8,61,1,61,3,61,1145,8,61,1,61,3,61,1148,8,61,1,61,1,61,1,61,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,5,62,1161,8,62,10,62,12,62,1164,9,62,3,62,1166,8,62,1,62,1,62,3,62,1170,8,62,1,63,1,63,1,63,3,63,1175,8,63,1,63,1,63,1,63,1,63,1,63,1,63,3,63,1183,8,63,1,64,1,64,1,64,1,64,1,64,1,64,5,64,1191,8,64,10,64,12,64,1194,9,64,1,65,1,65,1,65,1,65,1,65,1,65,1,65,5,65,1203,8,65,10,65,12,65,1206,9,65,1,66,1,66,1,66,3,66,1211,8,66,1,66,1,66,1,66,5,66,1216,8,66,10,66,12,66,1219,9,66,1,66,3,66,1222,8,66,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,3,67,1236,8,67,1,68,1,68,3,68,1240,8,68,1,68,3,68,1243,8,68,1,68,3,68,1246,8,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,69,1,69,5,69,1257,8,69,10,69,12,69,1260,9,69,1,69,3,69,1263,8,69,1,70,1,70,1,70,1,70,1,70,3,70,1270,8,70,1,70,3,70,1273,8,70,1,70,1,70,1,70,1,70,3,70,1279,8,70,1,70,1,70,3,70,1283,8,70,1,70,1,70,1,71,1,71,3,71,1289,8,71,1,71,3,71,1292,8,71,1,71,3,71,1295,8,71,1,71,1,71,1,71,1,72,1,72,1,72,1,72,1,72,3,72,1305,8,72,1,72,1,72,1,72,1,72,1,72,1,72,3,72,1313,8,72,1,72,1,72,3,72,1317,8,72,1,73,1,73,1,73,3,73,1322,8,73,1,73,1,73,1,73,5,73,1327,8,73,10,73,12,73,1330,9,73,1,73,3,73,1333,8,73,1,74,1,74,3,74,1337,8,74,1,74,3,74,1340,8,74,1,74,3,74,1343,8,74,1,74,1,74,1,74,1,75,1,75,1,75,3,75,1351,8,75,1,75,1,75,1,75,5,75,1356,8,75,10,75,12,75,1359,9,75,1,75,3,75,1362,8,75,1,76,1,76,1,76,1,77,1,77,3,77,1369,8,77,1,77,3,77,1372,8,77,1,77,3,77,1375,8,77,1,77,1,77,1,77,1,78,1,78,1,78,3,78,1383,8,78,1,78,1,78,1,78,5,78,1388,8,78,10,78,12,78,1391,9,78,1,78,3,78,1394,8,78,1,79,1,79,1,79,3,79,1399,8,79,1,79,3,79,1402,8,79,1,79,1,79,1,80,1,80,1,80,3,80,1409,8,80,1,80,1,80,1,80,5,80,1414,8,80,10,80,12,80,1417,9,80,1,80,3,80,1420,8,80,1,81,1,81,3,81,1424,8,81,1,81,1,81,1,81,1,81,3,81,1430,8,81,3,81,1432,8,81,1,81,3,81,1435,8,81,1,81,3,81,1438,8,81,1,81,1,81,1,81,1,82,1,82,1,82,1,82,1,82,1,82,5,82,1449,8,82,10,82,12,82,1452,9,82,1,83,1,83,1,83,1,83,1,83,1,83,5,83,1460,8,83,10,83,12,83,1463,9,83,1,84,1,84,1,84,1,84,1,84,3,84,1470,8,84,1,84,3,84,1473,8,84,1,84,1,84,1,84,1,84,3,84,1479,8,84,1,84,1,84,3,84,1483,8,84,1,84,1,84,1,85,1,85,1,85,1,85,1,85,1,85,5,85,1493,8,85,10,85,12,85,1496,9,85,1,86,4,86,1499,8,86,11,86,12,86,1500,1,87,4,87,1504,8,87,11,87,12,87,1505,1,88,4,88,1509,8,88,11,88,12,88,1510,1,88,0,3,46,48,52,89,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,0,28,2,0,45,45,56,56,2,0,49,50,94,95,1,0,58,59,3,0,51,52,68,68,91,93,1,0,49,50,1,0,94,95,1,0,98,99,1,0,96,97,1,0,85,90,2,0,53,53,69,80,1,0,5,6,2,0,6,6,11,11,2,0,6,6,15,15,2,0,6,6,19,19,2,0,6,6,21,21,2,0,6,6,23,23,2,0,6,6,31,31,2,0,6,6,34,34,2,1,6,6,28,28,2,1,6,6,36,36,2,0,56,56,83,83,2,0,6,6,40,40,2,0,6,6,44,44,2,0,6,6,42,42,2,0,6,6,38,38,2,0,6,6,48,48,1,0,55,56,2,0,55,56,106,106,1666,0,190,1,0,0,0,2,192,1,0,0,0,4,208,1,0,0,0,6,233,1,0,0,0,8,235,1,0,0,0,10,248,1,0,0,0,12,261,1,0,0,0,14,268,1,0,0,0,16,270,1,0,0,0,18,285,1,0,0,0,20,287,1,0,0,0,22,290,1,0,0,0,24,302,1,0,0,0,26,366,1,0,0,0,28,387,1,0,0,0,30,389,1,0,0,0,32,393,1,0,0,0,34,397,1,0,0,0,36,424,1,0,0,0,38,426,1,0,0,0,40,429,1,0,0,0,42,441,1,0,0,0,44,443,1,0,0,0,46,466,1,0,0,0,48,542,1,0,0,0,50,588,1,0,0,0,52,604,1,0,0,0,54,647,1,0,0,0,56,658,1,0,0,0,58,660,1,0,0,0,60,698,1,0,0,0,62,704,1,0,0,0,64,727,1,0,0,0,66,729,1,0,0,0,68,757,1,0,0,0,70,765,1,0,0,0,72,767,1,0,0,0,74,790,1,0,0,0,76,803,1,0,0,0,78,812,1,0,0,0,80,826,1,0,0,0,82,842,1,0,0,0,84,855,1,0,0,0,86,879,1,0,0,0,88,881,1,0,0,0,90,892,1,0,0,0,92,963,1,0,0,0,94,965,1,0,0,0,96,978,1,0,0,0,98,995,1,0,0,0,100,1003,1,0,0,0,102,1025,1,0,0,0,104,1027,1,0,0,0,106,1036,1,0,0,0,108,1047,1,0,0,0,110,1056,1,0,0,0,112,1079,1,0,0,0,114,1087,1,0,0,0,116,1108,1,0,0,0,118,1110,1,0,0,0,120,1132,1,0,0,0,122,1135,1,0,0,0,124,1152,1,0,0,0,126,1182,1,0,0,0,128,1184,1,0,0,0,130,1195,1,0,0,0,132,1207,1,0,0,0,134,1235,1,0,0,0,136,1237,1,0,0,0,138,1250,1,0,0,0,140,1264,1,0,0,0,142,1286,1,0,0,0,144,1316,1,0,0,0,146,1318,1,0,0,0,148,1334,1,0,0,0,150,1347,1,0,0,0,152,1363,1,0,0,0,154,1366,1,0,0,0,156,1379,1,0,0,0,158,1395,1,0,0,0,160,1405,1,0,0,0,162,1421,1,0,0,0,164,1442,1,0,0,0,166,1453,1,0,0,0,168,1464,1,0,0,0,170,1486,1,0,0,0,172,1498,1,0,0,0,174,1503,1,0,0,0,176,1508,1,0,0,0,178,180,3,176,88,0,179,178,1,0,0,0,179,180,1,0,0,0,180,181,1,0,0,0,181,182,5,0,0,1,182,191,6,0,-1,0,183,185,3,176,88,0,184,183,1,0,0,0,184,185,1,0,0,0,185,186,1,0,0,0,186,187,3,2,1,0,187,188,5,0,0,1,188,189,6,0,-1,0,189,191,1,0,0,0,190,179,1,0,0,0,190,184,1,0,0,0,191,1,1,0,0,0,192,193,3,6,3,0,193,200,6,1,-1,0,194,195,3,176,88,0,195,196,3,6,3,0,196,197,6,1,-1,0,197,199,1,0,0,0,198,194,1,0,0,0,199,202,1,0,0,0,200,198,1,0,0,0,200,201,1,0,0,0,201,204,1,0,0,0,202,200,1,0,0,0,203,205,3,176,88,0,204,203,1,0,0,0,204,205,1,0,0,0,205,206,1,0,0,0,206,207,6,1,-1,0,207,3,1,0,0,0,208,209,3,6,3,0,209,216,6,2,-1,0,210,211,3,176,88,0,211,212,3,6,3,0,212,213,6,2,-1,0,213,215,1,0,0,0,214,210,1,0,0,0,215,218,1,0,0,0,216,214,1,0,0,0,216,217,1,0,0,0,217,220,1,0,0,0,218,216,1,0,0,0,219,221,3,176,88,0,220,219,1,0,0,0,220,221,1,0,0,0,221,222,1,0,0,0,222,223,6,2,-1,0,223,5,1,0,0,0,224,225,3,60,30,0,225,226,6,3,-1,0,226,234,1,0,0,0,227,228,3,8,4,0,228,229,6,3,-1,0,229,234,1,0,0,0,230,231,3,54,27,0,231,232,6,3,-1,0,232,234,1,0,0,0,233,224,1,0,0,0,233,227,1,0,0,0,233,230,1,0,0,0,234,7,1,0,0,0,235,236,3,12,6,0,236,237,3,10,5,0,237,243,6,4,-1,0,238,239,3,10,5,0,239,240,6,4,-1,0,240,242,1,0,0,0,241,238,1,0,0,0,242,245,1,0,0,0,243,241,1,0,0,0,243,244,1,0,0,0,244,246,1,0,0,0,245,243,1,0,0,0,246,247,6,4,-1,0,247,9,1,0,0,0,248,249,3,18,9,0,249,250,6,5,-1,0,250,11,1,0,0,0,251,252,5,101,0,0,252,262,6,6,-1,0,253,254,5,39,0,0,254,262,6,6,-1,0,255,256,5,43,0,0,256,262,6,6,-1,0,257,258,5,41,0,0,258,262,6,6,-1,0,259,260,5,37,0,0,260,262,6,6,-1,0,261,251,1,0,0,0,261,253,1,0,0,0,261,255,1,0,0,0,261,257,1,0,0,0,261,259,1,0,0,0,262,13,1,0,0,0,263,264,3,12,6,0,264,265,6,7,-1,0,265,269,1,0,0,0,266,267,5,6,0,0,267,269,6,7,-1,0,268,263,1,0,0,0,268,266,1,0,0,0,269,15,1,0,0,0,270,271,3,14,7,0,271,278,6,8,-1,0,272,273,5,57,0,0,273,274,3,14,7,0,274,275,6,8,-1,0,275,277,1,0,0,0,276,272,1,0,0,0,277,280,1,0,0,0,278,276,1,0,0,0,278,279,1,0,0,0,279,17,1,0,0,0,280,278,1,0,0,0,281,282,5,46,0,0,282,286,6,9,-1,0,283,284,5,142,0,0,284,286,6,9,-1,0,285,281,1,0,0,0,285,283,1,0,0,0,286,19,1,0,0,0,287,288,5,102,0,0,288,289,6,10,-1,0,289,21,1,0,0,0,290,291,5,7,0,0,291,292,6,11,-1,0,292,23,1,0,0,0,293,294,3,20,10,0,294,295,6,12,-1,0,295,303,1,0,0,0,296,297,3,18,9,0,297,298,6,12,-1,0,298,303,1,0,0,0,299,300,3,22,11,0,300,301,6,12,-1,0,301,303,1,0,0,0,302,293,1,0,0,0,302,296,1,0,0,0,302,299,1,0,0,0,303,25,1,0,0,0,304,305,5,64,0,0,305,306,5,65,0,0,306,367,6,13,-1,0,307,312,5,64,0,0,308,311,5,55,0,0,309,311,3,174,87,0,310,308,1,0,0,0,310,309,1,0,0,0,311,314,1,0,0,0,312,310,1,0,0,0,312,313,1,0,0,0,313,316,1,0,0,0,314,312,1,0,0,0,315,317,3,28,14,0,316,315,1,0,0,0,316,317,1,0,0,0,317,318,1,0,0,0,318,331,6,13,-1,0,319,322,5,55,0,0,320,322,3,174,87,0,321,319,1,0,0,0,321,320,1,0,0,0,322,323,1,0,0,0,323,321,1,0,0,0,323,324,1,0,0,0,324,326,1,0,0,0,325,327,3,28,14,0,326,325,1,0,0,0,326,327,1,0,0,0,327,328,1,0,0,0,328,330,6,13,-1,0,329,321,1,0,0,0,330,333,1,0,0,0,331,329,1,0,0,0,331,332,1,0,0,0,332,334,1,0,0,0,333,331,1,0,0,0,334,367,5,65,0,0,335,336,5,66,0,0,336,337,5,67,0,0,337,367,6,13,-1,0,338,343,5,66,0,0,339,342,5,55,0,0,340,342,3,174,87,0,341,339,1,0,0,0,341,340,1,0,0,0,342,345,1,0,0,0,343,341,1,0,0,0,343,344,1,0,0,0,344,347,1,0,0,0,345,343,1,0,0,0,346,348,3,28,14,0,347,346,1,0,0,0,347,348,1,0,0,0,348,349,1,0,0,0,349,362,6,13,-1,0,350,353,5,55,0,0,351,353,3,174,87,0,352,350,1,0,0,0,352,351,1,0,0,0,353,354,1,0,0,0,354,352,1,0,0,0,354,355,1,0,0,0,355,357,1,0,0,0,356,358,3,28,14,0,357,356,1,0,0,0,357,358,1,0,0,0,358,359,1,0,0,0,359,361,6,13,-1,0,360,352,1,0,0,0,361,364,1,0,0,0,362,360,1,0,0,0,362,363,1,0,0,0,363,365,1,0,0,0,364,362,1,0,0,0,365,367,5,67,0,0,366,304,1,0,0,0,366,307,1,0,0,0,366,335,1,0,0,0,366,338,1,0,0,0,367,27,1,0,0,0,368,369,7,0,0,0,369,388,6,14,-1,0,370,372,7,0,0,0,371,370,1,0,0,0,371,372,1,0,0,0,372,373,1,0,0,0,373,374,3,42,21,0,374,381,6,14,-1,0,375,376,7,0,0,0,376,377,3,42,21,0,377,378,6,14,-1,0,378,380,1,0,0,0,379,375,1,0,0,0,380,383,1,0,0,0,381,379,1,0,0,0,381,382,1,0,0,0,382,385,1,0,0,0,383,381,1,0,0,0,384,386,7,0,0,0,385,384,1,0,0,0,385,386,1,0,0,0,386,388,1,0,0,0,387,368,1,0,0,0,387,371,1,0,0,0,388,29,1,0,0,0,389,390,5,60,0,0,390,391,3,16,8,0,391,392,6,15,-1,0,392,31,1,0,0,0,393,394,5,61,0,0,394,395,3,16,8,0,395,396,6,16,-1,0,396,33,1,0,0,0,397,398,5,60,0,0,398,399,3,110,55,0,399,400,3,54,27,0,400,401,6,17,-1,0,401,35,1,0,0,0,402,403,3,12,6,0,403,404,6,18,-1,0,404,425,1,0,0,0,405,406,5,3,0,0,406,425,6,18,-1,0,407,408,3,24,12,0,408,409,6,18,-1,0,409,425,1,0,0,0,410,411,3,30,15,0,411,412,6,18,-1,0,412,425,1,0,0,0,413,414,3,32,16,0,414,415,6,18,-1,0,415,425,1,0,0,0,416,417,3,26,13,0,417,418,6,18,-1,0,418,425,1,0,0,0,419,420,5,62,0,0,420,421,3,54,27,0,421,422,5,63,0,0,422,423,6,18,-1,0,423,425,1,0,0,0,424,402,1,0,0,0,424,405,1,0,0,0,424,407,1,0,0,0,424,410,1,0,0,0,424,413,1,0,0,0,424,416,1,0,0,0,424,419,1,0,0,0,425,37,1,0,0,0,426,427,5,54,0,0,427,428,6,19,-1,0,428,39,1,0,0,0,429,430,5,58,0,0,430,431,6,20,-1,0,431,41,1,0,0,0,432,433,3,54,27,0,433,434,6,21,-1,0,434,442,1,0,0,0,435,436,3,38,19,0,436,437,6,21,-1,0,437,442,1,0,0,0,438,439,3,40,20,0,439,440,6,21,-1,0,440,442,1,0,0,0,441,432,1,0,0,0,441,435,1,0,0,0,441,438,1,0,0,0,442,43,1,0,0,0,443,444,3,42,21,0,444,451,6,22,-1,0,445,446,5,56,0,0,446,447,3,42,21,0,447,448,6,22,-1,0,448,450,1,0,0,0,449,445,1,0,0,0,450,453,1,0,0,0,451,449,1,0,0,0,451,452,1,0,0,0,452,45,1,0,0,0,453,451,1,0,0,0,454,455,6,23,-1,0,455,456,3,36,18,0,456,457,6,23,-1,0,457,467,1,0,0,0,458,459,7,1,0,0,459,460,3,46,23,4,460,461,6,23,-1,0,461,467,1,0,0,0,462,463,7,2,0,0,463,464,3,46,23,3,464,465,6,23,-1,0,465,467,1,0,0,0,466,454,1,0,0,0,466,458,1,0,0,0,466,462,1,0,0,0,467,527,1,0,0,0,468,469,10,2,0,0,469,470,7,3,0,0,470,471,3,46,23,3,471,472,6,23,-1,0,472,526,1,0,0,0,473,474,10,1,0,0,474,475,7,4,0,0,475,476,3,46,23,2,476,477,6,23,-1,0,477,526,1,0,0,0,478,479,10,12,0,0,479,480,7,5,0,0,480,526,6,23,-1,0,481,482,10,11,0,0,482,484,5,62,0,0,483,485,3,44,22,0,484,483,1,0,0,0,484,485,1,0,0,0,485,486,1,0,0,0,486,487,5,63,0,0,487,526,6,23,-1,0,488,489,10,10,0,0,489,491,5,66,0,0,490,492,3,44,22,0,491,490,1,0,0,0,491,492,1,0,0,0,492,493,1,0,0,0,493,494,5,67,0,0,494,526,6,23,-1,0,495,496,10,9,0,0,496,497,5,60,0,0,497,498,3,16,8,0,498,500,5,62,0,0,499,501,3,44,22,0,500,499,1,0,0,0,500,501,1,0,0,0,501,502,1,0,0,0,502,503,5,63,0,0,503,504,6,23,-1,0,504,526,1,0,0,0,505,506,10,8,0,0,506,507,7,6,0,0,507,526,6,23,-1,0,508,509,10,7,0,0,509,510,5,57,0,0,510,511,3,14,7,0,511,512,6,23,-1,0,512,526,1,0,0,0,513,514,10,6,0,0,514,515,5,57,0,0,515,516,5,62,0,0,516,517,3,54,27,0,517,518,5,63,0,0,518,519,6,23,-1,0,519,526,1,0,0,0,520,521,10,5,0,0,521,522,7,7,0,0,522,523,3,48,24,0,523,524,6,23,-1,0,524,526,1,0,0,0,525,468,1,0,0,0,525,473,1,0,0,0,525,478,1,0,0,0,525,481,1,0,0,0,525,488,1,0,0,0,525,495,1,0,0,0,525,505,1,0,0,0,525,508,1,0,0,0,525,513,1,0,0,0,525,520,1,0,0,0,526,529,1,0,0,0,527,525,1,0,0,0,527,528,1,0,0,0,528,47,1,0,0,0,529,527,1,0,0,0,530,531,6,24,-1,0,531,532,3,36,18,0,532,533,6,24,-1,0,533,543,1,0,0,0,534,535,7,1,0,0,535,536,3,48,24,2,536,537,6,24,-1,0,537,543,1,0,0,0,538,539,7,2,0,0,539,540,3,48,24,1,540,541,6,24,-1,0,541,543,1,0,0,0,542,530,1,0,0,0,542,534,1,0,0,0,542,538,1,0,0,0,543,585,1,0,0,0,544,545,10,8,0,0,545,546,7,5,0,0,546,584,6,24,-1,0,547,548,10,7,0,0,548,550,5,62,0,0,549,551,3,44,22,0,550,549,1,0,0,0,550,551,1,0,0,0,551,552,1,0,0,0,552,553,5,63,0,0,553,584,6,24,-1,0,554,555,10,6,0,0,555,557,5,66,0,0,556,558,3,44,22,0,557,556,1,0,0,0,557,558,1,0,0,0,558,559,1,0,0,0,559,560,5,67,0,0,560,584,6,24,-1,0,561,562,10,5,0,0,562,563,5,60,0,0,563,564,3,16,8,0,564,566,5,62,0,0,565,567,3,44,22,0,566,565,1,0,0,0,566,567,1,0,0,0,567,568,1,0,0,0,568,569,5,63,0,0,569,570,6,24,-1,0,570,584,1,0,0,0,571,572,10,4,0,0,572,573,5,57,0,0,573,574,3,14,7,0,574,575,6,24,-1,0,575,584,1,0,0,0,576,577,10,3,0,0,577,578,5,57,0,0,578,579,5,62,0,0,579,580,3,54,27,0,580,581,5,63,0,0,581,582,6,24,-1,0,582,584,1,0,0,0,583,544,1,0,0,0,583,547,1,0,0,0,583,554,1,0,0,0,583,561,1,0,0,0,583,571,1,0,0,0,583,576,1,0,0,0,584,587,1,0,0,0,585,583,1,0,0,0,585,586,1,0,0,0,586,49,1,0,0,0,587,585,1,0,0,0,588,589,3,46,23,0,589,590,5,54,0,0,590,593,3,46,23,0,591,592,5,54,0,0,592,594,3,46,23,0,593,591,1,0,0,0,593,594,1,0,0,0,594,595,1,0,0,0,595,596,6,25,-1,0,596,51,1,0,0,0,597,598,6,26,-1,0,598,599,3,46,23,0,599,600,6,26,-1,0,600,605,1,0,0,0,601,602,3,50,25,0,602,603,6,26,-1,0,603,605,1,0,0,0,604,597,1,0,0,0,604,601,1,0,0,0,605,633,1,0,0,0,606,607,10,5,0,0,607,608,7,8,0,0,608,609,3,52,26,6,609,610,6,26,-1,0,610,632,1,0,0,0,611,612,10,4,0,0,612,613,5,83,0,0,613,614,3,52,26,5,614,615,6,26,-1,0,615,632,1,0,0,0,616,617,10,3,0,0,617,618,5,84,0,0,618,619,3,52,26,4,619,620,6,26,-1,0,620,632,1,0,0,0,621,622,10,2,0,0,622,623,5,81,0,0,623,624,3,52,26,3,624,625,6,26,-1,0,625,632,1,0,0,0,626,627,10,1,0,0,627,628,5,82,0,0,628,629,3,52,26,2,629,630,6,26,-1,0,630,632,1,0,0,0,631,606,1,0,0,0,631,611,1,0,0,0,631,616,1,0,0,0,631,621,1,0,0,0,631,626,1,0,0,0,632,635,1,0,0,0,633,631,1,0,0,0,633,634,1,0,0,0,634,53,1,0,0,0,635,633,1,0,0,0,636,637,3,52,26,0,637,638,6,27,-1,0,638,648,1,0,0,0,639,640,3,52,26,0,640,641,7,9,0,0,641,642,3,54,27,0,642,643,6,27,-1,0,643,648,1,0,0,0,644,645,3,34,17,0,645,646,6,27,-1,0,646,648,1,0,0,0,647,636,1,0,0,0,647,639,1,0,0,0,647,644,1,0,0,0,648,55,1,0,0,0,649,650,3,52,26,0,650,651,6,28,-1,0,651,659,1,0,0,0,652,654,5,64,0,0,653,655,3,58,29,0,654,653,1,0,0,0,654,655,1,0,0,0,655,656,1,0,0,0,656,657,5,65,0,0,657,659,6,28,-1,0,658,649,1,0,0,0,658,652,1,0,0,0,659,57,1,0,0,0,660,661,3,42,21,0,661,668,6,29,-1,0,662,663,7,0,0,0,663,664,3,42,21,0,664,665,6,29,-1,0,665,667,1,0,0,0,666,662,1,0,0,0,667,670,1,0,0,0,668,666,1,0,0,0,668,669,1,0,0,0,669,672,1,0,0,0,670,668,1,0,0,0,671,673,7,0,0,0,672,671,1,0,0,0,672,673,1,0,0,0,673,59,1,0,0,0,674,675,3,62,31,0,675,676,6,30,-1,0,676,699,1,0,0,0,677,678,3,66,33,0,678,679,6,30,-1,0,679,699,1,0,0,0,680,681,3,70,35,0,681,682,6,30,-1,0,682,699,1,0,0,0,683,684,3,86,43,0,684,685,6,30,-1,0,685,699,1,0,0,0,686,687,3,98,49,0,687,688,6,30,-1,0,688,699,1,0,0,0,689,690,3,100,50,0,690,691,6,30,-1,0,691,699,1,0,0,0,692,693,3,118,59,0,693,694,6,30,-1,0,694,699,1,0,0,0,695,696,3,122,61,0,696,697,6,30,-1,0,697,699,1,0,0,0,698,674,1,0,0,0,698,677,1,0,0,0,698,680,1,0,0,0,698,683,1,0,0,0,698,686,1,0,0,0,698,689,1,0,0,0,698,692,1,0,0,0,698,695,1,0,0,0,699,61,1,0,0,0,700,701,5,1,0,0,701,705,6,31,-1,0,702,703,5,2,0,0,703,705,6,31,-1,0,704,700,1,0,0,0,704,702,1,0,0,0,705,706,1,0,0,0,706,707,3,64,32,0,707,716,6,31,-1,0,708,710,5,56,0,0,709,708,1,0,0,0,709,710,1,0,0,0,710,711,1,0,0,0,711,712,3,64,32,0,712,713,6,31,-1,0,713,715,1,0,0,0,714,709,1,0,0,0,715,718,1,0,0,0,716,714,1,0,0,0,716,717,1,0,0,0,717,63,1,0,0,0,718,716,1,0,0,0,719,720,3,12,6,0,720,721,6,32,-1,0,721,728,1,0,0,0,722,723,3,12,6,0,723,724,5,53,0,0,724,725,3,54,27,0,725,726,6,32,-1,0,726,728,1,0,0,0,727,719,1,0,0,0,727,722,1,0,0,0,728,65,1,0,0,0,729,730,5,3,0,0,730,744,6,33,-1,0,731,732,3,68,34,0,732,741,6,33,-1,0,733,735,5,56,0,0,734,733,1,0,0,0,734,735,1,0,0,0,735,736,1,0,0,0,736,737,3,68,34,0,737,738,6,33,-1,0,738,740,1,0,0,0,739,734,1,0,0,0,740,743,1,0,0,0,741,739,1,0,0,0,741,742,1,0,0,0,742,745,1,0,0,0,743,741,1,0,0,0,744,731,1,0,0,0,744,745,1,0,0,0,745,67,1,0,0,0,746,747,3,16,8,0,747,748,6,34,-1,0,748,758,1,0,0,0,749,753,3,16,8,0,750,751,5,57,0,0,751,754,5,51,0,0,752,754,5,91,0,0,753,750,1,0,0,0,753,752,1,0,0,0,754,755,1,0,0,0,755,756,6,34,-1,0,756,758,1,0,0,0,757,746,1,0,0,0,757,749,1,0,0,0,758,69,1,0,0,0,759,760,3,72,36,0,760,761,6,35,-1,0,761,766,1,0,0,0,762,763,3,78,39,0,763,764,6,35,-1,0,764,766,1,0,0,0,765,759,1,0,0,0,765,762,1,0,0,0,766,71,1,0,0,0,767,768,5,4,0,0,768,770,3,54,27,0,769,771,3,176,88,0,770,769,1,0,0,0,770,771,1,0,0,0,771,773,1,0,0,0,772,774,3,4,2,0,773,772,1,0,0,0,773,774,1,0,0,0,774,775,1,0,0,0,775,781,6,36,-1,0,776,777,3,74,37,0,777,778,6,36,-1,0,778,780,1,0,0,0,779,776,1,0,0,0,780,783,1,0,0,0,781,779,1,0,0,0,781,782,1,0,0,0,782,785,1,0,0,0,783,781,1,0,0,0,784,786,3,76,38,0,785,784,1,0,0,0,785,786,1,0,0,0,786,787,1,0,0,0,787,788,6,36,-1,0,788,789,7,10,0,0,789,73,1,0,0,0,790,792,5,8,0,0,791,793,3,176,88,0,792,791,1,0,0,0,792,793,1,0,0,0,793,794,1,0,0,0,794,796,3,54,27,0,795,797,3,176,88,0,796,795,1,0,0,0,796,797,1,0,0,0,797,799,1,0,0,0,798,800,3,4,2,0,799,798,1,0,0,0,799,800,1,0,0,0,800,801,1,0,0,0,801,802,6,37,-1,0,802,75,1,0,0,0,803,805,5,9,0,0,804,806,3,176,88,0,805,804,1,0,0,0,805,806,1,0,0,0,806,808,1,0,0,0,807,809,3,4,2,0,808,807,1,0,0,0,808,809,1,0,0,0,809,810,1,0,0,0,810,811,6,38,-1,0,811,77,1,0,0,0,812,813,5,10,0,0,813,815,3,54,27,0,814,816,3,176,88,0,815,814,1,0,0,0,815,816,1,0,0,0,816,818,1,0,0,0,817,819,3,80,40,0,818,817,1,0,0,0,818,819,1,0,0,0,819,821,1,0,0,0,820,822,3,84,42,0,821,820,1,0,0,0,821,822,1,0,0,0,822,823,1,0,0,0,823,824,7,11,0,0,824,825,6,39,-1,0,825,79,1,0,0,0,826,827,3,82,41,0,827,836,6,40,-1,0,828,830,3,176,88,0,829,828,1,0,0,0,829,830,1,0,0,0,830,831,1,0,0,0,831,832,3,82,41,0,832,833,6,40,-1,0,833,835,1,0,0,0,834,829,1,0,0,0,835,838,1,0,0,0,836,834,1,0,0,0,836,837,1,0,0,0,837,840,1,0,0,0,838,836,1,0,0,0,839,841,3,176,88,0,840,839,1,0,0,0,840,841,1,0,0,0,841,81,1,0,0,0,842,844,5,12,0,0,843,845,3,176,88,0,844,843,1,0,0,0,844,845,1,0,0,0,845,846,1,0,0,0,846,848,3,54,27,0,847,849,3,176,88,0,848,847,1,0,0,0,848,849,1,0,0,0,849,851,1,0,0,0,850,852,3,4,2,0,851,850,1,0,0,0,851,852,1,0,0,0,852,853,1,0,0,0,853,854,6,41,-1,0,854,83,1,0,0,0,855,857,5,13,0,0,856,858,3,176,88,0,857,856,1,0,0,0,857,858,1,0,0,0,858,860,1,0,0,0,859,861,3,4,2,0,860,859,1,0,0,0,860,861,1,0,0,0,861,863,1,0,0,0,862,864,3,176,88,0,863,862,1,0,0,0,863,864,1,0,0,0,864,865,1,0,0,0,865,866,6,42,-1,0,866,85,1,0,0,0,867,868,3,88,44,0,868,869,6,43,-1,0,869,880,1,0,0,0,870,871,3,90,45,0,871,872,6,43,-1,0,872,880,1,0,0,0,873,874,3,92,46,0,874,875,6,43,-1,0,875,880,1,0,0,0,876,877,3,94,47,0,877,878,6,43,-1,0,878,880,1,0,0,0,879,867,1,0,0,0,879,870,1,0,0,0,879,873,1,0,0,0,879,876,1,0,0,0,880,87,1,0,0,0,881,882,5,14,0,0,882,884,3,54,27,0,883,885,3,176,88,0,884,883,1,0,0,0,884,885,1,0,0,0,885,887,1,0,0,0,886,888,3,4,2,0,887,886,1,0,0,0,887,888,1,0,0,0,888,889,1,0,0,0,889,890,7,12,0,0,890,891,6,44,-1,0,891,89,1,0,0,0,892,894,5,16,0,0,893,895,3,176,88,0,894,893,1,0,0,0,894,895,1,0,0,0,895,897,1,0,0,0,896,898,3,4,2,0,897,896,1,0,0,0,897,898,1,0,0,0,898,899,1,0,0,0,899,900,5,17,0,0,900,901,3,54,27,0,901,902,6,45,-1,0,902,91,1,0,0,0,903,904,5,18,0,0,904,905,3,56,28,0,905,906,5,53,0,0,906,908,3,54,27,0,907,909,3,176,88,0,908,907,1,0,0,0,908,909,1,0,0,0,909,911,1,0,0,0,910,912,3,4,2,0,911,910,1,0,0,0,911,912,1,0,0,0,912,913,1,0,0,0,913,914,7,13,0,0,914,915,6,46,-1,0,915,964,1,0,0,0,916,917,5,18,0,0,917,918,5,62,0,0,918,919,3,56,28,0,919,920,5,53,0,0,920,921,3,54,27,0,921,923,5,63,0,0,922,924,3,176,88,0,923,922,1,0,0,0,923,924,1,0,0,0,924,926,1,0,0,0,925,927,3,4,2,0,926,925,1,0,0,0,926,927,1,0,0,0,927,928,1,0,0,0,928,929,7,13,0,0,929,930,6,46,-1,0,930,964,1,0,0,0,931,932,5,20,0,0,932,933,3,56,28,0,933,934,5,53,0,0,934,936,3,54,27,0,935,937,3,176,88,0,936,935,1,0,0,0,936,937,1,0,0,0,937,939,1,0,0,0,938,940,3,4,2,0,939,938,1,0,0,0,939,940,1,0,0,0,940,941,1,0,0,0,941,942,7,14,0,0,942,943,6,46,-1,0,943,964,1,0,0,0,944,945,5,20,0,0,945,946,5,62,0,0,946,947,3,56,28,0,947,948,5,53,0,0,948,951,3,54,27,0,949,950,5,56,0,0,950,952,3,54,27,0,951,949,1,0,0,0,951,952,1,0,0,0,952,953,1,0,0,0,953,955,5,63,0,0,954,956,3,176,88,0,955,954,1,0,0,0,955,956,1,0,0,0,956,958,1,0,0,0,957,959,3,4,2,0,958,957,1,0,0,0,958,959,1,0,0,0,959,960,1,0,0,0,960,961,7,14,0,0,961,962,6,46,-1,0,962,964,1,0,0,0,963,903,1,0,0,0,963,916,1,0,0,0,963,931,1,0,0,0,963,944,1,0,0,0,964,93,1,0,0,0,965,967,5,22,0,0,966,968,3,96,48,0,967,966,1,0,0,0,967,968,1,0,0,0,968,970,1,0,0,0,969,971,3,176,88,0,970,969,1,0,0,0,970,971,1,0,0,0,971,973,1,0,0,0,972,974,3,4,2,0,973,972,1,0,0,0,973,974,1,0,0,0,974,975,1,0,0,0,975,976,7,15,0,0,976,977,6,47,-1,0,977,95,1,0,0,0,978,979,5,62,0,0,979,980,3,54,27,0,980,985,6,48,-1,0,981,982,5,56,0,0,982,983,3,54,27,0,983,984,6,48,-1,0,984,986,1,0,0,0,985,981,1,0,0,0,985,986,1,0,0,0,986,987,1,0,0,0,987,988,5,63,0,0,988,97,1,0,0,0,989,990,5,24,0,0,990,996,6,49,-1,0,991,992,5,25,0,0,992,996,6,49,-1,0,993,994,5,26,0,0,994,996,6,49,-1,0,995,989,1,0,0,0,995,991,1,0,0,0,995,993,1,0,0,0,996,99,1,0,0,0,997,998,3,102,51,0,998,999,6,50,-1,0,999,1004,1,0,0,0,1e3,1001,3,106,53,0,1001,1002,6,50,-1,0,1002,1004,1,0,0,0,1003,997,1,0,0,0,1003,1e3,1,0,0,0,1004,101,1,0,0,0,1005,1007,5,29,0,0,1006,1008,3,176,88,0,1007,1006,1,0,0,0,1007,1008,1,0,0,0,1008,1010,1,0,0,0,1009,1011,3,4,2,0,1010,1009,1,0,0,0,1010,1011,1,0,0,0,1011,1012,1,0,0,0,1012,1013,3,104,52,0,1013,1014,7,16,0,0,1014,1015,6,51,-1,0,1015,1026,1,0,0,0,1016,1018,5,29,0,0,1017,1019,3,176,88,0,1018,1017,1,0,0,0,1018,1019,1,0,0,0,1019,1021,1,0,0,0,1020,1022,3,4,2,0,1021,1020,1,0,0,0,1021,1022,1,0,0,0,1022,1023,1,0,0,0,1023,1024,7,16,0,0,1024,1026,6,51,-1,0,1025,1005,1,0,0,0,1025,1016,1,0,0,0,1026,103,1,0,0,0,1027,1029,5,30,0,0,1028,1030,3,176,88,0,1029,1028,1,0,0,0,1029,1030,1,0,0,0,1030,1032,1,0,0,0,1031,1033,3,4,2,0,1032,1031,1,0,0,0,1032,1033,1,0,0,0,1033,1034,1,0,0,0,1034,1035,6,52,-1,0,1035,105,1,0,0,0,1036,1038,5,32,0,0,1037,1039,3,176,88,0,1038,1037,1,0,0,0,1038,1039,1,0,0,0,1039,1041,1,0,0,0,1040,1042,3,4,2,0,1041,1040,1,0,0,0,1041,1042,1,0,0,0,1042,1043,1,0,0,0,1043,1044,3,108,54,0,1044,1045,7,17,0,0,1045,1046,6,53,-1,0,1046,107,1,0,0,0,1047,1049,5,33,0,0,1048,1050,3,176,88,0,1049,1048,1,0,0,0,1049,1050,1,0,0,0,1050,1052,1,0,0,0,1051,1053,3,4,2,0,1052,1051,1,0,0,0,1052,1053,1,0,0,0,1053,1054,1,0,0,0,1054,1055,6,54,-1,0,1055,109,1,0,0,0,1056,1057,5,62,0,0,1057,1069,6,55,-1,0,1058,1059,3,112,56,0,1059,1066,6,55,-1,0,1060,1061,5,56,0,0,1061,1062,3,112,56,0,1062,1063,6,55,-1,0,1063,1065,1,0,0,0,1064,1060,1,0,0,0,1065,1068,1,0,0,0,1066,1064,1,0,0,0,1066,1067,1,0,0,0,1067,1070,1,0,0,0,1068,1066,1,0,0,0,1069,1058,1,0,0,0,1069,1070,1,0,0,0,1070,1071,1,0,0,0,1071,1072,5,63,0,0,1072,111,1,0,0,0,1073,1074,3,64,32,0,1074,1075,6,56,-1,0,1075,1080,1,0,0,0,1076,1077,3,40,20,0,1077,1078,6,56,-1,0,1078,1080,1,0,0,0,1079,1073,1,0,0,0,1079,1076,1,0,0,0,1080,113,1,0,0,0,1081,1082,3,12,6,0,1082,1083,6,57,-1,0,1083,1088,1,0,0,0,1084,1085,3,40,20,0,1085,1086,6,57,-1,0,1086,1088,1,0,0,0,1087,1081,1,0,0,0,1087,1084,1,0,0,0,1088,115,1,0,0,0,1089,1090,3,114,57,0,1090,1091,6,58,-1,0,1091,1109,1,0,0,0,1092,1093,5,64,0,0,1093,1105,6,58,-1,0,1094,1095,3,114,57,0,1095,1102,6,58,-1,0,1096,1097,7,0,0,0,1097,1098,3,114,57,0,1098,1099,6,58,-1,0,1099,1101,1,0,0,0,1100,1096,1,0,0,0,1101,1104,1,0,0,0,1102,1100,1,0,0,0,1102,1103,1,0,0,0,1103,1106,1,0,0,0,1104,1102,1,0,0,0,1105,1094,1,0,0,0,1105,1106,1,0,0,0,1106,1107,1,0,0,0,1107,1109,5,65,0,0,1108,1089,1,0,0,0,1108,1092,1,0,0,0,1109,117,1,0,0,0,1110,1114,5,27,0,0,1111,1112,3,116,58,0,1112,1113,5,53,0,0,1113,1115,1,0,0,0,1114,1111,1,0,0,0,1114,1115,1,0,0,0,1115,1116,1,0,0,0,1116,1118,3,120,60,0,1117,1119,3,110,55,0,1118,1117,1,0,0,0,1118,1119,1,0,0,0,1119,1121,1,0,0,0,1120,1122,3,176,88,0,1121,1120,1,0,0,0,1121,1122,1,0,0,0,1122,1124,1,0,0,0,1123,1125,3,160,80,0,1124,1123,1,0,0,0,1124,1125,1,0,0,0,1125,1127,1,0,0,0,1126,1128,3,4,2,0,1127,1126,1,0,0,0,1127,1128,1,0,0,0,1128,1129,1,0,0,0,1129,1130,7,18,0,0,1130,1131,6,59,-1,0,1131,119,1,0,0,0,1132,1133,3,16,8,0,1133,1134,6,60,-1,0,1134,121,1,0,0,0,1135,1137,5,35,0,0,1136,1138,3,124,62,0,1137,1136,1,0,0,0,1137,1138,1,0,0,0,1138,1139,1,0,0,0,1139,1141,3,16,8,0,1140,1142,3,130,65,0,1141,1140,1,0,0,0,1141,1142,1,0,0,0,1142,1144,1,0,0,0,1143,1145,3,176,88,0,1144,1143,1,0,0,0,1144,1145,1,0,0,0,1145,1147,1,0,0,0,1146,1148,3,132,66,0,1147,1146,1,0,0,0,1147,1148,1,0,0,0,1148,1149,1,0,0,0,1149,1150,7,19,0,0,1150,1151,6,61,-1,0,1151,123,1,0,0,0,1152,1153,5,62,0,0,1153,1165,6,62,-1,0,1154,1155,3,126,63,0,1155,1162,6,62,-1,0,1156,1157,5,56,0,0,1157,1158,3,126,63,0,1158,1159,6,62,-1,0,1159,1161,1,0,0,0,1160,1156,1,0,0,0,1161,1164,1,0,0,0,1162,1160,1,0,0,0,1162,1163,1,0,0,0,1163,1166,1,0,0,0,1164,1162,1,0,0,0,1165,1154,1,0,0,0,1165,1166,1,0,0,0,1166,1167,1,0,0,0,1167,1169,5,63,0,0,1168,1170,3,176,88,0,1169,1168,1,0,0,0,1169,1170,1,0,0,0,1170,125,1,0,0,0,1171,1174,3,12,6,0,1172,1173,5,53,0,0,1173,1175,3,54,27,0,1174,1172,1,0,0,0,1174,1175,1,0,0,0,1175,1176,1,0,0,0,1176,1177,6,63,-1,0,1177,1183,1,0,0,0,1178,1179,7,2,0,0,1179,1180,3,12,6,0,1180,1181,6,63,-1,0,1181,1183,1,0,0,0,1182,1171,1,0,0,0,1182,1178,1,0,0,0,1183,127,1,0,0,0,1184,1185,3,12,6,0,1185,1192,6,64,-1,0,1186,1187,5,57,0,0,1187,1188,3,12,6,0,1188,1189,6,64,-1,0,1189,1191,1,0,0,0,1190,1186,1,0,0,0,1191,1194,1,0,0,0,1192,1190,1,0,0,0,1192,1193,1,0,0,0,1193,129,1,0,0,0,1194,1192,1,0,0,0,1195,1196,5,85,0,0,1196,1197,3,16,8,0,1197,1204,6,65,-1,0,1198,1199,7,20,0,0,1199,1200,3,16,8,0,1200,1201,6,65,-1,0,1201,1203,1,0,0,0,1202,1198,1,0,0,0,1203,1206,1,0,0,0,1204,1202,1,0,0,0,1204,1205,1,0,0,0,1205,131,1,0,0,0,1206,1204,1,0,0,0,1207,1208,3,134,67,0,1208,1217,6,66,-1,0,1209,1211,3,176,88,0,1210,1209,1,0,0,0,1210,1211,1,0,0,0,1211,1212,1,0,0,0,1212,1213,3,134,67,0,1213,1214,6,66,-1,0,1214,1216,1,0,0,0,1215,1210,1,0,0,0,1216,1219,1,0,0,0,1217,1215,1,0,0,0,1217,1218,1,0,0,0,1218,1221,1,0,0,0,1219,1217,1,0,0,0,1220,1222,3,176,88,0,1221,1220,1,0,0,0,1221,1222,1,0,0,0,1222,133,1,0,0,0,1223,1224,3,136,68,0,1224,1225,6,67,-1,0,1225,1236,1,0,0,0,1226,1227,3,142,71,0,1227,1228,6,67,-1,0,1228,1236,1,0,0,0,1229,1230,3,148,74,0,1230,1231,6,67,-1,0,1231,1236,1,0,0,0,1232,1233,3,154,77,0,1233,1234,6,67,-1,0,1234,1236,1,0,0,0,1235,1223,1,0,0,0,1235,1226,1,0,0,0,1235,1229,1,0,0,0,1235,1232,1,0,0,0,1236,135,1,0,0,0,1237,1239,5,39,0,0,1238,1240,3,124,62,0,1239,1238,1,0,0,0,1239,1240,1,0,0,0,1240,1242,1,0,0,0,1241,1243,3,176,88,0,1242,1241,1,0,0,0,1242,1243,1,0,0,0,1243,1245,1,0,0,0,1244,1246,3,138,69,0,1245,1244,1,0,0,0,1245,1246,1,0,0,0,1246,1247,1,0,0,0,1247,1248,7,21,0,0,1248,1249,6,68,-1,0,1249,137,1,0,0,0,1250,1251,3,140,70,0,1251,1258,6,69,-1,0,1252,1253,3,176,88,0,1253,1254,3,140,70,0,1254,1255,6,69,-1,0,1255,1257,1,0,0,0,1256,1252,1,0,0,0,1257,1260,1,0,0,0,1258,1256,1,0,0,0,1258,1259,1,0,0,0,1259,1262,1,0,0,0,1260,1258,1,0,0,0,1261,1263,3,176,88,0,1262,1261,1,0,0,0,1262,1263,1,0,0,0,1263,139,1,0,0,0,1264,1269,3,12,6,0,1265,1266,5,62,0,0,1266,1267,3,44,22,0,1267,1268,5,63,0,0,1268,1270,1,0,0,0,1269,1265,1,0,0,0,1269,1270,1,0,0,0,1270,1272,1,0,0,0,1271,1273,3,16,8,0,1272,1271,1,0,0,0,1272,1273,1,0,0,0,1273,1278,1,0,0,0,1274,1275,5,66,0,0,1275,1276,3,44,22,0,1276,1277,5,67,0,0,1277,1279,1,0,0,0,1278,1274,1,0,0,0,1278,1279,1,0,0,0,1279,1282,1,0,0,0,1280,1281,5,53,0,0,1281,1283,3,54,27,0,1282,1280,1,0,0,0,1282,1283,1,0,0,0,1283,1284,1,0,0,0,1284,1285,6,70,-1,0,1285,141,1,0,0,0,1286,1288,5,43,0,0,1287,1289,3,124,62,0,1288,1287,1,0,0,0,1288,1289,1,0,0,0,1289,1291,1,0,0,0,1290,1292,3,176,88,0,1291,1290,1,0,0,0,1291,1292,1,0,0,0,1292,1294,1,0,0,0,1293,1295,3,146,73,0,1294,1293,1,0,0,0,1294,1295,1,0,0,0,1295,1296,1,0,0,0,1296,1297,7,22,0,0,1297,1298,6,71,-1,0,1298,143,1,0,0,0,1299,1300,3,118,59,0,1300,1301,6,72,-1,0,1301,1317,1,0,0,0,1302,1304,3,128,64,0,1303,1305,3,110,55,0,1304,1303,1,0,0,0,1304,1305,1,0,0,0,1305,1306,1,0,0,0,1306,1307,6,72,-1,0,1307,1317,1,0,0,0,1308,1309,3,116,58,0,1309,1310,5,53,0,0,1310,1312,3,128,64,0,1311,1313,3,110,55,0,1312,1311,1,0,0,0,1312,1313,1,0,0,0,1313,1314,1,0,0,0,1314,1315,6,72,-1,0,1315,1317,1,0,0,0,1316,1299,1,0,0,0,1316,1302,1,0,0,0,1316,1308,1,0,0,0,1317,145,1,0,0,0,1318,1319,3,144,72,0,1319,1328,6,73,-1,0,1320,1322,3,176,88,0,1321,1320,1,0,0,0,1321,1322,1,0,0,0,1322,1323,1,0,0,0,1323,1324,3,144,72,0,1324,1325,6,73,-1,0,1325,1327,1,0,0,0,1326,1321,1,0,0,0,1327,1330,1,0,0,0,1328,1326,1,0,0,0,1328,1329,1,0,0,0,1329,1332,1,0,0,0,1330,1328,1,0,0,0,1331,1333,3,176,88,0,1332,1331,1,0,0,0,1332,1333,1,0,0,0,1333,147,1,0,0,0,1334,1336,5,41,0,0,1335,1337,3,124,62,0,1336,1335,1,0,0,0,1336,1337,1,0,0,0,1337,1339,1,0,0,0,1338,1340,3,176,88,0,1339,1338,1,0,0,0,1339,1340,1,0,0,0,1340,1342,1,0,0,0,1341,1343,3,150,75,0,1342,1341,1,0,0,0,1342,1343,1,0,0,0,1343,1344,1,0,0,0,1344,1345,7,23,0,0,1345,1346,6,74,-1,0,1346,149,1,0,0,0,1347,1348,3,152,76,0,1348,1357,6,75,-1,0,1349,1351,3,176,88,0,1350,1349,1,0,0,0,1350,1351,1,0,0,0,1351,1352,1,0,0,0,1352,1353,3,152,76,0,1353,1354,6,75,-1,0,1354,1356,1,0,0,0,1355,1350,1,0,0,0,1356,1359,1,0,0,0,1357,1355,1,0,0,0,1357,1358,1,0,0,0,1358,1361,1,0,0,0,1359,1357,1,0,0,0,1360,1362,3,176,88,0,1361,1360,1,0,0,0,1361,1362,1,0,0,0,1362,151,1,0,0,0,1363,1364,3,12,6,0,1364,1365,6,76,-1,0,1365,153,1,0,0,0,1366,1368,5,37,0,0,1367,1369,3,124,62,0,1368,1367,1,0,0,0,1368,1369,1,0,0,0,1369,1371,1,0,0,0,1370,1372,3,176,88,0,1371,1370,1,0,0,0,1371,1372,1,0,0,0,1372,1374,1,0,0,0,1373,1375,3,156,78,0,1374,1373,1,0,0,0,1374,1375,1,0,0,0,1375,1376,1,0,0,0,1376,1377,7,24,0,0,1377,1378,6,77,-1,0,1378,155,1,0,0,0,1379,1380,3,158,79,0,1380,1389,6,78,-1,0,1381,1383,3,176,88,0,1382,1381,1,0,0,0,1382,1383,1,0,0,0,1383,1384,1,0,0,0,1384,1385,3,158,79,0,1385,1386,6,78,-1,0,1386,1388,1,0,0,0,1387,1382,1,0,0,0,1388,1391,1,0,0,0,1389,1387,1,0,0,0,1389,1390,1,0,0,0,1390,1393,1,0,0,0,1391,1389,1,0,0,0,1392,1394,3,176,88,0,1393,1392,1,0,0,0,1393,1394,1,0,0,0,1394,157,1,0,0,0,1395,1401,3,12,6,0,1396,1398,5,62,0,0,1397,1399,3,44,22,0,1398,1397,1,0,0,0,1398,1399,1,0,0,0,1399,1400,1,0,0,0,1400,1402,5,63,0,0,1401,1396,1,0,0,0,1401,1402,1,0,0,0,1402,1403,1,0,0,0,1403,1404,6,79,-1,0,1404,159,1,0,0,0,1405,1406,3,162,81,0,1406,1415,6,80,-1,0,1407,1409,3,176,88,0,1408,1407,1,0,0,0,1408,1409,1,0,0,0,1409,1410,1,0,0,0,1410,1411,3,162,81,0,1411,1412,6,80,-1,0,1412,1414,1,0,0,0,1413,1408,1,0,0,0,1414,1417,1,0,0,0,1415,1413,1,0,0,0,1415,1416,1,0,0,0,1416,1419,1,0,0,0,1417,1415,1,0,0,0,1418,1420,3,176,88,0,1419,1418,1,0,0,0,1419,1420,1,0,0,0,1420,161,1,0,0,0,1421,1423,5,47,0,0,1422,1424,3,176,88,0,1423,1422,1,0,0,0,1423,1424,1,0,0,0,1424,1431,1,0,0,0,1425,1426,5,62,0,0,1426,1427,3,164,82,0,1427,1429,5,63,0,0,1428,1430,3,176,88,0,1429,1428,1,0,0,0,1429,1430,1,0,0,0,1430,1432,1,0,0,0,1431,1425,1,0,0,0,1431,1432,1,0,0,0,1432,1434,1,0,0,0,1433,1435,3,166,83,0,1434,1433,1,0,0,0,1434,1435,1,0,0,0,1435,1437,1,0,0,0,1436,1438,3,176,88,0,1437,1436,1,0,0,0,1437,1438,1,0,0,0,1438,1439,1,0,0,0,1439,1440,7,25,0,0,1440,1441,6,81,-1,0,1441,163,1,0,0,0,1442,1443,3,12,6,0,1443,1450,6,82,-1,0,1444,1445,5,56,0,0,1445,1446,3,12,6,0,1446,1447,6,82,-1,0,1447,1449,1,0,0,0,1448,1444,1,0,0,0,1449,1452,1,0,0,0,1450,1448,1,0,0,0,1450,1451,1,0,0,0,1451,165,1,0,0,0,1452,1450,1,0,0,0,1453,1454,3,168,84,0,1454,1461,6,83,-1,0,1455,1456,3,176,88,0,1456,1457,3,168,84,0,1457,1458,6,83,-1,0,1458,1460,1,0,0,0,1459,1455,1,0,0,0,1460,1463,1,0,0,0,1461,1459,1,0,0,0,1461,1462,1,0,0,0,1462,167,1,0,0,0,1463,1461,1,0,0,0,1464,1469,3,170,85,0,1465,1466,5,62,0,0,1466,1467,3,44,22,0,1467,1468,5,63,0,0,1468,1470,1,0,0,0,1469,1465,1,0,0,0,1469,1470,1,0,0,0,1470,1472,1,0,0,0,1471,1473,3,16,8,0,1472,1471,1,0,0,0,1472,1473,1,0,0,0,1473,1478,1,0,0,0,1474,1475,5,66,0,0,1475,1476,3,44,22,0,1476,1477,5,67,0,0,1477,1479,1,0,0,0,1478,1474,1,0,0,0,1478,1479,1,0,0,0,1479,1482,1,0,0,0,1480,1481,5,53,0,0,1481,1483,3,54,27,0,1482,1480,1,0,0,0,1482,1483,1,0,0,0,1483,1484,1,0,0,0,1484,1485,6,84,-1,0,1485,169,1,0,0,0,1486,1487,3,12,6,0,1487,1494,6,85,-1,0,1488,1489,5,57,0,0,1489,1490,3,12,6,0,1490,1491,6,85,-1,0,1491,1493,1,0,0,0,1492,1488,1,0,0,0,1493,1496,1,0,0,0,1494,1492,1,0,0,0,1494,1495,1,0,0,0,1495,171,1,0,0,0,1496,1494,1,0,0,0,1497,1499,7,26,0,0,1498,1497,1,0,0,0,1499,1500,1,0,0,0,1500,1498,1,0,0,0,1500,1501,1,0,0,0,1501,173,1,0,0,0,1502,1504,5,106,0,0,1503,1502,1,0,0,0,1504,1505,1,0,0,0,1505,1503,1,0,0,0,1505,1506,1,0,0,0,1506,175,1,0,0,0,1507,1509,7,27,0,0,1508,1507,1,0,0,0,1509,1510,1,0,0,0,1510,1508,1,0,0,0,1510,1511,1,0,0,0,1511,177,1,0,0,0,198,179,184,190,200,204,216,220,233,243,261,268,278,285,302,310,312,316,321,323,326,331,341,343,347,352,354,357,362,366,371,381,385,387,424,441,451,466,484,491,500,525,527,542,550,557,566,583,585,593,604,631,633,647,654,658,668,672,698,704,709,716,727,734,741,744,753,757,765,770,773,781,785,792,796,799,805,808,815,818,821,829,836,840,844,848,851,857,860,863,879,884,887,894,897,908,911,923,926,936,939,951,955,958,963,967,970,973,985,995,1003,1007,1010,1018,1021,1025,1029,1032,1038,1041,1049,1052,1066,1069,1079,1087,1102,1105,1108,1114,1118,1121,1124,1127,1137,1141,1144,1147,1162,1165,1169,1174,1182,1192,1204,1210,1217,1221,1235,1239,1242,1245,1258,1262,1269,1272,1278,1282,1288,1291,1294,1304,1312,1316,1321,1328,1332,1336,1339,1342,1350,1357,1361,1368,1371,1374,1382,1389,1393,1398,1401,1408,1415,1419,1423,1429,1431,1434,1437,1450,1461,1469,1472,1478,1482,1494,1500,1505,1510];static __ATN;static get _ATN(){return n.__ATN||(n.__ATN=(new s.ATNDeserializer).deserialize(n._serializedATN)),n.__ATN}static DecisionsToDFA=n._ATN.decisionToState.map((t,e)=>new s.DFA(t,e))}e.default=n;class a extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}EOF(){return this.getToken(n.EOF,0)}sep(){return this.getTypedRuleContext($t,0)}global_list(){return this.getTypedRuleContext(o,0)}get ruleIndex(){return n.RULE_input}}e.InputContext=a;class o extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}statement_list(){return this.getTypedRuleContexts(c)}statement(t){return this.getTypedRuleContext(c,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_global_list}}e.Global_listContext=o;class l extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}statement_list(){return this.getTypedRuleContexts(c)}statement(t){return this.getTypedRuleContext(c,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_list}}e.ListContext=l;class c extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}command(){return this.getTypedRuleContext(P,0)}word_list_cmd(){return this.getTypedRuleContext(u,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_statement}}e.StatementContext=c;class u extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}command_word_list(){return this.getTypedRuleContexts(h)}command_word(t){return this.getTypedRuleContext(h,t)}get ruleIndex(){return n.RULE_word_list_cmd}}e.Word_list_cmdContext=u;class h extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}string_(){return this.getTypedRuleContext(f,0)}get ruleIndex(){return n.RULE_command_word}}e.Command_wordContext=h;class d extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}IDENTIFIER(){return this.getToken(n.IDENTIFIER,0)}PROPERTIES(){return this.getToken(n.PROPERTIES,0)}METHODS(){return this.getToken(n.METHODS,0)}EVENTS(){return this.getToken(n.EVENTS,0)}ENUMERATION(){return this.getToken(n.ENUMERATION,0)}get ruleIndex(){return n.RULE_identifier}}e.IdentifierContext=d;class m extends s.ParserRuleContext{text;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}END(){return this.getToken(n.END,0)}get ruleIndex(){return n.RULE_qualified_identifier_part}}e.Qualified_identifier_partContext=m;class p extends s.ParserRuleContext{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier_part_list(){return this.getTypedRuleContexts(m)}qualified_identifier_part(t){return this.getTypedRuleContext(m,t)}DOT_list(){return this.getTokens(n.DOT)}DOT(t){return this.getToken(n.DOT,t)}get ruleIndex(){return n.RULE_qualified_identifier}}e.Qualified_identifierContext=p;class f extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}STRING(){return this.getToken(n.STRING,0)}UNQUOTED_STRING(){return this.getToken(n.UNQUOTED_STRING,0)}get ruleIndex(){return n.RULE_string}}e.StringContext=f;class g extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}FLOAT_NUMBER(){return this.getToken(n.FLOAT_NUMBER,0)}get ruleIndex(){return n.RULE_number}}e.NumberContext=g;class y extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}ENDRANGE(){return this.getToken(n.ENDRANGE,0)}get ruleIndex(){return n.RULE_end_range}}e.End_rangeContext=y;class x extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}number_(){return this.getTypedRuleContext(g,0)}string_(){return this.getTypedRuleContext(f,0)}end_range(){return this.getTypedRuleContext(y,0)}get ruleIndex(){return n.RULE_constant}}e.ConstantContext=x;class C extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LBRACKET(){return this.getToken(n.LBRACKET,0)}RBRACKET(){return this.getToken(n.RBRACKET,0)}SEMICOLON_list(){return this.getTokens(n.SEMICOLON)}SEMICOLON(t){return this.getToken(n.SEMICOLON,t)}nl_list(){return this.getTypedRuleContexts(Ut)}nl(t){return this.getTypedRuleContext(Ut,t)}matrix_row_list(){return this.getTypedRuleContexts(E)}matrix_row(t){return this.getTypedRuleContext(E,t)}LCURLYBR(){return this.getToken(n.LCURLYBR,0)}RCURLYBR(){return this.getToken(n.RCURLYBR,0)}get ruleIndex(){return n.RULE_matrix}}e.MatrixContext=C;class E extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}WSPACE_list(){return this.getTokens(n.WSPACE)}WSPACE(t){return this.getToken(n.WSPACE,t)}list_element_list(){return this.getTypedRuleContexts(N)}list_element(t){return this.getTypedRuleContext(N,t)}get ruleIndex(){return n.RULE_matrix_row}}e.Matrix_rowContext=E;class A extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}COMMAT(){return this.getToken(n.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return n.RULE_fcn_handle}}e.Fcn_handleContext=A;class _ extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}QUESTION(){return this.getToken(n.QUESTION,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return n.RULE_meta_class}}e.Meta_classContext=_;class S extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}COMMAT(){return this.getToken(n.COMMAT,0)}param_list(){return this.getTypedRuleContext(ot,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_anon_fcn_handle}}e.Anon_fcn_handleContext=S;class v extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}IMPORT(){return this.getToken(n.IMPORT,0)}constant(){return this.getTypedRuleContext(x,0)}fcn_handle(){return this.getTypedRuleContext(A,0)}meta_class(){return this.getTypedRuleContext(_,0)}matrix(){return this.getTypedRuleContext(C,0)}LPAREN(){return this.getToken(n.LPAREN,0)}expression(){return this.getTypedRuleContext(R,0)}RPAREN(){return this.getToken(n.RPAREN,0)}get ruleIndex(){return n.RULE_primary_expr}}e.Primary_exprContext=v;class T extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}COLON(){return this.getToken(n.COLON,0)}get ruleIndex(){return n.RULE_magic_colon}}e.Magic_colonContext=T;class b extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}TILDE(){return this.getToken(n.TILDE,0)}get ruleIndex(){return n.RULE_magic_tilde}}e.Magic_tildeContext=b;class N extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}expression(){return this.getTypedRuleContext(R,0)}magic_colon(){return this.getTypedRuleContext(T,0)}magic_tilde(){return this.getTypedRuleContext(b,0)}get ruleIndex(){return n.RULE_list_element}}e.List_elementContext=N;class I extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}list_element_list(){return this.getTypedRuleContexts(N)}list_element(t){return this.getTypedRuleContext(N,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_arg_list}}e.Arg_listContext=I;class M extends s.ParserRuleContext{node;_op;constructor(t,e,r){super(e,r),this.parser=t}primary_expr(){return this.getTypedRuleContext(v,0)}oper_expr_list(){return this.getTypedRuleContexts(M)}oper_expr(t){return this.getTypedRuleContext(M,t)}PLUS_PLUS(){return this.getToken(n.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(n.MINUS_MINUS,0)}PLUS(){return this.getToken(n.PLUS,0)}MINUS(){return this.getToken(n.MINUS,0)}TILDE(){return this.getToken(n.TILDE,0)}EXCLAMATION(){return this.getToken(n.EXCLAMATION,0)}MUL(){return this.getToken(n.MUL,0)}DIV(){return this.getToken(n.DIV,0)}LEFTDIV(){return this.getToken(n.LEFTDIV,0)}EMUL(){return this.getToken(n.EMUL,0)}EDIV(){return this.getToken(n.EDIV,0)}ELEFTDIV(){return this.getToken(n.ELEFTDIV,0)}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}arg_list(){return this.getTypedRuleContext(I,0)}LCURLYBR(){return this.getToken(n.LCURLYBR,0)}RCURLYBR(){return this.getToken(n.RCURLYBR,0)}COMMAT(){return this.getToken(n.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}TRANSPOSE(){return this.getToken(n.TRANSPOSE,0)}HERMITIAN(){return this.getToken(n.HERMITIAN,0)}DOT(){return this.getToken(n.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(m,0)}expression(){return this.getTypedRuleContext(R,0)}power_expr(){return this.getTypedRuleContext(w,0)}POW(){return this.getToken(n.POW,0)}EPOW(){return this.getToken(n.EPOW,0)}get ruleIndex(){return n.RULE_oper_expr}}e.Oper_exprContext=M;class w extends s.ParserRuleContext{node;_op;constructor(t,e,r){super(e,r),this.parser=t}primary_expr(){return this.getTypedRuleContext(v,0)}power_expr(){return this.getTypedRuleContext(w,0)}PLUS_PLUS(){return this.getToken(n.PLUS_PLUS,0)}MINUS_MINUS(){return this.getToken(n.MINUS_MINUS,0)}PLUS(){return this.getToken(n.PLUS,0)}MINUS(){return this.getToken(n.MINUS,0)}TILDE(){return this.getToken(n.TILDE,0)}EXCLAMATION(){return this.getToken(n.EXCLAMATION,0)}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}arg_list(){return this.getTypedRuleContext(I,0)}LCURLYBR(){return this.getToken(n.LCURLYBR,0)}RCURLYBR(){return this.getToken(n.RCURLYBR,0)}COMMAT(){return this.getToken(n.COMMAT,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}DOT(){return this.getToken(n.DOT,0)}qualified_identifier_part(){return this.getTypedRuleContext(m,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_power_expr}}e.Power_exprContext=w;class L extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}oper_expr_list(){return this.getTypedRuleContexts(M)}oper_expr(t){return this.getTypedRuleContext(M,t)}COLON_list(){return this.getTokens(n.COLON)}COLON(t){return this.getToken(n.COLON,t)}get ruleIndex(){return n.RULE_colon_expr}}e.Colon_exprContext=L;class O extends s.ParserRuleContext{node;_op;constructor(t,e,r){super(e,r),this.parser=t}oper_expr(){return this.getTypedRuleContext(M,0)}colon_expr(){return this.getTypedRuleContext(L,0)}simple_expr_list(){return this.getTypedRuleContexts(O)}simple_expr(t){return this.getTypedRuleContext(O,t)}EXPR_LT(){return this.getToken(n.EXPR_LT,0)}EXPR_LE(){return this.getToken(n.EXPR_LE,0)}EXPR_GT(){return this.getToken(n.EXPR_GT,0)}EXPR_GE(){return this.getToken(n.EXPR_GE,0)}EXPR_EQ(){return this.getToken(n.EXPR_EQ,0)}EXPR_NE(){return this.getToken(n.EXPR_NE,0)}EXPR_AND(){return this.getToken(n.EXPR_AND,0)}EXPR_OR(){return this.getToken(n.EXPR_OR,0)}EXPR_AND_AND(){return this.getToken(n.EXPR_AND_AND,0)}EXPR_OR_OR(){return this.getToken(n.EXPR_OR_OR,0)}get ruleIndex(){return n.RULE_simple_expr}}e.Simple_exprContext=O;class R extends s.ParserRuleContext{node;_op;constructor(t,e,r){super(e,r),this.parser=t}simple_expr(){return this.getTypedRuleContext(O,0)}expression(){return this.getTypedRuleContext(R,0)}EQ(){return this.getToken(n.EQ,0)}ADD_EQ(){return this.getToken(n.ADD_EQ,0)}SUB_EQ(){return this.getToken(n.SUB_EQ,0)}MUL_EQ(){return this.getToken(n.MUL_EQ,0)}EMUL_EQ(){return this.getToken(n.EMUL_EQ,0)}DIV_EQ(){return this.getToken(n.DIV_EQ,0)}EDIV_EQ(){return this.getToken(n.EDIV_EQ,0)}LEFTDIV_EQ(){return this.getToken(n.LEFTDIV_EQ,0)}ELEFTDIV_EQ(){return this.getToken(n.ELEFTDIV_EQ,0)}POW_EQ(){return this.getToken(n.POW_EQ,0)}EPOW_EQ(){return this.getToken(n.EPOW_EQ,0)}AND_EQ(){return this.getToken(n.AND_EQ,0)}OR_EQ(){return this.getToken(n.OR_EQ,0)}anon_fcn_handle(){return this.getTypedRuleContext(S,0)}get ruleIndex(){return n.RULE_expression}}e.ExpressionContext=R;class D extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}simple_expr(){return this.getTypedRuleContext(O,0)}LBRACKET(){return this.getToken(n.LBRACKET,0)}RBRACKET(){return this.getToken(n.RBRACKET,0)}assign_list(){return this.getTypedRuleContext(F,0)}get ruleIndex(){return n.RULE_assign_lhs}}e.Assign_lhsContext=D;class F extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}list_element_list(){return this.getTypedRuleContexts(N)}list_element(t){return this.getTypedRuleContext(N,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}WSPACE_list(){return this.getTokens(n.WSPACE)}WSPACE(t){return this.getToken(n.WSPACE,t)}get ruleIndex(){return n.RULE_assign_list}}e.Assign_listContext=F;class P extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}declaration(){return this.getTypedRuleContext(k,0)}import_command(){return this.getTypedRuleContext(U,0)}select_command(){return this.getTypedRuleContext(B,0)}loop_command(){return this.getTypedRuleContext(K,0)}jump_command(){return this.getTypedRuleContext(et,0)}except_command(){return this.getTypedRuleContext(rt,0)}function_(){return this.getTypedRuleContext(ht,0)}classdef_command(){return this.getTypedRuleContext(mt,0)}get ruleIndex(){return n.RULE_command}}e.CommandContext=P;class k extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}declaration_element_list(){return this.getTypedRuleContexts(V)}declaration_element(t){return this.getTypedRuleContext(V,t)}GLOBAL(){return this.getToken(n.GLOBAL,0)}PERSISTENT(){return this.getToken(n.PERSISTENT,0)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_declaration}}e.DeclarationContext=k;class V extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}EQ(){return this.getToken(n.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_declaration_element}}e.Declaration_elementContext=V;class U extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}IMPORT(){return this.getToken(n.IMPORT,0)}import_name_list(){return this.getTypedRuleContexts($)}import_name(t){return this.getTypedRuleContext($,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_import_command}}e.Import_commandContext=U;class $ extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier(){return this.getTypedRuleContext(p,0)}DOT(){return this.getToken(n.DOT,0)}MUL(){return this.getToken(n.MUL,0)}EMUL(){return this.getToken(n.EMUL,0)}get ruleIndex(){return n.RULE_import_name}}e.Import_nameContext=$;class B extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}if_command(){return this.getTypedRuleContext(H,0)}switch_command(){return this.getTypedRuleContext(z,0)}get ruleIndex(){return n.RULE_select_command}}e.Select_commandContext=B;class H extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}IF(){return this.getToken(n.IF,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(n.END,0)}ENDIF(){return this.getToken(n.ENDIF,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}elseif_clause_list(){return this.getTypedRuleContexts(q)}elseif_clause(t){return this.getTypedRuleContext(q,t)}else_clause(){return this.getTypedRuleContext(j,0)}get ruleIndex(){return n.RULE_if_command}}e.If_commandContext=H;class q extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}ELSEIF(){return this.getToken(n.ELSEIF,0)}expression(){return this.getTypedRuleContext(R,0)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_elseif_clause}}e.Elseif_clauseContext=q;class j extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}ELSE(){return this.getToken(n.ELSE,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_else_clause}}e.Else_clauseContext=j;class z extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}SWITCH(){return this.getToken(n.SWITCH,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(n.END,0)}ENDSWITCH(){return this.getToken(n.ENDSWITCH,0)}sep(){return this.getTypedRuleContext($t,0)}switch_case_list(){return this.getTypedRuleContext(G,0)}otherwise_case(){return this.getTypedRuleContext(Q,0)}get ruleIndex(){return n.RULE_switch_command}}e.Switch_commandContext=z;class G extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}switch_case_list(){return this.getTypedRuleContexts(W)}switch_case(t){return this.getTypedRuleContext(W,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_switch_case_list}}e.Switch_case_listContext=G;class W extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}CASE(){return this.getToken(n.CASE,0)}expression(){return this.getTypedRuleContext(R,0)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_switch_case}}e.Switch_caseContext=W;class Q extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}OTHERWISE(){return this.getToken(n.OTHERWISE,0)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_otherwise_case}}e.Otherwise_caseContext=Q;class K extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}while_command(){return this.getTypedRuleContext(J,0)}do_until_command(){return this.getTypedRuleContext(Z,0)}for_command(){return this.getTypedRuleContext(X,0)}spmd_command(){return this.getTypedRuleContext(Y,0)}get ruleIndex(){return n.RULE_loop_command}}e.Loop_commandContext=K;class J extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}WHILE(){return this.getToken(n.WHILE,0)}expression(){return this.getTypedRuleContext(R,0)}END(){return this.getToken(n.END,0)}ENDWHILE(){return this.getToken(n.ENDWHILE,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_while_command}}e.While_commandContext=J;class Z extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}DO(){return this.getToken(n.DO,0)}UNTIL(){return this.getToken(n.UNTIL,0)}expression(){return this.getTypedRuleContext(R,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_do_until_command}}e.Do_until_commandContext=Z;class X extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}FOR(){return this.getToken(n.FOR,0)}assign_lhs(){return this.getTypedRuleContext(D,0)}EQ(){return this.getToken(n.EQ,0)}expression_list(){return this.getTypedRuleContexts(R)}expression(t){return this.getTypedRuleContext(R,t)}END(){return this.getToken(n.END,0)}ENDFOR(){return this.getToken(n.ENDFOR,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}PARFOR(){return this.getToken(n.PARFOR,0)}ENDPARFOR(){return this.getToken(n.ENDPARFOR,0)}COMMA(){return this.getToken(n.COMMA,0)}get ruleIndex(){return n.RULE_for_command}}e.For_commandContext=X;class Y extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}SPMD(){return this.getToken(n.SPMD,0)}END(){return this.getToken(n.END,0)}ENDSPMD(){return this.getToken(n.ENDSPMD,0)}spmd_worker_spec(){return this.getTypedRuleContext(tt,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_spmd_command}}e.Spmd_commandContext=Y;class tt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(n.LPAREN,0)}expression_list(){return this.getTypedRuleContexts(R)}expression(t){return this.getTypedRuleContext(R,t)}RPAREN(){return this.getToken(n.RPAREN,0)}COMMA(){return this.getToken(n.COMMA,0)}get ruleIndex(){return n.RULE_spmd_worker_spec}}e.Spmd_worker_specContext=tt;class et extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}BREAK(){return this.getToken(n.BREAK,0)}CONTINUE(){return this.getToken(n.CONTINUE,0)}RETURN(){return this.getToken(n.RETURN,0)}get ruleIndex(){return n.RULE_jump_command}}e.Jump_commandContext=et;class rt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}try_command(){return this.getTypedRuleContext(st,0)}unwind_command(){return this.getTypedRuleContext(nt,0)}get ruleIndex(){return n.RULE_except_command}}e.Except_commandContext=rt;class st extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}TRY(){return this.getToken(n.TRY,0)}catch_clause(){return this.getTypedRuleContext(it,0)}END(){return this.getToken(n.END,0)}END_TRY_CATCH(){return this.getToken(n.END_TRY_CATCH,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_try_command}}e.Try_commandContext=st;class it extends s.ParserRuleContext{body;identifierNode;constructor(t,e,r){super(e,r),this.parser=t}CATCH(){return this.getToken(n.CATCH,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_catch_clause}}e.Catch_clauseContext=it;class nt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}UNWIND_PROTECT(){return this.getToken(n.UNWIND_PROTECT,0)}unwind_cleanup_clause(){return this.getTypedRuleContext(at,0)}END(){return this.getToken(n.END,0)}END_UNWIND_PROTECT(){return this.getToken(n.END_UNWIND_PROTECT,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_unwind_command}}e.Unwind_commandContext=nt;class at extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}UNWIND_PROTECT_CLEANUP(){return this.getToken(n.UNWIND_PROTECT_CLEANUP,0)}sep(){return this.getTypedRuleContext($t,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_unwind_cleanup_clause}}e.Unwind_cleanup_clauseContext=at;class ot extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}param_list_elt_list(){return this.getTypedRuleContexts(lt)}param_list_elt(t){return this.getTypedRuleContext(lt,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_param_list}}e.Param_listContext=ot;class lt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}declaration_element(){return this.getTypedRuleContext(V,0)}magic_tilde(){return this.getTypedRuleContext(b,0)}get ruleIndex(){return n.RULE_param_list_elt}}e.Param_list_eltContext=lt;class ct extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}magic_tilde(){return this.getTypedRuleContext(b,0)}get ruleIndex(){return n.RULE_return_list_elt}}e.Return_list_eltContext=ct;class ut extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}return_list_elt_list(){return this.getTypedRuleContexts(ct)}return_list_elt(t){return this.getTypedRuleContext(ct,t)}LBRACKET(){return this.getToken(n.LBRACKET,0)}RBRACKET(){return this.getToken(n.RBRACKET,0)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}WSPACE_list(){return this.getTokens(n.WSPACE)}WSPACE(t){return this.getToken(n.WSPACE,t)}get ruleIndex(){return n.RULE_return_list}}e.Return_listContext=ut;class ht extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}FUNCTION(){return this.getToken(n.FUNCTION,0)}function_name(){return this.getTypedRuleContext(dt,0)}END(){return this.getToken(n.END,0)}ENDFUNCTION(){return this.getToken(n.ENDFUNCTION,0)}EOF(){return this.getToken(n.EOF,0)}return_list(){return this.getTypedRuleContext(ut,0)}EQ(){return this.getToken(n.EQ,0)}param_list(){return this.getTypedRuleContext(ot,0)}sep(){return this.getTypedRuleContext($t,0)}arguments_block_list(){return this.getTypedRuleContext(Ot,0)}list(){return this.getTypedRuleContext(l,0)}get ruleIndex(){return n.RULE_function}}e.FunctionContext=ht;class dt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}qualified_identifier(){return this.getTypedRuleContext(p,0)}get ruleIndex(){return n.RULE_function_name}}e.Function_nameContext=dt;class mt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}CLASSDEF(){return this.getToken(n.CLASSDEF,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}END(){return this.getToken(n.END,0)}ENDCLASSDEF(){return this.getToken(n.ENDCLASSDEF,0)}EOF(){return this.getToken(n.EOF,0)}class_attribute_list(){return this.getTypedRuleContext(pt,0)}class_superclass_list(){return this.getTypedRuleContext(yt,0)}sep(){return this.getTypedRuleContext($t,0)}class_section_list(){return this.getTypedRuleContext(xt,0)}get ruleIndex(){return n.RULE_classdef_command}}e.Classdef_commandContext=mt;class pt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}class_attribute_list(){return this.getTypedRuleContexts(ft)}class_attribute(t){return this.getTypedRuleContext(ft,t)}sep(){return this.getTypedRuleContext($t,0)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_class_attribute_list}}e.Class_attribute_listContext=pt;class ft extends s.ParserRuleContext{node;_op;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}EQ(){return this.getToken(n.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}TILDE(){return this.getToken(n.TILDE,0)}EXCLAMATION(){return this.getToken(n.EXCLAMATION,0)}get ruleIndex(){return n.RULE_class_attribute}}e.Class_attributeContext=ft;class gt extends s.ParserRuleContext{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(d)}identifier(t){return this.getTypedRuleContext(d,t)}DOT_list(){return this.getTokens(n.DOT)}DOT(t){return this.getToken(n.DOT,t)}get ruleIndex(){return n.RULE_class_method_name}}e.Class_method_nameContext=gt;class yt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}EXPR_LT(){return this.getToken(n.EXPR_LT,0)}qualified_identifier_list(){return this.getTypedRuleContexts(p)}qualified_identifier(t){return this.getTypedRuleContext(p,t)}EXPR_AND_list(){return this.getTokens(n.EXPR_AND)}EXPR_AND(t){return this.getToken(n.EXPR_AND,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_class_superclass_list}}e.Class_superclass_listContext=yt;class xt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_section_list(){return this.getTypedRuleContexts(Ct)}class_section(t){return this.getTypedRuleContext(Ct,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_class_section_list}}e.Class_section_listContext=xt;class Ct extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}properties_section(){return this.getTypedRuleContext(Et,0)}methods_section(){return this.getTypedRuleContext(St,0)}events_section(){return this.getTypedRuleContext(bt,0)}enumeration_section(){return this.getTypedRuleContext(Mt,0)}get ruleIndex(){return n.RULE_class_section}}e.Class_sectionContext=Ct;class Et extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}PROPERTIES(){return this.getToken(n.PROPERTIES,0)}END(){return this.getToken(n.END,0)}ENDPROPERTIES(){return this.getToken(n.ENDPROPERTIES,0)}class_attribute_list(){return this.getTypedRuleContext(pt,0)}sep(){return this.getTypedRuleContext($t,0)}class_property_list(){return this.getTypedRuleContext(At,0)}get ruleIndex(){return n.RULE_properties_section}}e.Properties_sectionContext=Et;class At extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_property_list(){return this.getTypedRuleContexts(_t)}class_property(t){return this.getTypedRuleContext(_t,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_class_property_list}}e.Class_property_listContext=At;class _t extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}LPAREN(){return this.getToken(n.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(I)}arg_list(t){return this.getTypedRuleContext(I,t)}RPAREN(){return this.getToken(n.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}LCURLYBR(){return this.getToken(n.LCURLYBR,0)}RCURLYBR(){return this.getToken(n.RCURLYBR,0)}EQ(){return this.getToken(n.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_class_property}}e.Class_propertyContext=_t;class St extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}METHODS(){return this.getToken(n.METHODS,0)}END(){return this.getToken(n.END,0)}ENDMETHODS(){return this.getToken(n.ENDMETHODS,0)}class_attribute_list(){return this.getTypedRuleContext(pt,0)}sep(){return this.getTypedRuleContext($t,0)}class_method_list(){return this.getTypedRuleContext(Tt,0)}get ruleIndex(){return n.RULE_methods_section}}e.Methods_sectionContext=St;class vt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}function_(){return this.getTypedRuleContext(ht,0)}class_method_name(){return this.getTypedRuleContext(gt,0)}param_list(){return this.getTypedRuleContext(ot,0)}return_list(){return this.getTypedRuleContext(ut,0)}EQ(){return this.getToken(n.EQ,0)}get ruleIndex(){return n.RULE_class_method}}e.Class_methodContext=vt;class Tt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_method_list(){return this.getTypedRuleContexts(vt)}class_method(t){return this.getTypedRuleContext(vt,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_class_method_list}}e.Class_method_listContext=Tt;class bt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}EVENTS(){return this.getToken(n.EVENTS,0)}END(){return this.getToken(n.END,0)}ENDEVENTS(){return this.getToken(n.ENDEVENTS,0)}class_attribute_list(){return this.getTypedRuleContext(pt,0)}sep(){return this.getTypedRuleContext($t,0)}class_event_list(){return this.getTypedRuleContext(Nt,0)}get ruleIndex(){return n.RULE_events_section}}e.Events_sectionContext=bt;class Nt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_event_list(){return this.getTypedRuleContexts(It)}class_event(t){return this.getTypedRuleContext(It,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_class_event_list}}e.Class_event_listContext=Nt;class It extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}get ruleIndex(){return n.RULE_class_event}}e.Class_eventContext=It;class Mt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}ENUMERATION(){return this.getToken(n.ENUMERATION,0)}END(){return this.getToken(n.END,0)}ENDENUMERATION(){return this.getToken(n.ENDENUMERATION,0)}class_attribute_list(){return this.getTypedRuleContext(pt,0)}sep(){return this.getTypedRuleContext($t,0)}class_enumeration_list(){return this.getTypedRuleContext(wt,0)}get ruleIndex(){return n.RULE_enumeration_section}}e.Enumeration_sectionContext=Mt;class wt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}class_enumeration_list(){return this.getTypedRuleContexts(Lt)}class_enumeration(t){return this.getTypedRuleContext(Lt,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_class_enumeration_list}}e.Class_enumeration_listContext=wt;class Lt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}identifier(){return this.getTypedRuleContext(d,0)}LPAREN(){return this.getToken(n.LPAREN,0)}RPAREN(){return this.getToken(n.RPAREN,0)}arg_list(){return this.getTypedRuleContext(I,0)}get ruleIndex(){return n.RULE_class_enumeration}}e.Class_enumerationContext=Lt;class Ot extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}arguments_block_list(){return this.getTypedRuleContexts(Rt)}arguments_block(t){return this.getTypedRuleContext(Rt,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_arguments_block_list}}e.Arguments_block_listContext=Ot;class Rt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}ARGUMENTS(){return this.getToken(n.ARGUMENTS,0)}END(){return this.getToken(n.END,0)}ENDARGUMENTS(){return this.getToken(n.ENDARGUMENTS,0)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}LPAREN(){return this.getToken(n.LPAREN,0)}arguments_attribute_list(){return this.getTypedRuleContext(Dt,0)}RPAREN(){return this.getToken(n.RPAREN,0)}args_validation_list(){return this.getTypedRuleContext(Ft,0)}get ruleIndex(){return n.RULE_arguments_block}}e.Arguments_blockContext=Rt;class Dt extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(d)}identifier(t){return this.getTypedRuleContext(d,t)}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}get ruleIndex(){return n.RULE_arguments_attribute_list}}e.Arguments_attribute_listContext=Dt;class Ft extends s.ParserRuleContext{node;i=0;constructor(t,e,r){super(e,r),this.parser=t}arg_validation_list(){return this.getTypedRuleContexts(Pt)}arg_validation(t){return this.getTypedRuleContext(Pt,t)}sep_list(){return this.getTypedRuleContexts($t)}sep(t){return this.getTypedRuleContext($t,t)}get ruleIndex(){return n.RULE_args_validation_list}}e.Args_validation_listContext=Ft;class Pt extends s.ParserRuleContext{node;constructor(t,e,r){super(e,r),this.parser=t}arg_validation_name(){return this.getTypedRuleContext(kt,0)}LPAREN(){return this.getToken(n.LPAREN,0)}arg_list_list(){return this.getTypedRuleContexts(I)}arg_list(t){return this.getTypedRuleContext(I,t)}RPAREN(){return this.getToken(n.RPAREN,0)}qualified_identifier(){return this.getTypedRuleContext(p,0)}LCURLYBR(){return this.getToken(n.LCURLYBR,0)}RCURLYBR(){return this.getToken(n.RCURLYBR,0)}EQ(){return this.getToken(n.EQ,0)}expression(){return this.getTypedRuleContext(R,0)}get ruleIndex(){return n.RULE_arg_validation}}e.Arg_validationContext=Pt;class kt extends s.ParserRuleContext{node;i=1;constructor(t,e,r){super(e,r),this.parser=t}identifier_list(){return this.getTypedRuleContexts(d)}identifier(t){return this.getTypedRuleContext(d,t)}DOT_list(){return this.getTokens(n.DOT)}DOT(t){return this.getToken(n.DOT,t)}get ruleIndex(){return n.RULE_arg_validation_name}}e.Arg_validation_nameContext=kt;class Vt extends s.ParserRuleContext{constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}SEMICOLON_list(){return this.getTokens(n.SEMICOLON)}SEMICOLON(t){return this.getToken(n.SEMICOLON,t)}get ruleIndex(){return n.RULE_sep_no_nl}}e.Sep_no_nlContext=Vt;class Ut extends s.ParserRuleContext{constructor(t,e,r){super(e,r),this.parser=t}NEWLINE_list(){return this.getTokens(n.NEWLINE)}NEWLINE(t){return this.getToken(n.NEWLINE,t)}get ruleIndex(){return n.RULE_nl}}e.NlContext=Ut;class $t extends s.ParserRuleContext{constructor(t,e,r){super(e,r),this.parser=t}COMMA_list(){return this.getTokens(n.COMMA)}COMMA(t){return this.getToken(n.COMMA,t)}SEMICOLON_list(){return this.getTokens(n.SEMICOLON)}SEMICOLON(t){return this.getToken(n.SEMICOLON,t)}NEWLINE_list(){return this.getTokens(n.NEWLINE)}NEWLINE(t){return this.getToken(n.NEWLINE,t)}get ruleIndex(){return n.RULE_sep}}e.SepContext=$t},7686(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MathML=e.format=void 0;class r{static format={"+":(t,e)=>t+'<mo form="infix" stretchy="true">+</mo>'+e,"-":(t,e)=>t+'<mo form="infix" stretchy="true">-</mo>'+e,".*":(t,e)=>t+'<mo form="infix" stretchy="true">.*</mo>'+e,"./":(t,e)=>t+'<mo form="infix" stretchy="true">./</mo>'+e,".\\":(t,e)=>t+'<mo form="infix" stretchy="true">.\\</mo>'+e,"\\":(t,e)=>t+'<mo form="infix" stretchy="true">\\</mo>'+e,".^":(t,e)=>t+'<mo form="infix" stretchy="true">.^</mo>'+e,".**":(t,e)=>t+'<mo form="infix" stretchy="true">.**</mo>'+e,"<":(t,e)=>t+'<mo form="infix" stretchy="true"><</mo>'+e,"<=":(t,e)=>t+'<mo form="infix" stretchy="true">≤</mo>'+e,">":(t,e)=>t+'<mo form="infix" stretchy="true">></mo>'+e,">=":(t,e)=>t+'<mo form="infix" stretchy="true">≥</mo>'+e,"==":(t,e)=>t+'<mo form="infix" stretchy="true">==</mo>'+e,"!=":(t,e)=>t+'<mo form="infix" stretchy="true">≠</mo>'+e,"~=":(t,e)=>t+'<mo form="infix" stretchy="true">≠</mo>'+e,"&":(t,e)=>t+'<mo form="infix" stretchy="true">&</mo>'+e,"|":(t,e)=>t+'<mo form="infix" stretchy="true">|</mo>'+e,"&&":(t,e)=>t+'<mo form="infix" stretchy="true">&&</mo>'+e,"||":(t,e)=>t+'<mo form="infix" stretchy="true">||</mo>'+e,"=":(t,e)=>t+'<mo form="infix" stretchy="true">=</mo>'+e,"+=":(t,e)=>t+'<mo form="infix" stretchy="true">+=</mo>'+e,"-=":(t,e)=>t+'<mo form="infix" stretchy="true">-=</mo>'+e,"*=":(t,e)=>t+'<mo form="infix" stretchy="true">*=</mo>'+e,"/=":(t,e)=>t+'<mo form="infix" stretchy="true">/=</mo>'+e,"\\=":(t,e)=>t+'<mo form="infix" stretchy="true">\\=</mo>'+e,"^=":(t,e)=>t+'<mo form="infix" stretchy="true">^=</mo>'+e,"**=":(t,e)=>t+'<mo form="infix" stretchy="true">**=</mo>'+e,".*=":(t,e)=>t+'<mo form="infix" stretchy="true">.*=</mo>'+e,"./=":(t,e)=>t+'<mo form="infix" stretchy="true">./=</mo>'+e,".\\=":(t,e)=>t+'<mo form="infix" stretchy="true">.\\=</mo>'+e,".^=":(t,e)=>t+'<mo form="infix" stretchy="true">.^=</mo>'+e,".**=":(t,e)=>t+'<mo form="infix" stretchy="true">.**=</mo>'+e,"&=":(t,e)=>t+'<mo form="infix" stretchy="true">&=</mo>'+e,"|=":(t,e)=>t+'<mo form="infix" stretchy="true">|=</mo>'+e,"*":(t,e)=>t+'<mo form="infix" stretchy="true">×</mo>'+e,"+_":t=>'<mo form="prefix" stretchy="true">+</mo>'+t,"-_":t=>'<mo form="prefix" stretchy="true">-</mo>'+t,"++_":t=>'<mo form="prefix" stretchy="true">++</mo>'+t,"--_":t=>'<mo form="prefix" stretchy="true">--</mo>'+t,"_++":t=>t+'<mo form="postfix" stretchy="true">++</mo>',"_--":t=>t+'<mo form="postfix" stretchy="true">--</mo>',"!":t=>'<mo form="prefix" stretchy="true">!</mo>'+t,"~":t=>'<mo form="prefix" stretchy="true">~</mo>'+t,"/":(t,e)=>"<mfrac><mrow>"+t+"</mrow><mrow>"+e+"</mrow></mfrac>","^":(t,e)=>"<msup><mrow>"+t+"</mrow><mrow>"+e+"</mrow></msup>","**":(t,e)=>"<msup><mrow>"+t+"</mrow><mrow>"+e+"</mrow></msup>",".'":t=>"<msup><mrow>"+t+"</mrow><mrow><mi>T</mi></mrow></msup>","'":t=>"<msup><mrow>"+t+"</mrow><mrow><mi>H</mi></mrow></msup>","()":(t,e,r)=>'<mo fence="true" stretchy="true">'+t+"</mo>"+e+'<mo fence="true" stretchy="true">'+r+"</mo>",IDENT:t=>"<mi>"+t+"</mi>",".":(t,e)=>t+"<mo>.</mo>"+e.join("<mo>.</mo>"),LIST:t=>"<mtable>"+t.map(t=>"<mtr><mtd>"+t+"</mtd></mtr>").join("")+"</mtable>",RANGE:(...t)=>t.length?t.join("<mo>:</mo>"):"<mo>:</mo>",ENDRANGE:()=>"<mi>end</mi>",":":()=>"<mo>:</mo>","<~>":()=>"<mo>~</mo>",IDX:(t,e,r,s)=>t+'<mrow><mo fence="true" stretchy="true">'+e+"</mo>"+r.join("<mo>,</mo>")+'<mo fence="true" stretchy="true">'+s+"</mo></mrow>",RETLIST:()=>"<mi>RETLIST</mi>",CMDWLIST:(t,e)=>"<mrow><mtext>"+t+"</mtext> "+e.join(" ")+"</mrow>",PERSIST:()=>"",FCNDEF:()=>"",VOID:()=>"",INVALID:()=>"<mi>invalid</mi>",UNDEFINED:()=>"<mi>undefined tree</mi>",ERROR:()=>"<mi>error</mi>",math:(t,e)=>"none"===e?t:'<math xmlns = "http://www.w3.org/1998/Math/MathML" display="'+e+'">'+t+"</math>",errorReplace:t=>t.replace(/\<mo\>\(\<\/mo\>\<mi\>error\<\/mi\><\mi\>error\<\/mi\>\<mi\>i\<\/mi\>\<mo\>\)\<\/mo\>/gi,"<mi>error</mi>"),abs:(...t)=>'<mrow><mo fence="true" stretchy="true">|</mo>'+t[0]+'<mo fence="true" stretchy="true">|</mo></mrow>',conj:(...t)=>'<mover accent="true"><mrow>'+t[0]+'</mrow><mo stretchy="true">‾</mo></mover>',sqrt:(...t)=>"<msqrt><mrow>"+t[0]+"</mrow></msqrt>",root:(...t)=>"<mroot><mrow>"+t[0]+"</mrow><mrow>"+t[1]+"</mrow></mroot>",exp:(...t)=>"<msup><mi>e</mi><mrow>"+t[0]+"</mrow></msup>",logb:(...t)=>"<mrow><msub><mi>log</mi><mrow>"+t[0]+"</mrow></msub><mrow>"+t[1]+"</mrow></mrow>",log2:(...t)=>"<mrow><msub><mi>log</mi><mrow><mn>2</mn></mrow></msub><mrow>"+t[0]+"</mrow></mrow>",log10:(...t)=>"<mrow><msub><mi>log</mi><mrow><mn>10</mn></mrow></msub><mrow>"+t[0]+"</mrow></mrow>",gamma:(...t)=>'<mi>Γ</mi><mrow><mo fence="true" stretchy="true">(</mo>'+t[0]+'<mo fence="true" stretchy="true">)</mo></mrow>',factorial:(...t)=>"<mrow>"+t[0]+'</mrow><mo format="postfix" stretchy="true">!</mo>'};static formatFunction=t=>{const e=r.format[t];return"function"==typeof e?e:void 0};static formatDynamic=(t,...e)=>{const s=r.formatFunction(t);if(!s)throw new Error(`MathML formatter '${t}' is not defined.`);return s(...e)}}e.MathML=r;const s=r.format;e.format=s,e.default={format:s,MathML:r}},6554(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MathOperation=void 0;const s=r(5956),i=r(845),n=r(7679),a=r(5212),o=r(9770),l=r(4610),c=r(1604);class u{static elementWiseOperatorSymbols={add:"+",sub:"-",mod:"mod",rem:"rem",mul:".*",rdiv:"./",ldiv:".\\",power:".^",lt:"<",le:"<=",eq:"==",ge:">=",gt:">",ne:"~=",and:"&",or:"|",xor:"xor",minWise:"min",maxWise:"max"};static unaryOperatorSymbols={copy:"+",neg:"-",not:"~"};static copy=t=>c.RuntimeValue.copy(t);static elementWiseOperation=(t,e,r)=>{if(s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),s.CharString.isInstanceOf(r)&&(r=n.MultiArray.fromCharString(r)),u.throwIfStructureBinaryOperand(u.elementWiseOperatorSymbols[t],e,r),u.throwIfCellBinaryOperand(u.elementWiseOperatorSymbols[t],e,r),("lt"===t||"le"===t||"eq"===t||"ge"===t||"gt"===t||"ne"===t)&&(u.hasClassInstanceOperand(e)||u.hasClassInstanceOperand(r)))return u.classInstanceRelationalOperation(t,e,r);if(i.Complex.isInstanceOf(e)&&i.Complex.isInstanceOf(r))return i.Complex[t](e,r);if(i.Complex.isInstanceOf(e)&&n.MultiArray.isInstanceOf(r))return n.MultiArray.scalarOpMultiArray(t,e,r);if(n.MultiArray.isInstanceOf(e)&&i.Complex.isInstanceOf(r))return n.MultiArray.MultiArrayOpScalar(t,e,r);if(n.MultiArray.isInstanceOf(e)&&n.MultiArray.isInstanceOf(r))return n.MultiArray.elementWiseOperation(t,e,r);throw new EvalError(`operator ${u.elementWiseOperatorSymbols[t]} is not defined for these operands.`)};static hasStructureOperand=t=>a.Structure.isInstanceOf(t)||n.MultiArray.isInstanceOf(t)&&a.Structure.isStructure(t);static hasCellOperand=t=>n.MultiArray.isInstanceOf(t)&&t.isCell;static throwIfCellBinaryOperand=(t,e,r)=>{if(u.hasCellOperand(e)||u.hasCellOperand(r))throw new EvalError(`operator ${t} is not defined for cell operands.`)};static throwIfStructureBinaryOperand=(t,e,r)=>{if(u.hasStructureOperand(e)||u.hasStructureOperand(r))throw new EvalError(`operator ${t} is not defined for struct operands.`)};static throwIfCellUnaryOperand=(t,e)=>{if(u.hasCellOperand(e))throw new EvalError(`operator ${t} is not defined for cell operands.`)};static throwIfStructureUnaryOperand=(t,e)=>{if(u.hasStructureOperand(e))throw new EvalError(`operator ${t} is not defined for struct operands.`)};static hasClassInstanceOperand=t=>o.ClassInstance.isInstanceOf(t)||n.MultiArray.isInstanceOf(t)&&n.MultiArray.linearize(t).some(t=>o.ClassInstance.isInstanceOf(t));static handleComparisonOrder=new WeakMap;static nextHandleComparisonOrder=1;static handleOrder=t=>{let e=u.handleComparisonOrder.get(t);return void 0===e&&(e=u.nextHandleComparisonOrder++,u.handleComparisonOrder.set(t,e)),e};static numericScalarValue=t=>{if(i.Complex.isInstanceOf(t))return t;if(n.MultiArray.isInstanceOf(t)&&c.RuntimeValue.isScalar(t)){const e=n.MultiArray.firstElement(t);return i.Complex.isInstanceOf(e)?e:void 0}};static classInstanceRelationalOperation=(t,e,r)=>{const s=(e,r)=>{const s=o.ClassInstance.isInstanceOf(e),n=o.ClassInstance.isInstanceOf(r);if(!s||!n)return i.Complex.false();if(!e.classDefinition.isHandleClass()||!r.classDefinition.isHandleClass())throw new EvalError(`binary operator '${t}' is not defined for value class operands.`);if(e.classDefinition.name!==r.classDefinition.name)return i.Complex.false();const a=u.handleOrder(e),l=u.handleOrder(r);return("lt"===t?a<l:"le"===t?a<=l:"eq"===t?e===r:"ge"===t?a>=l:"gt"===t?a>l:e!==r)?i.Complex.true():i.Complex.false()},a=n.MultiArray.scalarToMultiArray(e),l=n.MultiArray.scalarToMultiArray(r),c=a.dimension.slice(),h=l.dimension.slice(),d=Math.max(c.length,h.length);for(;c.length<d;)c.push(1);for(;h.length<d;)h.push(1);const m=new Array(d),p=new Array(d),f=new Array(d);for(let e=0;e<d;e++)if(c[e]===h[e])m[e]=c[e],p[e]=f[e]=!1;else if(1===c[e])m[e]=h[e],p[e]=!0,f[e]=!1;else{if(1!==h[e])throw new EvalError(`operator ${t}: nonconformant arguments (op1 is ${c.join("x")}, op2 is ${h.join("x")}).`);m[e]=c[e],p[e]=!1,f[e]=!0}const g=n.MultiArray.computeStrides(c),y=n.MultiArray.computeStrides(h),x=n.MultiArray.computeStrides(m),C=new n.MultiArray(m),E=m.reduce((t,e)=>t*e,1);for(let t=0;t<E;t++){let e=0,r=0;for(let s=0;s<d;s++){const i=Math.floor(t/x[s])%m[s];e+=(p[s]?0:i)*g[s],r+=(f[s]?0:i)*y[s]}const[i,o]=n.MultiArray.linearIndexToMultiArrayRowColumn(c[0],c[1],e),[u,E]=n.MultiArray.linearIndexToMultiArrayRowColumn(h[0],h[1],r),[A,_]=n.MultiArray.linearIndexToMultiArrayRowColumn(m[0],m[1],t);C.array[A][_]=s(a.array[i][o],l.array[u][E])}return C.type=i.Complex.LOGICAL,n.MultiArray.MultiArrayToScalar(C)};static leftOperation=(t,e)=>{if(s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),u.throwIfStructureUnaryOperand(u.unaryOperatorSymbols[t],e),u.throwIfCellUnaryOperand(u.unaryOperatorSymbols[t],e),i.Complex.isInstanceOf(e))return i.Complex[t](e);if(n.MultiArray.isInstanceOf(e))return n.MultiArray.leftOperation(t,e);throw new EvalError(`operator ${u.unaryOperatorSymbols[t]} is not defined for this operand.`)};static plus=(t,e)=>u.elementWiseOperation("add",t,e);static minus=(t,e)=>u.elementWiseOperation("sub",t,e);static mod=(t,e)=>u.elementWiseOperation("mod",t,e);static rem=(t,e)=>u.elementWiseOperation("rem",t,e);static times=(t,e)=>u.elementWiseOperation("mul",t,e);static mtimes=(t,e)=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),u.throwIfStructureBinaryOperand("*",t,e),i.Complex.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.mul(t,e):i.Complex.isInstanceOf(t)&&n.MultiArray.isInstanceOf(e)?n.MultiArray.scalarOpMultiArray("mul",t,e):n.MultiArray.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?n.MultiArray.MultiArrayOpScalar("mul",t,e):l.LinearAlgebra.mul(t,e));static rdivide=(t,e)=>u.elementWiseOperation("rdiv",t,e);static mrdivide=(t,e)=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),u.throwIfStructureBinaryOperand("/",t,e),i.Complex.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.rdiv(t,e):i.Complex.isInstanceOf(t)&&n.MultiArray.isInstanceOf(e)?n.MultiArray.scalarOpMultiArray("mul",t,l.LinearAlgebra.inv(e)):n.MultiArray.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?n.MultiArray.scalarOpMultiArray("mul",i.Complex.inv(e),t):l.LinearAlgebra.mrdivide(t,e));static ldivide=(t,e)=>u.elementWiseOperation("ldiv",t,e);static mldivide=(t,e)=>{if(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),u.throwIfStructureBinaryOperand("\\",t,e),i.Complex.isInstanceOf(t)&&i.Complex.isInstanceOf(e))return i.Complex.ldiv(t,e);if(i.Complex.isInstanceOf(t)&&n.MultiArray.isInstanceOf(e))return n.MultiArray.scalarOpMultiArray("ldiv",t,e);if(n.MultiArray.isInstanceOf(t)&&i.Complex.isInstanceOf(e))throw new EvalError(`operator \\: nonconformant arguments (op1 is ${t.dimension.join("x")}, op2 is 1x1).`);return l.LinearAlgebra.mldivide(t,e)};static power=(t,e)=>u.elementWiseOperation("power",t,e);static mpower=(t,e)=>{s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),u.throwIfStructureBinaryOperand("^",t,e);const r=u.numericScalarValue(t),a=u.numericScalarValue(e);if(r&&a)return i.Complex.power(r,a);if(n.MultiArray.isInstanceOf(t)&&a)return l.LinearAlgebra.power(t,a);if(r&&n.MultiArray.isInstanceOf(e))return l.LinearAlgebra.scalarPower(r,e);throw new Error("invalid exponent in '^'.")};static uplus=t=>u.leftOperation("copy",t);static uminus=t=>u.leftOperation("neg",t);static transpose=t=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.characterVectorFromCharString(t)),n.MultiArray.isInstanceOf(t)?l.LinearAlgebra.transpose(t):c.RuntimeValue.copy(t));static ctranspose=t=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.characterVectorFromCharString(t)),i.Complex.isInstanceOf(t)?i.Complex.conj(t):n.MultiArray.isInstanceOf(t)?l.LinearAlgebra.ctranspose(t):c.RuntimeValue.copy(t));static lt=(t,e)=>u.elementWiseOperation("lt",t,e);static le=(t,e)=>u.elementWiseOperation("le",t,e);static eq=(t,e)=>u.elementWiseOperation("eq",t,e);static ge=(t,e)=>u.elementWiseOperation("ge",t,e);static gt=(t,e)=>u.elementWiseOperation("gt",t,e);static ne=(t,e)=>u.elementWiseOperation("ne",t,e);static mand=(t,e)=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),i.Complex.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.and(t,e):i.Complex.isInstanceOf(t)&&n.MultiArray.isInstanceOf(e)?i.Complex.and(t,n.MultiArray.toLogical(e)):n.MultiArray.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.and(n.MultiArray.toLogical(t),e):i.Complex.and(n.MultiArray.toLogical(t),n.MultiArray.toLogical(e)));static mor=(t,e)=>(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),s.CharString.isInstanceOf(e)&&(e=n.MultiArray.fromCharString(e)),i.Complex.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.or(t,e):i.Complex.isInstanceOf(t)&&n.MultiArray.isInstanceOf(e)?i.Complex.or(t,n.MultiArray.toLogical(e)):n.MultiArray.isInstanceOf(t)&&i.Complex.isInstanceOf(e)?i.Complex.or(n.MultiArray.toLogical(t),e):i.Complex.or(n.MultiArray.toLogical(t),n.MultiArray.toLogical(e)));static not=t=>{if(s.CharString.isInstanceOf(t)&&(t=n.MultiArray.fromCharString(t)),u.throwIfStructureUnaryOperand(u.unaryOperatorSymbols.not,t),u.throwIfCellUnaryOperand(u.unaryOperatorSymbols.not,t),i.Complex.isInstanceOf(t))return i.Complex.not(t);if(n.MultiArray.isInstanceOf(t))return n.MultiArray.leftOperation("not",t);throw new EvalError(`operator ${u.unaryOperatorSymbols.not} is not defined for this operand.`)};static and=(t,e)=>u.elementWiseOperation("and",t,e);static or=(t,e)=>u.elementWiseOperation("or",t,e);static xor=(t,e)=>u.elementWiseOperation("xor",t,e);static unaryOperations={uplus:u.uplus,uminus:u.uminus,not:u.not,transpose:u.transpose,ctranspose:u.ctranspose};static binaryOperations={minus:u.minus,mod:u.mod,rem:u.rem,rdivide:u.rdivide,mrdivide:u.mrdivide,ldivide:u.ldivide,mldivide:u.mldivide,power:u.power,mpower:u.mpower,lt:u.lt,le:u.le,ge:u.ge,gt:u.gt,eq:u.eq,ne:u.ne};static leftAssociativeMultipleOperations={plus:u.plus,times:u.times,mtimes:u.mtimes,and:u.and,or:u.or,xor:u.xor}}e.MathOperation=u,e.default={MathOperation:u}},7679(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MultiArray=void 0;const s=r(845),i=r(5956),n=r(1604),a=(t,e)=>{if(e>t)throw new EvalError(`element number ${e} undefined in return list`)},o=(t,e,r)=>((t,e)=>({type:"RETLIST",selector:t,handler:e}))((r,s)=>(a(t,r.length),e(r,s)),e=>(a(t,e),r?r(e):{length:e}));class l{dimension;get dimensionR(){return[this.dimension[0],...this.dimension.slice(2)]}array;type;static isInstanceOf=t=>t instanceof l;static isIndexArgument(t){return s.Complex.isInstanceOf(t)||l.isInstanceOf(t)}static indexArguments(t,e="index"){return t.map((t,r)=>{if(!l.isIndexArgument(t))throw new EvalError(`${e}${r+1}: invalid subscript type.`);return t})}static numericElement=(t,e)=>{if(!s.Complex.isInstanceOf(t))throw new TypeError(`${e}: expected numeric array element.`);return t};static LOGICAL=s.Complex.LOGICAL;static REAL=s.Complex.REAL;static COMPLEX=s.Complex.COMPLEX;static STRING=i.CharString.STRING;static STRUCTURE=4;static FUNCTION_HANDLE=n.RuntimeValue.FUNCTION_HANDLE;isCell;parent;static invalidStructureReferenceMessage="value cannot be indexed with .";constructor(t,e,r){if(t)if(this.dimension=t.slice(),l.appendSingletonTail(this.dimension,2),l.removeSingletonTail(this.dimension),e)if("function"==typeof e)this.array=Array.from({length:t[0]*t.slice(2).reduce((t,e)=>t*e,1)},(r,s)=>Array.from({length:t[1]},(r,i)=>e(...l.rowColumnToSubscript(t,s,i))));else if(Array.isArray(e)&&Array.isArray(e[0]))this.array=e.map(t=>t.map(t=>n.RuntimeValue.copy(t)));else{this.array=new Array(this.dimensionR.reduce((t,e)=>t*e,1));for(let t=0;t<this.array.length;t++){this.array[t]=new Array(this.dimension[1]);for(let r=0;r<this.dimension[1];r++)this.array[t][r]=n.RuntimeValue.copy(e)}this.type=e.type}else this.array=Array.from({length:t[0]*t.slice(2).reduce((t,e)=>t*e,1)},e=>Array.from({length:t[1]},t=>s.Complex.zero())),this.type=-1;else this.dimension=[0,0],this.array=[],this.type=-1;this.isCell=r??!1}static isScalar=t=>!(t instanceof l&&t.dimension.reduce((t,e)=>t*e,1)>1);static isRowVector=t=>t instanceof l&&2===t.dimension.length&&1===t.dimension[0];static toRowVector=t=>{const e=new l([1,t.length]);return e.array[0]=t.slice(),e};static fromRowVector=t=>t.array[0];static isColumnVector=t=>t instanceof l&&2===t.dimension.length&&1===t.dimension[1];static toColumnVector=t=>{const e=new l([t.length,1]);return e.array.map((e,r,s)=>s[r][0]=t[r]),e};static fromColumnVector=t=>t.array.map(t=>t[0]);static arrayIsVector=t=>2===t.dimension.length&&(1===t.dimension[0]||1===t.dimension[1]);static isVector=t=>t instanceof l&&2===t.dimension.length&&(1===t.dimension[0]||1===t.dimension[1]);static toDiagonalMatrix=t=>{const e=new l([t.length,t.length]);return e.array.map((e,r,s)=>s[r][r]=t[r]),e};static isMatrix=t=>!(t instanceof l)||2===t.dimension.length;static isEmpty=t=>t instanceof l&&0===t.dimension.reduce((t,e)=>t*e,1);static isReducedArrayLine=t=>Array.isArray(t);static isReducedComplexArrayLine=t=>l.isReducedArrayLine(t)&&t.every(s.Complex.isInstanceOf);static isCellArray=t=>t instanceof l&&t.isCell;static isComplexMultiArray=t=>{let e=!1;for(let r=0;r<t.dimensionR.reduce((t,e)=>t*e,1);r++)for(let i=0;i<t.dimension[1];i++)if(s.Complex.isComplexValue(l.numericElement(t.array[r][i],"isComplexMultiArray"))){e=!0;break}return e};static setType=t=>{t.type=Math.max(...t.array.map(t=>Math.max(...t.map(t=>t.type))))};static arrayEquals=(t,e)=>t.length===e.length&&t.every((t,r)=>t===e[r]);static rangeArray=t=>{const e=[];for(let r=1;r<=t;r++)e.push(r);return e};static linearIndexToSubscript=(t,e)=>t.map((r,s)=>Math.floor(e/t.slice(0,s).reduce((t,e)=>t*e,1))%r+1);static subscriptToLinearIndex=(t,e)=>e.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0);static linearIndexToMultiArrayRowColumn=(t,e,r)=>{const s=t*e,i=r%s;return[Math.floor(r/s)*t+i%t,Math.floor(i/t)]};static subscriptToMultiArrayRowColumn=(t,e)=>{const r=e.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0),s=t[0]*t[1],i=r%s;return[Math.floor(r/s)*t[0]+i%t[0],Math.floor(i/t[0])]};static rowColumnToLinearIndex=(t,e,r)=>Math.floor(e/t[0])*t[0]*t[1]+r*t[0]+e%t[0];static rowColumnToSubscript=(t,e,r)=>{const s=Math.floor(e/t[0])*t[0]*t[1]+r*t[0]+e%t[0];return t.map((e,r)=>Math.floor(s/t.slice(0,r).reduce((t,e)=>t*e,1))%e+1)};static computeStrides=t=>{const e=new Array(t.length);let r=1;for(let s=0;s<t.length;s++)e[s]=r,r*=t[s];return e};static getStride=(t,e)=>t.dimension.slice(e+1).reduce((t,e)=>t*e,1);static pageSlice=(t,e)=>{const r=t.dimension;if(r.length<=2)return t.array.map(t=>t.map(t=>l.numericElement(t,"pageSlice")));const[s,i]=r.slice(-2),n=r.slice(0,-2).reduce((t,e)=>t*e,1);if(e>=n)throw new RangeError(`pageSlice: invalid page index ${e}/${n}`);const a=l.flatten(t).map(t=>l.numericElement(t,"pageSlice")),o=e*s*i,c=[];for(let t=0;t<s;t++){const e=[];for(let r=0;r<i;r++)e.push(a[o+t+r*s]);c.push(e)}return c};static setPage=(t,e,r)=>{const[s,i,...n]=t.dimension,a=n.reduce((t,e)=>t*e,1)||1;if(e>=a)throw new RangeError(`setPage: invalid page index ${e}/${a}`);const o=e*s;for(let e=0;e<s;e++)t.array[o+e].splice(0,i,...r[e])};static toFlatArray=t=>{const e=t.dimension,r=e.reduce((t,e)=>t*e,1),s=new Array(r);for(let i=0;i<r;i++){const[r,n]=l.linearIndexToMultiArrayRowColumn(e[0],e[1],i);if(!t.array[r]||void 0===t.array[r][n])throw new Error(`toFlatArray: missing element at linear ${i} -> array[${r}][${n}] is undefined.`);s[i]=l.numericElement(t.array[r][n],"toFlatArray")}return s};static fromFlatArray=(t,e)=>{const r=t.dimension,s=r.reduce((t,e)=>t*e,1);if(e.length!==s)throw new Error(`fromFlatArray: length mismatch (flat ${e.length} vs expected ${s}).`);const i=r[0],n=r.slice(2).reduce((t,e)=>t*e,1),a=i*Math.max(1,n);if(!Array.isArray(t.array)||t.array.length!==a){t.array=new Array(a);for(let e=0;e<a;e++)t.array[e]=new Array(r[1]).fill(void 0)}for(let i=0;i<s;i++){const[s,n]=l.linearIndexToMultiArrayRowColumn(r[0],r[1],i);t.array[s][n]=e[i]}};static sameSizeExcept=(t,e)=>{const r=t.dimension,s=e.dimension;if(r.length!==s.length)return!1;let i=!0;for(let t=0;t<r.length;t++)if(r[t]!==s[t]){i=!1;break}if(i)return!0;for(let t=0;t<r.length;t++)if(3===r[t]&&3===s[t]){let e=!0;for(let i=0;i<r.length;i++)if(i!==t&&r[i]!==s[i]){e=!1;break}if(e)return!0}return!1};static ind2subNumber=(t,e)=>(t=[...t,e+1]).map((r,s)=>Math.floor((e-1)/t.slice(0,s).reduce((t,e)=>t*e,1))%r).map(t=>t+1);static linearLength=t=>t.array.length*t.dimension[1];static getDimension=(t,e)=>e<t.dimension.length?t.dimension[e]:1;static removeSingletonTail=t=>{let e=t.length-1;for(;1===t[e]&&e>1;)t.pop(),e--};static appendSingletonTail=(t,e)=>{e>t.length&&t.push(...new Array(e-t.length).fill(1))};static firstNonSingleDimension=t=>{if(!t.dimension||0===t.dimension.length)return 0;const e=t.dimension.findIndex(t=>t>1);return e>=0?e:0};static linkArrayElementParent=(t,e)=>{t&&"object"==typeof t&&(t.parent=e)};static firstRow=(t,e)=>{const r=new l([1,t.length]);return r.array[0]=t,r.array[0].forEach(t=>l.linkArrayElementParent(t,r)),r.isCell=e??!1,r};static appendRow=(t,e)=>(e.forEach(e=>l.linkArrayElementParent(e,t)),t.array.push(e),t.dimension[0]++,t);static unparse=(t,e,r=0)=>{const s=t=>t.map(t=>e.Unparse(t)).join()+";\n";let i="";if(0===t.dimension.reduce((t,e)=>t*e,1))return`${t.isCell?"{ }":"[ ]"}(${t.dimension.join("x")})`;if(t.dimension.length>2){let e="";for(let r=0;r<t.array.length;r+=t.dimension[0])i=t.array.slice(r,r+t.dimension[0]).map(s).join(""),i=i.substring(0,i.length-2),e+=`${t.isCell?"{":"["}${i}${t.isCell?"}":"]"} (:,:,${l.linearIndexToSubscript(t.dimensionR,r).slice(1).join()})\n`;return e}return i=t.array.map(s).join(""),i=i.substring(0,i.length-2),`${t.isCell?"{":"["}${i}${t.isCell?"}":"]"}`};toString(){return`array ${this.dimension.join("x")}`}static unparseMathML=(t,e,r=0)=>{const s=t=>`<mtr>${t.map(t=>`<mtd>${e.UnparserMathML(t)}</mtd>`).join("")}</mtr>`,i=e=>`<mrow><mo fence="true" stretchy="true">${t.isCell?"{":"["}</mo><mtable>${e}</mtable><mo fence="true" stretchy="true">${t.isCell?"}":"]"}</mo></mrow>`;if(0===t.dimension.reduce((t,e)=>t*e,1))return`${i('<mspace width="0.5em"/>')}<mo fence="true" stretchy="true">(</mo><mn>${t.dimension.join("</mn><mi>×</mi><mn>")}</mn><mo fence="true" stretchy="true">)</mo>`;if(t.dimension.length>2){let e="";for(let r=0;r<t.array.length;r+=t.dimension[0]){const n=t.array.slice(r,r+t.dimension[0]).map(s).join(""),a=l.linearIndexToSubscript(t.dimensionR,r).slice(1).map(t=>`<mn>${t}</mn>`).join("<mo>,</mo>");e+=`<mtr><mtd><msub>${i(n)}<mrow><mo fence="true" stretchy="true">(</mo><mo>:</mo><mo>,</mo><mo>:</mo><mo>,</mo>${a}<mo fence="true" stretchy="true">)</mo></mrow></msub></mtd></mtr>`}return`<mtable>${e}</mtable>`}return i(t.array.map(s).join(""))};static fromCharString=t=>{if(t.length>0){const e=new l(t.dimension);return e.array=[t.vector().map(t=>s.Complex.create(t.charCodeAt(0)))],e.type=s.Complex.REAL,l.MultiArrayToScalar(e)}return l.emptyArray()};static characterVectorFromCharString=t=>{const e=new l(t.dimension);return e.array[0]=t.toCharacterScalars(),e.type=i.CharString.STRING,e};static charStringFromCharacterVectorResult=(t,e)=>{const r=l.isInstanceOf(t)?l.linearize(t):[t];if(0===r.length)return i.CharString.create("",e);if(!l.isCharStringList(r))throw new EvalError("character string indexing produced a non-character value.");return i.CharString.fromCharacterScalars(r,e)};static flatten=t=>{const e=[];for(let r=0;r<t.array[0].length;r++)for(let s=0;s<t.array.length;s++)e.push(t.array[s][r]);return e};static linearize=t=>{if(t instanceof l){const e=t.dimension[0],r=t.dimension[1],s=new Array(l.linearLength(t));let i=0;for(let n=0;n<t.array.length;n+=e)for(let a=0;a<r;a++)for(let r=0;r<e;r++)s[i++]=t.array[n+r][a];return s}return[t]};static emptyArray=t=>{const e=new l([0,0]);return e.isCell=t??!1,e};static isObjectRecord=t=>"object"==typeof t&&null!==t;static isElementRecord=t=>l.isObjectRecord(t)&&!Array.isArray(t)&&Object.values(t).every(t=>null!=t);static isStructureScalar=t=>l.isObjectRecord(t)&&Reflect.get(t,"type")===l.STRUCTURE&&l.isElementRecord(Reflect.get(t,"field"));static structureElements=t=>{if(l.isStructureScalar(t))return[t];if(t instanceof l&&!t.isCell){const e=l.linearize(t);return 0!==e.length&&e.every(l.isStructureScalar)?e:[]}return[]};static structureFieldValue=t=>t??l.emptyArray();static structureFieldNames=t=>Object.keys(l.structureElements(t)[0]?.field??{}).sort();static createStructureValue=t=>{const e=n.RuntimeValue.createStructure(t);if(!l.isStructureScalar(e))throw new Error("runtime structure factory returned an invalid structure value.");return e};static isCharStringList=t=>t.length>0&&t.every(t=>i.CharString.isInstanceOf(t));static cloneStructureFields=t=>{const e=l.createStructureValue({});return Object.keys(t.field).forEach(t=>{e.field[t]=l.emptyArray()}),e};static structureHasField=(t,e)=>{const r=l.structureElements(t);return r.length>0&&r.every(t=>n.RuntimeValue.hasOwnField(t.field,e))};static structureCollectFieldPath=(t,e)=>{if(0===e.length)return[t];const r=l.structureElements(t);if(r.length>0&&t instanceof l)return r.flatMap(t=>l.structureCollectFieldPath(t,e));if(l.isStructureScalar(t)){const r=t.field[e[0]];if(void 0===r)throw new EvalError(l.invalidStructureReferenceMessage);return 1===e.length?[r]:l.structureCollectFieldPath(r,e.slice(1))}throw new EvalError(l.invalidStructureReferenceMessage)};static getStructureField=(t,e)=>{const r=l.structureCollectFieldPath(t,e);return 1===r.length?r[0]:l.toRowVector(r)};static structureAssignFieldPath=(t,e,r)=>{if(t instanceof l){const s=l.structureElements(t);if(0===s.length)throw new EvalError(l.invalidStructureReferenceMessage);return void s.forEach(t=>l.structureAssignFieldPath(t,e,r))}if(!l.isStructureScalar(t)||0===e.length)throw new EvalError(l.invalidStructureReferenceMessage);if(1===e.length)return void(t.field[e[0]]=l.structureFieldValue(r));const s=e[0],i=t.field[s];if(void 0===i||l.isEmpty(i))t.field[s]=l.cloneStructureFields(t);else if(!l.isStructureScalar(i)&&0===l.structureElements(i).length)throw new EvalError(l.invalidStructureReferenceMessage);l.structureAssignFieldPath(t.field[s],e.slice(1),r)};static setEmptyStructureField=(t,e)=>{const r=l.structureElements(t);if(0===r.length)throw new EvalError(l.invalidStructureReferenceMessage);t.isCell||l.structureHasField(t,e)||r.forEach(t=>{t.field[e]=l.emptyArray()})};static blankValueForExpansion=t=>l.isStructureScalar(t)?l.cloneStructureFields(t):n.RuntimeValue.isClassInstance(t)?n.RuntimeValue.copy(t):i.CharString.isInstanceOf(t)?i.CharString.create(" ",t.quote):s.Complex.zero();static scalarToMultiArrayWithTest=(t,e)=>{if(t instanceof l&&e)return t;{const e=new l([1,1]);return e.array[0]=[t],e.type=t.type??-1,e}};static scalarToMultiArray=t=>l.scalarToMultiArrayWithTest(t,!(l.isInstanceOf(t)&&t.isCell));static scalarOrCellToMultiArray=t=>l.scalarToMultiArrayWithTest(t,!0);static MultiArrayToScalar=t=>t instanceof l&&2===t.dimension.length&&1===t.dimension[0]&&1===t.dimension[1]?t.array[0][0]:t;static firstElement=t=>t instanceof l&&t.dimension.reduce((t,e)=>t*e,1)>0?t.array[0][0]:t;static firstVector=t=>t instanceof l?1===t.dimension[0]?t.array[0]:t.array.map(t=>t[0]):[t];static copy=t=>{const e=new l(t.dimension,void 0,t.isCell);return e.array=t.array.map(t=>t.map(t=>n.RuntimeValue.copy(t))),e.type=t.type,e};copy(){const t=new l(this.dimension,void 0,this.isCell);return t.array=this.array.map(t=>t.map(t=>n.RuntimeValue.copy(t))),t.type=this.type,t}static toLogical=t=>{if(t.dimension.some(t=>0===t))return s.Complex.false();for(let e=0;e<t.array.length;e++){const r=t.array[e];for(let e=0;e<t.dimension[1];e++){const t=l.numericElement(r[e],"toLogical").toLogical();if(s.Complex.realEquals(t,0))return s.Complex.false()}}return s.Complex.true()};toLogical(){if(this.dimension.some(t=>0===t))return s.Complex.false();for(let t=0;t<this.array.length;t++){const e=this.array[t];for(let t=0;t<this.dimension[1];t++){const r=l.numericElement(e[t],"toLogical").toLogical();if(s.Complex.realEquals(r,0))return s.Complex.false()}}return s.Complex.true()}static expand=(t,e,r)=>{let s=t.dimension.slice(),i=e.slice();s.length<i.length&&(s=s.concat(new Array(i.length-s.length).fill(1))),i.length<s.length&&(i=i.concat(new Array(s.length-i.length).fill(1)));const n=i.map((t,e)=>Math.max(t,s[e]));if(l.arrayEquals(s,n))return;const a=r?l.blankValueForExpansion(r):t.isCell?l.emptyArray():l.blankValueForExpansion(t.array[0]?.[0]),o=new l(n,a,t.isCell);for(let e=0;e<l.linearLength(t);e++){const[r,s]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e),i=l.linearIndexToSubscript(t.dimension,e),[n,a]=l.subscriptToMultiArrayRowColumn(o.dimension,i);o.array[n][a]=t.array[r][s]}l.removeSingletonTail(o.dimension),t.dimension=o.dimension,t.array=o.array};static reshape=(t,e,r=-1)=>{const s=t.dimension.reduce((t,e)=>t*e,1),i=e.slice();if(-1!==r){i[r]=1;const t=i.reduce((t,e)=>t*e,1);if(!(t<=s&&Number.isInteger(s/t)))throw new Error(`reshape: SIZE is not divisible by the product of known dimensions (= ${t})`);i[r]=s/t}else if(s!==i.reduce((t,e)=>t*e,1))throw new Error(`reshape: can't reshape ${t.dimension.join("x")} array to ${i.join("x")} array`);let n;return t.dimension[1]===i[1]?(n=l.copy(t),n.dimension=i):(n=new l(i),l.rawMapLinearIndex(t,(t,e)=>{const[r,s]=l.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],e);return n.array[r][s]=t,t})),n.type=t.type,n.isCell=t.isCell,l.removeSingletonTail(n.dimension),n};static expandRange=(t,e,r)=>{const i=[],n=r?s.Complex.realToNumber(r):1;for(let r=s.Complex.realToNumber(t),a=0;n>0?r<=s.Complex.realToNumber(e):r>=s.Complex.realToNumber(e);r+=n,a++)i[a]=s.Complex.create(r);const a=new l([1,i.length]);return a.array=[i],l.setType(a),a};static expandColon=t=>{const e=new l([t,1]);for(let r=0;r<t;r++)e.array[r]=[s.Complex.create(r+1)];return l.setType(e),e};static haveAnyComplex=t=>{for(let e=0;e<t.dimension[0];e++)for(let r=0;r<t.dimension[1];r++)if(!s.Complex.imagIsZero(l.numericElement(t.array[e][r],"haveAnyComplex")))return!0;return!1};static testInteger=(t,e,r,i)=>{const n=(t,e,r)=>{throw new RangeError((t?t+": ":"")+e+" must be "+r)};if(s.Complex.realIsInteger(t)&&!s.Complex.realLessThan(t,1)||n(e,r,"either integers greater than or equal 1 or logicals."),!s.Complex.imagEquals(t,0))throw n(e,r,"real."),new RangeError((e?e+": ":"")+r+" must be real.");const a=s.Complex.realToNumber(t),o=typeof i;return"undefined"!==o&&("number"===o?a>i&&n(e,r,"less than or equal to "+i+" "):(a<i[0]&&n(e,r,"greater than or equal to"+i[0]+" "),a>i&&n(e,r,"less than or equal to"+i[1]+" "))),a};static testIndex=(t,e)=>{if(!s.Complex.realIsInteger(t)||s.Complex.realLessThan(t,1))throw new RangeError((e?`${e}: `:"")+"subscripts must be either integers greater than or equal 1 or logicals.");if(!s.Complex.imagEquals(t,0))throw new RangeError((e?`${e}: `:"")+"subscripts must be real.");return s.Complex.realToNumber(t)};static testIndexBound=(t,e,r,s)=>{const i=l.testIndex(t,s);if(i>e)throw new RangeError(`${s?`${s}: `:""}out of bound ${e} (dimensions are ${r.join("x")}).`);return i};static parseSubscript=(t,e,r,s)=>{const i=e.map(t=>l.testIndex(t,`${r||""}${s?"("+e.map(t=>s.Unparse(t)).join()+")":""}`)),n=(e,s)=>{const n=t=>t>4?`...[x${t}]...`:new Array(t).fill("_").join(),a=n(e),o=n(i.length-e-1);throw new RangeError(`${r||""}(${a}${a?",":""}${i[e]}${o?",":""}${o}): out of bound ${s} (dimensions are ${t.join("x")}).`)},a=i.slice();if(l.removeSingletonTail(a),a.length>t.length){const e=i.map((e,r)=>e>t[r]).indexOf(!0);e>=0&&n(e,1)}let o;if(i.length<t.length){o=t.slice();const e=i.map((e,r)=>e>t[r]).indexOf(!0);if(e>=0)if(e===i.length-1){const t=o.slice(i.length-1).reduce((t,e)=>t*e,1);i[i.length-1]>t&&n(e,t)}else n(e,o[e])}else{o=t.concat(new Array(i.length-t.length).fill(1));const e=i.map((e,r)=>e>t[r]).indexOf(!0);e>=0&&n(e,o[e])}return a.reduce((e,r,s)=>e+(r-1)*t.slice(0,s).reduce((t,e)=>t*e,1),0)};static scalarOpMultiArray=(t,e,r)=>{const i=new l(r.dimension);return i.array=r.array.map(r=>r.map(r=>s.Complex[t](e,r))),l.setType(i),i};static MultiArrayOpScalar=(t,e,r)=>{const i=new l(e.dimension);return i.array=e.array.map(e=>e.map(e=>s.Complex[t](e,r))),l.setType(i),i};static leftOperation=(t,e)=>{const r=new l(e.dimension);return r.array=e.array.map(e=>e.map(e=>s.Complex[t](e))),l.setType(r),r};static elementWiseOperation=(t,e,r)=>{let i=e.dimension.slice(),n=r.dimension.slice();const a=Math.max(i.length,n.length);for(;i.length<a;)i.push(1);for(;n.length<a;)n.push(1);const o=new Array(a),c=new Array(a),u=new Array(a);for(let e=0;e<a;e++){const r=i[e],s=n[e];if(r===s)o[e]=r,c[e]=u[e]=!1;else if(1===r)o[e]=s,c[e]=!0,u[e]=!1;else{if(1!==s)throw new EvalError(`operator ${t}: nonconformant arguments (op1 is ${i.join("x")}, op2 is ${n.join("x")}).`);o[e]=r,c[e]=!1,u[e]=!0}}const h=l.computeStrides(i),d=l.computeStrides(n),m=l.computeStrides(o),p=o.reduce((t,e)=>t*e,1),f=new l(o),g=i[0],y=g*(i[1]||1),x=n[0],C=x*(n[1]||1),E=o[0],A=E*(o[1]||1);for(let i=0;i<p;i++){let n=0,l=0;for(let t=0;t<a;t++){const e=Math.floor(i/m[t])%o[t],r=c[t]?0:e,s=u[t]?0:e;n+=r*h[t],l+=s*d[t]}const p=Math.floor(n/y),_=n-p*y,S=p*g+_%g,v=Math.floor(_/g),T=Math.floor(l/C),b=l-T*C,N=T*x+b%x,I=Math.floor(b/x),M=Math.floor(i/A),w=i-M*A,L=M*E+w%E,O=Math.floor(w/E);f.array[L][O]=s.Complex[t](e.array[S][v],r.array[N][I])}return l.setType(f),f};static rawMap=(t,e)=>{const r=new l(t.dimension);return r.array=t.array.map(t=>t.map(e)),l.setType(r),r};static rawMapRowColumn=(t,e)=>{const r=new l(t.dimension);return r.array=t.array.map((t,r)=>t.map((t,s)=>e(t,r,s))),l.setType(r),r};static rawMapLinearIndex=(t,e)=>{const r=new l(t.dimension);return r.array=t.array.map((r,s)=>r.map((r,i)=>e(r,Math.floor(s/t.dimension[0])*t.dimension[0]*t.dimension[1]+i*t.dimension[0]+s%t.dimension[0],s,i))),l.setType(r),r};static alongDimensionMap=(t,e,r)=>{const s=new l(e.dimension);if(t>=e.dimension.length)s.array=e.array.map((t,e)=>t.map((t,s)=>r(t,0,e,s)));else{const i=e.dimension.slice();i[t]=1;const n=i.reduce((t,e)=>t*e,1),a=i.map(t=>l.rangeArray(t));for(let o=0;o<n;o++)for(let n=1;n<=e.dimension[t];n++){const c=a.slice();c[t]=[n];const u=l.linearIndexToSubscript(i,o).map((t,e)=>c[e][t-1]),[h,d]=l.subscriptToMultiArrayRowColumn(e.dimension,u);s.array[h]||(s.array[h]=[]),s.array[h][d]=r(e.array[h][d],u[t]-1,h,d)}}return l.setType(s),s};static sizeAlongDimension=(t,e)=>{const r=void 0!==e?s.Complex.realToNumber(l.firstElement(e))-1:Math.max(0,l.firstNonSingleDimension(t));return t.dimension[r]};static getElementAlongDimension=(t,e,r)=>{const s=t.dimension;if(e<0||e>=s.length)throw new RangeError(`getElementAlongDimension: invalid dimension ${e} for array of ${s.length}D`);if(r<0||r>=s[e])throw new RangeError(`getElementAlongDimension: index ${r} out of bounds for dimension ${e} of size ${s[e]}`);const i=new Array(s.length).fill(1);i[e]=r+1;const n=l.subscriptToLinearIndex(s,i),[a,o]=l.linearIndexToMultiArrayRowColumn(s[0],s[1],n);return t.array[a][o]};static divideElementByScalar=(t,e)=>l.isInstanceOf(t)?l.rawMap(t,t=>s.Complex.rdiv(t,e)):s.Complex.rdiv(t,e);static getMeanElementForPosition=(t,e,r)=>l.isInstanceOf(t)?l.getElementAlongDimension(t,e,r-1):t;static reduceToArray=(t,e)=>{if(t>=e.dimension.length){const t=new l(e.dimension);return t.array=e.array.map(t=>t.map(t=>[t])),t.type=e.type,t}{const r=e.dimension.slice();r[t]=1;const s=new l(r),i=e.dimension.slice();i[t]=1;const n=i.reduce((t,e)=>t*e,1);for(let r=1;r<=e.dimension[t];r++){const i=e.dimension.slice();i[t]=1;const a=i.map(t=>l.rangeArray(t));a[t]=[r];for(let t=0;t<n;t++){const n=l.linearIndexToSubscript(i,t).map((t,e)=>a[e][t-1]),o=l.subscriptToLinearIndex(e.dimension,n),[c,u]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],o),[h,d]=l.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t);if(1===r)s.array[h][d]=[e.array[c][u]];else{const t=s.array[h][d];if(!l.isReducedArrayLine(t))throw new Error("reduceToArray: invalid reduced slot.");t.push(e.array[c][u])}}}return s.type=e.type,s}};static reduce=(t,e,r,s)=>{if(t>=e.dimension.length)return e;{const i=e.dimension.slice();i[t]=1;const n=new l(i),a=e.dimension.slice();a[t]=1;const o=a.reduce((t,e)=>t*e,1),c=a.map(t=>l.rangeArray(t));for(let t=0;t<o;t++){const i=l.linearIndexToSubscript(a,t).map((t,e)=>c[e][t-1]),o=l.subscriptToLinearIndex(e.dimension,i),[u,h]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],o),[d,m]=l.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[d][m]=s?r(s,e.array[u][h],t):e.array[u][h]}for(let s=2;s<=e.dimension[t];s++){const i=e.dimension.slice();i[t]=1;const a=i.map(t=>l.rangeArray(t));a[t]=[s];for(let s=0;s<o;s++){const o=l.linearIndexToSubscript(i,s).map((t,e)=>a[e][t-1]),c=l.subscriptToLinearIndex(e.dimension,o),[u,h]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],c),[d,m]=l.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],s),p=l.linearIndexToSubscript(n.dimension,s);p[t]=1;const[f,g]=l.subscriptToMultiArrayRowColumn(n.dimension,p);n.array[d][m]=r(n.array[f][g],e.array[u][h],s)}}return l.setType(n),l.MultiArrayToScalar(n)}};static concatenate=(t,e,...r)=>{const s=r.some(t=>!l.isEmpty(t))?r.filter(t=>!l.isEmpty(t)):r;let i,a;for(const t of s)for(const r of l.linearize(t)){const t=n.RuntimeValue.classDefinitionOfInstance(r);if(i){if(t&&t!==i)throw new Error(`${e}: object arrays must contain objects of the same class.`)}else i=t;if(l.isStructureScalar(r)){const t=l.structureFieldNames(r);if(a){if(!l.arrayEquals(t,a))throw new Error(`${e}: structure arrays must contain structures with the same fields.`)}else a=t}}const o=[],c=s.map(e=>{const r=e.dimension.slice();return l.appendSingletonTail(r,t+1),o.push(r[t]),r[t]=0,r});if(!c.every(t=>l.arrayEquals(t,c[0])))throw new EvalError(`${e}: dimension mismatch`);const u=c[0].slice();u[t]=o.reduce((t,e)=>t+e,0);const h=new l(u);return s.forEach((e,r)=>{const s=o.slice(0,r).reduce((t,e)=>t+e,0);for(let r=0;r<l.linearLength(e);r++){const i=e.dimension.slice();l.appendSingletonTail(i,t+1);const n=l.linearIndexToSubscript(i,r);n[t]+=s;const[a,o]=l.subscriptToMultiArrayRowColumn(h.dimension,n),[c,u]=l.linearIndexToMultiArrayRowColumn(e.dimension[0],e.dimension[1],r);h.array[a][o]=e.array[c][u]}}),l.setType(h),h};static splitLastDimension=t=>{const e=[],r=t.dimension[t.dimension.length-1];for(let s=0;s<r;s++){const i=t.array.length/r,n=new l(t.dimension.slice(0,-1));n.array=t.array.slice(s*i,(s+1)*i),e.push(n)}return e};static evaluateRecursive=(t,e,r)=>{if(t.dimension.length>2)return l.concatenate(t.dimension.length-1,"evaluate",...l.splitLastDimension(t).map(t=>l.scalarToMultiArray(l.evaluateRecursive(t,e,r))));{const s=[],n=t.array.map(n=>{const a=n.flatMap(t=>(t=>{if(!e)return[t];e.context.pushCommaListExpansion();try{return e.context.expandCommaSeparatedList(e.Evaluator(t,r))}finally{e.context.popCommaListExpansion()}})(t)),o=a.length>1?e?.concatenateOverload?.("horzcat",a,t):void 0;if(void 0!==o)return s.push(o),l.scalarToMultiArray(o);if(s.push(void 0),l.isCharStringList(a)&&a.every(i.CharString.isChar)){const t=a[0].quote;return l.scalarToMultiArray(i.CharString.fromCharacterScalars(a,t))}return l.concatenate(1,"evaluate",...a.map(t=>l.scalarToMultiArray(t)))});if(1===n.length&&void 0!==s[0])return s[0];const a=n.map(t=>l.MultiArrayToScalar(t)),o=e?.concatenateOverload?.("vertcat",a,t);return void 0!==o?o:l.concatenate(0,"evaluate",...n)}};static evaluate=(t,e,r)=>{if(l.isEmpty(t))return t;if(t.isCell){const s=t.array.map(s=>s.flatMap(s=>(()=>{if(!e)return[s];e.context.pushCommaListExpansion();try{return e.context.expandCommaSeparatedList(e.Evaluator(s,r))}finally{e.context.popCommaListExpansion()}})().map(e=>(e&&(e.parent=t),e))));if(s.length>1&&s.some(t=>t.length!==s[0].length))throw new EvalError("evaluate: dimension mismatch");const i=new l([s.length,s[0]?.length??0],void 0,!0);return i.array=s,i.array.forEach(t=>t.forEach(t=>{t&&(t.parent=i)})),i}{const s=l.evaluateRecursive(t,e,r);return l.isInstanceOf(s)?(s.isCell=t.isCell,l.setType(s),2===s.dimension.length&&1===s.dimension[0]&&1===s.dimension[1]&&i.CharString.isInstanceOf(s.array[0][0])?s.array[0][0]:s):s}};static colon(t){const e=new l([1,t],s.Complex.zero());for(let r=0;r<t;r++)e.array[0][r]=s.Complex.create(r+1);return e}static computeIndexingStructure=(t,e)=>{if(0===e.length)throw new RangeError("invalid empty index list.");const r=t.length,i=e.length;if(1===e.length){const r=e[0],n=l.linearize(r),a=t.reduce((t,e)=>t*e,1);return{isLinear:!0,isLinearColonOnly:l.isInstanceOf(r)&&l.isColumnVector(r)&&n.length===a&&n.every((t,e)=>s.Complex.isInstanceOf(t)&&s.Complex.realToNumber(t)===e+1),linearIndexDimension:l.isInstanceOf(r)?r.dimension.slice():[1,1],originalIndexCount:i,args:[n],argsLength:[n.length],total:n.length}}const n=e.slice();for(;n.length<r;)n.push(l.colon(t[n.length]));const a=n.map((e,r)=>l.linearize(((e,r)=>{if(!l.isLogicalIndex(e))return e;const i=l.logicalMaskFromIndexArgument(e),n=l.linearizedLogicalMask(i),a=[];for(let e=0;e<n.length;e++){if(e>=t[r])throw new RangeError(`logical index out of bound ${t[r]}.`);s.Complex.realToNumber(n[e])&&a.push(s.Complex.create(e+1))}return l.toColumnVector(a)})(e,r))),o=a.map(t=>t.length),c=o.reduce((t,e)=>t*e,1);return{isLinear:!1,isLinearColonOnly:!1,originalIndexCount:i,args:a,argsLength:o,total:c}};static iterateWithLinearIndex=(t,e,r,s,i)=>{for(let n=0;n<t.total;n++){const a=l.linearIndexToSubscript(t.argsLength,n).map((e,r)=>t.args[r][e-1]);r(a,l.parseSubscript(e,a,s,i),n)}};static resolveIndexPlan=(t,e)=>{const r=t.length;if(e.isLinear)return{isLinear:!0,isColonOnly:e.isLinearColonOnly,isRowSelection:!1,isColumnSelection:!1,requiresCollapse:!1,activeDimensions:[0],isFullSlice:[e.isLinearColonOnly],isScalarIndex:[1===e.argsLength[0]]};const s=e.argsLength.slice();for(;s.length<r;)s.push(t[s.length]);const i=[],n=[],a=[];for(let e=0;e<r;e++){const r=s[e],o=r===t[e],l=1===r;i.push(o),n.push(l),o||a.push(e)}return{isLinear:!1,isColonOnly:!1,isRowSelection:2===e.originalIndexCount&&1===e.argsLength[0],isColumnSelection:2===e.originalIndexCount&&1===e.argsLength[1],requiresCollapse:e.originalIndexCount<r,activeDimensions:a,isFullSlice:i,isScalarIndex:n}};static getElementByLinearIndex=(t,e,r)=>{const[s,i]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);return r.length>0?l.getStructureField(t.array[s][i],r):t.array[s][i]};static setElementByLinearIndex=(t,e,r,s)=>{const[i,n]=l.linearIndexToMultiArrayRowColumn(t.dimension[0],t.dimension[1],e);s.length>0?l.structureAssignFieldPath(t.array[i][n],s,r):t.array[i][n]=r};static collapseResult=(t,e,r,s)=>{if(!s.requiresCollapse)return t;const i=l.linearize(t);if(2===r.originalIndexCount&&1===r.argsLength[1]){const e=r.argsLength[0],s=new l([e,1]);for(let r=0;r<e;r++)s.array[r][0]=t.array[r][0];return l.setType(s),s}if(2===r.originalIndexCount&&1===r.argsLength[0]){const t=l.toRowVector(i);return l.setType(t),t}if(t.dimension.length>2){const e=t.dimension[0],r=i.length/e,s=new l([e,r]);let n=0;for(let t=0;t<r;t++)for(let r=0;r<e;r++)s.array[r][t]=i[n++];return l.setType(s),s}return t};static linearIndexResult=(t,e,r,s)=>{if(s.isColonOnly)return l.toColumnVector(e);const i=r.linearIndexDimension??[1,e.length];if(l.arrayIsVector(t)&&2===i.length&&(1===i[0]||1===i[1]))return l.isRowVector(t)?l.toRowVector(e):l.toColumnVector(e);const n=new l(i);for(let t=0;t<e.length;t++){const[r,s]=l.linearIndexToMultiArrayRowColumn(n.dimension[0],n.dimension[1],t);n.array[r][s]=e[t]}return n};static logicalIndexResult=(t,e,r)=>l.arrayIsVector(t)&&l.arrayIsVector(r)?l.isRowVector(t)?l.toRowVector(e):l.toColumnVector(e):l.arrayIsVector(r)&&l.isRowVector(r)?l.toRowVector(e):l.toColumnVector(e);static logicalMaskFromIndexArgument=t=>s.Complex.isInstanceOf(t)?l.scalarToMultiArray(t):t;static linearizedLogicalMask=(t,e)=>{const r=l.linearize(t);if(!r.every(s.Complex.isInstanceOf))throw new EvalError(`${e??""}: invalid logical index.`);return r};static logicalToLinearIndices=(t,e,r)=>{const i=l.linearize(t),n=l.linearizedLogicalMask(e,r);if(n.length>i.length)throw new EvalError(`${r??""}(${n.length}): out of bound ${i.length} (dimensions are ${t.dimension.join("x")})`);const a=[];for(let t=0;t<n.length;t++)s.Complex.realToNumber(n[t])&&a.push(t);return a};static logicalMaskToIndexList=(t,e,r)=>l.logicalToLinearIndices(t,e,r);static isLogicalIndex(t){return l.isInstanceOf(t)&&t.type===s.Complex.LOGICAL||s.Complex.isInstanceOf(t)&&t.type===s.Complex.LOGICAL}static applyLinearSelection=(t,e,r)=>{const s=[];for(const i of e)s.push(l.getElementByLinearIndex(t,i,r));return s};static applyLinearAssignment=(t,e,r,s)=>{const i=1===r.length;if(!i&&r.length!==e.length)throw new EvalError(`=: nonconformant arguments (op1 is ${e.length}x1, op2 is ${r.length}x1)`);for(let n=0;n<e.length;n++){const a=i?r[0]:r[n];l.setElementByLinearIndex(t,e[n],a,s)}};static resolveLinearIndices=(t,e,r,s)=>{if(1===r.length&&l.isLogicalIndex(r[0])){const s=l.logicalMaskFromIndexArgument(r[0]);return l.logicalToLinearIndices(t,s,e)}const i=l.computeIndexingStructure(t.dimension,r),n=[];return l.iterateWithLinearIndex(i,t.dimension,(t,e)=>{n.push(e)},e,s),n};static collectLinearIndices=(t,e,r,s)=>{const i=[];return l.iterateWithLinearIndex(t,e,(t,e)=>{i.push(e)},r,s),i};static applyDeletionFromIndices=(t,e)=>{const r=l.linearize(t),s=new Set(e),i=r.filter((t,e)=>!s.has(e));let n;n=l.arrayIsVector(t)&&l.isRowVector(t)?l.toRowVector(i):l.toColumnVector(i),t.array=n.array,t.dimension=n.dimension};static getElements=(t,e,r,s,i)=>{if(0===s.length)return t;const n=l.resolveLinearIndices(t,e,s,i),a=l.applyLinearSelection(t,n,r);if(1===s.length&&l.isLogicalIndex(s[0])){const e=l.logicalMaskFromIndexArgument(s[0]),r=l.logicalIndexResult(t,a,e);return l.setType(r),r}const o=l.computeIndexingStructure(t.dimension,s),c=l.resolveIndexPlan(t.dimension,o);if(o.isLinear){const e=l.linearIndexResult(t,a,o,c);return l.setType(e),e}const u=new l(o.argsLength);for(let t=0;t<a.length;t++){const[e,r]=l.subscriptToMultiArrayRowColumn(u.dimension,l.linearIndexToSubscript(u.dimension,t));u.array[e][r]=a[t]}return l.setType(u),l.collapseResult(u,t.dimension,o,c)};static setElementsNumerical=(t,e,r,s,i,n,a)=>{const o=l.linearize(i),c=r.length>0&&0===o.length?[i]:o;if(0===c.length){const r=t.resolveName(e);if(!(r&&r.node instanceof l))throw new RangeError(`A(I) = []: index out of bounds: value ${l.firstElement(s[0])} out of bound 0`);return void l.deleteElements(r.node,s,n,a)}if(0===s.length)throw new RangeError("invalid empty index list.");const u=t.resolveName(e),h=u?.node,d=l.computeIndexingStructure(h instanceof l?h.dimension:[1],s);if(1!==c.length&&c.length!==d.total)throw new RangeError(`=: nonconformant arguments (op1 is ${d.argsLength.join("x")}, op2 is ${i.dimension.join("x")})`);let m=u;const p=d.args.map(t=>Math.max(...t.map(t=>l.testIndex(t))));if(m)if(m.node instanceof l)if(d.isLinear){if(p[0]>l.linearLength(m.node))if(l.isEmpty(m.node)){const t=r.length>0?l.createStructureValue(r):m.node.isCell?void 0:l.blankValueForExpansion(c[0]);l.expand(m.node,[1,p[0]],t)}else{if(!l.arrayIsVector(m.node))throw new RangeError("Invalid resizing operation or ambiguous assignment to an out-of-bounds array element.");1===m.node.dimension[0]?l.expand(m.node,[1,p[0]]):l.expand(m.node,[p[0],1])}}else l.expand(m.node,p);else{const r=m.node,s=l.blankValueForExpansion(r);if(m=d.isLinear?t.defineName(e,new l([1,p[0]],s)):t.defineName(e,new l(p,s)),!(m.node instanceof l))throw new TypeError("internal error: index assignment target is not an array.");m.node.array[0][0]=r}else{const s=0===r.length&&i.isCell,n=r.length>0?l.createStructureValue(r):s?l.emptyArray():l.blankValueForExpansion(c[0]);m=d.isLinear?t.defineName(e,new l([1,p[0]],n,s)):t.defineName(e,new l(p,n,s))}if(!(m.node instanceof l))throw new TypeError("internal error: index assignment target is not an array.");const f=m.node;r.length>0&&l.setEmptyStructureField(f,r[0]);const g=f.dimension.slice(),y=l.collectLinearIndices(d,g,n,a);l.applyLinearAssignment(f,y,c,r)};static setElements=(t,e,r,s,i,n,a)=>{if(1===s.length&&l.isLogicalIndex(s[0])){const n=l.logicalMaskFromIndexArgument(s[0]),a=t.resolveName(e);if(!(a&&a.node instanceof l))throw new EvalError(`${e}(_): invalid matrix indexing.`);const o=a.node,c=l.logicalMaskToIndexList(o,n,e),u=l.linearize(i),h=r.length>0&&0===u.length?[i]:u;if(0===h.length){const t=l.linearize(o),e=new Set(c),r=t.filter((t,r)=>!e.has(r));let s;return s=l.isRowVector(o)?l.toRowVector(r):l.toColumnVector(r),o.array=s.array,void(o.dimension=s.dimension)}return void l.applyLinearAssignment(o,c,h,r)}l.setElementsNumerical(t,e,r,s,i,n,a)};static deleteElements=(t,e,r,s)=>{if(0===e.length)throw new RangeError("invalid empty index list.");const i=l.computeIndexingStructure(t.dimension,e);if(i.isLinear){const e=l.collectLinearIndices(i,t.dimension,r,s);return void l.applyDeletionFromIndices(t,e)}let n=-1;for(let e=0;e<i.argsLength.length;e++)if(i.argsLength[e]!==t.dimension[e]){if(-1!==n)throw new RangeError("a null assignment can only have one non-colon index");n=e}if(-1===n)throw new RangeError("a null assignment can only have one non-colon index");const a=l.collectLinearIndices(i,t.dimension,r,s),o=new Set(a),c=t.dimension.slice();c[n]=0;const u=l.linearize(t),h=[];for(let t=0;t<u.length;t++)o.has(t)||h.push(u[t]);const d=u.length/t.dimension[n],m=h.length/d;c[n]=m;const p=new l(c);let f=0;for(let t=0;t<h.length;t++){const[e,r]=l.subscriptToMultiArrayRowColumn(p.dimension,l.linearIndexToSubscript(p.dimension,t));p.array[e][r]=h[f++]}l.setType(p),t.array=p.array,t.dimension=p.dimension};static reduceFactory=(t,e,r)=>{switch(e){case"reduce":return void 0!==r?(e,i)=>{const n=l.scalarToMultiArray(e),a=void 0!==i?s.Complex.realToNumber(l.firstElement(i))-1:Math.max(0,l.firstNonSingleDimension(n));return l.reduce(a,n,t,r)}:(e,r)=>{const i=l.scalarToMultiArray(e),n=void 0!==r?s.Complex.realToNumber(l.firstElement(r))-1:Math.max(0,l.firstNonSingleDimension(i));return l.reduce(n,i,t)};case"cumulative":return void 0!==r?(e,i)=>{const n=l.scalarToMultiArray(e),a=void 0!==i?s.Complex.realToNumber(l.firstElement(i))-1:l.firstNonSingleDimension(n),o=l.alongDimensionMap(a,n,(c=void 0,(e,s)=>c=t(0===s?r:c,e)));var c;return l.setType(o),o}:(e,r)=>{const i=l.scalarToMultiArray(e),n=void 0!==r?s.Complex.realToNumber(l.firstElement(r))-1:l.firstNonSingleDimension(i),a=l.alongDimensionMap(n,i,(o=void 0,(e,r)=>o=0===r?e:t(o,e)));var o;return l.setType(a),a};case"cumcomparison":return(e,r)=>{const i=l.scalarToMultiArray(e),n=r?s.Complex.realToNumber(l.firstElement(r))-1:l.firstNonSingleDimension(i),a=new l(i.dimension);let c,u;const h=l.alongDimensionMap(n,i,(e,r,i,n)=>(0===r?(c=e,u=s.Complex.one()):s.Complex.realToNumber(s.Complex[t](e,c))&&(c=e,u=s.Complex.create(r+1)),a.array[i][n]=u,c));return l.setType(h),l.setType(a),o(2,(t,e)=>{if(1===t.length)return l.MultiArrayToScalar(h);if(2===t.length)return l.MultiArrayToScalar(0===e?h:a);throw new EvalError("unreachable cumulative comparison return-list selector branch.")},t=>({length:t}))};case"comparison":const i="lt"===t?"min":"max";return(...e)=>{const r=(e,r)=>{const n=l.reduceToArray(r,e),a=new l(n.dimension),c=new l(n.dimension);for(let e=0;e<c.array.length;e++)for(let r=0;r<c.array[e].length;r++){const o=n.array[e][r];if(!l.isReducedComplexArrayLine(o))throw new Error(`${i}: invalid reduced array slot.`);let u=o[0],h=1;for(let e=1;e<o.length;e++){const r=o[e];s.Complex.realToNumber(s.Complex[t](r,u))&&(u=r,h=e+1)}a.array[e][r]=u,c.array[e][r]=s.Complex.create(h)}return l.setType(a),l.setType(c),o(2,(t,e)=>{if(1===t.length)return l.MultiArrayToScalar(a);if(2===t.length)return l.MultiArrayToScalar(0===e?a:c);throw new EvalError("unreachable comparison return-list selector branch.")},t=>({length:t}))};switch(e.length){case 1:{const t=l.scalarToMultiArray(e[0]);return r(t,l.firstNonSingleDimension(t))}case 2:{const t=l.scalarToMultiArray(e[0]),s=e[1];if(l.isScalar(s))return r(t,l.testInteger(s,"reduceFactory","dimension",[1,1/0])-1);const n=l.scalarToMultiArray(s);return l.elementWiseOperation(i+"Wise",t,n)}case 3:if(!l.isEmpty(e[1]))throw new Error(`${i}: second argument must be [] or omitted`);return r(l.scalarToMultiArray(e[0]),s.Complex.realToNumber(l.firstElement(e[2]))-1);default:(t=>{throw new EvalError(`Invalid call to ${t}.`)})(i)}};default:throw TypeError(`reduceFactory: invalid type argument: ${e}`)}}}e.MultiArray=l,e.default={MultiArray:l}},6430(t,e,r){"use strict";e.ParserErrorListener=void 0;const s=r(3222),i=r(2697);class n extends s.ErrorListener{source;constructor(t=""){super(),this.source=t}syntaxError(t,e,r,s,n,a){if(!i.SyntaxDiagnostic.isBenignEndOfInput(n))throw i.SyntaxDiagnostic.error(n,r,s,this.source)}}e.ParserErrorListener=n},7673(t,e){"use strict";e.RuntimeEquality=void 0;class r{static isObject=t=>!!t&&"object"==typeof t;static isComplexLike=t=>r.isObject(t)&&Object.prototype.hasOwnProperty.call(t,"re")&&Object.prototype.hasOwnProperty.call(t,"im");static isCharStringLike=t=>r.isObject(t)&&"string"==typeof t.str;static isArrayLike=t=>r.isObject(t)&&Array.isArray(t.dimension)&&Array.isArray(t.array)&&"boolean"==typeof t.isCell;static isStructureLike=t=>r.isObject(t)&&r.isObject(t.field);static isFunctionHandleLike=t=>r.isObject(t)&&5===t.type;static isClassInstanceLike=t=>r.isObject(t)&&7===t.type&&r.isObject(t.classDefinition)&&r.isObject(t.properties);static isClassEnumerationValueLike=t=>r.isObject(t)&&10===t.type&&r.isObject(t.classDefinition)&&r.isObject(t.enumeration)&&"string"==typeof t.enumeration.name&&Array.isArray(t.args);static scalarPartEqual=(t,e)=>{if(t===e)return!0;const s=r.partToString(t),i=r.partToString(e);return void 0!==s&&s===i};static partToString=t=>"number"==typeof t||"bigint"==typeof t||"boolean"==typeof t||"string"==typeof t?String(t):r.isObject(t)&&"function"==typeof t.toString?t.toString():void 0;static valuesEqual=(t,e)=>t===e||(null===t||null===e||void 0===t||void 0===e?t===e:r.isComplexLike(t)&&r.isComplexLike(e)?r.scalarPartEqual(t.re,e.re)&&r.scalarPartEqual(t.im,e.im):r.isCharStringLike(t)&&r.isCharStringLike(e)?t.str===e.str:r.isArrayLike(t)&&r.isArrayLike(e)?r.multiArraysEqual(t,e):r.isStructureLike(t)&&r.isStructureLike(e)?r.structuresEqual(t,e):r.isFunctionHandleLike(t)&&r.isFunctionHandleLike(e)?t.id===e.id&&r.functionHandleString(t)===r.functionHandleString(e):r.isClassInstanceLike(t)&&r.isClassInstanceLike(e)?t.classDefinition===e.classDefinition&&(t.classDefinition.isHandleClass()||e.classDefinition.isHandleClass()?t===e:r.propertyTablesEqual(t.properties,e.properties)):!(!r.isClassEnumerationValueLike(t)||!r.isClassEnumerationValueLike(e))&&t.classDefinition===e.classDefinition&&t.enumeration.name===e.enumeration.name&&r.elementListsEqual(t.args,e.args));static functionHandleString=t=>t.id?"@"+t.id:"@anonymous function handle";static multiArraysEqual=(t,e)=>t.isCell===e.isCell&&r.arrayEquals(t.dimension,e.dimension)&&r.elementListsEqual(r.linearize(t),r.linearize(e));static structuresEqual=(t,e)=>r.propertyTablesEqual(t.field,e.field);static propertyTablesEqual=(t,e)=>{const s=Object.keys(t).sort(),i=Object.keys(e).sort();return r.arrayEquals(s,i)&&s.every(s=>r.valuesEqual(t[s],e[s]))};static elementListsEqual=(t,e)=>t.length===e.length&&t.every((t,s)=>r.valuesEqual(t,e[s]));static arrayEquals=(t,e)=>t.length===e.length&&t.every((t,r)=>t===e[r]);static linearize=t=>{const e=[];for(let r=0;r<t.array.length;r+=t.dimension[0])for(let s=0;s<t.dimension[1];s++)e.push(...t.array.slice(r,r+t.dimension[0]).map(t=>t[s]));return e}}e.RuntimeEquality=r},1604(t,e){"use strict";e.RuntimeValue=void 0;class r{static FUNCTION_HANDLE=5;static CLASS_INSTANCE=7;static structureFactory;static hasCopy=t=>!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof Reflect.get(t,"copy");static copy=t=>r.hasCopy(t)?t.copy():t;static hasOwnField=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);static registerStructureFactory=t=>{r.structureFactory=t};static createStructure=t=>{if(!r.structureFactory)throw new Error("runtime structure factory is not registered.");return r.structureFactory(t)};static isClassInstance=t=>"object"==typeof t&&null!==t&&Reflect.get(t,"type")===r.CLASS_INSTANCE&&r.isNamedClassDefinition(Reflect.get(t,"classDefinition"))&&r.isObjectRecord(Reflect.get(t,"properties"));static classDefinitionOfInstance=t=>r.isClassInstance(t)?t.classDefinition:void 0;static hasDimensions=t=>"object"==typeof t&&null!==t&&r.isNumericDimensionVector(Reflect.get(t,"dimension"));static isObjectRecord=t=>"object"==typeof t&&null!==t;static isNamedClassDefinition=t=>r.isObjectRecord(t)&&"string"==typeof Reflect.get(t,"name");static isNumericDimensionVector=t=>Array.isArray(t)&&t.every(t=>"number"==typeof t);static dimensions=(t,e=2)=>{const s=r.hasDimensions(t)?t.dimension.slice():[1,1];for(;s.length<e;)s.push(1);return s};static elementCount=t=>r.dimensions(t).reduce((t,e)=>t*e,1);static isEmpty=t=>r.dimensions(t).some(t=>0===t);static isScalar=t=>1===r.elementCount(t);static isMatrix=t=>2===r.dimensions(t).length;static isVector=t=>{const e=r.dimensions(t);return 2===e.length&&(1===e[0]||1===e[1])};static isRowVector=t=>{const e=r.dimensions(t);return 2===e.length&&1===e[0]};static isColumnVector=t=>{const e=r.dimensions(t);return 2===e.length&&1===e[1]};static isSquareMatrix=t=>{const e=r.dimensions(t);return 2===e.length&&e[0]===e[1]}}e.RuntimeValue=r},2981(t,e){"use strict";e.Scope=void 0;class r{parent;nameTable;functionTable;undefinedReferenceTable;importTable;resolveParentNames;assignExistingParentNames;rejectDynamicNameCreation;staticWorkspaceNameSet;globalDeclarationTarget;constructor(t,e=Object.create(null),r=Object.create(null),s=Object.create(null),i={explicit:Object.create(null),wildcard:[]},n=!0,a=!1,o=!1,l){this.parent=t,this.nameTable=e,this.functionTable=r,this.undefinedReferenceTable=s,this.importTable=i,this.resolveParentNames=n,this.assignExistingParentNames=a,this.rejectDynamicNameCreation=o,this.staticWorkspaceNameSet=l}static create=(t,e=!0)=>new r(t,Object.create(null),Object.create(null),Object.create(null),{explicit:Object.create(null),wildcard:[]},e);defineName(t,e,r){const s=this.nameTable[t];if(s)return s.node=e,r?s.undefinedReference=r:delete s.undefinedReference,s;if(!this.canCreateLocalName(t))throw new Error(`Attempt to add variable '${t}' to a static workspace.`);return this.nameTable[t]=r?{undefinedReference:r,node:e}:{node:e}}assignName(t,e,r){if(this.assignExistingParentNames&&!this.hasLocalName(t)&&this.parent){const s=this.parent.resolveName(t);if(s)return s.node=e,r?s.undefinedReference=r:delete s.undefinedReference,s}if(!this.canCreateLocalName(t))throw new Error(`Attempt to add variable '${t}' to a static workspace.`);return this.defineName(t,e,r)}canCreateLocalName(t){return!this.rejectDynamicNameCreation||this.hasLocalName(t)||Boolean(this.staticWorkspaceNameSet?.has(t))}allowStaticWorkspaceName(t){(this.staticWorkspaceNameSet??=new Set).add(t)}allowStaticWorkspaceNames(t){for(const e of t)this.allowStaticWorkspaceName(e)}defineNameTable(t){for(const[e,r]of Object.entries(t))this.nameTable[e]={node:r}}resolveName(t){return this.nameTable[t]||(this.resolveParentNames&&this.parent?this.parent.resolveName(t):void 0)}hasLocalName(t){return t in this.nameTable}removeName(t){delete this.nameTable[t]}clearName(t){let e=this;for(;e;)delete e.nameTable[t],e=e.parent}defineFunction(t,e){return this.functionTable[t]=e}defineFunctionTable(t){Object.assign(this.functionTable,t)}resolveFunction(t){return this.functionTable[t]||(this.parent?this.parent.resolveFunction(t):void 0)}hasLocalFunction(t){return t in this.functionTable}removeFunction(t){delete this.functionTable[t]}clearFunction(t){let e=this;for(;e;)delete e.functionTable[t],e=e.parent}bindParameters(t,e){for(let r=0;r<t.length;r++)this.defineName(t[r],e[r])}bindParametersChecked(t,e){if(t.length!==e.length)throw new Error(`Arity mismatch: expected ${t.length} argument(s), got ${e.length}`);this.bindParameters(t,e)}defineUndefinedReference(t,e){const r=this.resolveUndefinedReference(t);return r?(r.add(e),r):this.undefinedReferenceTable[t]=new Set([e])}resolveUndefinedReference(t){return this.undefinedReferenceTable[t]||(this.parent?this.parent.resolveUndefinedReference(t):void 0)}removeUndefinedReference(t){delete this.undefinedReferenceTable[t]}clearUndefinedReference(t){let e=this;for(;e;)delete e.undefinedReferenceTable[t],e=e.parent}defineImport(t){if(t.endsWith(".*")){const e=t.slice(0,-2);return void(e&&!this.importTable.wildcard.includes(e)&&this.importTable.wildcard.push(e))}const e=t.split(".").pop()??t;if(e){const r=this.importTable.explicit[e]??=[];r.includes(t)||r.push(t)}}clearImports(){this.importTable.explicit=Object.create(null),this.importTable.wildcard=[]}importSnapshot(){return{explicit:r.cloneExplicitImports(this.importTable.explicit),wildcard:this.importTable.wildcard.slice()}}restoreImports(t){this.importTable={explicit:r.cloneExplicitImports(t.explicit),wildcard:t.wildcard.slice()}}importList(){const t=[],e=new Set;let r=this;for(;r;){for(const s of Object.values(r.importTable.explicit))for(const r of s)e.has(r)||(e.add(r),t.push(r));for(const s of r.importTable.wildcard){const r=`${s}.*`;e.has(r)||(e.add(r),t.push(r))}r=r.parent}return t}importedNameCandidates(t){const e=[];let r=this;for(;r;){const s=r.importTable.explicit[t];if(s?.length){e.push(...s);break}for(const s of r.importTable.wildcard)e.push(`${s}.${t}`);r=r.parent}return e}snapshot(t){const e=this.parent?this.parent.snapshot(t):void 0,s=r.create(e);for(const[e,r]of Object.entries(this.nameTable))s.nameTable[e]={...r,node:void 0!==r.node?t(r.node):r.node};s.functionTable={...this.functionTable},s.undefinedReferenceTable=Object.create(null);for(const[t,e]of Object.entries(this.undefinedReferenceTable))s.undefinedReferenceTable[t]=new Set(e);return s.importTable.explicit=r.cloneExplicitImports(this.importTable.explicit),s.importTable.wildcard=[...this.importTable.wildcard],s.assignExistingParentNames=this.assignExistingParentNames,s.rejectDynamicNameCreation=this.rejectDynamicNameCreation,s.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,s}capture(t,e=!0){const s=r.create(this,e);for(const[e,r]of Object.entries(this.nameTable))s.nameTable[e]={...r,node:void 0!==r.node?t(r.node):r.node};s.functionTable={...this.functionTable},s.undefinedReferenceTable=Object.create(null);for(const[t,e]of Object.entries(this.undefinedReferenceTable))s.undefinedReferenceTable[t]=new Set(e);return s.importTable.explicit=r.cloneExplicitImports(this.importTable.explicit),s.importTable.wildcard=[...this.importTable.wildcard],s.assignExistingParentNames=this.assignExistingParentNames,s.rejectDynamicNameCreation=this.rejectDynamicNameCreation,s.staticWorkspaceNameSet=this.staticWorkspaceNameSet?new Set(this.staticWorkspaceNameSet):void 0,s}static cloneExplicitImports(t){const e=Object.create(null);for(const[r,s]of Object.entries(t))e[r]=s.slice();return e}}e.Scope=r},9274(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TableSourceResolver=e.ManifestSourceResolver=void 0;const r=(t,e,r)=>{if(void 0!==e)return"string"==typeof e?{name:t,sourceName:r,source:e}:{name:e.name??t,sourceName:e.sourceName??r,source:e.source}},s=t=>/[\\/]/.test(t)||/\.m(?:[?#].*)?$/i.test(t)?t.replace(/\\/g,"/"):void 0,i=t=>t.replace(/\\/g,"/").split(/[?#]/,1)[0],n=t=>i(t).split("/").pop()?.replace(/\.m$/i,"")??t,a=t=>{const e=i(t).replace(/^\.\//,"").replace(/\.m$/i,"").split("/").filter(Boolean),r=[];for(let t=0;t<e.length;t++){const s=e[t];if(s.startsWith("+"))r.push(s.slice(1));else if(s.startsWith("@")){const i=s.slice(1);r.push(i),t===e.length-2&&e[t+1]===i&&t++}else t===e.length-1&&r.push(s)}return r.join(".")},o=t=>i(t).replace(/^\.\//,"").replace(/\/+$/g,""),l=t=>{if(!t.includes(".")||/[\\/]/.test(t))return;const e=t.split(".").filter(Boolean),r=e.pop();return r?`${e.map(t=>`+${t}`).join("/")}/${r}.m`:void 0},c=(t,e)=>{const r=(t=>{const e=o(t),r=[e];if(!/[\\/]/.test(e)&&!e.startsWith("+")&&!e.startsWith("@")){const t=e.split(".").filter(Boolean).map(t=>`+${t}`).join("/");t&&r.push(t)}return[...new Set(r)]})(t);return e.some(t=>Boolean(t&&Object.entries(t).some(([t,e])=>((t,e)=>{const r=[t],s=l(t);if(s&&r.push(s),"string"!=typeof e){if(e.name){r.push(e.name);const t=l(e.name);t&&r.push(t)}e.sourceName&&r.push(e.sourceName)}return r.map(o)})(t,e).some(t=>r.some(e=>t!==e&&t.startsWith(`${e}/`))))))},u=t=>{const e=a(t);return[...new Set([t,e])]},h=t=>{const e=a(t);return[...new Set([t,n(t),e,n(e)])]},d=(t,e,i)=>{for(const n of t){const t=e?.[n]??i?.(n);if(void 0!==t)return r(n,t,s(n))}},m=(t,e)=>{for(const s of t){const t=e[s];if(t)return r(s,t)}},p=(t,e,i,n=t=>t)=>{if(!e)return;const a=new Set(t.map(i));for(const[t,o]of Object.entries(e)){if(a.has(i(t)))return r(n(t),o,s(t));if("string"!=typeof o&&o.name&&a.has(i(o.name)))return r(n(o.name),o,s(o.name));if("string"!=typeof o&&o.sourceName&&a.has(i(o.sourceName)))return r(n(o.sourceName),o,s(o.sourceName))}},f=(t,e)=>/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:t?`${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`:e;class g{config;constructor(t){this.config=t}static create=(t={})=>new g(t);resolve(t,e){switch(t){case"function":{const t=u(e);return d(t,this.config.functionSourceTable,this.config.functionSourceProvider)??p(t,this.config.functionSourceTable,a,a)}case"script":return d(h(e),this.config.scriptSourceTable,this.config.scriptSourceProvider)??p(h(e),this.config.scriptSourceTable,n);case"class":{const t=u(e);return d(t,this.config.classSourceTable,this.config.classSourceProvider)??p(t,this.config.classSourceTable,a,a)}}}hasDirectory(t){return c(t,[this.config.functionSourceTable,this.config.scriptSourceTable,this.config.classSourceTable])}}e.TableSourceResolver=g;class y{sources;constructor(t){this.sources=t}static fromTable=t=>{const e={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const[i,o]of Object.entries(t)){const t="string"==typeof o?[i]:[i,...o.sourceName?[o.sourceName]:[],...o.name?[o.name]:[]];for(const i of t){const t=a(i),l=n(i),c=s(i),d=r(t,o,c),m=r(l,o,c);for(const t of u(i))e.function[t]=d,e.class[t]=d;for(const t of h(i))e.script[t]=m}}return new y(e)};static fromManifest=async(t,e=globalThis.fetch)=>{if(!e)throw new Error("ManifestSourceResolver.fromManifest requires a fetch implementation.");const r={function:Object.create(null),script:Object.create(null),class:Object.create(null)};for(const s of t.files){const i="string"==typeof s?{path:s}:s,o=f(t.baseUrl,i.path),l=await e(o);if(!1===l.ok)throw new Error(`failed to fetch ${o}: ${l.status??""} ${l.statusText??""}`.trim());const c=i.sourceName??i.path,d=i.name??a(c),m={name:d,sourceName:c,source:await l.text()},p=i.kind?[i.kind]:["function","script","class"];for(const t of p){const e="script"===t?[...h(i.path),...h(c),...h(d)]:[...u(i.path),...u(c),...u(d)];for(const s of e)r[t][s]=m;"script"===t&&(r.script[n(d)]=m)}}return new y(r)};resolve(t,e){return"script"===t?m(h(e),this.sources.script):m(u(e),this.sources[t])}hasDirectory(t){return c(t,[this.sources.function,this.sources.script,this.sources.class])}}e.ManifestSourceResolver=y,e.default={ManifestSourceResolver:y,TableSourceResolver:g}},5212(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Structure=void 0;const s=r(845),i=r(7679),n=r(1604);class a{static STRUCTURE=4;type=a.STRUCTURE;parent;field;static invalidReferenceMessage="value cannot be indexed with .";static isInstanceOf=t=>t instanceof a;constructor(t){if(this.field={},Array.isArray(t)){let e=this;for(let r=0;r<t.length-1;r++){const s=new a({});e.field[t[r]]=s,e=s}e.field[t[t.length-1]]=i.MultiArray.emptyArray()}else for(const[e,r]of Object.entries(t))this.field[e]=n.RuntimeValue.copy(r)}static structureElements=t=>{if(t instanceof a)return[t];if(t instanceof i.MultiArray&&!t.isCell){const e=i.MultiArray.linearize(t);return 0!==e.length&&e.every(a.isInstanceOf)?e:[]}return[]};static isStructure=t=>a.structureElements(t).length>0;static fieldNames=t=>Object.keys(a.structureElements(t)[0]?.field??{}).sort();static hasField=(t,e)=>{const r=a.structureElements(t);return r.length>0&&r.every(t=>n.RuntimeValue.hasOwnField(t.field,e))};static isMissingOrEmpty=t=>void 0===t||i.MultiArray.isEmpty(t);static ensureStructureLike=t=>{if(a.isMissingOrEmpty(t))return new a({});if(t instanceof a)return t;if(t instanceof i.MultiArray&&a.isStructure(t))return t;throw new EvalError(a.invalidReferenceMessage)};static assignFieldPath=(t,e,r)=>{if(t instanceof i.MultiArray){const s=a.structureElements(t);if(0===s.length)throw new EvalError(a.invalidReferenceMessage);return void s.forEach(t=>a.assignFieldPath(t,e,r))}if(0===e.length)throw new EvalError(a.invalidReferenceMessage);if(1===e.length)return void(t.field[e[0]]=r??i.MultiArray.emptyArray());const s=e[0],n=a.ensureStructureLike(t.field[s]);t.field[s]=n,a.assignFieldPath(n,e.slice(1),r)};static collectFieldPath=(t,e)=>{if(null==t)throw new EvalError(a.invalidReferenceMessage);if(0===e.length)return[t];if(t instanceof i.MultiArray&&a.isStructure(t))return a.structureElements(t).flatMap(t=>a.collectFieldPath(t,e));if(t instanceof a){const r=t.field[e[0]];if(void 0===r)throw new EvalError(a.invalidReferenceMessage);return 1===e.length?[r]:a.collectFieldPath(r,e.slice(1))}throw new EvalError(a.invalidReferenceMessage)};static setField=(t,e,r)=>{a.assignFieldPath(t,e,r)};static setNewField=(t,e,r)=>{a.assignFieldPath(t,e,r)};static getField=(t,e)=>{const r=a.collectFieldPath(t,e);return 1===r.length?r[0]:i.MultiArray.toRowVector(r)};static getFields=(t,e)=>a.collectFieldPath(t,e);static removeFields=(t,e)=>{if(t instanceof a){const r=a.copy(t);return e.forEach(t=>{delete r.field[t]}),r}if(0===a.structureElements(t).length)throw new EvalError(a.invalidReferenceMessage);const r=i.MultiArray.copy(t);return a.structureElements(r).forEach(t=>{e.forEach(e=>{delete t.field[e]})}),r};static orderFields=t=>{const e=t=>{const e=new a({});for(const r of Object.keys(t.field).sort())e.field[r]=n.RuntimeValue.copy(t.field[r]);return e};if(t instanceof a)return e(t);const r=a.structureElements(t);if(0===r.length)throw new EvalError(a.invalidReferenceMessage);const s=i.MultiArray.copy(t),o=r.map(e);for(let t=0;t<o.length;t++){const[e,r]=i.MultiArray.linearIndexToMultiArrayRowColumn(s.dimension[0],s.dimension[1],t);s.array[e][r]=o[t]}return s};static unparse=(t,e,r=0)=>`struct {\n${Object.entries(t.field).map(t=>`${t[0]}: ${e.Unparse(t[1])}`).join("\n")}\n}`;static unparseMathML=(t,e,r=0)=>{let s='<mtr><mtd columnspan="2"><mtext>struct {</mtext></mtd></mtr>';return s+=Object.entries(t.field).map(t=>`<mtr><mtd><mi>${t[0]}</mi><mo>:</mo></mtd><mtd>${e.UnparserMathML(t[1])}</mtd></mtr>`).join(""),s+='<mtr><mtd columnspan="2"><mtext>}</mtext></mtd></mtr>',`<mtable>${s}</mtable>`};static copy=t=>{const e=new a({});for(const[r,s]of Object.entries(t.field))e.field[r]=n.RuntimeValue.copy(s);return e};copy(){return a.copy(this)}static cloneFields=t=>{const e=new a({});return Object.keys(t.field).forEach(t=>{e.field[t]=i.MultiArray.emptyArray()}),e};static toLogical=t=>Object.keys(t.field).length>0?s.Complex.true():s.Complex.false();toLogical(){return a.toLogical(this)}static setEmptyField=(t,e)=>{const r=a.structureElements(t);if(0===r.length)throw new EvalError(a.invalidReferenceMessage);t.isCell||a.hasField(t,e)||r.forEach(t=>{t.field[e]=i.MultiArray.emptyArray()})}}e.Structure=a,e.default={Structure:a},n.RuntimeValue.registerStructureFactory(t=>new a(t))},2697(t,e,r){"use strict";e.SyntaxDiagnostic=void 0;const s=r(1201);class i{static benignEndOfInputMessages=new Set(["mismatched input '' expecting {';', SP}","missing ';' at ''","mismatched input '' expecting","mismatched input '' expecting "]);static error=(t,e,r,n="")=>{const a=`syntax error at ${Math.max(1,e)}:${Math.max(1,r+1)}: ${i.normalizeMessage(t)}`,o=i.sourceLine(n,e);if(!o)return new s.SyntaxError(a);const l=i.displayColumn(o,r);return new s.SyntaxError(`${a}\n${o}\n${" ".repeat(l)}^`)};static isBenignEndOfInput=t=>i.benignEndOfInputMessages.has(t);static normalizeMessage=t=>t.replace(/\bEOF\b/g,(t,e,r)=>"<"===r[e-1]&&">"===r[e+t.length]?t:"<EOF>");static displayColumn=(t,e)=>{const r=Math.max(0,Math.min(e,t.length));return[...t.slice(0,r)].reduce((t,e)=>t+("\t"===e?4:1),0)};static sourceLine=(t,e)=>t.replace(/\r\n?/g,"\n").split("\n")[e-1]??""}e.SyntaxDiagnostic=i},3504(t,e,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||s(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.MathML=e.Configuration=e.CoreFunctions=e.MathOperation=e.LinearAlgebra=e.ClassMetaEnumerationMember=e.ClassMetaEvent=e.ClassMetaMethod=e.ClassMetaProperty=e.ClassMetaMember=e.ClassMetaClass=e.ClassMetaObject=e.ClassPropertyEvent=e.ClassEventData=e.ClassEventListener=e.ClassEnumerationValue=e.ClassEmptyMethod=e.ClassStaticMethod=e.ClassBoundMethod=e.ClassInstance=e.ClassDefinition=e.ClassMember=e.FunctionHandle=e.Structure=e.MultiArray=e.Complex=e.ComplexDecimal=e.ComplexNumber=e.stringClass=e.doubleQuoteCharacter=e.singleQuoteCharacter=e.CharString=e.Decimal=void 0;var n=r(3110);Object.defineProperty(e,"Decimal",{enumerable:!0,get:function(){return n.Decimal}});var a=r(5956);Object.defineProperty(e,"CharString",{enumerable:!0,get:function(){return a.CharString}}),Object.defineProperty(e,"singleQuoteCharacter",{enumerable:!0,get:function(){return a.singleQuoteCharacter}}),Object.defineProperty(e,"doubleQuoteCharacter",{enumerable:!0,get:function(){return a.doubleQuoteCharacter}}),Object.defineProperty(e,"stringClass",{enumerable:!0,get:function(){return a.stringClass}});var o=r(3428);Object.defineProperty(e,"ComplexNumber",{enumerable:!0,get:function(){return o.ComplexNumber}});var l=r(3826);Object.defineProperty(e,"ComplexDecimal",{enumerable:!0,get:function(){return l.ComplexDecimal}});var c=r(845);Object.defineProperty(e,"Complex",{enumerable:!0,get:function(){return c.Complex}});var u=r(7679);Object.defineProperty(e,"MultiArray",{enumerable:!0,get:function(){return u.MultiArray}});var h=r(5212);Object.defineProperty(e,"Structure",{enumerable:!0,get:function(){return h.Structure}});var d=r(1271);Object.defineProperty(e,"FunctionHandle",{enumerable:!0,get:function(){return d.FunctionHandle}});var m=r(9283);Object.defineProperty(e,"ClassMember",{enumerable:!0,get:function(){return m.ClassMember}});var p=r(6816);Object.defineProperty(e,"ClassDefinition",{enumerable:!0,get:function(){return p.ClassDefinition}});var f=r(9770);Object.defineProperty(e,"ClassInstance",{enumerable:!0,get:function(){return f.ClassInstance}});var g=r(9656);Object.defineProperty(e,"ClassBoundMethod",{enumerable:!0,get:function(){return g.ClassBoundMethod}});var y=r(8986);Object.defineProperty(e,"ClassStaticMethod",{enumerable:!0,get:function(){return y.ClassStaticMethod}});var x=r(3226);Object.defineProperty(e,"ClassEmptyMethod",{enumerable:!0,get:function(){return x.ClassEmptyMethod}});var C=r(7325);Object.defineProperty(e,"ClassEnumerationValue",{enumerable:!0,get:function(){return C.ClassEnumerationValue}});var E=r(5577);Object.defineProperty(e,"ClassEventListener",{enumerable:!0,get:function(){return E.ClassEventListener}});var A=r(169);Object.defineProperty(e,"ClassEventData",{enumerable:!0,get:function(){return A.ClassEventData}});var _=r(482);Object.defineProperty(e,"ClassPropertyEvent",{enumerable:!0,get:function(){return _.ClassPropertyEvent}});var S=r(7268);Object.defineProperty(e,"ClassMetaObject",{enumerable:!0,get:function(){return S.ClassMetaObject}}),Object.defineProperty(e,"ClassMetaClass",{enumerable:!0,get:function(){return S.ClassMetaClass}}),Object.defineProperty(e,"ClassMetaMember",{enumerable:!0,get:function(){return S.ClassMetaMember}}),Object.defineProperty(e,"ClassMetaProperty",{enumerable:!0,get:function(){return S.ClassMetaProperty}}),Object.defineProperty(e,"ClassMetaMethod",{enumerable:!0,get:function(){return S.ClassMetaMethod}}),Object.defineProperty(e,"ClassMetaEvent",{enumerable:!0,get:function(){return S.ClassMetaEvent}}),Object.defineProperty(e,"ClassMetaEnumerationMember",{enumerable:!0,get:function(){return S.ClassMetaEnumerationMember}});var v=r(4610);Object.defineProperty(e,"LinearAlgebra",{enumerable:!0,get:function(){return v.LinearAlgebra}});var T=r(6554);Object.defineProperty(e,"MathOperation",{enumerable:!0,get:function(){return T.MathOperation}});var b=r(3717);Object.defineProperty(e,"CoreFunctions",{enumerable:!0,get:function(){return b.CoreFunctions}});var N=r(9947);Object.defineProperty(e,"Configuration",{enumerable:!0,get:function(){return N.Configuration}});var I=r(7686);Object.defineProperty(e,"MathML",{enumerable:!0,get:function(){return I.MathML}}),i(r(6109),e),i(r(7727),e)},5803(t,e,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(t,e,r,s){void 0===s&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){void 0===s&&(s=r),t[s]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||s(e,t,r)},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(r(6982));globalThis.crypto=a.default,i(r(3504),e)},2424(t,e){"use strict";e.substSymbol=function(t){const e=["alpha","beta","gamma","delta","epsilon","zeta","eta","theta","iota","kappa","lambda","mu","nu","xi","omicron","pi","rho","sigma","tau","upsilon","phi","chi","psi","omega"],r=[["alfa","alpha"],["Alfa","Alpha"],["gama","gamma"],["Gama","Gamma"],["épsilon","epsilon"],["Épsilon","Epsilon"],["dzeta","zeta"],["Dzeta","Zeta"],["teta","theta"],["Teta","Theta"],["capa","kappa"],["Capa","Kappa"],["kapa","kappa"],["Kapa","Kappa"],["mi","mu"],["Mi","Mu"],["ni","nu"],["Ni","Nu"],["csi","xi"],["Csi","Xi"],["ksi","xi"],["Ksi","Xi"],["ômicron","omicron"],["Ômicron","Omicron"],["ómicron","omicron"],["Ómicron","Omicron"],["ro","rho"],["Ro","Rho"],["rô","rho"],["Rô","Rho"],["úpsilon","upsilon"],["Úpsilon","Upsilon"],["ipsilon","upsilon"],["Ipsilon","Upsilon"],["ípsilon","upsilon"],["Ípsilon","Upsilon"],["ypsilon","upsilon"],["Ypsilon","Upsilon"],["ýpsilon","upsilon"],["Ýpsilon","Upsilon"],["fi","phi"],["Fi","Phi"],["qui","chi"],["Qui","Chi"],["ômega","omega"],["Ômega","Omega"]];let s;for(let e=0;e<r.length;e++)s=new RegExp("([^a-zA-Z0-9])("+r[e][0]+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"$1"+r[e][1]),s=new RegExp("^("+r[e][0]+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,r[e][1]);for(let r=0;r<e.length;r++)s=new RegExp("([^a-zA-Z0-9])(["+e[r][0]+e[r][0].toUpperCase()+"]"+e[r].substring(1)+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"$1&$2;"),s=new RegExp("^(["+e[r][0]+e[r][0].toUpperCase()+"]"+e[r].substring(1)+")(?![a-zA-Z0-9;])","g"),t=t.replace(s,"&$1;");return t.replace(/^[Ii]nf$/,"∞").replace(/^NaN$|^nan$/,"<b>NaN</b>")}},6982(t){"use strict";t.exports=require("crypto")},9896(t){"use strict";t.exports=require("fs")},3222(t,e,r){(()=>{"use strict";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},s={};t.r(s),t.d(s,{ATN:()=>K,ATNDeserializer:()=>It,BailErrorStrategy:()=>Se,CharStream:()=>Te,CharStreams:()=>we,CommonToken:()=>Rt,CommonTokenStream:()=>De,DFA:()=>le,DefaultErrorStrategy:()=>_e,DiagnosticErrorListener:()=>Ce,ErrorListener:()=>Mt,FailedPredicateException:()=>ye,FileStream:()=>Me,InputMismatchException:()=>ge,InputStream:()=>be,Interval:()=>E,IntervalSet:()=>A,LL1Analyzer:()=>Q,Lexer:()=>Vt,LexerATNSimulator:()=>Jt,NoViableAltException:()=>ee,ParseTreeListener:()=>de,ParseTreeVisitor:()=>me,ParseTreeWalker:()=>pe,Parser:()=>Pe,ParserATNSimulator:()=>se,ParserRuleContext:()=>Ue,PredictionContextCache:()=>ie,PredictionMode:()=>te,RecognitionException:()=>Pt,RuleContext:()=>V,RuleNode:()=>R,TerminalNode:()=>D,Token:()=>i,TokenStreamRewriter:()=>$e,arrayToString:()=>d,default:()=>ze});class i{constructor(){this.source=null,this.type=null,this.channel=null,this.start=null,this.stop=null,this.tokenIndex=null,this.line=null,this.column=null,this._text=null}getTokenSource(){return this.source[0]}getInputStream(){return this.source[1]}get text(){return this._text}set text(t){this._text=t}}function n(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!(t[r]===e[r]||t[r].equals&&t[r].equals(e[r])))return!1;return!0}i.INVALID_TYPE=0,i.EPSILON=-2,i.MIN_USER_TOKEN_TYPE=1,i.EOF=-1,i.DEFAULT_CHANNEL=0,i.HIDDEN_CHANNEL=1;const a=Math.round(Math.random()*Math.pow(2,32));function o(t){if(!t)return 0;const e=typeof t,r="string"===e?t:!("object"!==e||!t.toString)&&t.toString();if(!r)return 0;let s,i;const n=3&r.length,o=r.length-n;let l=a;const c=3432918353,u=461845907;let h=0;for(;h<o;)i=255&r.charCodeAt(h)|(255&r.charCodeAt(++h))<<8|(255&r.charCodeAt(++h))<<16|(255&r.charCodeAt(++h))<<24,++h,i=(65535&i)*c+(((i>>>16)*c&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,l^=i,l=l<<13|l>>>19,s=5*(65535&l)+((5*(l>>>16)&65535)<<16)&4294967295,l=27492+(65535&s)+((58964+(s>>>16)&65535)<<16);switch(i=0,n){case 3:i^=(255&r.charCodeAt(h+2))<<16;case 2:i^=(255&r.charCodeAt(h+1))<<8;case 1:i^=255&r.charCodeAt(h),i=(65535&i)*c+(((i>>>16)*c&65535)<<16)&4294967295,i=i<<15|i>>>17,i=(65535&i)*u+(((i>>>16)*u&65535)<<16)&4294967295,l^=i}return l^=r.length,l^=l>>>16,l=2246822507*(65535&l)+((2246822507*(l>>>16)&65535)<<16)&4294967295,l^=l>>>13,l=3266489909*(65535&l)+((3266489909*(l>>>16)&65535)<<16)&4294967295,l^=l>>>16,l>>>0}class l{constructor(){this.count=0,this.hash=0}update(){for(let t=0;t<arguments.length;t++){const e=arguments[t];if(null!=e)if(Array.isArray(e))this.update.apply(this,e);else{let t=0;switch(typeof e){case"undefined":case"function":continue;case"number":case"boolean":t=e;break;case"string":t=o(e);break;default:e.updateHashCode?e.updateHashCode(this):console.log("No updateHashCode for "+e.toString());continue}t*=3432918353,t=t<<15|t>>>17,t*=461845907,this.count=this.count+1;let r=this.hash^t;r=r<<13|r>>>19,r=5*r+3864292196,this.hash=r}}}finish(){let t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16,t}static hashStuff(){const t=new l;return t.update.apply(t,arguments),t.finish()}}function c(t){return t?"string"==typeof t?o(t):t.hashCode():-1}function u(t,e){return t&&t.equals?t.equals(e):t===e}function h(t){return null===t?"null":t}function d(t){return Array.isArray(t)?"["+t.map(h).join(", ")+"]":"null"}class m{constructor(t,e){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=t||c,this.equalsFunction=e||u}get(t){if(null==t)return t;const e=this._getBucket(t);if(!e)return null;for(const r of e)if(this.equalsFunction(r,t))return r;return null}add(t){return this.getOrAdd(t)===t}getOrAdd(t){this._expand();const e=this._getSlot(t);let r=this.buckets[e];if(!r)return r=[t],this.buckets[e]=r,this.itemCount++,t;for(const e of r)if(this.equalsFunction(e,t))return e;return r.push(t),this.itemCount++,t}has(t){return null!=this.get(t)}values(){return this.buckets.filter(t=>null!=t).flat(1)}toString(){return d(this.values())}get length(){return this.itemCount}_getSlot(t){return this.hashFunction(t)&this.buckets.length-1}_getBucket(t){return this.buckets[this._getSlot(t)]}_expand(){if(this.itemCount<=this.threshold)return;const t=this.buckets,e=2*this.buckets.length;this.buckets=new Array(e),this.threshold=Math.floor(.75*e);for(const e of t)if(e)for(const t of e){const e=this._getSlot(t);let r=this.buckets[e];r||(r=[],this.buckets[e]=r),r.push(t)}}}class p{hashCode(){const t=new l;return this.updateHashCode(t),t.finish()}evaluate(t,e){}evalPrecedence(t,e){return this}static andContext(t,e){if(null===t||t===p.NONE)return e;if(null===e||e===p.NONE)return t;const r=new f(t,e);return 1===r.opnds.length?r.opnds[0]:r}static orContext(t,e){if(null===t)return e;if(null===e)return t;if(t===p.NONE||e===p.NONE)return p.NONE;const r=new g(t,e);return 1===r.opnds.length?r.opnds[0]:r}}class f extends p{constructor(t,e){super();const r=new m;t instanceof f?t.opnds.map(function(t){r.add(t)}):r.add(t),e instanceof f?e.opnds.map(function(t){r.add(t)}):r.add(e);const s=y(r);if(s.length>0){let t=null;s.map(function(e){(null===t||e.precedence<t.precedence)&&(t=e)}),r.add(t)}this.opnds=Array.from(r.values())}equals(t){return this===t||t instanceof f&&n(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"AND")}evaluate(t,e){for(let r=0;r<this.opnds.length;r++)if(!this.opnds[r].evaluate(t,e))return!1;return!0}evalPrecedence(t,e){let r=!1;const s=[];for(let i=0;i<this.opnds.length;i++){const n=this.opnds[i],a=n.evalPrecedence(t,e);if(r|=a!==n,null===a)return null;a!==p.NONE&&s.push(a)}if(!r)return this;if(0===s.length)return p.NONE;let i=null;return s.map(function(t){i=null===i?t:p.andContext(i,t)}),i}toString(){const t=this.opnds.map(t=>t.toString());return(t.length>3?t.slice(3):t).join("&&")}}class g extends p{constructor(t,e){super();const r=new m;t instanceof g?t.opnds.map(function(t){r.add(t)}):r.add(t),e instanceof g?e.opnds.map(function(t){r.add(t)}):r.add(e);const s=y(r);if(s.length>0){const t=s.sort(function(t,e){return t.compareTo(e)}),e=t[t.length-1];r.add(e)}this.opnds=Array.from(r.values())}equals(t){return this===t||t instanceof g&&n(this.opnds,t.opnds)}updateHashCode(t){t.update(this.opnds,"OR")}evaluate(t,e){for(let r=0;r<this.opnds.length;r++)if(this.opnds[r].evaluate(t,e))return!0;return!1}evalPrecedence(t,e){let r=!1;const s=[];for(let i=0;i<this.opnds.length;i++){const n=this.opnds[i],a=n.evalPrecedence(t,e);if(r|=a!==n,a===p.NONE)return p.NONE;null!==a&&s.push(a)}return r?(0===s.length||s.map(function(t){return t}),null):this}toString(){const t=this.opnds.map(t=>t.toString());return(t.length>3?t.slice(3):t).join("||")}}function y(t){const e=[];return t.values().map(function(t){t instanceof p.PrecedencePredicate&&e.push(t)}),e}function x(t,e){if(null===t){const t={state:null,alt:null,context:null,semanticContext:null};return e&&(t.reachesIntoOuterContext=0),t}{const r={};return r.state=t.state||null,r.alt=void 0===t.alt?null:t.alt,r.context=t.context||null,r.semanticContext=t.semanticContext||null,e&&(r.reachesIntoOuterContext=t.reachesIntoOuterContext||0,r.precedenceFilterSuppressed=t.precedenceFilterSuppressed||!1),r}}class C{constructor(t,e){this.checkContext(t,e),t=x(t),e=x(e,!0),this.state=null!==t.state?t.state:e.state,this.alt=null!==t.alt?t.alt:e.alt,this.context=null!==t.context?t.context:e.context,this.semanticContext=null!==t.semanticContext?t.semanticContext:null!==e.semanticContext?e.semanticContext:p.NONE,this.reachesIntoOuterContext=e.reachesIntoOuterContext,this.precedenceFilterSuppressed=e.precedenceFilterSuppressed}checkContext(t,e){null!==t.context&&void 0!==t.context||null!==e&&null!==e.context&&void 0!==e.context||(this.context=null)}hashCode(){const t=new l;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext)}equals(t){return this===t||t instanceof C&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&(null===this.context?null===t.context:this.context.equals(t.context))&&this.semanticContext.equals(t.semanticContext)&&this.precedenceFilterSuppressed===t.precedenceFilterSuppressed}hashCodeForConfigSet(){const t=new l;return t.update(this.state.stateNumber,this.alt,this.semanticContext),t.finish()}equalsForConfigSet(t){return this===t||t instanceof C&&this.state.stateNumber===t.state.stateNumber&&this.alt===t.alt&&this.semanticContext.equals(t.semanticContext)}toString(){return"("+this.state+","+this.alt+(null!==this.context?",["+this.context.toString()+"]":"")+(this.semanticContext!==p.NONE?","+this.semanticContext.toString():"")+(this.reachesIntoOuterContext>0?",up="+this.reachesIntoOuterContext:"")+")"}}class E{constructor(t,e){this.start=t,this.stop=e}clone(){return new E(this.start,this.stop)}contains(t){return t>=this.start&&t<this.stop}toString(){return this.start===this.stop-1?this.start.toString():this.start.toString()+".."+(this.stop-1).toString()}get length(){return this.stop-this.start}}E.INVALID_INTERVAL=new E(-1,-2);class A{constructor(){this.intervals=null,this.readOnly=!1}first(t){return null===this.intervals||0===this.intervals.length?i.INVALID_TYPE:this.intervals[0].start}addOne(t){this.addInterval(new E(t,t+1))}addRange(t,e){this.addInterval(new E(t,e+1))}addInterval(t){if(null===this.intervals)this.intervals=[],this.intervals.push(t.clone());else{for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];if(t.stop<r.start)return void this.intervals.splice(e,0,t);if(t.stop===r.start)return void(this.intervals[e]=new E(t.start,r.stop));if(t.start<=r.stop)return this.intervals[e]=new E(Math.min(r.start,t.start),Math.max(r.stop,t.stop)),void this.reduce(e)}this.intervals.push(t.clone())}}addSet(t){return null!==t.intervals&&t.intervals.forEach(t=>this.addInterval(t),this),this}reduce(t){if(t<this.intervals.length-1){const e=this.intervals[t],r=this.intervals[t+1];e.stop>=r.stop?(this.intervals.splice(t+1,1),this.reduce(t)):e.stop>=r.start&&(this.intervals[t]=new E(e.start,r.stop),this.intervals.splice(t+1,1))}}complement(t,e){const r=new A;return r.addInterval(new E(t,e+1)),null!==this.intervals&&this.intervals.forEach(t=>r.removeRange(t)),r}contains(t){if(null===this.intervals)return!1;for(let e=0;e<this.intervals.length;e++)if(this.intervals[e].contains(t))return!0;return!1}removeRange(t){if(t.start===t.stop-1)this.removeOne(t.start);else if(null!==this.intervals){let e=0;for(let r=0;r<this.intervals.length;r++){const r=this.intervals[e];if(t.stop<=r.start)return;if(t.start>r.start&&t.stop<r.stop){this.intervals[e]=new E(r.start,t.start);const s=new E(t.stop,r.stop);return void this.intervals.splice(e,0,s)}t.start<=r.start&&t.stop>=r.stop?(this.intervals.splice(e,1),e-=1):t.start<r.stop?this.intervals[e]=new E(r.start,t.start):t.stop<r.stop&&(this.intervals[e]=new E(t.stop,r.stop)),e+=1}}}removeOne(t){if(null!==this.intervals)for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];if(t<r.start)return;if(t===r.start&&t===r.stop-1)return void this.intervals.splice(e,1);if(t===r.start)return void(this.intervals[e]=new E(r.start+1,r.stop));if(t===r.stop-1)return void(this.intervals[e]=new E(r.start,r.stop-1));if(t<r.stop-1){const s=new E(r.start,t);return r.start=t+1,void this.intervals.splice(e,0,s)}}}toString(t,e,r){return t=t||null,e=e||null,r=r||!1,null===this.intervals?"{}":null!==t||null!==e?this.toTokenString(t,e):r?this.toCharString():this.toIndexString()}toCharString(){const t=[];for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];r.stop===r.start+1?r.start===i.EOF?t.push("<EOF>"):t.push("'"+String.fromCharCode(r.start)+"'"):t.push("'"+String.fromCharCode(r.start)+"'..'"+String.fromCharCode(r.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]}toIndexString(){const t=[];for(let e=0;e<this.intervals.length;e++){const r=this.intervals[e];r.stop===r.start+1?r.start===i.EOF?t.push("<EOF>"):t.push(r.start.toString()):t.push(r.start.toString()+".."+(r.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]}toTokenString(t,e){const r=[];for(let s=0;s<this.intervals.length;s++){const i=this.intervals[s];for(let s=i.start;s<i.stop;s++)r.push(this.elementName(t,e,s))}return r.length>1?"{"+r.join(", ")+"}":r[0]}elementName(t,e,r){return r===i.EOF?"<EOF>":r===i.EPSILON?"<EPSILON>":t[r]||e[r]}get length(){return this.intervals.map(t=>t.length).reduce((t,e)=>t+e)}}class _{constructor(){this.atn=null,this.stateNumber=_.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null}toString(){return this.stateNumber}equals(t){return t instanceof _&&this.stateNumber===t.stateNumber}isNonGreedyExitState(){return!1}addTransition(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)}}_.INVALID_TYPE=0,_.BASIC=1,_.RULE_START=2,_.BLOCK_START=3,_.PLUS_BLOCK_START=4,_.STAR_BLOCK_START=5,_.TOKEN_START=6,_.RULE_STOP=7,_.BLOCK_END=8,_.STAR_LOOP_BACK=9,_.STAR_LOOP_ENTRY=10,_.PLUS_LOOP_BACK=11,_.LOOP_END=12,_.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],_.INVALID_STATE_NUMBER=-1;class S extends _{constructor(){return super(),this.stateType=_.RULE_STOP,this}}class v{constructor(t){if(null==t)throw"target cannot be null.";this.target=t,this.isEpsilon=!1,this.label=null}}v.EPSILON=1,v.RANGE=2,v.RULE=3,v.PREDICATE=4,v.ATOM=5,v.ACTION=6,v.SET=7,v.NOT_SET=8,v.WILDCARD=9,v.PRECEDENCE=10,v.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],v.serializationTypes={EpsilonTransition:v.EPSILON,RangeTransition:v.RANGE,RuleTransition:v.RULE,PredicateTransition:v.PREDICATE,AtomTransition:v.ATOM,ActionTransition:v.ACTION,SetTransition:v.SET,NotSetTransition:v.NOT_SET,WildcardTransition:v.WILDCARD,PrecedencePredicateTransition:v.PRECEDENCE};class T extends v{constructor(t,e,r,s){super(t),this.ruleIndex=e,this.precedence=r,this.followState=s,this.serializationType=v.RULE,this.isEpsilon=!0}matches(t,e,r){return!1}}class b extends v{constructor(t,e){super(t),this.serializationType=v.SET,null!=e?this.label=e:(this.label=new A,this.label.addOne(i.INVALID_TYPE))}matches(t,e,r){return this.label.contains(t)}toString(){return this.label.toString()}}class N extends b{constructor(t,e){super(t,e),this.serializationType=v.NOT_SET}matches(t,e,r){return t>=e&&t<=r&&!super.matches(t,e,r)}toString(){return"~"+super.toString()}}class I extends v{constructor(t){super(t),this.serializationType=v.WILDCARD}matches(t,e,r){return t>=e&&t<=r}toString(){return"."}}class M extends v{constructor(t){super(t)}}class w{}class L extends w{}class O extends L{}class R extends O{get ruleContext(){throw new Error("missing interface implementation")}}class D extends O{}class F extends D{}const P={toStringTree:function(t,e,r){e=e||null,null!==(r=r||null)&&(e=r.ruleNames);let s=P.getNodeText(t,e);s=function(t){return t.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r")}(s);const i=t.getChildCount();if(0===i)return s;let n="("+s+" ";i>0&&(s=P.toStringTree(t.getChild(0),e),n=n.concat(s));for(let r=1;r<i;r++)s=P.toStringTree(t.getChild(r),e),n=n.concat(" "+s);return n=n.concat(")"),n},getNodeText:function(t,e,r){if(e=e||null,null!==(r=r||null)&&(e=r.ruleNames),null!==e){if(t instanceof R){const r=t.ruleContext.getAltNumber();return 0!=r?e[t.ruleIndex]+":"+r:e[t.ruleIndex]}if(t instanceof F)return t.toString();if(t instanceof D&&null!==t.symbol)return t.symbol.text}const s=t.getPayload();return s instanceof i?s.text:t.getPayload().toString()},getChildren:function(t){const e=[];for(let r=0;r<t.getChildCount();r++)e.push(t.getChild(r));return e},getAncestors:function(t){let e=[];for(t=t.getParent();null!==t;)e=[t].concat(e),t=t.getParent();return e},findAllTokenNodes:function(t,e){return P.findAllNodes(t,e,!0)},findAllRuleNodes:function(t,e){return P.findAllNodes(t,e,!1)},findAllNodes:function(t,e,r){const s=[];return P._findAllNodes(t,e,r,s),s},_findAllNodes:function(t,e,r,s){r&&t instanceof D?t.symbol.type===e&&s.push(t):!r&&t instanceof R&&t.ruleIndex===e&&s.push(t);for(let i=0;i<t.getChildCount();i++)P._findAllNodes(t.getChild(i),e,r,s)},descendants:function(t){let e=[t];for(let r=0;r<t.getChildCount();r++)e=e.concat(P.descendants(t.getChild(r)));return e}},k=P;class V extends R{constructor(t,e){super(),this.parentCtx=t||null,this.invokingState=e||-1}depth(){let t=0,e=this;for(;null!==e;)e=e.parentCtx,t+=1;return t}isEmpty(){return-1===this.invokingState}getSourceInterval(){return E.INVALID_INTERVAL}get ruleContext(){return this}getPayload(){return this}getText(){return 0===this.getChildCount()?"":this.children.map(function(t){return t.getText()}).join("")}getAltNumber(){return 0}setAltNumber(t){}getChild(t){return null}getChildCount(){return 0}accept(t){return t.visitChildren(this)}toStringTree(t,e){return k.toStringTree(this,t,e)}toString(t,e){t=t||null,e=e||null;let r=this,s="[";for(;null!==r&&r!==e;){if(null===t)r.isEmpty()||(s+=r.invokingState);else{const e=r.ruleIndex;s+=e>=0&&e<t.length?t[e]:""+e}null===r.parentCtx||null===t&&r.parentCtx.isEmpty()||(s+=" "),r=r.parentCtx}return s+="]",s}}class U{constructor(t){this.cachedHashCode=t}isEmpty(){return this===U.EMPTY}hasEmptyPath(){return this.getReturnState(this.length-1)===U.EMPTY_RETURN_STATE}hashCode(){return this.cachedHashCode}updateHashCode(t){t.update(this.cachedHashCode)}}U.EMPTY=null,U.EMPTY_RETURN_STATE=2147483647,U.globalNodeCount=1,U.id=U.globalNodeCount,U.trace_atn_sim=!1;class $ extends U{constructor(t,e){const r=new l;return r.update(t,e),super(r.finish()),this.parents=t,this.returnStates=e,this}isEmpty(){return this.returnStates[0]===U.EMPTY_RETURN_STATE}getParent(t){return this.parents[t]}getReturnState(t){return this.returnStates[t]}equals(t){return this===t||t instanceof $&&this.hashCode()===t.hashCode()&&n(this.returnStates,t.returnStates)&&n(this.parents,t.parents)}toString(){if(this.isEmpty())return"[]";{let t="[";for(let e=0;e<this.returnStates.length;e++)e>0&&(t+=", "),this.returnStates[e]!==U.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"}}get length(){return this.returnStates.length}}class B extends U{constructor(t,e){let r=0;const s=new l;null!==t?s.update(t,e):s.update(1),r=s.finish(),super(r),this.parentCtx=t,this.returnState=e}getParent(t){return this.parentCtx}getReturnState(t){return this.returnState}equals(t){return this===t||t instanceof B&&this.hashCode()===t.hashCode()&&this.returnState===t.returnState&&(null==this.parentCtx?null==t.parentCtx:this.parentCtx.equals(t.parentCtx))}toString(){const t=null===this.parentCtx?"":this.parentCtx.toString();return 0===t.length?this.returnState===U.EMPTY_RETURN_STATE?"$":""+this.returnState:this.returnState+" "+t}get length(){return 1}static create(t,e){return e===U.EMPTY_RETURN_STATE&&null===t?U.EMPTY:new B(t,e)}}class H extends B{constructor(){super(null,U.EMPTY_RETURN_STATE)}isEmpty(){return!0}getParent(t){return null}getReturnState(t){return this.returnState}equals(t){return this===t}toString(){return"$"}}U.EMPTY=new H;class q{constructor(t,e){this.buckets=new Array(16),this.threshold=Math.floor(12),this.itemCount=0,this.hashFunction=t||c,this.equalsFunction=e||u}set(t,e){this._expand();const r=this._getSlot(t);let s=this.buckets[r];if(!s)return s=[[t,e]],this.buckets[r]=s,this.itemCount++,e;const i=s.find(e=>this.equalsFunction(e[0],t),this);if(i){const t=i[1];return i[1]=e,t}return s.push([t,e]),this.itemCount++,e}containsKey(t){const e=this._getBucket(t);return!!e&&!!e.find(e=>this.equalsFunction(e[0],t),this)}get(t){const e=this._getBucket(t);if(!e)return null;const r=e.find(e=>this.equalsFunction(e[0],t),this);return r?r[1]:null}entries(){return this.buckets.filter(t=>null!=t).flat(1)}getKeys(){return this.entries().map(t=>t[0])}getValues(){return this.entries().map(t=>t[1])}toString(){return"["+this.entries().map(t=>"{"+t[0]+":"+t[1]+"}").join(", ")+"]"}get length(){return this.itemCount}_getSlot(t){return this.hashFunction(t)&this.buckets.length-1}_getBucket(t){return this.buckets[this._getSlot(t)]}_expand(){if(this.itemCount<=this.threshold)return;const t=this.buckets,e=2*this.buckets.length;this.buckets=new Array(e),this.threshold=Math.floor(.75*e);for(const e of t)if(e)for(const t of e){const e=this._getSlot(t[0]);let r=this.buckets[e];r||(r=[],this.buckets[e]=r),r.push(t)}}}function j(t,e){if(null==e&&(e=V.EMPTY),null===e.parentCtx||e===V.EMPTY)return U.EMPTY;const r=j(t,e.parentCtx),s=t.states[e.invokingState].transitions[0];return B.create(r,s.followState.stateNumber)}function z(t,e,r){if(t.isEmpty())return t;let s=r.get(t)||null;if(null!==s)return s;if(s=e.get(t),null!==s)return r.set(t,s),s;let i=!1,n=[];for(let s=0;s<n.length;s++){const a=z(t.getParent(s),e,r);if(i||a!==t.getParent(s)){if(!i){n=[];for(let e=0;e<t.length;e++)n[e]=t.getParent(e);i=!0}n[s]=a}}if(!i)return e.add(t),r.set(t,t),t;let a=null;return a=0===n.length?U.EMPTY:1===n.length?B.create(n[0],t.getReturnState(0)):new $(n,t.returnStates),e.add(a),r.set(a,a),r.set(t,a),a}function G(t,e,r,s){if(t===e)return t;if(t instanceof B&&e instanceof B)return function(t,e,r,s){if(null!==s){let r=s.get(t,e);if(null!==r)return r;if(r=s.get(e,t),null!==r)return r}const i=function(t,e,r){if(r){if(t===U.EMPTY)return U.EMPTY;if(e===U.EMPTY)return U.EMPTY}else{if(t===U.EMPTY&&e===U.EMPTY)return U.EMPTY;if(t===U.EMPTY){const t=[e.returnState,U.EMPTY_RETURN_STATE],r=[e.parentCtx,null];return new $(r,t)}if(e===U.EMPTY){const e=[t.returnState,U.EMPTY_RETURN_STATE],r=[t.parentCtx,null];return new $(r,e)}}return null}(t,e,r);if(null!==i)return null!==s&&s.set(t,e,i),i;if(t.returnState===e.returnState){const i=G(t.parentCtx,e.parentCtx,r,s);if(i===t.parentCtx)return t;if(i===e.parentCtx)return e;const n=B.create(i,t.returnState);return null!==s&&s.set(t,e,n),n}{let r=null;if((t===e||null!==t.parentCtx&&t.parentCtx===e.parentCtx)&&(r=t.parentCtx),null!==r){const i=[t.returnState,e.returnState];t.returnState>e.returnState&&(i[0]=e.returnState,i[1]=t.returnState);const n=new $([r,r],i);return null!==s&&s.set(t,e,n),n}const i=[t.returnState,e.returnState];let n=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(i[0]=e.returnState,i[1]=t.returnState,n=[e.parentCtx,t.parentCtx]);const a=new $(n,i);return null!==s&&s.set(t,e,a),a}}(t,e,r,s);if(r){if(t instanceof H)return t;if(e instanceof H)return e}return t instanceof B&&(t=new $([t.getParent()],[t.returnState])),e instanceof B&&(e=new $([e.getParent()],[e.returnState])),function(t,e,r,s){if(null!==s){let r=s.get(t,e);if(null!==r)return U.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> previous"),r;if(r=s.get(e,t),null!==r)return U.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> previous"),r}let i=0,n=0,a=0,o=new Array(t.returnStates.length+e.returnStates.length).fill(0),l=new Array(t.returnStates.length+e.returnStates.length).fill(null);for(;i<t.returnStates.length&&n<e.returnStates.length;){const c=t.parents[i],u=e.parents[n];if(t.returnStates[i]===e.returnStates[n]){const e=t.returnStates[i];e===U.EMPTY_RETURN_STATE&&null===c&&null===u||null!==c&&null!==u&&c===u?(l[a]=c,o[a]=e):(l[a]=G(c,u,r,s),o[a]=e),i+=1,n+=1}else t.returnStates[i]<e.returnStates[n]?(l[a]=c,o[a]=t.returnStates[i],i+=1):(l[a]=u,o[a]=e.returnStates[n],n+=1);a+=1}if(i<t.returnStates.length)for(let e=i;e<t.returnStates.length;e++)l[a]=t.parents[e],o[a]=t.returnStates[e],a+=1;else for(let t=n;t<e.returnStates.length;t++)l[a]=e.parents[t],o[a]=e.returnStates[t],a+=1;if(a<l.length){if(1===a){const r=B.create(l[0],o[0]);return null!==s&&s.set(t,e,r),r}l=l.slice(0,a),o=o.slice(0,a)}const c=new $(l,o);return c.equals(t)?(null!==s&&s.set(t,e,t),U.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> a"),t):c.equals(e)?(null!==s&&s.set(t,e,e),U.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> b"),e):(function(t){const e=new q;for(let r=0;r<t.length;r++){const s=t[r];e.containsKey(s)||e.set(s,s)}for(let r=0;r<t.length;r++)t[r]=e.get(t[r])}(l),null!==s&&s.set(t,e,c),U.trace_atn_sim&&console.log("mergeArrays a="+t+",b="+e+" -> "+c),c)}(t,e,r,s)}class W{constructor(){this.data=new Uint32Array(1)}set(t){W._checkIndex(t),this._resize(t),this.data[t>>>5]|=1<<t%32}get(t){W._checkIndex(t);const e=t>>>5;return!(e>=this.data.length||!(this.data[e]&1<<t%32))}clear(t){W._checkIndex(t);const e=t>>>5;e<this.data.length&&(this.data[e]&=~(1<<t))}or(t){const e=Math.min(this.data.length,t.data.length);for(let r=0;r<e;++r)this.data[r]|=t.data[r];if(this.data.length<t.data.length){this._resize((t.data.length<<5)-1);const r=t.data.length;for(let s=e;s<r;++s)this.data[s]=t.data[s]}}values(){const t=new Array(this.length);let e=0;const r=this.data.length;for(let s=0;s<r;++s){let r=this.data[s];for(;0!==r;){const i=r&-r;t[e++]=(s<<5)+W._bitCount(i-1),r^=i}}return t}minValue(){for(let t=0;t<this.data.length;++t){let e=this.data[t];if(0!==e){let r=0;for(;!(1&e);)r++,e>>=1;return r+32*t}}return 0}hashCode(){return l.hashStuff(this.values())}equals(t){return t instanceof W&&n(this.data,t.data)}toString(){return"{"+this.values().join(", ")+"}"}get length(){return this.data.map(t=>W._bitCount(t)).reduce((t,e)=>t+e,0)}_resize(t){const e=t+32>>>5;if(e<=this.data.length)return;const r=new Uint32Array(e);r.set(this.data),r.fill(0,this.data.length),this.data=r}static _checkIndex(t){if(t<0)throw new RangeError("index cannot be negative")}static _bitCount(t){return t=(t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,0+(t+=t>>16)&63}}class Q{constructor(t){this.atn=t}getDecisionLookahead(t){if(null===t)return null;const e=t.transitions.length,r=[];for(let s=0;s<e;s++){r[s]=new A;const e=new m,i=!1;this._LOOK(t.transition(s).target,null,U.EMPTY,r[s],e,new W,i,!1),(0===r[s].length||r[s].contains(Q.HIT_PRED))&&(r[s]=null)}return r}LOOK(t,e,r){const s=new A,i=null!==(r=r||null)?j(t.atn,r):null;return this._LOOK(t,e,i,s,new m,new W,!0,!0),s}_LOOK(t,e,r,s,n,a,o,l){const c=new C({state:t,alt:0,context:r},null);if(!n.has(c)){if(n.add(c),t===e){if(null===r)return void s.addOne(i.EPSILON);if(r.isEmpty()&&l)return void s.addOne(i.EOF)}if(t instanceof S){if(null===r)return void s.addOne(i.EPSILON);if(r.isEmpty()&&l)return void s.addOne(i.EOF);if(r!==U.EMPTY){const i=a.get(t.ruleIndex);try{a.clear(t.ruleIndex);for(let t=0;t<r.length;t++){const i=this.atn.states[r.getReturnState(t)];this._LOOK(i,e,r.getParent(t),s,n,a,o,l)}}finally{i&&a.set(t.ruleIndex)}return}}for(let c=0;c<t.transitions.length;c++){const u=t.transitions[c];if(u.constructor===T){if(a.get(u.target.ruleIndex))continue;const t=B.create(r,u.followState.stateNumber);try{a.set(u.target.ruleIndex),this._LOOK(u.target,e,t,s,n,a,o,l)}finally{a.clear(u.target.ruleIndex)}}else if(u instanceof M)o?this._LOOK(u.target,e,r,s,n,a,o,l):s.addOne(Q.HIT_PRED);else if(u.isEpsilon)this._LOOK(u.target,e,r,s,n,a,o,l);else if(u.constructor===I)s.addRange(i.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType);else{let t=u.label;null!==t&&(u instanceof N&&(t=t.complement(i.MIN_USER_TOKEN_TYPE,this.atn.maxTokenType)),s.addSet(t))}}}}}Q.HIT_PRED=i.INVALID_TYPE;class K{constructor(t,e){this.grammarType=t,this.maxTokenType=e,this.states=[],this.decisionToState=[],this.ruleToStartState=[],this.ruleToStopState=null,this.modeNameToStartState={},this.ruleToTokenType=null,this.lexerActions=null,this.modeToStartState=[]}nextTokensInContext(t,e){return new Q(this).LOOK(t,null,e)}nextTokensNoContext(t){return null!==t.nextTokenWithinRule||(t.nextTokenWithinRule=this.nextTokensInContext(t,null),t.nextTokenWithinRule.readOnly=!0),t.nextTokenWithinRule}nextTokens(t,e){return void 0===e?this.nextTokensNoContext(t):this.nextTokensInContext(t,e)}addState(t){null!==t&&(t.atn=this,t.stateNumber=this.states.length),this.states.push(t)}removeState(t){this.states[t.stateNumber]=null}defineDecisionState(t){return this.decisionToState.push(t),t.decision=this.decisionToState.length-1,t.decision}getDecisionState(t){return 0===this.decisionToState.length?null:this.decisionToState[t]}getExpectedTokens(t,e){if(t<0||t>=this.states.length)throw"Invalid state number.";const r=this.states[t];let s=this.nextTokens(r);if(!s.contains(i.EPSILON))return s;const n=new A;for(n.addSet(s),n.removeOne(i.EPSILON);null!==e&&e.invokingState>=0&&s.contains(i.EPSILON);){const t=this.states[e.invokingState].transitions[0];s=this.nextTokens(t.followState),n.addSet(s),n.removeOne(i.EPSILON),e=e.parentCtx}return s.contains(i.EPSILON)&&n.addOne(i.EOF),n}}K.INVALID_ALT_NUMBER=0;class J extends _{constructor(){super(),this.stateType=_.BASIC}}class Z extends _{constructor(){return super(),this.decision=-1,this.nonGreedy=!1,this}}class X extends Z{constructor(){return super(),this.endState=null,this}}class Y extends _{constructor(){return super(),this.stateType=_.BLOCK_END,this.startState=null,this}}class tt extends _{constructor(){return super(),this.stateType=_.LOOP_END,this.loopBackState=null,this}}class et extends _{constructor(){return super(),this.stateType=_.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}}class rt extends Z{constructor(){return super(),this.stateType=_.TOKEN_START,this}}class st extends Z{constructor(){return super(),this.stateType=_.PLUS_LOOP_BACK,this}}class it extends _{constructor(){return super(),this.stateType=_.STAR_LOOP_BACK,this}}class nt extends Z{constructor(){return super(),this.stateType=_.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}}class at extends X{constructor(){return super(),this.stateType=_.PLUS_BLOCK_START,this.loopBackState=null,this}}class ot extends X{constructor(){return super(),this.stateType=_.STAR_BLOCK_START,this}}class lt extends X{constructor(){return super(),this.stateType=_.BLOCK_START,this}}class ct extends v{constructor(t,e){super(t),this.label_=e,this.label=this.makeLabel(),this.serializationType=v.ATOM}makeLabel(){const t=new A;return t.addOne(this.label_),t}matches(t,e,r){return this.label_===t}toString(){return this.label_}}class ut extends v{constructor(t,e,r){super(t),this.serializationType=v.RANGE,this.start=e,this.stop=r,this.label=this.makeLabel()}makeLabel(){const t=new A;return t.addRange(this.start,this.stop),t}matches(t,e,r){return t>=this.start&&t<=this.stop}toString(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"}}class ht extends v{constructor(t,e,r,s){super(t),this.serializationType=v.ACTION,this.ruleIndex=e,this.actionIndex=void 0===r?-1:r,this.isCtxDependent=void 0!==s&&s,this.isEpsilon=!0}matches(t,e,r){return!1}toString(){return"action_"+this.ruleIndex+":"+this.actionIndex}}class dt extends v{constructor(t,e){super(t),this.serializationType=v.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e}matches(t,e,r){return!1}toString(){return"epsilon"}}class mt extends p{constructor(t,e,r){super(),this.ruleIndex=void 0===t?-1:t,this.predIndex=void 0===e?-1:e,this.isCtxDependent=void 0!==r&&r}evaluate(t,e){const r=this.isCtxDependent?e:null;return t.sempred(r,this.ruleIndex,this.predIndex)}updateHashCode(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)}equals(t){return this===t||t instanceof mt&&this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent}toString(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"}}p.NONE=new mt;class pt extends M{constructor(t,e,r,s){super(t),this.serializationType=v.PREDICATE,this.ruleIndex=e,this.predIndex=r,this.isCtxDependent=s,this.isEpsilon=!0}matches(t,e,r){return!1}getPredicate(){return new mt(this.ruleIndex,this.predIndex,this.isCtxDependent)}toString(){return"pred_"+this.ruleIndex+":"+this.predIndex}}class ft extends p{constructor(t){super(),this.precedence=void 0===t?0:t}evaluate(t,e){return t.precpred(e,this.precedence)}evalPrecedence(t,e){return t.precpred(e,this.precedence)?p.NONE:null}compareTo(t){return this.precedence-t.precedence}updateHashCode(t){t.update(this.precedence)}equals(t){return this===t||t instanceof ft&&this.precedence===t.precedence}toString(){return"{"+this.precedence+">=prec}?"}}p.PrecedencePredicate=ft;class gt extends M{constructor(t,e){super(t),this.serializationType=v.PRECEDENCE,this.precedence=e,this.isEpsilon=!0}matches(t,e,r){return!1}getPredicate(){return new ft(this.precedence)}toString(){return this.precedence+" >= _p"}}class yt{constructor(t){void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions}}yt.defaultOptions=new yt,yt.defaultOptions.readOnly=!0;class xt{constructor(t){this.actionType=t,this.isPositionDependent=!1}hashCode(){const t=new l;return this.updateHashCode(t),t.finish()}updateHashCode(t){t.update(this.actionType)}equals(t){return this===t}}class Ct extends xt{constructor(){super(6)}execute(t){t.skip()}toString(){return"skip"}}Ct.INSTANCE=new Ct;class Et extends xt{constructor(t){super(0),this.channel=t}execute(t){t._channel=this.channel}updateHashCode(t){t.update(this.actionType,this.channel)}equals(t){return this===t||t instanceof Et&&this.channel===t.channel}toString(){return"channel("+this.channel+")"}}class At extends xt{constructor(t,e){super(1),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0}execute(t){t.action(null,this.ruleIndex,this.actionIndex)}updateHashCode(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)}equals(t){return this===t||t instanceof At&&this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex}}class _t extends xt{constructor(){super(3)}execute(t){t.more()}toString(){return"more"}}_t.INSTANCE=new _t;class St extends xt{constructor(t){super(7),this.type=t}execute(t){t.type=this.type}updateHashCode(t){t.update(this.actionType,this.type)}equals(t){return this===t||t instanceof St&&this.type===t.type}toString(){return"type("+this.type+")"}}class vt extends xt{constructor(t){super(5),this.mode=t}execute(t){t.pushMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof vt&&this.mode===t.mode}toString(){return"pushMode("+this.mode+")"}}class Tt extends xt{constructor(){super(4)}execute(t){t.popMode()}toString(){return"popMode"}}Tt.INSTANCE=new Tt;class bt extends xt{constructor(t){super(2),this.mode=t}execute(t){t.setMode(this.mode)}updateHashCode(t){t.update(this.actionType,this.mode)}equals(t){return this===t||t instanceof bt&&this.mode===t.mode}toString(){return"mode("+this.mode+")"}}function Nt(t,e){const r=[];return r[t-1]=e,r.map(function(t){return e})}class It{constructor(t){null==t&&(t=yt.defaultOptions),this.deserializationOptions=t,this.stateFactories=null,this.actionFactories=null}deserialize(t){const e=this.reset(t);this.checkVersion(e),e&&this.skipUUID();const r=this.readATN();this.readStates(r,e),this.readRules(r,e),this.readModes(r);const s=[];return this.readSets(r,s,this.readInt.bind(this)),e&&this.readSets(r,s,this.readInt32.bind(this)),this.readEdges(r,s),this.readDecisions(r),this.readLexerActions(r,e),this.markPrecedenceDecisions(r),this.verifyATN(r),this.deserializationOptions.generateRuleBypassTransitions&&1===r.grammarType&&(this.generateRuleBypassTransitions(r),this.verifyATN(r)),r}reset(t){if(3===(t.charCodeAt?t.charCodeAt(0):t[0])){const e=function(t){const e=t.charCodeAt(0);return e>1?e-2:e+65534},r=t.split("").map(e);return r[0]=t.charCodeAt(0),this.data=r,this.pos=0,!0}return this.data=t,this.pos=0,!1}skipUUID(){let t=0;for(;t++<8;)this.readInt()}checkVersion(t){const e=this.readInt();if(!t&&4!==e)throw"Could not deserialize ATN with version "+e+" (expected 4)."}readATN(){const t=this.readInt(),e=this.readInt();return new K(t,e)}readStates(t,e){let r,s,i;const n=[],a=[],o=this.readInt();for(let r=0;r<o;r++){const r=this.readInt();if(r===_.INVALID_TYPE){t.addState(null);continue}let s=this.readInt();e&&65535===s&&(s=-1);const i=this.stateFactory(r,s);if(r===_.LOOP_END){const t=this.readInt();n.push([i,t])}else if(i instanceof X){const t=this.readInt();a.push([i,t])}t.addState(i)}for(r=0;r<n.length;r++)s=n[r],s[0].loopBackState=t.states[s[1]];for(r=0;r<a.length;r++)s=a[r],s[0].endState=t.states[s[1]];let l=this.readInt();for(r=0;r<l;r++)i=this.readInt(),t.states[i].nonGreedy=!0;let c=this.readInt();for(r=0;r<c;r++)i=this.readInt(),t.states[i].isPrecedenceRule=!0}readRules(t,e){let r;const s=this.readInt();for(0===t.grammarType&&(t.ruleToTokenType=Nt(s,0)),t.ruleToStartState=Nt(s,0),r=0;r<s;r++){const s=this.readInt();if(t.ruleToStartState[r]=t.states[s],0===t.grammarType){let s=this.readInt();e&&65535===s&&(s=i.EOF),t.ruleToTokenType[r]=s}}for(t.ruleToStopState=Nt(s,0),r=0;r<t.states.length;r++){const e=t.states[r];e instanceof S&&(t.ruleToStopState[e.ruleIndex]=e,t.ruleToStartState[e.ruleIndex].stopState=e)}}readModes(t){const e=this.readInt();for(let r=0;r<e;r++){let e=this.readInt();t.modeToStartState.push(t.states[e])}}readSets(t,e,r){const s=this.readInt();for(let t=0;t<s;t++){const t=new A;e.push(t);const s=this.readInt();0!==this.readInt()&&t.addOne(-1);for(let e=0;e<s;e++){const e=r(),s=r();t.addRange(e,s)}}}readEdges(t,e){let r,s,i,n,a;const o=this.readInt();for(r=0;r<o;r++){const r=this.readInt(),s=this.readInt(),i=this.readInt(),a=this.readInt(),o=this.readInt(),l=this.readInt();n=this.edgeFactory(t,i,r,s,a,o,l,e),t.states[r].addTransition(n)}for(r=0;r<t.states.length;r++)for(i=t.states[r],s=0;s<i.transitions.length;s++){const e=i.transitions[s];if(!(e instanceof T))continue;let r=-1;t.ruleToStartState[e.target.ruleIndex].isPrecedenceRule&&0===e.precedence&&(r=e.target.ruleIndex),n=new dt(e.followState,r),t.ruleToStopState[e.target.ruleIndex].addTransition(n)}for(r=0;r<t.states.length;r++){if(i=t.states[r],i instanceof X){if(null===i.endState)throw"IllegalState";if(null!==i.endState.startState)throw"IllegalState";i.endState.startState=i}if(i instanceof st)for(s=0;s<i.transitions.length;s++)a=i.transitions[s].target,a instanceof at&&(a.loopBackState=i);else if(i instanceof it)for(s=0;s<i.transitions.length;s++)a=i.transitions[s].target,a instanceof nt&&(a.loopBackState=i)}}readDecisions(t){const e=this.readInt();for(let r=0;r<e;r++){const e=this.readInt(),s=t.states[e];t.decisionToState.push(s),s.decision=r}}readLexerActions(t,e){if(0===t.grammarType){const r=this.readInt();t.lexerActions=Nt(r,null);for(let s=0;s<r;s++){const r=this.readInt();let i=this.readInt();e&&65535===i&&(i=-1);let n=this.readInt();e&&65535===n&&(n=-1),t.lexerActions[s]=this.lexerActionFactory(r,i,n)}}}generateRuleBypassTransitions(t){let e;const r=t.ruleToStartState.length;for(e=0;e<r;e++)t.ruleToTokenType[e]=t.maxTokenType+e+1;for(e=0;e<r;e++)this.generateRuleBypassTransition(t,e)}generateRuleBypassTransition(t,e){let r,s;const i=new lt;i.ruleIndex=e,t.addState(i);const n=new Y;n.ruleIndex=e,t.addState(n),i.endState=n,t.defineDecisionState(i),n.startState=i;let a=null,o=null;if(t.ruleToStartState[e].isPrecedenceRule){for(o=null,r=0;r<t.states.length;r++)if(s=t.states[r],this.stateIsEndStateFor(s,e)){o=s,a=s.loopBackState.transitions[0];break}if(null===a)throw"Couldn't identify final state of the precedence rule prefix section."}else o=t.ruleToStopState[e];for(r=0;r<t.states.length;r++){s=t.states[r];for(let t=0;t<s.transitions.length;t++){const e=s.transitions[t];e!==a&&e.target===o&&(e.target=n)}}const l=t.ruleToStartState[e],c=l.transitions.length;for(;c>0;)i.addTransition(l.transitions[c-1]),l.transitions=l.transitions.slice(-1);t.ruleToStartState[e].addTransition(new dt(i)),n.addTransition(new dt(o));const u=new J;t.addState(u),u.addTransition(new ct(n,t.ruleToTokenType[e])),i.addTransition(new dt(u))}stateIsEndStateFor(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof nt))return null;const r=t.transitions[t.transitions.length-1].target;return r instanceof tt&&r.epsilonOnlyTransitions&&r.transitions[0].target instanceof S?t:null}markPrecedenceDecisions(t){for(let e=0;e<t.states.length;e++){const r=t.states[e];if(r instanceof nt&&t.ruleToStartState[r.ruleIndex].isPrecedenceRule){const t=r.transitions[r.transitions.length-1].target;t instanceof tt&&t.epsilonOnlyTransitions&&t.transitions[0].target instanceof S&&(r.isPrecedenceDecision=!0)}}}verifyATN(t){if(this.deserializationOptions.verifyATN)for(let e=0;e<t.states.length;e++){const r=t.states[e];if(null!==r)if(this.checkCondition(r.epsilonOnlyTransitions||r.transitions.length<=1),r instanceof at)this.checkCondition(null!==r.loopBackState);else if(r instanceof nt)if(this.checkCondition(null!==r.loopBackState),this.checkCondition(2===r.transitions.length),r.transitions[0].target instanceof ot)this.checkCondition(r.transitions[1].target instanceof tt),this.checkCondition(!r.nonGreedy);else{if(!(r.transitions[0].target instanceof tt))throw"IllegalState";this.checkCondition(r.transitions[1].target instanceof ot),this.checkCondition(r.nonGreedy)}else r instanceof it?(this.checkCondition(1===r.transitions.length),this.checkCondition(r.transitions[0].target instanceof nt)):r instanceof tt?this.checkCondition(null!==r.loopBackState):r instanceof et?this.checkCondition(null!==r.stopState):r instanceof X?this.checkCondition(null!==r.endState):r instanceof Y?this.checkCondition(null!==r.startState):r instanceof Z?this.checkCondition(r.transitions.length<=1||r.decision>=0):this.checkCondition(r.transitions.length<=1||r instanceof S)}}checkCondition(t,e){if(!t)throw null==e&&(e="IllegalState"),e}readInt(){return this.data[this.pos++]}readInt32(){return this.readInt()|this.readInt()<<16}edgeFactory(t,e,r,s,n,a,o,l){const c=t.states[s];switch(e){case v.EPSILON:return new dt(c);case v.RANGE:return new ut(c,0!==o?i.EOF:n,a);case v.RULE:return new T(t.states[n],a,o,c);case v.PREDICATE:return new pt(c,n,a,0!==o);case v.PRECEDENCE:return new gt(c,n);case v.ATOM:return new ct(c,0!==o?i.EOF:n);case v.ACTION:return new ht(c,n,a,0!==o);case v.SET:return new b(c,l[n]);case v.NOT_SET:return new N(c,l[n]);case v.WILDCARD:return new I(c);default:throw"The specified transition type: "+e+" is not valid."}}stateFactory(t,e){if(null===this.stateFactories){const t=[];t[_.INVALID_TYPE]=null,t[_.BASIC]=()=>new J,t[_.RULE_START]=()=>new et,t[_.BLOCK_START]=()=>new lt,t[_.PLUS_BLOCK_START]=()=>new at,t[_.STAR_BLOCK_START]=()=>new ot,t[_.TOKEN_START]=()=>new rt,t[_.RULE_STOP]=()=>new S,t[_.BLOCK_END]=()=>new Y,t[_.STAR_LOOP_BACK]=()=>new it,t[_.STAR_LOOP_ENTRY]=()=>new nt,t[_.PLUS_LOOP_BACK]=()=>new st,t[_.LOOP_END]=()=>new tt,this.stateFactories=t}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";{const r=this.stateFactories[t]();if(null!==r)return r.ruleIndex=e,r}}lexerActionFactory(t,e,r){if(null===this.actionFactories){const t=[];t[0]=(t,e)=>new Et(t),t[1]=(t,e)=>new At(t,e),t[2]=(t,e)=>new bt(t),t[3]=(t,e)=>_t.INSTANCE,t[4]=(t,e)=>Tt.INSTANCE,t[5]=(t,e)=>new vt(t),t[6]=(t,e)=>Ct.INSTANCE,t[7]=(t,e)=>new St(t),this.actionFactories=t}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,r)}}class Mt{syntaxError(t,e,r,s,i,n){}reportAmbiguity(t,e,r,s,i,n,a){}reportAttemptingFullContext(t,e,r,s,i,n){}reportContextSensitivity(t,e,r,s,i,n){}}class wt extends Mt{constructor(){super()}syntaxError(t,e,r,s,i,n){console.error("line "+r+":"+s+" "+i)}}wt.INSTANCE=new wt;class Lt extends Mt{constructor(t){if(super(),null===t)throw"delegates";return this.delegates=t,this}syntaxError(t,e,r,s,i,n){this.delegates.map(a=>a.syntaxError(t,e,r,s,i,n))}reportAmbiguity(t,e,r,s,i,n,a){this.delegates.map(o=>o.reportAmbiguity(t,e,r,s,i,n,a))}reportAttemptingFullContext(t,e,r,s,i,n){this.delegates.map(a=>a.reportAttemptingFullContext(t,e,r,s,i,n))}reportContextSensitivity(t,e,r,s,i,n){this.delegates.map(a=>a.reportContextSensitivity(t,e,r,s,i,n))}}class Ot{constructor(){this._listeners=[wt.INSTANCE],this._interp=null,this._stateNumber=-1}checkVersion(t){const e="4.13.2";e!==t&&console.log("ANTLR runtime and generated code versions disagree: "+e+"!="+t)}addErrorListener(t){this._listeners.push(t)}removeErrorListeners(){this._listeners=[]}getLiteralNames(){return Object.getPrototypeOf(this).constructor.literalNames||[]}getSymbolicNames(){return Object.getPrototypeOf(this).constructor.symbolicNames||[]}getTokenNames(){if(!this.tokenNames){const t=this.getLiteralNames(),e=this.getSymbolicNames(),r=t.length>e.length?t.length:e.length;this.tokenNames=[];for(let s=0;s<r;s++)this.tokenNames[s]=t[s]||e[s]||"<INVALID"}return this.tokenNames}getTokenTypeMap(){const t=this.getTokenNames();if(null===t)throw"The current recognizer does not provide a list of token names.";let e=this.tokenTypeMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,r){t[e]=r}),e.EOF=i.EOF,this.tokenTypeMapCache[t]=e),e}getRuleIndexMap(){const t=this.ruleNames;if(null===t)throw"The current recognizer does not provide a list of rule names.";let e=this.ruleIndexMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,r){t[e]=r}),this.ruleIndexMapCache[t]=e),e}getTokenType(t){const e=this.getTokenTypeMap()[t];return void 0!==e?e:i.INVALID_TYPE}getErrorHeader(t){return"line "+t.getOffendingToken().line+":"+t.getOffendingToken().column}getTokenErrorDisplay(t){if(null===t)return"<no token>";let e=t.text;return null===e&&(e=t.type===i.EOF?"<EOF>":"<"+t.type+">"),e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"),"'"+e+"'"}getErrorListenerDispatch(){return console.warn("Calling deprecated method in Recognizer class: getErrorListenerDispatch()"),this.getErrorListener()}getErrorListener(){return new Lt(this._listeners)}sempred(t,e,r){return!0}precpred(t,e){return!0}get atn(){return this._interp.atn}get state(){return this._stateNumber}set state(t){this._stateNumber=t}}Ot.tokenTypeMapCache={},Ot.ruleIndexMapCache={};class Rt extends i{constructor(t,e,r,s,n){super(),this.source=void 0!==t?t:Rt.EMPTY_SOURCE,this.type=void 0!==e?e:null,this.channel=void 0!==r?r:i.DEFAULT_CHANNEL,this.start=void 0!==s?s:-1,this.stop=void 0!==n?n:-1,this.tokenIndex=-1,null!==this.source[0]?(this.line=t[0].line,this.column=t[0].column):this.column=-1}clone(){const t=new Rt(this.source,this.type,this.channel,this.start,this.stop);return t.tokenIndex=this.tokenIndex,t.line=this.line,t.column=this.column,t.text=this.text,t}cloneWithType(t){const e=new Rt(this.source,t,this.channel,this.start,this.stop);return e.tokenIndex=this.tokenIndex,e.line=this.line,e.column=this.column,t===i.EOF&&(e.text=""),e}toString(){let t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"<no text>","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"}get text(){if(null!==this._text)return this._text;const t=this.getInputStream();if(null===t)return null;const e=t.size;return this.start<e&&this.stop<e?t.getText(this.start,this.stop):"<EOF>"}set text(t){this._text=t}}Rt.EMPTY_SOURCE=[null,null];class Dt{}class Ft extends Dt{constructor(t){super(),this.copyText=void 0!==t&&t}create(t,e,r,s,i,n,a,o){const l=new Rt(t,e,s,i,n);return l.line=a,l.column=o,null!==r?l.text=r:this.copyText&&null!==t[1]&&(l.text=t[1].getText(i,n)),l}createThin(t,e){const r=new Rt(null,t);return r.text=e,r}}Ft.DEFAULT=new Ft;class Pt extends Error{constructor(t){super(t.message),Error.captureStackTrace&&Error.captureStackTrace(this,Pt),this.message=t.message,this.recognizer=t.recognizer,this.input=t.input,this.ctx=t.ctx,this.offendingToken=null,this.offendingState=-1,null!==this.recognizer&&(this.offendingState=this.recognizer.state)}getExpectedTokens(){return null!==this.recognizer?this.recognizer.atn.getExpectedTokens(this.offendingState,this.ctx):null}toString(){return this.message}}class kt extends Pt{constructor(t,e,r,s){super({message:"",recognizer:t,input:e,ctx:null}),this.startIndex=r,this.deadEndConfigs=s}toString(){let t="";return this.startIndex>=0&&this.startIndex<this.input.size&&(t=this.input.getText(new E(this.startIndex,this.startIndex))),"LexerNoViableAltException"+t}}class Vt extends Ot{constructor(t){super(),this._input=t,this._factory=Ft.DEFAULT,this._tokenFactorySourcePair=[this,t],this._interp=null,this._token=null,this._tokenStartCharIndex=-1,this._tokenStartLine=-1,this._tokenStartColumn=-1,this._hitEOF=!1,this._channel=i.DEFAULT_CHANNEL,this._type=i.INVALID_TYPE,this._modeStack=[],this._mode=Vt.DEFAULT_MODE,this._text=null}reset(){null!==this._input&&this._input.seek(0),this._token=null,this._type=i.INVALID_TYPE,this._channel=i.DEFAULT_CHANNEL,this._tokenStartCharIndex=-1,this._tokenStartColumn=-1,this._tokenStartLine=-1,this._text=null,this._hitEOF=!1,this._mode=Vt.DEFAULT_MODE,this._modeStack=[],this._interp.reset()}nextToken(){if(null===this._input)throw"nextToken requires a non-null input stream.";const t=this._input.mark();try{for(;;){if(this._hitEOF)return this.emitEOF(),this._token;this._token=null,this._channel=i.DEFAULT_CHANNEL,this._tokenStartCharIndex=this._input.index,this._tokenStartColumn=this._interp.column,this._tokenStartLine=this._interp.line,this._text=null;let e=!1;for(;;){this._type=i.INVALID_TYPE;let r=Vt.SKIP;try{r=this._interp.match(this._input,this._mode)}catch(t){if(!(t instanceof Pt))throw console.log(t.stack),t;this.notifyListeners(t),this.recover(t)}if(this._input.LA(1)===i.EOF&&(this._hitEOF=!0),this._type===i.INVALID_TYPE&&(this._type=r),this._type===Vt.SKIP){e=!0;break}if(this._type!==Vt.MORE)break}if(!e)return null===this._token&&this.emit(),this._token}}finally{this._input.release(t)}}skip(){this._type=Vt.SKIP}more(){this._type=Vt.MORE}mode(t){console.warn("Calling deprecated method in Lexer class: mode(...)"),this.setMode(t)}setMode(t){this._mode=t}getMode(){return this._mode}getModeStack(){return this._modeStack}pushMode(t){this._interp.debug&&console.log("pushMode "+t),this._modeStack.push(this._mode),this.setMode(t)}popMode(){if(0===this._modeStack.length)throw"Empty Stack";return this._interp.debug&&console.log("popMode back to "+this._modeStack.slice(0,-1)),this.setMode(this._modeStack.pop()),this._mode}emitToken(t){this._token=t}emit(){const t=this._factory.create(this._tokenFactorySourcePair,this._type,this._text,this._channel,this._tokenStartCharIndex,this.getCharIndex()-1,this._tokenStartLine,this._tokenStartColumn);return this.emitToken(t),t}emitEOF(){const t=this.column,e=this.line,r=this._factory.create(this._tokenFactorySourcePair,i.EOF,null,i.DEFAULT_CHANNEL,this._input.index,this._input.index-1,e,t);return this.emitToken(r),r}getCharIndex(){return this._input.index}getAllTokens(){const t=[];let e=this.nextToken();for(;e.type!==i.EOF;)t.push(e),e=this.nextToken();return t}notifyListeners(t){const e=this._tokenStartCharIndex,r=this._input.index,s=this._input.getText(e,r),i="token recognition error at: '"+this.getErrorDisplay(s)+"'";this.getErrorListener().syntaxError(this,null,this._tokenStartLine,this._tokenStartColumn,i,t)}getErrorDisplay(t){const e=[];for(let r=0;r<t.length;r++)e.push(t[r]);return e.join("")}getErrorDisplayForChar(t){return t.charCodeAt(0)===i.EOF?"<EOF>":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t}getCharErrorDisplay(t){return"'"+this.getErrorDisplayForChar(t)+"'"}recover(t){this._input.LA(1)!==i.EOF&&(t instanceof kt?this._interp.consume(this._input):this._input.consume())}get inputStream(){return this._input}set inputStream(t){this._input=null,this._tokenFactorySourcePair=[this,this._input],this.reset(),this._input=t,this._tokenFactorySourcePair=[this,this._input]}get sourceName(){return this._input.sourceName}get type(){return this._type}set type(t){this._type=t}get line(){return this._interp.line}set line(t){this._interp.line=t}get column(){return this._interp.column}set column(t){this._interp.column=t}get text(){return null!==this._text?this._text:this._interp.getText(this._input)}set text(t){this._text=t}}function Ut(t){return t.hashCodeForConfigSet()}function $t(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}Vt.DEFAULT_MODE=0,Vt.MORE=-2,Vt.SKIP=-3,Vt.DEFAULT_TOKEN_CHANNEL=i.DEFAULT_CHANNEL,Vt.HIDDEN=i.HIDDEN_CHANNEL,Vt.MIN_CHAR_VALUE=0,Vt.MAX_CHAR_VALUE=1114111;class Bt{constructor(t){this.configLookup=new m(Ut,$t),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1}add(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==p.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);const r=this.configLookup.getOrAdd(t);if(r===t)return this.cachedHashCode=-1,this.configs.push(t),!0;const s=!this.fullCtx,i=G(r.context,t.context,s,e);return r.reachesIntoOuterContext=Math.max(r.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(r.precedenceFilterSuppressed=!0),r.context=i,!0}getStates(){const t=new m;for(let e=0;e<this.configs.length;e++)t.add(this.configs[e].state);return t}getPredicates(){const t=[];for(let e=0;e<this.configs.length;e++){const r=this.configs[e].semanticContext;r!==p.NONE&&t.push(r.semanticContext)}return t}optimizeConfigs(t){if(this.readOnly)throw"This set is readonly";if(0!==this.configLookup.length)for(let e=0;e<this.configs.length;e++){const r=this.configs[e];r.context=t.getCachedContext(r.context)}}addAll(t){for(let e=0;e<t.length;e++)this.add(t[e]);return!1}equals(t){return this===t||t instanceof Bt&&n(this.configs,t.configs)&&this.fullCtx===t.fullCtx&&this.uniqueAlt===t.uniqueAlt&&this.conflictingAlts===t.conflictingAlts&&this.hasSemanticContext===t.hasSemanticContext&&this.dipsIntoOuterContext===t.dipsIntoOuterContext}hashCode(){const t=new l;return t.update(this.configs),t.finish()}updateHashCode(t){this.readOnly?(-1===this.cachedHashCode&&(this.cachedHashCode=this.hashCode()),t.update(this.cachedHashCode)):t.update(this.hashCode())}isEmpty(){return 0===this.configs.length}contains(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.contains(t)}containsFast(t){if(null===this.configLookup)throw"This method is not implemented for readonly sets.";return this.configLookup.containsFast(t)}clear(){if(this.readOnly)throw"This set is readonly";this.configs=[],this.cachedHashCode=-1,this.configLookup=new m}setReadonly(t){this.readOnly=t,t&&(this.configLookup=null)}toString(){return d(this.configs)+(this.hasSemanticContext?",hasSemanticContext="+this.hasSemanticContext:"")+(this.uniqueAlt!==K.INVALID_ALT_NUMBER?",uniqueAlt="+this.uniqueAlt:"")+(null!==this.conflictingAlts?",conflictingAlts="+this.conflictingAlts:"")+(this.dipsIntoOuterContext?",dipsIntoOuterContext":"")}get items(){return this.configs}get length(){return this.configs.length}}class Ht{constructor(t,e){return null===t&&(t=-1),null===e&&(e=new Bt),this.stateNumber=t,this.configs=e,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}getAltSet(){const t=new m;if(null!==this.configs)for(let e=0;e<this.configs.length;e++){const r=this.configs[e];t.add(r.alt)}return 0===t.length?null:t}equals(t){return this===t||t instanceof Ht&&this.configs.equals(t.configs)}toString(){let t=this.stateNumber+":"+this.configs;return this.isAcceptState&&(t+="=>",null!==this.predicates?t+=this.predicates:t+=this.prediction),t}hashCode(){const t=new l;return t.update(this.configs),t.finish()}}class qt{constructor(t,e){return this.atn=t,this.sharedContextCache=e,this}getCachedContext(t){if(null===this.sharedContextCache)return t;const e=new q;return z(t,this.sharedContextCache,e)}}qt.ERROR=new Ht(2147483647,new Bt);class jt extends Bt{constructor(){super(),this.configLookup=new m}}class zt extends C{constructor(t,e){super(t,e);const r=t.lexerActionExecutor||null;return this.lexerActionExecutor=r||(null!==e?e.lexerActionExecutor:null),this.passedThroughNonGreedyDecision=null!==e&&this.checkNonGreedyDecision(e,this.state),this.hashCodeForConfigSet=zt.prototype.hashCode,this.equalsForConfigSet=zt.prototype.equals,this}updateHashCode(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)}equals(t){return this===t||t instanceof zt&&this.passedThroughNonGreedyDecision===t.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(t.lexerActionExecutor):!t.lexerActionExecutor)&&super.equals(t)}checkNonGreedyDecision(t,e){return t.passedThroughNonGreedyDecision||e instanceof Z&&e.nonGreedy}}class Gt extends xt{constructor(t,e){super(e.actionType),this.offset=t,this.action=e,this.isPositionDependent=!0}execute(t){this.action.execute(t)}updateHashCode(t){t.update(this.actionType,this.offset,this.action)}equals(t){return this===t||t instanceof Gt&&this.offset===t.offset&&this.action===t.action}}class Wt{constructor(t){return this.lexerActions=null===t?[]:t,this.cachedHashCode=l.hashStuff(t),this}fixOffsetBeforeMatch(t){let e=null;for(let r=0;r<this.lexerActions.length;r++)!this.lexerActions[r].isPositionDependent||this.lexerActions[r]instanceof Gt||(null===e&&(e=this.lexerActions.concat([])),e[r]=new Gt(t,this.lexerActions[r]));return null===e?this:new Wt(e)}execute(t,e,r){let s=!1;const i=e.index;try{for(let n=0;n<this.lexerActions.length;n++){let a=this.lexerActions[n];if(a instanceof Gt){const t=a.offset;e.seek(r+t),a=a.action,s=r+t!==i}else a.isPositionDependent&&(e.seek(i),s=!1);a.execute(t)}}finally{s&&e.seek(i)}}hashCode(){return this.cachedHashCode}updateHashCode(t){t.update(this.cachedHashCode)}equals(t){if(this===t)return!0;if(t instanceof Wt){if(this.cachedHashCode!=t.cachedHashCode)return!1;if(this.lexerActions.length!=t.lexerActions.length)return!1;{const e=this.lexerActions.length;for(let r=0;r<e;++r)if(!this.lexerActions[r].equals(t.lexerActions[r]))return!1;return!0}}return!1}static append(t,e){if(null===t)return new Wt([e]);const r=t.lexerActions.concat([e]);return new Wt(r)}}function Qt(t){t.index=-1,t.line=0,t.column=-1,t.dfaState=null}class Kt{constructor(){Qt(this)}reset(){Qt(this)}}class Jt extends qt{constructor(t,e,r,s){super(e,s),this.decisionToDFA=r,this.recog=t,this.startIndex=-1,this.line=1,this.column=0,this.mode=Vt.DEFAULT_MODE,this.prevAccept=new Kt}copyState(t){this.column=t.column,this.line=t.line,this.mode=t.mode,this.startIndex=t.startIndex}match(t,e){this.mode=e;const r=t.mark();try{this.startIndex=t.index,this.prevAccept.reset();const r=this.decisionToDFA[e];return null===r.s0?this.matchATN(t):this.execATN(t,r.s0)}finally{t.release(r)}}reset(){this.prevAccept.reset(),this.startIndex=-1,this.line=1,this.column=0,this.mode=Vt.DEFAULT_MODE}matchATN(t){const e=this.atn.modeToStartState[this.mode];Jt.debug&&console.log("matchATN mode "+this.mode+" start: "+e);const r=this.mode,s=this.computeStartState(t,e),i=s.hasSemanticContext;s.hasSemanticContext=!1;const n=this.addDFAState(s);i||(this.decisionToDFA[this.mode].s0=n);const a=this.execATN(t,n);return Jt.debug&&console.log("DFA after matchATN: "+this.decisionToDFA[r].toLexerString()),a}execATN(t,e){Jt.debug&&console.log("start state closure="+e.configs),e.isAcceptState&&this.captureSimState(this.prevAccept,t,e);let r=t.LA(1),s=e;for(;;){Jt.debug&&console.log("execATN loop starting closure: "+s.configs);let e=this.getExistingTargetState(s,r);if(null===e&&(e=this.computeTargetState(t,s,r)),e===qt.ERROR)break;if(r!==i.EOF&&this.consume(t),e.isAcceptState&&(this.captureSimState(this.prevAccept,t,e),r===i.EOF))break;r=t.LA(1),s=e}return this.failOrAccept(this.prevAccept,t,s.configs,r)}getExistingTargetState(t,e){if(null===t.edges||e<Jt.MIN_DFA_EDGE||e>Jt.MAX_DFA_EDGE)return null;let r=t.edges[e-Jt.MIN_DFA_EDGE];return void 0===r&&(r=null),Jt.debug&&null!==r&&console.log("reuse state "+t.stateNumber+" edge to "+r.stateNumber),r}computeTargetState(t,e,r){const s=new jt;return this.getReachableConfigSet(t,e.configs,s,r),0===s.items.length?(s.hasSemanticContext||this.addDFAEdge(e,r,qt.ERROR),qt.ERROR):this.addDFAEdge(e,r,null,s)}failOrAccept(t,e,r,s){if(null!==this.prevAccept.dfaState){const r=t.dfaState.lexerActionExecutor;return this.accept(e,r,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(s===i.EOF&&e.index===this.startIndex)return i.EOF;throw new kt(this.recog,e,this.startIndex,r)}getReachableConfigSet(t,e,r,s){let n=K.INVALID_ALT_NUMBER;for(let a=0;a<e.items.length;a++){const o=e.items[a],l=o.alt===n;if(!l||!o.passedThroughNonGreedyDecision){Jt.debug&&console.log("testing %s at %s\n",this.getTokenName(s),o.toString(this.recog,!0));for(let e=0;e<o.state.transitions.length;e++){const a=o.state.transitions[e],c=this.getReachableTarget(a,s);if(null!==c){let e=o.lexerActionExecutor;null!==e&&(e=e.fixOffsetBeforeMatch(t.index-this.startIndex));const a=s===i.EOF,u=new zt({state:c,lexerActionExecutor:e},o);this.closure(t,u,r,l,!0,a)&&(n=o.alt)}}}}}accept(t,e,r,s,i,n){Jt.debug&&console.log("ACTION %s\n",e),t.seek(s),this.line=i,this.column=n,null!==e&&null!==this.recog&&e.execute(this.recog,t,r)}getReachableTarget(t,e){return t.matches(e,0,Vt.MAX_CHAR_VALUE)?t.target:null}computeStartState(t,e){const r=U.EMPTY,s=new jt;for(let i=0;i<e.transitions.length;i++){const n=e.transitions[i].target,a=new zt({state:n,alt:i+1,context:r},null);this.closure(t,a,s,!1,!1,!1)}return s}closure(t,e,r,s,i,n){let a=null;if(Jt.debug&&console.log("closure("+e.toString(this.recog,!0)+")"),e.state instanceof S){if(Jt.debug&&(null!==this.recog?console.log("closure at %s rule stop %s\n",this.recog.ruleNames[e.state.ruleIndex],e):console.log("closure at rule stop %s\n",e)),null===e.context||e.context.hasEmptyPath()){if(null===e.context||e.context.isEmpty())return r.add(e),!0;r.add(new zt({state:e.state,context:U.EMPTY},e)),s=!0}if(null!==e.context&&!e.context.isEmpty())for(let o=0;o<e.context.length;o++)if(e.context.getReturnState(o)!==U.EMPTY_RETURN_STATE){const l=e.context.getParent(o),c=this.atn.states[e.context.getReturnState(o)];a=new zt({state:c,context:l},e),s=this.closure(t,a,r,s,i,n)}return s}e.state.epsilonOnlyTransitions||s&&e.passedThroughNonGreedyDecision||r.add(e);for(let o=0;o<e.state.transitions.length;o++){const l=e.state.transitions[o];a=this.getEpsilonTarget(t,e,l,r,i,n),null!==a&&(s=this.closure(t,a,r,s,i,n))}return s}getEpsilonTarget(t,e,r,s,n,a){let o=null;if(r.serializationType===v.RULE){const t=B.create(e.context,r.followState.stateNumber);o=new zt({state:r.target,context:t},e)}else{if(r.serializationType===v.PRECEDENCE)throw"Precedence predicates are not supported in lexers.";if(r.serializationType===v.PREDICATE)Jt.debug&&console.log("EVAL rule "+r.ruleIndex+":"+r.predIndex),s.hasSemanticContext=!0,this.evaluatePredicate(t,r.ruleIndex,r.predIndex,n)&&(o=new zt({state:r.target},e));else if(r.serializationType===v.ACTION)if(null===e.context||e.context.hasEmptyPath()){const t=Wt.append(e.lexerActionExecutor,this.atn.lexerActions[r.actionIndex]);o=new zt({state:r.target,lexerActionExecutor:t},e)}else o=new zt({state:r.target},e);else r.serializationType===v.EPSILON?o=new zt({state:r.target},e):r.serializationType!==v.ATOM&&r.serializationType!==v.RANGE&&r.serializationType!==v.SET||a&&r.matches(i.EOF,0,Vt.MAX_CHAR_VALUE)&&(o=new zt({state:r.target},e))}return o}evaluatePredicate(t,e,r,s){if(null===this.recog)return!0;if(!s)return this.recog.sempred(null,e,r);const i=this.column,n=this.line,a=t.index,o=t.mark();try{return this.consume(t),this.recog.sempred(null,e,r)}finally{this.column=i,this.line=n,t.seek(a),t.release(o)}}captureSimState(t,e,r){t.index=e.index,t.line=this.line,t.column=this.column,t.dfaState=r}addDFAEdge(t,e,r,s){if(void 0===r&&(r=null),void 0===s&&(s=null),null===r&&null!==s){const t=s.hasSemanticContext;if(s.hasSemanticContext=!1,r=this.addDFAState(s),t)return r}return e<Jt.MIN_DFA_EDGE||e>Jt.MAX_DFA_EDGE||(Jt.debug&&console.log("EDGE "+t+" -> "+r+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-Jt.MIN_DFA_EDGE]=r),r}addDFAState(t){const e=new Ht(null,t);let r=null;for(let e=0;e<t.items.length;e++){const s=t.items[e];if(s.state instanceof S){r=s;break}}null!==r&&(e.isAcceptState=!0,e.lexerActionExecutor=r.lexerActionExecutor,e.prediction=this.atn.ruleToTokenType[r.state.ruleIndex]);const s=this.decisionToDFA[this.mode],i=s.states.get(e);if(null!==i)return i;const n=e;return n.stateNumber=s.states.length,t.setReadonly(!0),n.configs=t,s.states.add(n),n}getDFA(t){return this.decisionToDFA[t]}getText(t){return t.getText(this.startIndex,t.index-1)}consume(t){t.LA(1)==="\n".charCodeAt(0)?(this.line+=1,this.column=0):this.column+=1,t.consume()}getTokenName(t){return-1===t?"EOF":"'"+String.fromCharCode(t)+"'"}}Jt.debug=!1,Jt.dfa_debug=!1,Jt.MIN_DFA_EDGE=0,Jt.MAX_DFA_EDGE=127;class Zt{constructor(t,e){this.alt=e,this.pred=t}toString(){return"("+this.pred+", "+this.alt+")"}}class Xt{constructor(){this.data={}}get(t){return this.data["k-"+t]||null}set(t,e){this.data["k-"+t]=e}values(){return Object.keys(this.data).filter(t=>t.startsWith("k-")).map(t=>this.data[t],this)}}const Yt={SLL:0,LL:1,LL_EXACT_AMBIG_DETECTION:2,hasSLLConflictTerminatingPrediction:function(t,e){if(Yt.allConfigsInRuleStopStates(e))return!0;if(t===Yt.SLL&&e.hasSemanticContext){const t=new Bt;for(let r=0;r<e.items.length;r++){let s=e.items[r];s=new C({semanticContext:p.NONE},s),t.add(s)}e=t}const r=Yt.getConflictingAltSubsets(e);return Yt.hasConflictingAltSet(r)&&!Yt.hasStateAssociatedWithOneAlt(e)},hasConfigInRuleStopState:function(t){for(let e=0;e<t.items.length;e++)if(t.items[e].state instanceof S)return!0;return!1},allConfigsInRuleStopStates:function(t){for(let e=0;e<t.items.length;e++)if(!(t.items[e].state instanceof S))return!1;return!0},resolvesToJustOneViableAlt:function(t){return Yt.getSingleViableAlt(t)},allSubsetsConflict:function(t){return!Yt.hasNonConflictingAltSet(t)},hasNonConflictingAltSet:function(t){for(let e=0;e<t.length;e++)if(1===t[e].length)return!0;return!1},hasConflictingAltSet:function(t){for(let e=0;e<t.length;e++)if(t[e].length>1)return!0;return!1},allSubsetsEqual:function(t){let e=null;for(let r=0;r<t.length;r++){const s=t[r];if(null===e)e=s;else if(s!==e)return!1}return!0},getUniqueAlt:function(t){const e=Yt.getAlts(t);return 1===e.length?e.minValue():K.INVALID_ALT_NUMBER},getAlts:function(t){const e=new W;return t.map(function(t){e.or(t)}),e},getConflictingAltSubsets:function(t){const e=new q;return e.hashFunction=function(t){l.hashStuff(t.state.stateNumber,t.context)},e.equalsFunction=function(t,e){return t.state.stateNumber===e.state.stateNumber&&t.context.equals(e.context)},t.items.map(function(t){let r=e.get(t);null===r&&(r=new W,e.set(t,r)),r.set(t.alt)}),e.getValues()},getStateToAltMap:function(t){const e=new Xt;return t.items.map(function(t){let r=e.get(t.state);null===r&&(r=new W,e.set(t.state,r)),r.set(t.alt)}),e},hasStateAssociatedWithOneAlt:function(t){const e=Yt.getStateToAltMap(t).values();for(let t=0;t<e.length;t++)if(1===e[t].length)return!0;return!1},getSingleViableAlt:function(t){let e=null;for(let r=0;r<t.length;r++){const s=t[r].minValue();if(null===e)e=s;else if(e!==s)return K.INVALID_ALT_NUMBER}return e}},te=Yt;class ee extends Pt{constructor(t,e,r,s,i,n){n=n||t._ctx,s=s||t.getCurrentToken(),r=r||t.getCurrentToken(),e=e||t.getInputStream(),super({message:"",recognizer:t,input:e,ctx:n}),this.deadEndConfigs=i,this.startToken=r,this.offendingToken=s}}class re{constructor(t){this.defaultMapCtor=t||q,this.cacheMap=new this.defaultMapCtor}get(t,e){const r=this.cacheMap.get(t)||null;return null===r?null:r.get(e)||null}set(t,e,r){let s=this.cacheMap.get(t)||null;null===s&&(s=new this.defaultMapCtor,this.cacheMap.set(t,s)),s.set(e,r)}}class se extends qt{constructor(t,e,r,s){super(e,s),this.parser=t,this.decisionToDFA=r,this.predictionMode=te.LL,this._input=null,this._startIndex=0,this._outerContext=null,this._dfa=null,this.mergeCache=null,this.debug=!1,this.debug_closure=!1,this.debug_add=!1,this.trace_atn_sim=!1,this.dfa_debug=!1,this.retry_debug=!1}reset(){}adaptivePredict(t,e,r){(this.debug||this.trace_atn_sim)&&console.log("adaptivePredict decision "+e+" exec LA(1)=="+this.getLookaheadName(t)+" line "+t.LT(1).line+":"+t.LT(1).column),this._input=t,this._startIndex=t.index,this._outerContext=r;const s=this.decisionToDFA[e];this._dfa=s;const i=t.mark(),n=t.index;try{let e;if(e=s.precedenceDfa?s.getPrecedenceStartState(this.parser.getPrecedence()):s.s0,null===e){null===r&&(r=V.EMPTY),this.debug&&console.log("predictATN decision "+s.decision+" exec LA(1)=="+this.getLookaheadName(t)+", outerContext="+r.toString(this.parser.ruleNames));const i=!1;let n=this.computeStartState(s.atnStartState,V.EMPTY,i);s.precedenceDfa?(s.s0.configs=n,n=this.applyPrecedenceFilter(n),e=this.addDFAState(s,new Ht(null,n)),s.setPrecedenceStartState(this.parser.getPrecedence(),e)):(e=this.addDFAState(s,new Ht(null,n)),s.s0=e)}const i=this.execATN(s,e,t,n,r);return this.debug&&console.log("DFA after predictATN: "+s.toString(this.parser.literalNames,this.parser.symbolicNames)),i}finally{this._dfa=null,this.mergeCache=null,t.seek(n),t.release(i)}}execATN(t,e,r,s,n){let a;(this.debug||this.trace_atn_sim)&&console.log("execATN decision "+t.decision+", DFA state "+e+", LA(1)=="+this.getLookaheadName(r)+" line "+r.LT(1).line+":"+r.LT(1).column);let o=e;this.debug&&console.log("s0 = "+e);let l=r.LA(1);for(;;){let e=this.getExistingTargetState(o,l);if(null===e&&(e=this.computeTargetState(t,o,l)),e===qt.ERROR){const t=this.noViableAlt(r,n,o.configs,s);if(r.seek(s),a=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(o.configs,n),a!==K.INVALID_ALT_NUMBER)return a;throw t}if(e.requiresFullContext&&this.predictionMode!==te.SLL){let i=null;if(null!==e.predicates){this.debug&&console.log("DFA state has preds in DFA sim LL failover");const t=r.index;if(t!==s&&r.seek(s),i=this.evalSemanticContext(e.predicates,n,!0),1===i.length)return this.debug&&console.log("Full LL avoided"),i.minValue();t!==s&&r.seek(t)}this.dfa_debug&&console.log("ctx sensitive state "+n+" in "+e);const o=!0,l=this.computeStartState(t.atnStartState,n,o);return this.reportAttemptingFullContext(t,i,e.configs,s,r.index),a=this.execATNWithFullContext(t,e,l,r,s,n),a}if(e.isAcceptState){if(null===e.predicates)return e.prediction;const i=r.index;r.seek(s);const a=this.evalSemanticContext(e.predicates,n,!0);if(0===a.length)throw this.noViableAlt(r,n,e.configs,s);return 1===a.length||this.reportAmbiguity(t,e,s,i,!1,a,e.configs),a.minValue()}o=e,l!==i.EOF&&(r.consume(),l=r.LA(1))}}getExistingTargetState(t,e){const r=t.edges;return null===r?null:r[e+1]||null}computeTargetState(t,e,r){const s=this.computeReachSet(e.configs,r,!1);if(null===s)return this.addDFAEdge(t,e,r,qt.ERROR),qt.ERROR;let i=new Ht(null,s);const n=this.getUniqueAlt(s);if(this.debug){const t=te.getConflictingAltSubsets(s);console.log("SLL altSubSets="+d(t)+", configs="+s+", predict="+n+", allSubsetsConflict="+te.allSubsetsConflict(t)+", conflictingAlts="+this.getConflictingAlts(s))}return n!==K.INVALID_ALT_NUMBER?(i.isAcceptState=!0,i.configs.uniqueAlt=n,i.prediction=n):te.hasSLLConflictTerminatingPrediction(this.predictionMode,s)&&(i.configs.conflictingAlts=this.getConflictingAlts(s),i.requiresFullContext=!0,i.isAcceptState=!0,i.prediction=i.configs.conflictingAlts.minValue()),i.isAcceptState&&i.configs.hasSemanticContext&&(this.predicateDFAState(i,this.atn.getDecisionState(t.decision)),null!==i.predicates&&(i.prediction=K.INVALID_ALT_NUMBER)),i=this.addDFAEdge(t,e,r,i),i}predicateDFAState(t,e){const r=e.transitions.length,s=this.getConflictingAltsOrUniqueAlt(t.configs),i=this.getPredsForAmbigAlts(s,t.configs,r);null!==i?(t.predicates=this.getPredicatePredictions(s,i),t.prediction=K.INVALID_ALT_NUMBER):t.prediction=s.minValue()}execATNWithFullContext(t,e,r,s,n,a){(this.debug||this.trace_atn_sim)&&console.log("execATNWithFullContext "+r);let o,l=!1,c=r;s.seek(n);let u=s.LA(1),h=-1;for(;;){if(o=this.computeReachSet(c,u,!0),null===o){const t=this.noViableAlt(s,a,c,n);s.seek(n);const e=this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(c,a);if(e!==K.INVALID_ALT_NUMBER)return e;throw t}const t=te.getConflictingAltSubsets(o);if(this.debug&&console.log("LL altSubSets="+t+", predict="+te.getUniqueAlt(t)+", resolvesToJustOneViableAlt="+te.resolvesToJustOneViableAlt(t)),o.uniqueAlt=this.getUniqueAlt(o),o.uniqueAlt!==K.INVALID_ALT_NUMBER){h=o.uniqueAlt;break}if(this.predictionMode!==te.LL_EXACT_AMBIG_DETECTION){if(h=te.resolvesToJustOneViableAlt(t),h!==K.INVALID_ALT_NUMBER)break}else if(te.allSubsetsConflict(t)&&te.allSubsetsEqual(t)){l=!0,h=te.getSingleViableAlt(t);break}c=o,u!==i.EOF&&(s.consume(),u=s.LA(1))}return o.uniqueAlt!==K.INVALID_ALT_NUMBER?(this.reportContextSensitivity(t,h,o,n,s.index),h):(this.reportAmbiguity(t,e,n,s.index,l,null,o),h)}computeReachSet(t,e,r){this.debug&&console.log("in computeReachSet, starting closure: "+t),null===this.mergeCache&&(this.mergeCache=new re);const s=new Bt(r);let n=null;for(let a=0;a<t.items.length;a++){const o=t.items[a];if(this.debug&&console.log("testing "+this.getTokenName(e)+" at "+o),o.state instanceof S)(r||e===i.EOF)&&(null===n&&(n=[]),n.push(o),this.debug_add&&console.log("added "+o+" to skippedStopStates"));else for(let t=0;t<o.state.transitions.length;t++){const r=o.state.transitions[t],i=this.getReachableTarget(r,e);if(null!==i){const t=new C({state:i},o);s.add(t,this.mergeCache),this.debug_add&&console.log("added "+t+" to intermediate")}}}let a=null;if(null===n&&e!==i.EOF&&(1===s.items.length||this.getUniqueAlt(s)!==K.INVALID_ALT_NUMBER)&&(a=s),null===a){a=new Bt(r);const t=new m,n=e===i.EOF;for(let e=0;e<s.items.length;e++)this.closure(s.items[e],a,t,!1,r,n)}if(e===i.EOF&&(a=this.removeAllConfigsNotInRuleStopState(a,a===s)),!(null===n||r&&te.hasConfigInRuleStopState(a)))for(let t=0;t<n.length;t++)a.add(n[t],this.mergeCache);return this.trace_atn_sim&&console.log("computeReachSet "+t+" -> "+a),0===a.items.length?null:a}removeAllConfigsNotInRuleStopState(t,e){if(te.allConfigsInRuleStopStates(t))return t;const r=new Bt(t.fullCtx);for(let s=0;s<t.items.length;s++){const n=t.items[s];if(n.state instanceof S)r.add(n,this.mergeCache);else if(e&&n.state.epsilonOnlyTransitions&&this.atn.nextTokens(n.state).contains(i.EPSILON)){const t=this.atn.ruleToStopState[n.state.ruleIndex];r.add(new C({state:t},n),this.mergeCache)}}return r}computeStartState(t,e,r){const s=j(this.atn,e),i=new Bt(r);this.trace_atn_sim&&console.log("computeStartState from ATN state "+t+" initialContext="+s.toString(this.parser));for(let e=0;e<t.transitions.length;e++){const n=t.transitions[e].target,a=new C({state:n,alt:e+1,context:s},null),o=new m;this.closure(a,i,o,!0,r,!1)}return i}applyPrecedenceFilter(t){let e;const r=[],s=new Bt(t.fullCtx);for(let i=0;i<t.items.length;i++){if(e=t.items[i],1!==e.alt)continue;const n=e.semanticContext.evalPrecedence(this.parser,this._outerContext);null!==n&&(r[e.state.stateNumber]=e.context,n!==e.semanticContext?s.add(new C({semanticContext:n},e),this.mergeCache):s.add(e,this.mergeCache))}for(let i=0;i<t.items.length;i++)if(e=t.items[i],1!==e.alt){if(!e.precedenceFilterSuppressed){const t=r[e.state.stateNumber]||null;if(null!==t&&t.equals(e.context))continue}s.add(e,this.mergeCache)}return s}getReachableTarget(t,e){return t.matches(e,0,this.atn.maxTokenType)?t.target:null}getPredsForAmbigAlts(t,e,r){let s=[];for(let r=0;r<e.items.length;r++){const i=e.items[r];t.get(i.alt)&&(s[i.alt]=p.orContext(s[i.alt]||null,i.semanticContext))}let i=0;for(let t=1;t<r+1;t++){const e=s[t]||null;null===e?s[t]=p.NONE:e!==p.NONE&&(i+=1)}return 0===i&&(s=null),this.debug&&console.log("getPredsForAmbigAlts result "+d(s)),s}getPredicatePredictions(t,e){const r=[];let s=!1;for(let i=1;i<e.length;i++){const n=e[i];null!==t&&t.get(i)&&r.push(new Zt(n,i)),n!==p.NONE&&(s=!0)}return s?r:null}getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(t,e){const r=this.splitAccordingToSemanticValidity(t,e),s=r[0],i=r[1];let n=this.getAltThatFinishedDecisionEntryRule(s);return n!==K.INVALID_ALT_NUMBER||i.items.length>0&&(n=this.getAltThatFinishedDecisionEntryRule(i),n!==K.INVALID_ALT_NUMBER)?n:K.INVALID_ALT_NUMBER}getAltThatFinishedDecisionEntryRule(t){const e=[];for(let r=0;r<t.items.length;r++){const s=t.items[r];(s.reachesIntoOuterContext>0||s.state instanceof S&&s.context.hasEmptyPath())&&e.indexOf(s.alt)<0&&e.push(s.alt)}return 0===e.length?K.INVALID_ALT_NUMBER:Math.min.apply(null,e)}splitAccordingToSemanticValidity(t,e){const r=new Bt(t.fullCtx),s=new Bt(t.fullCtx);for(let i=0;i<t.items.length;i++){const n=t.items[i];n.semanticContext!==p.NONE?n.semanticContext.evaluate(this.parser,e)?r.add(n):s.add(n):r.add(n)}return[r,s]}evalSemanticContext(t,e,r){const s=new W;for(let i=0;i<t.length;i++){const n=t[i];if(n.pred===p.NONE){if(s.set(n.alt),!r)break;continue}const a=n.pred.evaluate(this.parser,e);if((this.debug||this.dfa_debug)&&console.log("eval pred "+n+"="+a),a&&((this.debug||this.dfa_debug)&&console.log("PREDICT "+n.alt),s.set(n.alt),!r))break}return s}closure(t,e,r,s,i,n){this.closureCheckingStopState(t,e,r,s,i,0,n)}closureCheckingStopState(t,e,r,s,i,n,a){if((this.trace_atn_sim||this.debug_closure)&&console.log("closure("+t.toString(this.parser,!0)+")"),t.state instanceof S){if(!t.context.isEmpty()){for(let o=0;o<t.context.length;o++){if(t.context.getReturnState(o)===U.EMPTY_RETURN_STATE){if(i){e.add(new C({state:t.state,context:U.EMPTY},t),this.mergeCache);continue}this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex)),this.closure_(t,e,r,s,i,n,a);continue}const l=this.atn.states[t.context.getReturnState(o)],c=t.context.getParent(o),u={state:l,alt:t.alt,context:c,semanticContext:t.semanticContext},h=new C(u,null);h.reachesIntoOuterContext=t.reachesIntoOuterContext,this.closureCheckingStopState(h,e,r,s,i,n-1,a)}return}if(i)return void e.add(t,this.mergeCache);this.debug&&console.log("FALLING off rule "+this.getRuleName(t.state.ruleIndex))}this.closure_(t,e,r,s,i,n,a)}closure_(t,e,r,s,i,n,a){const o=t.state;o.epsilonOnlyTransitions||e.add(t,this.mergeCache);for(let l=0;l<o.transitions.length;l++){if(0===l&&this.canDropLoopEntryEdgeInLeftRecursiveRule(t))continue;const c=o.transitions[l],u=s&&!(c instanceof ht),h=this.getEpsilonTarget(t,c,u,0===n,i,a);if(null!==h){let s=n;if(t.state instanceof S){if(null!==this._dfa&&this._dfa.precedenceDfa&&c.outermostPrecedenceReturn===this._dfa.atnStartState.ruleIndex&&(h.precedenceFilterSuppressed=!0),h.reachesIntoOuterContext+=1,r.getOrAdd(h)!==h)continue;e.dipsIntoOuterContext=!0,s-=1,this.debug&&console.log("dips into outer ctx: "+h)}else{if(!c.isEpsilon&&r.getOrAdd(h)!==h)continue;c instanceof T&&s>=0&&(s+=1)}this.closureCheckingStopState(h,e,r,u,i,s,a)}}}canDropLoopEntryEdgeInLeftRecursiveRule(t){const e=t.state;if(e.stateType!==_.STAR_LOOP_ENTRY)return!1;if(e.stateType!==_.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;const r=t.context.length;for(let s=0;s<r;s++)if(this.atn.states[t.context.getReturnState(s)].ruleIndex!==e.ruleIndex)return!1;const s=e.transitions[0].target.endState.stateNumber,i=this.atn.states[s];for(let s=0;s<r;s++){const r=t.context.getReturnState(s),n=this.atn.states[r];if(1!==n.transitions.length||!n.transitions[0].isEpsilon)return!1;const a=n.transitions[0].target;if(!(n.stateType===_.BLOCK_END&&a===e||n===i||a===i||a.stateType===_.BLOCK_END&&1===a.transitions.length&&a.transitions[0].isEpsilon&&a.transitions[0].target===e))return!1}return!0}getRuleName(t){return null!==this.parser&&t>=0?this.parser.ruleNames[t]:"<rule "+t+">"}getEpsilonTarget(t,e,r,s,n,a){switch(e.serializationType){case v.RULE:return this.ruleTransition(t,e);case v.PRECEDENCE:return this.precedenceTransition(t,e,r,s,n);case v.PREDICATE:return this.predTransition(t,e,r,s,n);case v.ACTION:return this.actionTransition(t,e);case v.EPSILON:return new C({state:e.target},t);case v.ATOM:case v.RANGE:case v.SET:return a&&e.matches(i.EOF,0,1)?new C({state:e.target},t):null;default:return null}}actionTransition(t,e){if(this.debug){const t=-1===e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+t)}return new C({state:e.target},t)}precedenceTransition(t,e,r,s,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+d(this.parser.getRuleInvocationStack())));let n=null;if(r&&s)if(i){const r=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),s&&(n=new C({state:e.target},t))}else{const r=p.andContext(t.semanticContext,e.getPredicate());n=new C({state:e.target,semanticContext:r},t)}else n=new C({state:e.target},t);return this.debug&&console.log("config from pred transition="+n),n}predTransition(t,e,r,s,i){this.debug&&(console.log("PRED (collectPredicates="+r+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+d(this.parser.getRuleInvocationStack())));let n=null;if(r&&(e.isCtxDependent&&s||!e.isCtxDependent))if(i){const r=this._input.index;this._input.seek(this._startIndex);const s=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(r),s&&(n=new C({state:e.target},t))}else{const r=p.andContext(t.semanticContext,e.getPredicate());n=new C({state:e.target,semanticContext:r},t)}else n=new C({state:e.target},t);return this.debug&&console.log("config from pred transition="+n),n}ruleTransition(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);const r=e.followState,s=B.create(t.context,r.stateNumber);return new C({state:e.target,context:s},t)}getConflictingAlts(t){const e=te.getConflictingAltSubsets(t);return te.getAlts(e)}getConflictingAltsOrUniqueAlt(t){let e=null;return t.uniqueAlt!==K.INVALID_ALT_NUMBER?(e=new W,e.set(t.uniqueAlt)):e=t.conflictingAlts,e}getTokenName(t){if(t===i.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t}getLookaheadName(t){return this.getTokenName(t.LA(1))}dumpDeadEndConfigs(t){console.log("dead end configs: ");const e=t.getDeadEndConfigs();for(let t=0;t<e.length;t++){const r=e[t];let s="no edges";if(r.state.transitions.length>0){const t=r.state.transitions[0];t instanceof ct?s="Atom "+this.getTokenName(t.label):t instanceof b&&(s=(t instanceof N?"~":"")+"Set "+t.set)}console.error(r.toString(this.parser,!0)+":"+s)}}noViableAlt(t,e,r,s){return new ee(this.parser,t,t.get(s),t.LT(1),r,e)}getUniqueAlt(t){let e=K.INVALID_ALT_NUMBER;for(let r=0;r<t.items.length;r++){const s=t.items[r];if(e===K.INVALID_ALT_NUMBER)e=s.alt;else if(s.alt!==e)return K.INVALID_ALT_NUMBER}return e}addDFAEdge(t,e,r,s){if(this.debug&&console.log("EDGE "+e+" -> "+s+" upon "+this.getTokenName(r)),null===s)return null;if(s=this.addDFAState(t,s),null===e||r<-1||r>this.atn.maxTokenType)return s;if(null===e.edges&&(e.edges=[]),e.edges[r+1]=s,this.debug){const e=null===this.parser?null:this.parser.literalNames,r=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(e,r))}return s}addDFAState(t,e){if(e===qt.ERROR)return e;const r=t.states.get(e);return null!==r?(this.trace_atn_sim&&console.log("addDFAState "+e+" exists"),r):(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),this.trace_atn_sim&&console.log("addDFAState new "+e),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)}reportAttemptingFullContext(t,e,r,s,i){if(this.debug||this.retry_debug){const e=new E(s,i+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportAttemptingFullContext(this.parser,t,s,i,e,r)}reportContextSensitivity(t,e,r,s,i){if(this.debug||this.retry_debug){const e=new E(s,i+1);console.log("reportContextSensitivity decision="+t.decision+":"+r+", input="+this.parser.getTokenStream().getText(e))}null!==this.parser&&this.parser.getErrorListener().reportContextSensitivity(this.parser,t,s,i,e,r)}reportAmbiguity(t,e,r,s,i,n,a){if(this.debug||this.retry_debug){const t=new E(r,s+1);console.log("reportAmbiguity "+n+":"+a+", input="+this.parser.getTokenStream().getText(t))}null!==this.parser&&this.parser.getErrorListener().reportAmbiguity(this.parser,t,r,s,i,n,a)}}class ie{constructor(){this.cache=new q}add(t){if(t===U.EMPTY)return U.EMPTY;const e=this.cache.get(t)||null;return null!==e?e:(this.cache.set(t,t),t)}get(t){return this.cache.get(t)||null}get length(){return this.cache.length}}const ne={ATN:K,ATNDeserializer:It,LexerATNSimulator:Jt,ParserATNSimulator:se,PredictionMode:te,PredictionContextCache:ie};class ae{constructor(t,e,r){this.dfa=t,this.literalNames=e||[],this.symbolicNames=r||[]}toString(){if(null===this.dfa.s0)return null;let t="";const e=this.dfa.sortedStates();for(let r=0;r<e.length;r++){const s=e[r];if(null!==s.edges){const e=s.edges.length;for(let r=0;r<e;r++){const e=s.edges[r]||null;null!==e&&2147483647!==e.stateNumber&&(t=t.concat(this.getStateString(s)),t=t.concat("-"),t=t.concat(this.getEdgeLabel(r)),t=t.concat("->"),t=t.concat(this.getStateString(e)),t=t.concat("\n"))}}}return 0===t.length?null:t}getEdgeLabel(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)}getStateString(t){const e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+d(t.predicates):e+"=>"+t.prediction.toString():e}}class oe extends ae{constructor(t){super(t,null)}getEdgeLabel(t){return"'"+String.fromCharCode(t)+"'"}}class le{constructor(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new m,this.s0=null,this.precedenceDfa=!1,t instanceof nt&&t.isPrecedenceDecision){this.precedenceDfa=!0;const t=new Ht(null,new Bt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}}getPrecedenceStartState(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null}setPrecedenceStartState(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)}setPrecedenceDfa(t){if(this.precedenceDfa!==t){if(this._states=new m,t){const t=new Ht(null,new Bt);t.edges=[],t.isAcceptState=!1,t.requiresFullContext=!1,this.s0=t}else this.s0=null;this.precedenceDfa=t}}sortedStates(){return this._states.values().sort(function(t,e){return t.stateNumber-e.stateNumber})}toString(t,e){return t=t||null,e=e||null,null===this.s0?"":new ae(this,t,e).toString()}toLexerString(){return null===this.s0?"":new oe(this).toString()}get states(){return this._states}}const ce={DFA:le,DFASerializer:ae,LexerDFASerializer:oe,PredPrediction:Zt},ue={PredictionContext:U},he={Interval:E,IntervalSet:A};class de{visitTerminal(t){}visitErrorNode(t){}enterEveryRule(t){}exitEveryRule(t){}}class me{visit(t){return Array.isArray(t)?t.map(function(t){return t.accept(this)},this):t.accept(this)}visitChildren(t){return t.children?this.visit(t.children):null}visitTerminal(t){}visitErrorNode(t){}}class pe{walk(t,e){if(e instanceof F||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof D)t.visitTerminal(e);else{this.enterRule(t,e);for(let r=0;r<e.getChildCount();r++){const s=e.getChild(r);this.walk(t,s)}this.exitRule(t,e)}}enterRule(t,e){const r=e.ruleContext;t.enterEveryRule(r),r.enterRule(t)}exitRule(t,e){const r=e.ruleContext;r.exitRule(t),t.exitEveryRule(r)}}pe.DEFAULT=new pe;const fe={Trees:k,RuleNode:R,ErrorNode:F,TerminalNode:D,ParseTreeListener:de,ParseTreeVisitor:me,ParseTreeWalker:pe};class ge extends Pt{constructor(t){super({message:"",recognizer:t,input:t.getInputStream(),ctx:t._ctx}),this.offendingToken=t.getCurrentToken()}}class ye extends Pt{constructor(t,e,r){super({message:xe(e,r||null),recognizer:t,input:t.getInputStream(),ctx:t._ctx});const s=t._interp.atn.states[t.state].transitions[0];s instanceof pt?(this.ruleIndex=s.ruleIndex,this.predicateIndex=s.predIndex):(this.ruleIndex=0,this.predicateIndex=0),this.predicate=e,this.offendingToken=t.getCurrentToken()}}function xe(t,e){return null!==e?e:"failed predicate: {"+t+"}?"}class Ce extends Mt{constructor(t){super(),t=t||!0,this.exactOnly=t}reportAmbiguity(t,e,r,s,i,n,a){if(this.exactOnly&&!i)return;const o="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(n,a)+", input='"+t.getTokenStream().getText(new E(r,s))+"'";t.notifyErrorListeners(o)}reportAttemptingFullContext(t,e,r,s,i,n){const a="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new E(r,s))+"'";t.notifyErrorListeners(a)}reportContextSensitivity(t,e,r,s,i,n){const a="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new E(r,s))+"'";t.notifyErrorListeners(a)}getDecisionDescription(t,e){const r=e.decision,s=e.atnStartState.ruleIndex,i=t.ruleNames;if(s<0||s>=i.length)return""+r;const n=i[s]||null;return null===n||0===n.length?""+r:`${r} (${n})`}getConflictingAlts(t,e){if(null!==t)return t;const r=new W;for(let t=0;t<e.items.length;t++)r.set(e.items[t].alt);return`{${r.values().join(", ")}}`}}class Ee extends Error{constructor(){super(),Error.captureStackTrace(this,Ee)}}class Ae{reset(t){}recoverInline(t){}recover(t,e){}sync(t){}inErrorRecoveryMode(t){}reportError(t){}}class _e extends Ae{constructor(){super(),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this.nextTokensContext=null,this.nextTokenState=0}reset(t){this.endErrorCondition(t)}beginErrorCondition(t){this.errorRecoveryMode=!0}inErrorRecoveryMode(t){return this.errorRecoveryMode}endErrorCondition(t){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1}reportMatch(t){this.endErrorCondition(t)}reportError(t,e){this.inErrorRecoveryMode(t)||(this.beginErrorCondition(t),e instanceof ee?this.reportNoViableAlternative(t,e):e instanceof ge?this.reportInputMismatch(t,e):e instanceof ye?this.reportFailedPredicate(t,e):(console.log("unknown recognition error type: "+e.constructor.name),console.log(e.stack),t.notifyErrorListeners(e.getOffendingToken(),e.getMessage(),e)))}recover(t,e){this.lastErrorIndex===t.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(t.state)>=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);const r=this.getErrorRecoverySet(t);this.consumeUntil(t,r)}sync(t){if(this.inErrorRecoveryMode(t))return;const e=t._interp.atn.states[t.state],r=t.getTokenStream().LA(1),s=t.atn.nextTokens(e);if(s.contains(r))return this.nextTokensContext=null,void(this.nextTokenState=_.INVALID_STATE_NUMBER);if(s.contains(i.EPSILON))null===this.nextTokensContext&&(this.nextTokensContext=t._ctx,this.nextTokensState=t._stateNumber);else switch(e.stateType){case _.BLOCK_START:case _.STAR_BLOCK_START:case _.PLUS_BLOCK_START:case _.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new ge(t);case _.PLUS_LOOP_BACK:case _.STAR_LOOP_BACK:{this.reportUnwantedToken(t);const e=new A;e.addSet(t.getExpectedTokens());const r=e.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,r)}}}reportNoViableAlternative(t,e){const r=t.getTokenStream();let s;s=null!==r?e.startToken.type===i.EOF?"<EOF>":r.getText(new E(e.startToken.tokenIndex,e.offendingToken.tokenIndex)):"<unknown input>";const n="no viable alternative at input "+this.escapeWSAndQuote(s);t.notifyErrorListeners(n,e.offendingToken,e)}reportInputMismatch(t,e){const r="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e.offendingToken,e)}reportFailedPredicate(t,e){const r="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(r,e.offendingToken,e)}reportUnwantedToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),r="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(r,e,null)}reportMissingToken(t){if(this.inErrorRecoveryMode(t))return;this.beginErrorCondition(t);const e=t.getCurrentToken(),r="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(r,e,null)}recoverInline(t){const e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new ge(t)}singleTokenInsertion(t){const e=t.getTokenStream().LA(1),r=t._interp.atn,s=r.states[t.state].transitions[0].target;return!!r.nextTokens(s,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)}singleTokenDeletion(t){const e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();const e=t.getCurrentToken();return this.reportMatch(t),e}return null}getMissingSymbol(t){const e=t.getCurrentToken(),r=this.getExpectedTokens(t).first();let s;s=r===i.EOF?"<missing EOF>":"<missing "+t.literalNames[r]+">";let n=e;const a=t.getTokenStream().LT(-1);return n.type===i.EOF&&null!==a&&(n=a),t.getTokenFactory().create(n.source,r,s,i.DEFAULT_CHANNEL,-1,-1,n.line,n.column)}getExpectedTokens(t){return t.getExpectedTokens()}getTokenErrorDisplay(t){if(null===t)return"<no token>";let e=t.text;return null===e&&(e=t.type===i.EOF?"<EOF>":"<"+t.type+">"),this.escapeWSAndQuote(e)}escapeWSAndQuote(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"}getErrorRecoverySet(t){const e=t._interp.atn;let r=t._ctx;const s=new A;for(;null!==r&&r.invokingState>=0;){const t=e.states[r.invokingState].transitions[0],i=e.nextTokens(t.followState);s.addSet(i),r=r.parentCtx}return s.removeOne(i.EPSILON),s}consumeUntil(t,e){let r=t.getTokenStream().LA(1);for(;r!==i.EOF&&!e.contains(r);)t.consume(),r=t.getTokenStream().LA(1)}}class Se extends _e{constructor(){super()}recover(t,e){let r=t._ctx;for(;null!==r;)r.exception=e,r=r.parentCtx;throw new Ee(e)}recoverInline(t){this.recover(t,new ge(t))}sync(t){}}const ve={RecognitionException:Pt,NoViableAltException:ee,LexerNoViableAltException:kt,InputMismatchException:ge,FailedPredicateException:ye,DiagnosticErrorListener:Ce,BailErrorStrategy:Se,DefaultErrorStrategy:_e,ErrorListener:Mt};class Te{constructor(t,e){if(this.name="<empty>",this.strdata=t,this.decodeToUnicodeCodePoints=e||!1,this._index=0,this.data=[],this.decodeToUnicodeCodePoints)for(let t=0;t<this.strdata.length;){const e=this.strdata.codePointAt(t);this.data.push(e),t+=e<=65535?1:2}else{this.data=new Array(this.strdata.length);for(let t=0;t<this.strdata.length;t++)this.data[t]=this.strdata.charCodeAt(t)}this._size=this.data.length}reset(){this._index=0}consume(){if(this._index>=this._size)throw"cannot consume EOF";this._index+=1}LA(t){if(0===t)return 0;t<0&&(t+=1);const e=this._index+t-1;return e<0||e>=this._size?i.EOF:this.data[e]}LT(t){return this.LA(t)}mark(){return-1}release(t){}seek(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)}getText(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){let r="";for(let s=t;s<=e;s++)r+=String.fromCodePoint(this.data[s]);return r}return this.strdata.slice(t,e+1)}toString(){return this.strdata}get index(){return this._index}get size(){return this._size}}class be extends Te{constructor(t,e){super(t,e)}}const Ne=r(9896),Ie="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;class Me extends be{static fromPath(t,e,r){if(!Ie)throw new Error("FileStream is only available when running in Node!");Ne.readFile(t,e,function(t,e){let s=null;null!==e&&(s=new Te(e,!0)),r(t,s)})}constructor(t,e,r){if(!Ie)throw new Error("FileStream is only available when running in Node!");super(Ne.readFileSync(t,e||"utf-8"),r),this.fileName=t}}const we={fromString:function(t){return new Te(t,!0)},fromBlob:function(t,e,r,s){const i=new window.FileReader;i.onload=function(t){const e=new Te(t.target.result,!0);r(e)},i.onerror=s,i.readAsText(t,e)},fromBuffer:function(t,e){return new Te(t.toString(e),!0)},fromPath:function(t,e,r){Me.fromPath(t,e,r)},fromPathSync:function(t,e){return new Me(t,e)}},Le={arrayToString:d,stringToCharArray:function(t){let e=new Uint16Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}};class Oe{}class Re extends Oe{constructor(t){super(),this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}mark(){return 0}release(t){}reset(){this.seek(0)}seek(t){this.lazyInit(),this.index=this.adjustSeekIndex(t)}get size(){return this.tokens.length}get(t){return this.lazyInit(),this.tokens[t]}consume(){let t=!1;if(t=this.index>=0&&(this.fetchedEOF?this.index<this.tokens.length-1:this.index<this.tokens.length),!t&&this.LA(1)===i.EOF)throw"cannot consume EOF";this.sync(this.index+1)&&(this.index=this.adjustSeekIndex(this.index+1))}sync(t){const e=t-this.tokens.length+1;return!(e>0)||this.fetch(e)>=e}fetch(t){if(this.fetchedEOF)return 0;for(let e=0;e<t;e++){const t=this.tokenSource.nextToken();if(t.tokenIndex=this.tokens.length,this.tokens.push(t),t.type===i.EOF)return this.fetchedEOF=!0,e+1}return t}getTokens(t,e,r){if(void 0===r&&(r=null),t<0||e<0)return null;this.lazyInit();const s=[];e>=this.tokens.length&&(e=this.tokens.length-1);for(let n=t;n<e;n++){const t=this.tokens[n];if(t.type===i.EOF)break;(null===r||r.contains(t.type))&&s.push(t)}return s}LA(t){return this.LT(t).type}LB(t){return this.index-t<0?null:this.tokens[this.index-t]}LT(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);const e=this.index+t-1;return this.sync(e),e>=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]}adjustSeekIndex(t){return t}lazyInit(){-1===this.index&&this.setup()}setup(){this.sync(0),this.index=this.adjustSeekIndex(0)}setTokenSource(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1}nextTokenOnChannel(t,e){if(this.sync(t),t>=this.tokens.length)return-1;let r=this.tokens[t];for(;r.channel!==e;){if(r.type===i.EOF)return-1;t+=1,this.sync(t),r=this.tokens[t]}return t}previousTokenOnChannel(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t}getHiddenTokensToRight(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const r=this.nextTokenOnChannel(t+1,Vt.DEFAULT_TOKEN_CHANNEL),s=t+1,i=-1===r?this.tokens.length-1:r;return this.filterForChannel(s,i,e)}getHiddenTokensToLeft(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;const r=this.previousTokenOnChannel(t-1,Vt.DEFAULT_TOKEN_CHANNEL);if(r===t-1)return null;const s=r+1,i=t-1;return this.filterForChannel(s,i,e)}filterForChannel(t,e,r){const s=[];for(let i=t;i<e+1;i++){const t=this.tokens[i];-1===r?t.channel!==Vt.DEFAULT_TOKEN_CHANNEL&&s.push(t):t.channel===r&&s.push(t)}return 0===s.length?null:s}getSourceName(){return this.tokenSource.getSourceName()}getText(t){this.lazyInit(),this.fill(),t||(t=new E(0,this.tokens.length-1));let e=t.start;e instanceof i&&(e=e.tokenIndex);let r=t.stop;if(r instanceof i&&(r=r.tokenIndex),null===e||null===r||e<0||r<0)return"";r>=this.tokens.length&&(r=this.tokens.length-1);let s="";for(let t=e;t<r+1;t++){const e=this.tokens[t];if(e.type===i.EOF)break;s+=e.text}return s}fill(){for(this.lazyInit();1e3===this.fetch(1e3););}}Object.defineProperty(Re,"size",{get:function(){return this.tokens.length}});class De extends Re{constructor(t,e){super(t),this.channel=void 0===e?i.DEFAULT_CHANNEL:e}adjustSeekIndex(t){return this.nextTokenOnChannel(t,this.channel)}LB(t){if(0===t||this.index-t<0)return null;let e=this.index,r=1;for(;r<=t;)e=this.previousTokenOnChannel(e-1,this.channel),r+=1;return e<0?null:this.tokens[e]}LT(t){if(this.lazyInit(),0===t)return null;if(t<0)return this.LB(-t);let e=this.index,r=1;for(;r<t;)this.sync(e+1)&&(e=this.nextTokenOnChannel(e+1,this.channel)),r+=1;return this.tokens[e]}getNumberOfOnChannelTokens(){let t=0;this.fill();for(let e=0;e<this.tokens.length;e++){const r=this.tokens[e];if(r.channel===this.channel&&(t+=1),r.type===i.EOF)break}return t}}class Fe extends de{constructor(t){super(),this.parser=t}enterEveryRule(t){console.log("enter "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}visitTerminal(t){console.log("consume "+t.symbol+" rule "+this.parser.ruleNames[this.parser._ctx.ruleIndex])}exitEveryRule(t){console.log("exit "+this.parser.ruleNames[t.ruleIndex]+", LT(1)="+this.parser._input.LT(1).text)}}class Pe extends Ot{constructor(t){super(),this._input=null,this._errHandler=new _e,this._precedenceStack=[],this._precedenceStack.push(0),this._ctx=null,this.buildParseTrees=!0,this._tracer=null,this._parseListeners=null,this._syntaxErrors=0,this.setInputStream(t)}reset(){null!==this._input&&this._input.seek(0),this._errHandler.reset(this),this._ctx=null,this._syntaxErrors=0,this.setTrace(!1),this._precedenceStack=[],this._precedenceStack.push(0),null!==this._interp&&this._interp.reset()}match(t){let e=this.getCurrentToken();return e.type===t?(this._errHandler.reportMatch(this),this.consume()):(e=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===e.tokenIndex&&this._ctx.addErrorNode(e)),e}matchWildcard(){let t=this.getCurrentToken();return t.type>0?(this._errHandler.reportMatch(this),this.consume()):(t=this._errHandler.recoverInline(this),this.buildParseTrees&&-1===t.tokenIndex&&this._ctx.addErrorNode(t)),t}getParseListeners(){return this._parseListeners||[]}addParseListener(t){if(null===t)throw"listener";null===this._parseListeners&&(this._parseListeners=[]),this._parseListeners.push(t)}removeParseListener(t){if(null!==this._parseListeners){const e=this._parseListeners.indexOf(t);e>=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}}removeParseListeners(){this._parseListeners=null}triggerEnterRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.forEach(function(e){e.enterEveryRule(t),t.enterRule(e)})}}triggerExitRuleEvent(){if(null!==this._parseListeners){const t=this._ctx;this._parseListeners.slice(0).reverse().forEach(function(e){t.exitRule(e),e.exitEveryRule(t)})}}getTokenFactory(){return this._input.tokenSource._factory}setTokenFactory(t){this._input.tokenSource._factory=t}getATNWithBypassAlts(){const t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";let e=this.bypassAltsAtnCache[t];if(null===e){const r=new yt;r.generateRuleBypassTransitions=!0,e=new It(r).deserialize(t),this.bypassAltsAtnCache[t]=e}return e}getInputStream(){return this.getTokenStream()}setInputStream(t){this.setTokenStream(t)}getTokenStream(){return this._input}setTokenStream(t){this._input=null,this.reset(),this._input=t}get syntaxErrorsCount(){return this._syntaxErrors}getCurrentToken(){return this._input.LT(1)}notifyErrorListeners(t,e,r){r=r||null,null===(e=e||null)&&(e=this.getCurrentToken()),this._syntaxErrors+=1;const s=e.line,i=e.column;this.getErrorListener().syntaxError(this,e,s,i,t,r)}consume(){const t=this.getCurrentToken();t.type!==i.EOF&&this.getInputStream().consume();const e=null!==this._parseListeners&&this._parseListeners.length>0;if(this.buildParseTrees||e){let r;r=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t),r.invokingState=this.state,e&&this._parseListeners.forEach(function(t){r instanceof F||void 0!==r.isErrorNode&&r.isErrorNode()?t.visitErrorNode(r):r instanceof D&&t.visitTerminal(r)})}return t}addContextToParseTree(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)}enterRule(t,e,r){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),this.triggerEnterRuleEvent()}exitRule(){this._ctx.stop=this._input.LT(-1),this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx}enterOuterAlt(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t}getPrecedence(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]}enterRecursionRule(t,e,r,s){this.state=e,this._precedenceStack.push(s),this._ctx=t,this._ctx.start=this._input.LT(1),this.triggerEnterRuleEvent()}pushNewRecursionContext(t,e,r){const s=this._ctx;s.parentCtx=t,s.invokingState=e,s.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=s.start,this.buildParseTrees&&this._ctx.addChild(s),this.triggerEnterRuleEvent()}unrollRecursionContexts(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);const e=this._ctx,r=this.getParseListeners();if(null!==r&&r.length>0)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)}getInvokingContext(t){let e=this._ctx;for(;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null}precpred(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]}inContext(t){return!1}isExpectedToken(t){const e=this._interp.atn;let r=this._ctx;const s=e.states[this.state];let n=e.nextTokens(s);if(n.contains(t))return!0;if(!n.contains(i.EPSILON))return!1;for(;null!==r&&r.invokingState>=0&&n.contains(i.EPSILON);){const s=e.states[r.invokingState].transitions[0];if(n=e.nextTokens(s.followState),n.contains(t))return!0;r=r.parentCtx}return!(!n.contains(i.EPSILON)||t!==i.EOF)}getExpectedTokens(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)}getExpectedTokensWithinCurrentRule(){const t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)}getRuleIndex(t){const e=this.getRuleIndexMap()[t];return null!==e?e:-1}getRuleInvocationStack(t){null===(t=t||null)&&(t=this._ctx);const e=[];for(;null!==t;){const r=t.ruleIndex;r<0?e.push("n/a"):e.push(this.ruleNames[r]),t=t.parentCtx}return e}getDFAStrings(){return this._interp.decisionToDFA.toString()}dumpDFA(){let t=!1;for(let e=0;e<this._interp.decisionToDFA.length;e++){const r=this._interp.decisionToDFA[e];r.states.length>0&&(t&&console.log(),this.printer.println("Decision "+r.decision+":"),this.printer.print(r.toString(this.literalNames,this.symbolicNames)),t=!0)}}getSourceName(){return this._input.getSourceName()}setTrace(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new Fe(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)}}Pe.bypassAltsAtnCache={};class ke extends D{constructor(t){super(),this.parentCtx=null,this.symbol=t}getChild(t){return null}getSymbol(){return this.symbol}getParent(){return this.parentCtx}getPayload(){return this.symbol}getSourceInterval(){if(null===this.symbol)return E.INVALID_INTERVAL;const t=this.symbol.tokenIndex;return new E(t,t)}getChildCount(){return 0}accept(t){return t.visitTerminal(this)}getText(){return this.symbol.text}toString(){return this.symbol.type===i.EOF?"<EOF>":this.symbol.text}}class Ve extends ke{constructor(t){super(t)}isErrorNode(){return!0}accept(t){return t.visitErrorNode(this)}}class Ue extends V{constructor(t,e){super(t,e),this.children=null,this.start=null,this.stop=null,this.exception=null}copyFrom(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map(function(t){t instanceof Ve&&(this.children.push(t),t.parentCtx=this)},this))}enterRule(t){}exitRule(t){}addChild(t){return null===this.children&&(this.children=[]),this.children.push(t),t}removeLastChild(){null!==this.children&&this.children.pop()}addTokenNode(t){const e=new ke(t);return this.addChild(e),e.parentCtx=this,e}addErrorNode(t){const e=new Ve(t);return this.addChild(e),e.parentCtx=this,e}getChild(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(let r=0;r<this.children.length;r++){const s=this.children[r];if(s instanceof e){if(0===t)return s;t-=1}}return null}getToken(t,e){if(null===this.children||e<0||e>=this.children.length)return null;for(let r=0;r<this.children.length;r++){const s=this.children[r];if(s instanceof D&&s.symbol.type===t){if(0===e)return s;e-=1}}return null}getTokens(t){if(null===this.children)return[];{const e=[];for(let r=0;r<this.children.length;r++){const s=this.children[r];s instanceof D&&s.symbol.type===t&&e.push(s)}return e}}getTypedRuleContext(t,e){return this.getChild(e,t)}getTypedRuleContexts(t){if(null===this.children)return[];{const e=[];for(let r=0;r<this.children.length;r++){const s=this.children[r];s instanceof t&&e.push(s)}return e}}getChildCount(){return null===this.children?0:this.children.length}getSourceInterval(){return null===this.start||null===this.stop?E.INVALID_INTERVAL:new E(this.start.tokenIndex,this.stop.tokenIndex)}}V.EMPTY=new Ue;class $e{static DEFAULT_PROGRAM_NAME="default";constructor(t){this.tokens=t,this.programs=new Map}getTokenStream(){return this.tokens}insertAfter(t,e){let r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;r="number"==typeof t?t:t.tokenIndex;let i=this.getProgram(s),n=new qe(this.tokens,r,i.length,e);i.push(n)}insertBefore(t,e){let r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;r="number"==typeof t?t:t.tokenIndex;const i=this.getProgram(s),n=new He(this.tokens,r,i.length,e);i.push(n)}replaceSingle(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;this.replace(t,t,e,r)}replace(t,e,r){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$e.DEFAULT_PROGRAM_NAME;if("number"!=typeof t&&(t=t.tokenIndex),"number"!=typeof e&&(e=e.tokenIndex),t>e||t<0||e<0||e>=this.tokens.size)throw new RangeError(`replace: range invalid: ${t}..${e}(size=${this.tokens.size})`);let i=this.getProgram(s),n=new je(this.tokens,t,e,i.length,r);i.push(n)}delete(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e.DEFAULT_PROGRAM_NAME;void 0===e&&(e=t),this.replace(t,e,null,r)}getProgram(t){let e=this.programs.get(t);return null==e&&(e=this.initializeProgram(t)),e}initializeProgram(t){const e=[];return this.programs.set(t,e),e}getText(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$e.DEFAULT_PROGRAM_NAME;e=t instanceof E?t:new E(0,this.tokens.size-1),"string"==typeof t&&(r=t);const s=this.programs.get(r);let n=e.start,a=e.stop;if(a>this.tokens.size-1&&(a=this.tokens.size-1),n<0&&(n=0),null==s||0===s.length)return this.tokens.getText(new E(n,a));let o=[],l=this.reduceToSingleOperationPerIndex(s),c=n;for(;c<=a&&c<this.tokens.size;){let t=l.get(c);l.delete(c);let e=this.tokens.get(c);null==t?(e.type!==i.EOF&&o.push(String(e.text)),c++):c=t.execute(o)}if(a===this.tokens.size-1)for(const t of l.values())t.index>=this.tokens.size-1&&o.push(t.text.toString());return o.join("")}reduceToSingleOperationPerIndex(t){for(let e=0;e<t.length;e++){let r=t[e];if(null==r)continue;if(!(r instanceof je))continue;let s=r,i=this.getKindOfOps(t,He,e);for(let e of i)e.index===s.index?(t[e.instructionIndex]=void 0,s.text=e.text.toString()+(null!=s.text?s.text.toString():"")):e.index>s.index&&e.index<=s.lastIndex&&(t[e.instructionIndex]=void 0);let n=this.getKindOfOps(t,je,e);for(let e of n){if(e.index>=s.index&&e.lastIndex<=s.lastIndex){t[e.instructionIndex]=void 0;continue}let r=e.lastIndex<s.index||e.index>s.lastIndex;if(null!=e.text||null!=s.text||r){if(!r)throw new Error(`replace op boundaries of ${s} overlap with previous ${e}`)}else t[e.instructionIndex]=void 0,s.index=Math.min(e.index,s.index),s.lastIndex=Math.max(e.lastIndex,s.lastIndex)}}for(let e=0;e<t.length;e++){let r=t[e];if(null==r)continue;if(!(r instanceof He))continue;let s=r,i=this.getKindOfOps(t,He,e);for(let e of i)e.index===s.index&&(e instanceof qe?(s.text=this.catOpText(e.text,s.text),t[e.instructionIndex]=void 0):e instanceof He&&(s.text=this.catOpText(s.text,e.text),t[e.instructionIndex]=void 0));let n=this.getKindOfOps(t,je,e);for(let r of n)if(s.index!==r.index){if(s.index>=r.index&&s.index<=r.lastIndex)throw new Error(`insert op ${s} within boundaries of previous ${r}`)}else r.text=this.catOpText(s.text,r.text),t[e]=void 0}let e=new Map;for(let r of t)if(null!=r){if(null!=e.get(r.index))throw new Error("should only be one op per index");e.set(r.index,r)}return e}catOpText(t,e){let r="",s="";return null!=t&&(r=t.toString()),null!=e&&(s=e.toString()),r+s}getKindOfOps(t,e,r){return t.slice(0,r).filter(t=>t&&t instanceof e)}}class Be{constructor(t,e,r,s){this.tokens=t,this.instructionIndex=r,this.index=e,this.text=void 0===s?"":s}toString(){let t=this.constructor.name;const e=t.indexOf("$");return t=t.substring(e+1,t.length),"<"+t+"@"+this.tokens.get(this.index)+':"'+this.text+'">'}}class He extends Be{constructor(t,e,r,s){super(t,e,r,s)}execute(t){return this.text&&t.push(this.text.toString()),this.tokens.get(this.index).type!==i.EOF&&t.push(String(this.tokens.get(this.index).text)),this.index+1}}class qe extends He{constructor(t,e,r,s){super(t,e+1,r,s)}}class je extends Be{constructor(t,e,r,s,i){super(t,e,s,i),this.lastIndex=r}execute(t){return this.text&&t.push(this.text.toString()),this.lastIndex+1}toString(){return null==this.text?"<DeleteOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+">":"<ReplaceOp@"+this.tokens.get(this.index)+".."+this.tokens.get(this.lastIndex)+':"'+this.text+'">'}}const ze={atn:ne,dfa:ce,context:ue,misc:he,tree:fe,error:ve,Token:i,CommonToken:Rt,CharStreams:we,CharStream:Te,InputStream:be,FileStream:Me,CommonTokenStream:De,Lexer:Vt,Parser:Pe,ParserRuleContext:Ue,Interval:E,IntervalSet:A,LL1Analyzer:Q,Utils:Le,TokenStreamRewriter:$e};var Ge=e;for(var We in s)Ge[We]=s[We];s.__esModule&&Object.defineProperty(Ge,"__esModule",{value:!0})})()}};const __webpack_module_cache__={};function __webpack_require__(t){const e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;const r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}let __webpack_exports__=__webpack_require__(5803);module.exports.mathjslab=__webpack_exports__})();