Skip to content

Instantly share code, notes, and snippets.

@fasiha
Last active April 23, 2022 02:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasiha/2bbfc20ef882d76e27f17df31950d156 to your computer and use it in GitHub Desktop.
Save fasiha/2bbfc20ef882d76e27f17df31950d156 to your computer and use it in GitHub Desktop.
Random samples from (directed) spherical caps
license: mit

@Pedro77 posted their approach to generating random points on the surface of a sphere contained in a cone emanating from the middle of the sphere—a cone pointing in a specified direction and with a specified angular extent.

In other words, they wanted a way to randomly sample points from the spherical cap (Mathworld, Wikipedia) parameterized by

  • an angle, rather than a height, and
  • a specific direction, in terms of a 3D vector, rather than assuming the cap was centered on the sphere’s North Pole.

@Pedro77’s technique used rejection sampling (generating random points on the sphere’s surface until one was found that met the criteria).

I was able to cobble together an implementation of a deterministic algorithm (in 😭Matlab😭) using the insights from @joriki and @Jim Belk—see these to learn some surprising facts about the surface areas of cuts of cylinders and spheres (they’re the same!).

In order to more easily visualize samples from spherical caps, and to get a feel for scijs and modern JavaScript as exemplified by d3 4.0 (“D3 is written using ES2015 modules … create a custom bundle using Rollup…”), I put together an ES2015 package to generate points on such directed spherical caps, sphere-cap-random, which can run in the browser or in Node.

Here’s a taste of what that looks like (here’s the rest):

export default function sampleSphericalCap(params) {
  params = params == null ? {N : 1, z : 0} : params;

  const π = Math.PI;
  const π2 = 2 * π;
  const radPerDeg = π / 180;

  const minZ =
      (params.z ? +params.z
                : (params.deg ? Math.cos(+params.deg * radPerDeg)
                              : (params.rad ? Math.cos(+params.rad) : 0)));
  const N = params.N ? +params.N : 1;
  return pack(Array.from({length : N}, _ => {
           const z = Math.random() * (1 - minZ) + minZ;
           const r = Math.sqrt(1 - z * z);
           const θ = Math.random() * π2;
           const x = r * Math.cos(θ);
           const y = r * Math.sin(θ);
           return [ x, y, z ];
         })).transpose(1, 0);
}

The 3D scatter plot above, courtesy of plotly.js, shows random samples from three spherical caps:

  • the 30° spherical cap at the North Pole,
  • the 30° spherical cap pointing towards the middle of the first octant, [1, 1, 1], and
  • the 110° spherical cap, which looks like a Dymaxion dome, at the South Pole.
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.capRandom=e.capRandom||{})}(this,function(e){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function t(e,r){return r={exports:{}},e(r,r.exports),r.exports}function n(e){return ke(e)}function a(e){return ke(e.transpose(1,0))}function i(e){e=null==e?{N:1,z:0}:e;var r=Math.PI,t=2*r,n=r/180,a=e.z?+e.z:e.deg?Math.cos(+e.deg*n):e.rad?Math.cos(+e.rad):0,i=e.N?+e.N:1;return re(Array.from({length:i},function(e){var r=Math.random()*(1-a)+a,n=Math.sqrt(1-r*r),i=Math.random()*t,o=n*Math.cos(i),s=n*Math.sin(i);return[o,s,r]})).transpose(1,0)}function o(e){return e.data?e:re(e)}function s(e){for(var r=f(o(e)),t=f(l(c(0,0,1),r)),n=Math.acos(l(x([0,0,1],[1,3]),r).get(0,0)),a=u(t,n),s=arguments.length,p=Array(s>1?s-1:0),h=1;h<s;h++)p[h-1]=arguments[h];var d=i.apply(void 0,p);return l(a,d)}function u(e,r){var t=c.apply(void 0,B(p(e)));G(t,Math.sin(r));var n=j([3,3]);return $(ue(n),Math.cos(r)),W(n,t),oe(n,e,e.transpose(1,0),1-Math.cos(r),1),n}function c(e,r,t){return re([[0,-t,r],[t,0,-e],[-r,e,0]])}function l(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return r.reduce(function(e,r){var t=j([e.shape[0],r.shape[1]]);return oe(t,e,r),t})}function p(e){return e.data||e}function f(e){for(var r=0;r<e.shape[1];r++){var t=e.pick(null,r),n=X(t);n>0&&H(t,n)}return e}function h(e){for(var r=j(e.shape),t=0;t<e.shape[1];t++){var n=e.pick(null,t),a=X(n);a>0&&K(r.pick(null,t),n,a)}return r}function d(){return Y(x([1,2,3,4],[2,2]))}function y(){var e=Y(j([2,2])),r=x([100,200,300,400],[2,2]),t=j([2,2]);return z(t,e,r),t}var m="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},g=t(function(e){function r(e){for(var r=new Array(e),t=0;t<e;++t)r[t]=t;return r}e.exports=r}),v=r(g),b=Object.freeze({default:v}),_=t(function(e){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function t(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}e.exports=function(e){return null!=e&&(r(e)||t(e)||!!e._isBuffer)}}),w=r(_),k=Object.freeze({default:w}),S=t(function(e){function t(e,r){return e[0]-r[0]}function n(){var e,r=this.stride,n=new Array(r.length);for(e=0;e<n.length;++e)n[e]=[Math.abs(r[e]),e];n.sort(t);var a=new Array(n.length);for(e=0;e<a.length;++e)a[e]=n[e][1];return a}function a(e,r){var t=["View",r,"d",e].join("");r<0&&(t="View_Nil"+e);var a="generic"===e;if(r===-1){var i="function "+t+"(a){this.data=a;};var proto="+t+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+t+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+t+"(a){return new "+t+"(a);}",o=new Function(i);return o()}if(0===r){var i="function "+t+"(a,d) {this.data = a;this.offset = d};var proto="+t+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+t+"_copy() {return new "+t+"(this.data,this.offset)};proto.pick=function "+t+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+t+"_get(){return "+(a?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+t+"_set(v){return "+(a?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+t+"(a,b,c,d){return new "+t+"(a,d)}",o=new Function("TrivialArray",i);return o(l[e][0])}var i=["'use strict'"],u=s(r),c=u.map(function(e){return"i"+e}),p="this.offset+"+u.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),f=u.map(function(e){return"b"+e}).join(","),h=u.map(function(e){return"c"+e}).join(",");i.push("function "+t+"(a,"+f+","+h+",d){this.data=a","this.shape=["+f+"]","this.stride=["+h+"]","this.offset=d|0}","var proto="+t+".prototype","proto.dtype='"+e+"'","proto.dimension="+r),i.push("Object.defineProperty(proto,'size',{get:function "+t+"_size(){return "+u.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===r?i.push("proto.order=[0]"):(i.push("Object.defineProperty(proto,'order',{get:"),r<4?(i.push("function "+t+"_order(){"),2===r?i.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===r&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):i.push("ORDER})")),i.push("proto.set=function "+t+"_set("+c.join(",")+",v){"),a?i.push("return this.data.set("+p+",v)}"):i.push("return this.data["+p+"]=v}"),i.push("proto.get=function "+t+"_get("+c.join(",")+"){"),a?i.push("return this.data.get("+p+")}"):i.push("return this.data["+p+"]}"),i.push("proto.index=function "+t+"_index(",c.join(),"){return "+p+"}"),i.push("proto.hi=function "+t+"_hi("+c.join(",")+"){return new "+t+"(this.data,"+u.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+u.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var d=u.map(function(e){return"a"+e+"=this.shape["+e+"]"}),y=u.map(function(e){return"c"+e+"=this.stride["+e+"]"});i.push("proto.lo=function "+t+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+y.join(","));for(var m=0;m<r;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");i.push("return new "+t+"(this.data,"+u.map(function(e){return"a"+e}).join(",")+","+u.map(function(e){return"c"+e}).join(",")+",b)}"),i.push("proto.step=function "+t+"_step("+c.join(",")+"){var "+u.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+u.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var m=0;m<r;++m)i.push("if(typeof i"+m+"==='number'){d=i"+m+"|0;if(d<0){c+=b"+m+"*(a"+m+"-1);a"+m+"=ceil(-a"+m+"/d)}else{a"+m+"=ceil(a"+m+"/d)}b"+m+"*=d}");i.push("return new "+t+"(this.data,"+u.map(function(e){return"a"+e}).join(",")+","+u.map(function(e){return"b"+e}).join(",")+",c)}");for(var g=new Array(r),v=new Array(r),m=0;m<r;++m)g[m]="a[i"+m+"]",v[m]="b[i"+m+"]";i.push("proto.transpose=function "+t+"_transpose("+c+"){"+c.map(function(e,r){return e+"=("+e+"===undefined?"+r+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+t+"(this.data,"+g.join(",")+","+v.join(",")+",this.offset)}"),i.push("proto.pick=function "+t+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var m=0;m<r;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+t+"(data,shape,stride,offset){return new "+t+"(data,"+u.map(function(e){return"shape["+e+"]"}).join(",")+","+u.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",i.join("\n"));return o(l[e],n)}function i(e){if(u(e))return"buffer";if(c)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}function o(e,r,t,n){if(void 0===e){var o=l.array[0];return o([])}"number"==typeof e&&(e=[e]),void 0===r&&(r=[e.length]);var s=r.length;if(void 0===t){t=new Array(s);for(var u=s-1,c=1;u>=0;--u)t[u]=c,c*=r[u]}if(void 0===n){n=0;for(var u=0;u<s;++u)t[u]<0&&(n-=(r[u]-1)*t[u])}for(var p=i(e),f=l[p];f.length<=s+1;)f.push(a(p,f.length-1));var o=f[s+1];return o(e,r,t,n)}var s=r(b),u=r(k),c="undefined"!=typeof Float64Array,l={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=o}),x=r(S),E=Object.freeze({default:x}),A=t(function(e){function t(e){switch(e){case"uint8":return Uint8Array;case"uint16":return Uint16Array;case"uint32":return Uint32Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float":case"float32":return Float32Array;case"double":case"float64":return Float64Array;case"uint8_clamped":return Uint8ClampedArray;case"generic":case"buffer":case"data":case"dataview":return ArrayBuffer;case"array":return Array}}var n=r(E);e.exports=function(e,r){r=r||"float64";for(var a=1,i=0;i<e.length;++i)a*=e[i];return n(new(t(r))(a),e)}}),j=r(A),I=t(function(e){function r(e,r){for(var t=1,n=e.length,a=e[0],i=e[0],o=1;o<n;++o)if(i=a,a=e[o],r(a,i)){if(o===t){t++;continue}e[t++]=a}return e.length=t,e}function t(e){for(var r=1,t=e.length,n=e[0],a=e[0],i=1;i<t;++i,a=n)if(a=n,n=e[i],n!==a){if(i===r){r++;continue}e[r++]=n}return e.length=r,e}function n(e,n,a){return 0===e.length?e:n?(a||e.sort(n),r(e,n)):(a||e.sort(),t(e))}e.exports=n}),C=r(I),V=Object.freeze({default:C}),L=t(function(e){function t(e,r,t){var n,a,i=e.length,o=r.arrayArgs.length,s=r.indexArgs.length>0,u=[],c=[],l=0,p=0;for(n=0;n<i;++n)c.push(["i",n,"=0"].join(""));for(a=0;a<o;++a)for(n=0;n<i;++n)p=l,l=e[n],0===n?c.push(["d",a,"s",n,"=t",a,"p",l].join("")):c.push(["d",a,"s",n,"=(t",a,"p",l,"-s",p,"*t",a,"p",p,")"].join(""));for(u.push("var "+c.join(",")),n=i-1;n>=0;--n)l=e[n],u.push(["for(i",n,"=0;i",n,"<s",l,";++i",n,"){"].join(""));for(u.push(t),n=0;n<i;++n){for(p=l,l=e[n],a=0;a<o;++a)u.push(["p",a,"+=d",a,"s",n].join(""));s&&(n>0&&u.push(["index[",p,"]-=s",p].join("")),u.push(["++index[",l,"]"].join(""))),u.push("}")}return u.join("\n")}function n(e,r,n,a){for(var i=r.length,o=n.arrayArgs.length,s=n.blockSize,u=n.indexArgs.length>0,c=[],l=0;l<o;++l)c.push(["var offset",l,"=p",l].join(""));for(var l=e;l<i;++l)c.push(["for(var j"+l+"=SS[",r[l],"]|0;j",l,">0;){"].join("")),c.push(["if(j",l,"<",s,"){"].join("")),c.push(["s",r[l],"=j",l].join("")),c.push(["j",l,"=0"].join("")),c.push(["}else{s",r[l],"=",s].join("")),c.push(["j",l,"-=",s,"}"].join("")),u&&c.push(["index[",r[l],"]=j",l].join(""));for(var l=0;l<o;++l){for(var p=["offset"+l],f=e;f<i;++f)p.push(["j",f,"*t",l,"p",r[f]].join(""));c.push(["p",l,"=(",p.join("+"),")"].join(""))}c.push(t(r,n,a));for(var l=e;l<i;++l)c.push("}");return c.join("\n")}function a(e){for(var r=0,t=e[0].length;r<t;){for(var n=1;n<e.length;++n)if(e[n][r]!==e[0][r])return r;++r}return r}function i(e,r,t){for(var n=e.body,a=[],i=[],o=0;o<e.args.length;++o){var s=e.args[o];if(!(s.count<=0)){var u=new RegExp(s.name,"g"),c="",l=r.arrayArgs.indexOf(o);switch(r.argTypes[o]){case"offset":var p=r.offsetArgIndex.indexOf(o),f=r.offsetArgs[p];l=f.array,c="+q"+p;case"array":c="p"+l+c;var h="l"+o,d="a"+l;if(0===r.arrayBlockIndices[l])1===s.count?"generic"===t[l]?s.lvalue?(a.push(["var ",h,"=",d,".get(",c,")"].join("")),n=n.replace(u,h),i.push([d,".set(",c,",",h,")"].join(""))):n=n.replace(u,[d,".get(",c,")"].join("")):n=n.replace(u,[d,"[",c,"]"].join("")):"generic"===t[l]?(a.push(["var ",h,"=",d,".get(",c,")"].join("")),n=n.replace(u,h),s.lvalue&&i.push([d,".set(",c,",",h,")"].join(""))):(a.push(["var ",h,"=",d,"[",c,"]"].join("")),n=n.replace(u,h),s.lvalue&&i.push([d,"[",c,"]=",h].join("")));else{for(var y=[s.name],m=[c],g=0;g<Math.abs(r.arrayBlockIndices[l]);g++)y.push("\\s*\\[([^\\]]+)\\]"),m.push("$"+(g+1)+"*t"+l+"b"+g);if(u=new RegExp(y.join(""),"g"),c=m.join("+"),"generic"===t[l])throw new Error("cwise: Generic arrays not supported in combination with blocks!");n=n.replace(u,[d,"[",c,"]"].join(""))}break;case"scalar":n=n.replace(u,"Y"+r.scalarArgs.indexOf(o));break;case"index":n=n.replace(u,"index");break;case"shape":n=n.replace(u,"shape")}}}return[a.join("\n"),n,i.join("\n")].join("\n").trim()}function o(e){for(var r=new Array(e.length),t=!0,n=0;n<e.length;++n){var a=e[n],i=a.match(/\d+/);i=i?i[0]:"",0===a.charAt(0)?r[n]="u"+a.charAt(1)+i:r[n]=a.charAt(0)+i,n>0&&(t=t&&r[n]===r[n-1])}return t?r[0]:r.join("")}function s(e,r){for(var s=r[1].length-Math.abs(e.arrayBlockIndices[0])|0,c=new Array(e.arrayArgs.length),l=new Array(e.arrayArgs.length),p=0;p<e.arrayArgs.length;++p)l[p]=r[2*p],c[p]=r[2*p+1];for(var f=[],h=[],d=[],y=[],m=[],p=0;p<e.arrayArgs.length;++p){e.arrayBlockIndices[p]<0?(d.push(0),y.push(s),f.push(s),h.push(s+e.arrayBlockIndices[p])):(d.push(e.arrayBlockIndices[p]),y.push(e.arrayBlockIndices[p]+s),f.push(0),h.push(e.arrayBlockIndices[p]));for(var g=[],v=0;v<c[p].length;v++)d[p]<=c[p][v]&&c[p][v]<y[p]&&g.push(c[p][v]-d[p]);m.push(g)}for(var b=["SS"],_=["'use strict'"],w=[],v=0;v<s;++v)w.push(["s",v,"=SS[",v,"]"].join(""));for(var p=0;p<e.arrayArgs.length;++p){b.push("a"+p),b.push("t"+p),b.push("p"+p);for(var v=0;v<s;++v)w.push(["t",p,"p",v,"=t",p,"[",d[p]+v,"]"].join(""));for(var v=0;v<Math.abs(e.arrayBlockIndices[p]);++v)w.push(["t",p,"b",v,"=t",p,"[",f[p]+v,"]"].join(""))}for(var p=0;p<e.scalarArgs.length;++p)b.push("Y"+p);if(e.shapeArgs.length>0&&w.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var k=new Array(s),p=0;p<s;++p)k[p]="0";w.push(["index=[",k.join(","),"]"].join(""))}for(var p=0;p<e.offsetArgs.length;++p){for(var S=e.offsetArgs[p],x=[],v=0;v<S.offset.length;++v)0!==S.offset[v]&&(1===S.offset[v]?x.push(["t",S.array,"p",v].join("")):x.push([S.offset[v],"*t",S.array,"p",v].join("")));0===x.length?w.push("q"+p+"=0"):w.push(["q",p,"=",x.join("+")].join(""))}var E=u([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));w=w.concat(E),_.push("var "+w.join(","));for(var p=0;p<e.arrayArgs.length;++p)_.push("p"+p+"|=0");e.pre.body.length>3&&_.push(i(e.pre,e,l));var A=i(e.body,e,l),j=a(m);j<s?_.push(n(j,m[0],e,A)):_.push(t(m[0],e,A)),e.post.body.length>3&&_.push(i(e.post,e,l)),e.debug&&console.log("-----Generated cwise routine for ",r,":\n"+_.join("\n")+"\n----------");var I=[e.funcName||"unnamed","_cwise_loop_",c[0].join("s"),"m",j,o(l)].join(""),C=new Function(["function ",I,"(",b.join(","),"){",_.join("\n"),"} return ",I].join(""));return C()}var u=r(V);e.exports=s}),N=r(L),O=Object.freeze({default:N}),P=t(function(e){function t(e){var r=["'use strict'","var CACHED={}"],t=[],a=e.funcName+"_cwise_thunk";r.push(["return function ",a,"(",e.shimArgs.join(","),"){"].join(""));for(var i=[],o=[],s=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],u=[],c=[],l=0;l<e.arrayArgs.length;++l){var p=e.arrayArgs[l];t.push(["t",p,"=array",p,".dtype,","r",p,"=array",p,".order"].join("")),i.push("t"+p),i.push("r"+p),o.push("t"+p),o.push("r"+p+".join()"),s.push("array"+p+".data"),s.push("array"+p+".stride"),s.push("array"+p+".offset|0"),l>0&&(u.push("array"+e.arrayArgs[0]+".shape.length===array"+p+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[l]))),c.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+p+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[l])+"]"))}e.arrayArgs.length>1&&(r.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),r.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),r.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),r.push("}"));for(var l=0;l<e.scalarArgs.length;++l)s.push("scalar"+e.scalarArgs[l]);t.push(["type=[",o.join(","),"].join()"].join("")),t.push("proc=CACHED[type]"),r.push("var "+t.join(",")),r.push(["if(!proc){","CACHED[type]=proc=compile([",i.join(","),"])}","return proc(",s.join(","),")}"].join("")),e.debug&&console.log("-----Generated thunk:\n"+r.join("\n")+"\n----------");var f=new Function("compile",r.join("\n"));return f(n.bind(void 0,e))}var n=r(O);e.exports=t}),T=r(P),U=Object.freeze({default:T}),F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},B=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)},M=t(function(e){function t(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function n(e){var r=new t;r.pre=e.pre,r.body=e.body,r.post=e.post;var n=e.args.slice(0);r.argTypes=n;for(var i=0;i<n.length;++i){var o=n[i];if("array"===o||"object"===("undefined"==typeof o?"undefined":F(o))&&o.blockIndices){if(r.argTypes[i]="array",r.arrayArgs.push(i),r.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),r.shimArgs.push("array"+i),i<r.pre.args.length&&r.pre.args[i].count>0)throw new Error("cwise: pre() block may not reference array args");if(i<r.post.args.length&&r.post.args[i].count>0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)r.scalarArgs.push(i),r.shimArgs.push("scalar"+i);else if("index"===o){if(r.indexArgs.push(i),i<r.pre.args.length&&r.pre.args[i].count>0)throw new Error("cwise: pre() block may not reference array index");if(i<r.body.args.length&&r.body.args[i].lvalue)throw new Error("cwise: body() block may not write to array index");if(i<r.post.args.length&&r.post.args[i].count>0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(r.shapeArgs.push(i),i<r.pre.args.length&&r.pre.args[i].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(i<r.body.args.length&&r.body.args[i].lvalue)throw new Error("cwise: body() block may not write to array shape");if(i<r.post.args.length&&r.post.args[i].lvalue)throw new Error("cwise: post() block may not write to array shape")}else{if("object"!==("undefined"==typeof o?"undefined":F(o))||!o.offset)throw new Error("cwise: Unknown argument type "+n[i]);r.argTypes[i]="offset",r.offsetArgs.push({array:o.array,offset:o.offset}),r.offsetArgIndex.push(i)}}if(r.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(r.pre.args.length>n.length)throw new Error("cwise: Too many arguments in pre() block");if(r.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(r.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return r.debug=!!e.printCode||!!e.debug,r.funcName=e.funcName||"cwise",r.blockSize=e.blockSize||64,a(r)}var a=r(U);e.exports=n}),R=r(M),D=Object.freeze({default:R}),q=t(function(e,t){function n(e){if(!e)return s;for(var r=0;r<e.args.length;++r){var t=e.args[r];0===r?e.args[r]={name:t,lvalue:!0,rvalue:!!e.rvalue,count:e.count||1}:e.args[r]={name:t,lvalue:!1,rvalue:!0,count:1}}return e.thisVars||(e.thisVars=[]),e.localVars||(e.localVars=[]),e}function a(e){return o({args:e.args,pre:n(e.pre),body:n(e.body),post:n(e.proc),funcName:e.funcName})}function i(e){for(var r=[],t=0;t<e.args.length;++t)r.push("a"+t);var n=new Function("P",["return function ",e.funcName,"_ndarrayops(",r.join(","),") {P(",r.join(","),");return a0}"].join(""));return n(a(e))}var o=r(D),s={body:"",args:[],thisVars:[],localVars:[]},u={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};!function(){for(var e in u){var r=u[e];t[e]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+r+"c"},funcName:e}),t[e+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a"+r+"=b"},rvalue:!0,funcName:e+"eq"}),t[e+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+r+"s"},funcName:e+"s"}),t[e+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a"+r+"=s"},rvalue:!0,funcName:e+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var e in c){var r=c[e];t[e]=i({args:["array","array"],body:{args:["a","b"],body:"a="+r+"b"},funcName:e}),t[e+"eq"]=i({args:["array"],body:{args:["a"],body:"a="+r+"a"},rvalue:!0,count:2,funcName:e+"eq"})}}();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var e in l){var r=l[e];t[e]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+r+"c"},funcName:e}),t[e+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+r+"s"},funcName:e+"s"}),t[e+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a=a"+r+"b"},rvalue:!0,count:2,funcName:e+"eq"}),t[e+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+r+"s"},rvalue:!0,count:2,funcName:e+"seq"})}}();var p=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var e=0;e<p.length;++e){var r=p[e];t[r]=i({args:["array","array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:r}),t[r+"eq"]=i({args:["array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:r+"eq"})}}();var f=["max","min","atan2","pow"];!function(){for(var e=0;e<f.length;++e){var r=f[e];t[r]=i({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:r}),t[r+"s"]=i({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:r+"s"}),t[r+"eq"]=i({args:["array","array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:r+"eq"}),t[r+"seq"]=i({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:r+"seq"})}}();var h=["atan2","pow"];!function(){for(var e=0;e<h.length;++e){var r=h[e];t[r+"op"]=i({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:r+"op"}),t[r+"ops"]=i({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:r+"ops"}),t[r+"opeq"]=i({args:["array","array"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:r+"opeq"}),t[r+"opseq"]=i({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+r,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:r+"opseq"})}}(),t.any=o({args:["array"],pre:s,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),t.all=o({args:["array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),t.sum=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),t.prod=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),t.norm2squared=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),t.norm2=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),t.norminf=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),t.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),t.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),t.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),t.argmin=o({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),t.argmax=o({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),t.random=i({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),t.assign=i({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),t.assigns=i({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),t.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});r(q);var z=q.add,W=q.addeq,G=q.mulseq,K=q.divs,H=q.divseq,$=q.assigns,Y=q.random,X=q.norm2,J=t(function(e){e.exports=r(D)({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})}),Q=r(J),Z=Object.freeze({default:Q}),ee=t(function(e){var t=r(E),n=r(Z);e.exports=function(e,r){for(var a=[],i=e,o=1;Array.isArray(i);)a.push(i.length),o*=i.length,i=i[0];return 0===a.length?t():(r||(r=t(new Float64Array(o),a)),n(r,e),r)}}),re=r(ee),te=t(function(e){function r(e,r){return"native"===r[1]?[e,"d0=",e,".length,",e,"d1=",e,"[0].length,"].join(""):[e,"d0=",e,".shape[0],",e,"d1=",e,".shape[1],",e,"s0=",e,".stride[0],",e,"s1=",e,".stride[1],",e,"o=",e,".offset,",e,"d=",e,".data,"].join("")}function t(e,r,t,n,a,i){var o=[];return"native"===t[1]?e[0]&&(n?o.push("var ",r,"p=",r,"[",n,"];"):o.push("var ",r,"p=",r,"[0];")):n&&a?i?o.push("var ",r,"t0=",r,"s",e[0],",",r,"t1=",r,"s",e[1],"-",r,"s",e[0],"*",i,",",r,"p=",r,"o+",n,"*",r,"s0+",a,"*",r,"s1;"):o.push("var ",r,"t0=",r,"s",e[0],",",r,"p=",r,"o+",n,"*",r,"s0+",a,"*",r,"s1;"):n?o.push("var ",r,"t0=",r,"s",e[0],",",r,"p=",r,"o+",n,"*",r,"s0;"):a?o.push("var ",r,"t0=",r,"s",e[0],",",r,"p=",r,"o+",a,"*",r,"s1;"):o.push("var ",r,"t0=",r,"s",e[0],",",r,"t1=",r,"s",e[1],"-",r,"s",e[0],"*",r,"d",e[0],",",r,"p=",r,"o;"),o}function n(e,r,t,n,a){var i=[];return"native"===t[1]?e[0]&&1===n&&i.push(r,"p=",r,"[",a,"+1]"):i.push(r,"p+=",r,"t",n,";"),i}function a(e,r,t,n,a,i){var o=[];return"native"===t[1]?e[0]?o.push(r,"p[",a,"]=",i,";"):o.push(r,"[",n,"][",a,"]=",i,";"):"generic"===t[1]?o.push(r,"d.set(",r,"p,",i,");"):o.push(r,"d[",r,"p]=",i,";"),o}function i(e,r,t,n,a){var i=[];return"native"===t[1]?e[0]?i.push(r,"p[",a,"]"):i.push(r,"[",n,"][",a,"]"):"generic"===t[1]?i.push(r,"d.get(",r,"p)"):i.push(r,"d[",r,"p]"),i.join("")}function o(e,r,o,s,u){var c=[],l="r"===e[0]?[1,0]:[0,1],p=[1,0],f=[0,1],h=["i","j"];return c.push.apply(c,t(l,"o",e)),l[1]?(c.push("for(j=0;j<od1;++j){"),c.push("for(i=0;i<od0;++i){")):(c.push("for(i=0;i<od0;++i){"),c.push("for(j=0;j<od1;++j){")),c.push.apply(c,t(p,"a",r,"i")),c.push.apply(c,t(f,"b",o,void 0,"j")),c.push("var r=0.0;","for(k=0;k<ad1;++k){","r+=",i(p,"a",r,"i","k"),"*",i(f,"b",o,"k","j"),";"),c.push.apply(c,n(p,"a",r,0,"k")),c.push.apply(c,n(f,"b",o,0,"k")),c.push("}"),s&&c.push("r*=A;"),u&&c.push("r+=B*",i(l,"o",e,"i","j"),";"),c.push.apply(c,a(l,"o",e,"i","j","r")),c.push.apply(c,n(l,"o",e,0,h[1])),c.push("}"),c.push.apply(c,n(l,"o",e,1,h[0])),c.push("}"),c}function s(e,r){var o,s=[],u="r"===e[0]?[1,0]:[0,1];return r&&s.push("if(B!==1.0){"),s.push.apply(s,t(u,"o",e)),u[0]?(s.push("for(i=0;i<od0;++i){for(j=0;j<od1;++j){"),o=["i","j"]):(s.push("for(j=0;j<od1;++j){for(i=0;i<od0;++i){"),o=["j","i"]),r?s.push.apply(s,a(u,"o",e,"i","j","B*"+i(u,"o",e,"i","j"))):s.push.apply(s,a(u,"o",e,"i","j","0")),s.push.apply(s,n(u,"o",e,0,o[1])),s.push("}"),s.push.apply(s,n(u,"o",e,1,o[0])),s.push("}"),r&&s.push("}"),s}function u(e,r,o,u,c){var p=[],f=["od0","od1","ad1"],h=[1,0],d=[1,0],y=[0,1];p.push.apply(p,s(e,c));for(var m=0;m<3;++m)p.push("for(var i",m,"=",f[m],";i",m,">0;){","var w",m,"=",l,";","if(i",m,"<",l,"){","w",m,"=i",m,";","i",m,"=0;","}else{","i",m,"-=",l,";","}");p.push.apply(p,t(h,"o",e,"i0","i1","w1")),
p.push("for(i=0;i<w0;++i){for(j=0;j<w1;++j){var r=0.0;"),p.push.apply(p,t(d,"a",r,"(i0+i)","i2")),p.push.apply(p,t(y,"b",o,"i2","(i1+j)")),p.push("for(k=0;k<w2;++k){"),p.push("r+=",i(d,"a",r,"(i0+i)","(i2+k)"),"*",i(y,"b",o,"(i2+k)","(i1+j)"),";"),p.push.apply(p,n(d,"a",r,0,"(i2+k)")),p.push.apply(p,n(y,"b",o,0,"(i2+k)")),p.push("}");var g="r";return u&&(g="A*r"),p.push.apply(p,a(h,"o",e,"(i0+i)","(i1+j)",g+"+"+i(h,"o",e,"(i0+i)","(i1+j)"))),p.push.apply(p,n(h,"o",e,0,"(i1+j)")),p.push("}"),p.push.apply(p,n(h,"o",e,1,"(i0+i)")),p.push("}}}}"),p}function c(e,t,n,a,i){var s=["gemm",e[0],e[1],"a",t[0],t[1],"b",n[0],n[1],a?"alpha":"",i?"beta":""].join(""),c=["function ",s,"(o,a,b,A,B){","var ",r("o",e),r("a",t),r("b",n),"i,j,k;"];"r"===t[0]&&"c"===n[0]?c.push.apply(c,o(e,t,n,a,i)):c.push.apply(c,u(e,t,n,a,i)),c.push("}return ",s);var l=new Function(c.join(""));return l()}e.exports=c;var l=32}),ne=r(te),ae=Object.freeze({default:ne}),ie=t(function(e){function t(e){return Array.isArray(e)?[e.length,e[0].length]:e.shape}function n(e,r,n){var a=t(e),i=t(r),o=t(n);if(a[0]!==i[0]||a[1]!==o[1]||i[1]!==o[0])throw new Error("Mismatched array shapes for matrix product")}function a(e){if(Array.isArray(e)){if(Array.isArray(e))return["r","native"]}else if(e.shape&&2===e.shape.length)return e.order[0]?["r",e.dtype]:["c",e.dtype];throw new Error("Unrecognized data type")}function i(e,r,t,i,u){void 0===i&&(i=1),void 0===u&&(u=0);var c=1!==i,l=0!==u,p=a(e),f=a(r),h=a(t);n(e,r,t);var d=[p,f,h,c,l].join(":"),y=s[d];return y||(y=s[d]=o(p,f,h,c,l)),y(e,r,t,i,u)}e.exports=i;var o=r(ae),s={}}),oe=r(ie),se=t(function(e){function t(e){var r=e.dimension;if(r<=1)return e;for(var t=1<<30,a=0,i=e.shape,o=e.stride,s=0;s<r;++s)t=0|Math.min(t,i[s]),a+=o[s];return n(e.data,[t],[a],e.offset)}var n=r(E);e.exports=t}),ue=r(se),ce=t(function(e){function r(e,t,n){var a=0|e[n];if(a<=0)return[];var i,o=new Array(a);if(n===e.length-1)for(i=0;i<a;++i)o[i]=t;else for(i=0;i<a;++i)o[i]=r(e,t,n+1);return o}function t(e,r){var t,n;for(t=new Array(e),n=0;n<e;++n)t[n]=r;return t}function n(e,n){switch("undefined"==typeof n&&(n=0),"undefined"==typeof e?"undefined":F(e)){case"number":if(e>0)return t(0|e,n);break;case"object":if("number"==typeof e.length)return r(e,n,0)}return[]}e.exports=n}),le=r(ce),pe=Object.freeze({default:le}),fe=t(function(e,r){!function(e,t){"function"==typeof define&&define.amd?define(["exports"],t):t("undefined"!=typeof r?r:e.esprima={})}(this,function(e){function r(e,r){if(!e)throw new Error("ASSERT: "+r)}function t(e){return e>=48&&e<=57}function n(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function a(e){return"01234567".indexOf(e)>=0}function i(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function o(e){return 10===e||13===e||8232===e||8233===e}function s(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&ir.NonAsciiIdentifierStart.test(String.fromCharCode(e))}function u(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&ir.NonAsciiIdentifierPart.test(String.fromCharCode(e))}function c(e){switch(e){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}function l(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function p(e){return"eval"===e||"arguments"===e}function f(e){if(ur&&l(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e||"let"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function h(e,t,n,a,i){var o;r("number"==typeof n,"Comment must have valid position"),yr.lastCommentStart>=n||(yr.lastCommentStart=n,o={type:e,value:t},mr.range&&(o.range=[n,a]),mr.loc&&(o.loc=i),mr.comments.push(o),mr.attachComment&&(mr.leadingComments.push(o),mr.trailingComments.push(o)))}function d(e){var r,t,n,a;for(r=cr-e,t={start:{line:lr,column:cr-pr-e}};cr<fr;)if(n=sr.charCodeAt(cr),++cr,o(n))return mr.comments&&(a=sr.slice(r+e,cr-1),t.end={line:lr,column:cr-pr-1},h("Line",a,r,cr-1,t)),13===n&&10===sr.charCodeAt(cr)&&++cr,++lr,void(pr=cr);mr.comments&&(a=sr.slice(r+e,cr),t.end={line:lr,column:cr-pr},h("Line",a,r,cr,t))}function y(){var e,r,t,n;for(mr.comments&&(e=cr-2,r={start:{line:lr,column:cr-pr-2}});cr<fr;)if(t=sr.charCodeAt(cr),o(t))13===t&&10===sr.charCodeAt(cr+1)&&++cr,++lr,++cr,pr=cr,cr>=fr&&D({},ar.UnexpectedToken,"ILLEGAL");else if(42===t){if(47===sr.charCodeAt(cr+1))return++cr,++cr,void(mr.comments&&(n=sr.slice(e+2,cr-2),r.end={line:lr,column:cr-pr},h("Block",n,e,cr,r)));++cr}else++cr;D({},ar.UnexpectedToken,"ILLEGAL")}function m(){var e,r;for(r=0===cr;cr<fr;)if(e=sr.charCodeAt(cr),i(e))++cr;else if(o(e))++cr,13===e&&10===sr.charCodeAt(cr)&&++cr,++lr,pr=cr,r=!0;else if(47===e)if(e=sr.charCodeAt(cr+1),47===e)++cr,++cr,d(2),r=!0;else{if(42!==e)break;++cr,++cr,y()}else if(r&&45===e){if(45!==sr.charCodeAt(cr+1)||62!==sr.charCodeAt(cr+2))break;cr+=3,d(3)}else{if(60!==e)break;if("!--"!==sr.slice(cr+1,cr+4))break;++cr,++cr,++cr,++cr,d(4)}}function g(e){var r,t,a,i=0;for(t="u"===e?4:2,r=0;r<t;++r){if(!(cr<fr&&n(sr[cr])))return"";a=sr[cr++],i=16*i+"0123456789abcdef".indexOf(a.toLowerCase())}return String.fromCharCode(i)}function v(){var e,r;for(e=sr.charCodeAt(cr++),r=String.fromCharCode(e),92===e&&(117!==sr.charCodeAt(cr)&&D({},ar.UnexpectedToken,"ILLEGAL"),++cr,e=g("u"),e&&"\\"!==e&&s(e.charCodeAt(0))||D({},ar.UnexpectedToken,"ILLEGAL"),r=e);cr<fr&&(e=sr.charCodeAt(cr),u(e));)++cr,r+=String.fromCharCode(e),92===e&&(r=r.substr(0,r.length-1),117!==sr.charCodeAt(cr)&&D({},ar.UnexpectedToken,"ILLEGAL"),++cr,e=g("u"),e&&"\\"!==e&&u(e.charCodeAt(0))||D({},ar.UnexpectedToken,"ILLEGAL"),r+=e);return r}function b(){var e,r;for(e=cr++;cr<fr;){if(r=sr.charCodeAt(cr),92===r)return cr=e,v();if(!u(r))break;++cr}return sr.slice(e,cr)}function _(){var e,r,t;return e=cr,r=92===sr.charCodeAt(cr)?v():b(),t=1===r.length?Ze.Identifier:f(r)?Ze.Keyword:"null"===r?Ze.NullLiteral:"true"===r||"false"===r?Ze.BooleanLiteral:Ze.Identifier,{type:t,value:r,lineNumber:lr,lineStart:pr,start:e,end:cr}}function w(){var e,r,t,n,a=cr,i=sr.charCodeAt(cr),o=sr[cr];switch(i){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++cr,mr.tokenize&&(40===i?mr.openParenToken=mr.tokens.length:123===i&&(mr.openCurlyToken=mr.tokens.length)),{type:Ze.Punctuator,value:String.fromCharCode(i),lineNumber:lr,lineStart:pr,start:a,end:cr};default:if(e=sr.charCodeAt(cr+1),61===e)switch(i){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return cr+=2,{type:Ze.Punctuator,value:String.fromCharCode(i)+String.fromCharCode(e),lineNumber:lr,lineStart:pr,start:a,end:cr};case 33:case 61:return cr+=2,61===sr.charCodeAt(cr)&&++cr,{type:Ze.Punctuator,value:sr.slice(a,cr),lineNumber:lr,lineStart:pr,start:a,end:cr}}}return n=sr.substr(cr,4),">>>="===n?(cr+=4,{type:Ze.Punctuator,value:n,lineNumber:lr,lineStart:pr,start:a,end:cr}):(t=n.substr(0,3),">>>"===t||"<<="===t||">>="===t?(cr+=3,{type:Ze.Punctuator,value:t,lineNumber:lr,lineStart:pr,start:a,end:cr}):(r=t.substr(0,2),o===r[1]&&"+-<>&|".indexOf(o)>=0||"=>"===r?(cr+=2,{type:Ze.Punctuator,value:r,lineNumber:lr,lineStart:pr,start:a,end:cr}):"<>=!+-*%&|^/".indexOf(o)>=0?(++cr,{type:Ze.Punctuator,value:o,lineNumber:lr,lineStart:pr,start:a,end:cr}):void D({},ar.UnexpectedToken,"ILLEGAL")))}function k(e){for(var r="";cr<fr&&n(sr[cr]);)r+=sr[cr++];return 0===r.length&&D({},ar.UnexpectedToken,"ILLEGAL"),s(sr.charCodeAt(cr))&&D({},ar.UnexpectedToken,"ILLEGAL"),{type:Ze.NumericLiteral,value:parseInt("0x"+r,16),lineNumber:lr,lineStart:pr,start:e,end:cr}}function S(e){for(var r="0"+sr[cr++];cr<fr&&a(sr[cr]);)r+=sr[cr++];return(s(sr.charCodeAt(cr))||t(sr.charCodeAt(cr)))&&D({},ar.UnexpectedToken,"ILLEGAL"),{type:Ze.NumericLiteral,value:parseInt(r,8),octal:!0,lineNumber:lr,lineStart:pr,start:e,end:cr}}function x(){var e,r;for(e=cr+1;e<fr;++e){if(r=sr[e],"8"===r||"9"===r)return!1;if(!a(r))return!0}return!0}function E(){var e,n,i;if(i=sr[cr],r(t(i.charCodeAt(0))||"."===i,"Numeric literal must start with a decimal digit or a decimal point"),n=cr,e="","."!==i){if(e=sr[cr++],i=sr[cr],"0"===e){if("x"===i||"X"===i)return++cr,k(n);if(a(i)&&x())return S(n)}for(;t(sr.charCodeAt(cr));)e+=sr[cr++];i=sr[cr]}if("."===i){for(e+=sr[cr++];t(sr.charCodeAt(cr));)e+=sr[cr++];i=sr[cr]}if("e"===i||"E"===i)if(e+=sr[cr++],i=sr[cr],"+"!==i&&"-"!==i||(e+=sr[cr++]),t(sr.charCodeAt(cr)))for(;t(sr.charCodeAt(cr));)e+=sr[cr++];else D({},ar.UnexpectedToken,"ILLEGAL");return s(sr.charCodeAt(cr))&&D({},ar.UnexpectedToken,"ILLEGAL"),{type:Ze.NumericLiteral,value:parseFloat(e),lineNumber:lr,lineStart:pr,start:n,end:cr}}function A(){var e,t,n,i,s,u,c,l,p="",f=!1;for(c=lr,l=pr,e=sr[cr],r("'"===e||'"'===e,"String literal must starts with a quote"),t=cr,++cr;cr<fr;){if(n=sr[cr++],n===e){e="";break}if("\\"===n)if(n=sr[cr++],n&&o(n.charCodeAt(0)))++lr,"\r"===n&&"\n"===sr[cr]&&++cr,pr=cr;else switch(n){case"u":case"x":u=cr,s=g(n),s?p+=s:(cr=u,p+=n);break;case"n":p+="\n";break;case"r":p+="\r";break;case"t":p+="\t";break;case"b":p+="\b";break;case"f":p+="\f";break;case"v":p+="\v";break;default:a(n)?(i="01234567".indexOf(n),0!==i&&(f=!0),cr<fr&&a(sr[cr])&&(f=!0,i=8*i+"01234567".indexOf(sr[cr++]),"0123".indexOf(n)>=0&&cr<fr&&a(sr[cr])&&(i=8*i+"01234567".indexOf(sr[cr++]))),p+=String.fromCharCode(i)):p+=n}else{if(o(n.charCodeAt(0)))break;p+=n}}return""!==e&&D({},ar.UnexpectedToken,"ILLEGAL"),{type:Ze.StringLiteral,value:p,octal:f,startLineNumber:c,startLineStart:l,lineNumber:lr,lineStart:pr,start:t,end:cr}}function j(e,r){var t;try{t=new RegExp(e,r)}catch(e){D({},ar.InvalidRegExp)}return t}function I(){var e,t,n,a,i;for(e=sr[cr],r("/"===e,"Regular expression literal must start with a slash"),t=sr[cr++],n=!1,a=!1;cr<fr;)if(e=sr[cr++],t+=e,"\\"===e)e=sr[cr++],o(e.charCodeAt(0))&&D({},ar.UnterminatedRegExp),t+=e;else if(o(e.charCodeAt(0)))D({},ar.UnterminatedRegExp);else if(n)"]"===e&&(n=!1);else{if("/"===e){a=!0;break}"["===e&&(n=!0)}return a||D({},ar.UnterminatedRegExp),i=t.substr(1,t.length-2),{value:i,literal:t}}function C(){var e,r,t,n;for(r="",t="";cr<fr&&(e=sr[cr],u(e.charCodeAt(0)));)if(++cr,"\\"===e&&cr<fr)if(e=sr[cr],"u"===e){if(++cr,n=cr,e=g("u"))for(t+=e,r+="\\u";n<cr;++n)r+=sr[n];else cr=n,t+="u",r+="\\u";q({},ar.UnexpectedToken,"ILLEGAL")}else r+="\\",q({},ar.UnexpectedToken,"ILLEGAL");else t+=e,r+=e;return{value:t,literal:r}}function V(){var e,r,t,n;return dr=null,m(),e=cr,r=I(),t=C(),n=j(r.value,t.value),mr.tokenize?{type:Ze.RegularExpression,value:n,lineNumber:lr,lineStart:pr,start:e,end:cr}:{literal:r.literal+t.literal,value:n,start:e,end:cr}}function L(){var e,r,t,n;return m(),e=cr,r={start:{line:lr,column:cr-pr}},t=V(),r.end={line:lr,column:cr-pr},mr.tokenize||(mr.tokens.length>0&&(n=mr.tokens[mr.tokens.length-1],n.range[0]===e&&"Punctuator"===n.type&&("/"!==n.value&&"/="!==n.value||mr.tokens.pop())),mr.tokens.push({type:"RegularExpression",value:t.literal,range:[e,cr],loc:r})),t}function N(e){return e.type===Ze.Identifier||e.type===Ze.Keyword||e.type===Ze.BooleanLiteral||e.type===Ze.NullLiteral}function O(){var e,r;if(e=mr.tokens[mr.tokens.length-1],!e)return L();if("Punctuator"===e.type){if("]"===e.value)return w();if(")"===e.value)return r=mr.tokens[mr.openParenToken-1],!r||"Keyword"!==r.type||"if"!==r.value&&"while"!==r.value&&"for"!==r.value&&"with"!==r.value?w():L();if("}"===e.value){if(mr.tokens[mr.openCurlyToken-3]&&"Keyword"===mr.tokens[mr.openCurlyToken-3].type){if(r=mr.tokens[mr.openCurlyToken-4],!r)return w()}else{if(!mr.tokens[mr.openCurlyToken-4]||"Keyword"!==mr.tokens[mr.openCurlyToken-4].type)return w();if(r=mr.tokens[mr.openCurlyToken-5],!r)return L()}return rr.indexOf(r.value)>=0?w():L()}return L()}return"Keyword"===e.type&&"this"!==e.value?L():w()}function P(){var e;return m(),cr>=fr?{type:Ze.EOF,lineNumber:lr,lineStart:pr,start:cr,end:cr}:(e=sr.charCodeAt(cr),s(e)?_():40===e||41===e||59===e?w():39===e||34===e?A():46===e?t(sr.charCodeAt(cr+1))?E():w():t(e)?E():mr.tokenize&&47===e?O():w())}function T(){var e,r,t;return m(),e={start:{line:lr,column:cr-pr}},r=P(),e.end={line:lr,column:cr-pr},r.type!==Ze.EOF&&(t=sr.slice(r.start,r.end),mr.tokens.push({type:er[r.type],value:t,range:[r.start,r.end],loc:e})),r}function U(){var e;return e=dr,cr=e.end,lr=e.lineNumber,pr=e.lineStart,dr="undefined"!=typeof mr.tokens?T():P(),cr=e.end,lr=e.lineNumber,pr=e.lineStart,e}function F(){var e,r,t;e=cr,r=lr,t=pr,dr="undefined"!=typeof mr.tokens?T():P(),cr=e,lr=r,pr=t}function B(e,r){this.line=e,this.column=r}function M(e,r,t,n){this.start=new B(e,r),this.end=new B(t,n)}function R(){var e,r,t,n;return e=cr,r=lr,t=pr,m(),n=lr!==r,cr=e,lr=r,pr=t,n}function D(e,t){var n,a=Array.prototype.slice.call(arguments,2),i=t.replace(/%(\d)/g,function(e,t){return r(t<a.length,"Message reference must be in range"),a[t]});throw"number"==typeof e.lineNumber?(n=new Error("Line "+e.lineNumber+": "+i),n.index=e.start,n.lineNumber=e.lineNumber,n.column=e.start-pr+1):(n=new Error("Line "+lr+": "+i),n.index=cr,n.lineNumber=lr,n.column=cr-pr+1),n.description=i,n}function q(){try{D.apply(null,arguments)}catch(e){if(!mr.errors)throw e;mr.errors.push(e)}}function z(e){if(e.type===Ze.EOF&&D(e,ar.UnexpectedEOS),e.type===Ze.NumericLiteral&&D(e,ar.UnexpectedNumber),e.type===Ze.StringLiteral&&D(e,ar.UnexpectedString),e.type===Ze.Identifier&&D(e,ar.UnexpectedIdentifier),e.type===Ze.Keyword){if(c(e.value))D(e,ar.UnexpectedReserved);else if(ur&&l(e.value))return void q(e,ar.StrictReservedWord);D(e,ar.UnexpectedToken,e.value)}D(e,ar.UnexpectedToken,e.value)}function W(e){var r=U();r.type===Ze.Punctuator&&r.value===e||z(r)}function G(e){var r=U();r.type===Ze.Keyword&&r.value===e||z(r)}function K(e){return dr.type===Ze.Punctuator&&dr.value===e}function H(e){return dr.type===Ze.Keyword&&dr.value===e}function $(){var e;return dr.type===Ze.Punctuator&&(e=dr.value,"="===e||"*="===e||"/="===e||"%="===e||"+="===e||"-="===e||"<<="===e||">>="===e||">>>="===e||"&="===e||"^="===e||"|="===e)}function Y(){var e,r=cr,t=lr,n=pr,a=dr;return 59===sr.charCodeAt(cr)||K(";")?void U():(e=lr,m(),lr!==e?(cr=r,lr=t,pr=n,void(dr=a)):void(dr.type===Ze.EOF||K("}")||z(dr)))}function X(e){return e.type===tr.Identifier||e.type===tr.MemberExpression}function J(){var e,r=[];for(e=dr,W("[");!K("]");)K(",")?(U(),r.push(null)):(r.push(me()),K("]")||W(","));return U(),hr.markEnd(hr.createArrayExpression(r),e)}function Q(e,r){var t,n,a;return t=ur,a=dr,n=ze(),r&&ur&&p(e[0].name)&&q(r,ar.StrictParamName),ur=t,hr.markEnd(hr.createFunctionExpression(null,e,[],n),a)}function Z(){var e,r;return r=dr,e=U(),e.type===Ze.StringLiteral||e.type===Ze.NumericLiteral?(ur&&e.octal&&q(e,ar.StrictOctalLiteral),hr.markEnd(hr.createLiteral(e),r)):hr.markEnd(hr.createIdentifier(e.value),r)}function ee(){var e,r,t,n,a,i;return e=dr,i=dr,e.type===Ze.Identifier?(t=Z(),"get"!==e.value||K(":")?"set"!==e.value||K(":")?(W(":"),n=me(),hr.markEnd(hr.createProperty("init",t,n),i)):(r=Z(),W("("),e=dr,e.type!==Ze.Identifier?(W(")"),q(e,ar.UnexpectedToken,e.value),n=Q([])):(a=[_e()],W(")"),n=Q(a,e)),hr.markEnd(hr.createProperty("set",r,n),i)):(r=Z(),W("("),W(")"),n=Q([]),hr.markEnd(hr.createProperty("get",r,n),i))):e.type!==Ze.EOF&&e.type!==Ze.Punctuator?(r=Z(),W(":"),n=me(),hr.markEnd(hr.createProperty("init",r,n),i)):void z(e)}function re(){var e,r,t,n,a,i=[],o={},s=String;for(a=dr,W("{");!K("}");)e=ee(),r=e.key.type===tr.Identifier?e.key.name:s(e.key.value),n="init"===e.kind?nr.Data:"get"===e.kind?nr.Get:nr.Set,t="$"+r,Object.prototype.hasOwnProperty.call(o,t)?(o[t]===nr.Data?ur&&n===nr.Data?q({},ar.StrictDuplicateProperty):n!==nr.Data&&q({},ar.AccessorDataProperty):n===nr.Data?q({},ar.AccessorDataProperty):o[t]&n&&q({},ar.AccessorGetSet),o[t]|=n):o[t]=n,i.push(e),K("}")||W(",");return W("}"),hr.markEnd(hr.createObjectExpression(i),a)}function te(){var e;return W("("),e=ge(),W(")"),e}function ne(){var e,r,t,n;if(K("("))return te();if(K("["))return J();if(K("{"))return re();if(e=dr.type,n=dr,e===Ze.Identifier)t=hr.createIdentifier(U().value);else if(e===Ze.StringLiteral||e===Ze.NumericLiteral)ur&&dr.octal&&q(dr,ar.StrictOctalLiteral),t=hr.createLiteral(U());else if(e===Ze.Keyword){if(H("function"))return Ke();H("this")?(U(),t=hr.createThisExpression()):z(U())}else e===Ze.BooleanLiteral?(r=U(),r.value="true"===r.value,t=hr.createLiteral(r)):e===Ze.NullLiteral?(r=U(),r.value=null,t=hr.createLiteral(r)):K("/")||K("/=")?(t="undefined"!=typeof mr.tokens?hr.createLiteral(L()):hr.createLiteral(V()),F()):z(U());return hr.markEnd(t,n)}function ae(){var e=[];if(W("("),!K(")"))for(;cr<fr&&(e.push(me()),!K(")"));)W(",");return W(")"),e}function ie(){var e,r;return r=dr,e=U(),N(e)||z(e),hr.markEnd(hr.createIdentifier(e.value),r)}function oe(){return W("."),ie()}function se(){var e;return W("["),e=ge(),W("]"),e}function ue(){var e,r,t;return t=dr,G("new"),e=le(),r=K("(")?ae():[],hr.markEnd(hr.createNewExpression(e,r),t)}function ce(){var e,r,t,n,a=yr.allowIn;for(n=dr,yr.allowIn=!0,e=H("new")?ue():ne();;){if(K("."))t=oe(),e=hr.createMemberExpression(".",e,t);else if(K("("))r=ae(),e=hr.createCallExpression(e,r);else{if(!K("["))break;t=se(),e=hr.createMemberExpression("[",e,t)}hr.markEnd(e,n)}return yr.allowIn=a,e}function le(){var e,t,n;for(r(yr.allowIn,"callee of new expression always allow in keyword."),n=dr,e=H("new")?ue():ne();K(".")||K("[");)K("[")?(t=se(),e=hr.createMemberExpression("[",e,t)):(t=oe(),e=hr.createMemberExpression(".",e,t)),hr.markEnd(e,n);return e}function pe(){var e,r,t=dr;return e=ce(),dr.type===Ze.Punctuator&&(!K("++")&&!K("--")||R()||(ur&&e.type===tr.Identifier&&p(e.name)&&q({},ar.StrictLHSPostfix),X(e)||q({},ar.InvalidLHSInAssignment),r=U(),e=hr.markEnd(hr.createPostfixExpression(r.value,e),t))),e}function fe(){var e,r,t;return dr.type!==Ze.Punctuator&&dr.type!==Ze.Keyword?r=pe():K("++")||K("--")?(t=dr,e=U(),r=fe(),ur&&r.type===tr.Identifier&&p(r.name)&&q({},ar.StrictLHSPrefix),X(r)||q({},ar.InvalidLHSInAssignment),r=hr.createUnaryExpression(e.value,r),r=hr.markEnd(r,t)):K("+")||K("-")||K("~")||K("!")?(t=dr,e=U(),r=fe(),r=hr.createUnaryExpression(e.value,r),r=hr.markEnd(r,t)):H("delete")||H("void")||H("typeof")?(t=dr,e=U(),r=fe(),r=hr.createUnaryExpression(e.value,r),r=hr.markEnd(r,t),ur&&"delete"===r.operator&&r.argument.type===tr.Identifier&&q({},ar.StrictDelete)):r=pe(),r}function he(e,r){var t=0;if(e.type!==Ze.Punctuator&&e.type!==Ze.Keyword)return 0;switch(e.value){case"||":t=1;break;case"&&":t=2;break;case"|":t=3;break;case"^":t=4;break;case"&":t=5;break;case"==":case"!=":case"===":case"!==":t=6;break;case"<":case">":case"<=":case">=":case"instanceof":t=7;break;case"in":t=r?7:0;break;case"<<":case">>":case">>>":t=8;break;case"+":case"-":t=9;break;case"*":case"/":case"%":t=11}return t}function de(){var e,r,t,n,a,i,o,s,u,c;if(e=dr,u=fe(),n=dr,a=he(n,yr.allowIn),0===a)return u;for(n.prec=a,U(),r=[e,dr],o=fe(),i=[u,n,o];(a=he(dr,yr.allowIn))>0;){for(;i.length>2&&a<=i[i.length-2].prec;)o=i.pop(),s=i.pop().value,u=i.pop(),t=hr.createBinaryExpression(s,u,o),r.pop(),e=r[r.length-1],hr.markEnd(t,e),i.push(t);n=U(),n.prec=a,i.push(n),r.push(dr),t=fe(),i.push(t)}for(c=i.length-1,t=i[c],r.pop();c>1;)t=hr.createBinaryExpression(i[c-1].value,i[c-2],t),c-=2,e=r.pop(),hr.markEnd(t,e);return t}function ye(){var e,r,t,n,a;return a=dr,e=de(),K("?")&&(U(),r=yr.allowIn,yr.allowIn=!0,t=me(),yr.allowIn=r,W(":"),n=me(),e=hr.createConditionalExpression(e,t,n),hr.markEnd(e,a)),e}function me(){var e,r,t,n,a;return e=dr,a=dr,n=r=ye(),$()&&(X(r)||q({},ar.InvalidLHSInAssignment),ur&&r.type===tr.Identifier&&p(r.name)&&q(e,ar.StrictLHSAssignment),e=U(),t=me(),n=hr.markEnd(hr.createAssignmentExpression(e.value,r,t),a)),n}function ge(){var e,r=dr;if(e=me(),K(",")){for(e=hr.createSequenceExpression([e]);cr<fr&&K(",");)U(),e.expressions.push(me());hr.markEnd(e,r)}return e}function ve(){for(var e,r=[];cr<fr&&!K("}")&&(e=He(),"undefined"!=typeof e);)r.push(e);return r}function be(){var e,r;return r=dr,W("{"),e=ve(),W("}"),hr.markEnd(hr.createBlockStatement(e),r)}function _e(){var e,r;return r=dr,e=U(),e.type!==Ze.Identifier&&z(e),hr.markEnd(hr.createIdentifier(e.value),r)}function we(e){var r,t,n=null;return t=dr,r=_e(),ur&&p(r.name)&&q({},ar.StrictVarName),"const"===e?(W("="),n=me()):K("=")&&(U(),n=me()),hr.markEnd(hr.createVariableDeclarator(r,n),t)}function ke(e){var r=[];do{if(r.push(we(e)),!K(","))break;U()}while(cr<fr);return r}function Se(){var e;return G("var"),e=ke(),Y(),hr.createVariableDeclaration(e,"var")}function xe(e){var r,t;return t=dr,G(e),r=ke(e),Y(),hr.markEnd(hr.createVariableDeclaration(r,e),t)}function Ee(){return W(";"),hr.createEmptyStatement()}function Ae(){var e=ge();return Y(),hr.createExpressionStatement(e)}function je(){var e,r,t;return G("if"),W("("),e=ge(),W(")"),r=qe(),H("else")?(U(),t=qe()):t=null,hr.createIfStatement(e,r,t)}function Ie(){var e,r,t;return G("do"),t=yr.inIteration,yr.inIteration=!0,e=qe(),yr.inIteration=t,G("while"),W("("),r=ge(),W(")"),K(";")&&U(),hr.createDoWhileStatement(e,r)}function Ce(){var e,r,t;return G("while"),W("("),e=ge(),W(")"),t=yr.inIteration,yr.inIteration=!0,r=qe(),yr.inIteration=t,hr.createWhileStatement(e,r)}function Ve(){var e,r,t;return t=dr,e=U(),r=ke(),hr.markEnd(hr.createVariableDeclaration(r,e.value),t)}function Le(){var e,r,t,n,a,i,o,s=yr.allowIn;return e=r=t=null,G("for"),W("("),K(";")?U():(H("var")||H("let")?(yr.allowIn=!1,e=Ve(),yr.allowIn=s,1===e.declarations.length&&H("in")&&(U(),n=e,a=ge(),e=null)):(yr.allowIn=!1,e=ge(),yr.allowIn=s,H("in")&&(X(e)||q({},ar.InvalidLHSInForIn),U(),n=e,a=ge(),e=null)),"undefined"==typeof n&&W(";")),"undefined"==typeof n&&(K(";")||(r=ge()),W(";"),K(")")||(t=ge())),W(")"),o=yr.inIteration,yr.inIteration=!0,i=qe(),yr.inIteration=o,"undefined"==typeof n?hr.createForStatement(e,r,t,i):hr.createForInStatement(n,a,i)}function Ne(){var e,r=null;return G("continue"),59===sr.charCodeAt(cr)?(U(),yr.inIteration||D({},ar.IllegalContinue),hr.createContinueStatement(null)):R()?(yr.inIteration||D({},ar.IllegalContinue),hr.createContinueStatement(null)):(dr.type===Ze.Identifier&&(r=_e(),e="$"+r.name,Object.prototype.hasOwnProperty.call(yr.labelSet,e)||D({},ar.UnknownLabel,r.name)),Y(),null!==r||yr.inIteration||D({},ar.IllegalContinue),hr.createContinueStatement(r))}function Oe(){var e,r=null;return G("break"),59===sr.charCodeAt(cr)?(U(),yr.inIteration||yr.inSwitch||D({},ar.IllegalBreak),hr.createBreakStatement(null)):R()?(yr.inIteration||yr.inSwitch||D({},ar.IllegalBreak),hr.createBreakStatement(null)):(dr.type===Ze.Identifier&&(r=_e(),e="$"+r.name,Object.prototype.hasOwnProperty.call(yr.labelSet,e)||D({},ar.UnknownLabel,r.name)),Y(),null!==r||yr.inIteration||yr.inSwitch||D({},ar.IllegalBreak),hr.createBreakStatement(r))}function Pe(){var e=null;return G("return"),yr.inFunctionBody||q({},ar.IllegalReturn),32===sr.charCodeAt(cr)&&s(sr.charCodeAt(cr+1))?(e=ge(),Y(),hr.createReturnStatement(e)):R()?hr.createReturnStatement(null):(K(";")||K("}")||dr.type===Ze.EOF||(e=ge()),Y(),hr.createReturnStatement(e))}function Te(){var e,r;return ur&&(m(),q({},ar.StrictModeWith)),G("with"),W("("),e=ge(),W(")"),r=qe(),hr.createWithStatement(e,r)}function Ue(){var e,r,t,n=[];for(t=dr,H("default")?(U(),e=null):(G("case"),e=ge()),W(":");cr<fr&&!(K("}")||H("default")||H("case"));)r=qe(),n.push(r);return hr.markEnd(hr.createSwitchCase(e,n),t)}function Fe(){var e,r,t,n,a;if(G("switch"),W("("),e=ge(),W(")"),W("{"),r=[],K("}"))return U(),hr.createSwitchStatement(e,r);for(n=yr.inSwitch,yr.inSwitch=!0,a=!1;cr<fr&&!K("}");)t=Ue(),null===t.test&&(a&&D({},ar.MultipleDefaultsInSwitch),a=!0),r.push(t);return yr.inSwitch=n,W("}"),hr.createSwitchStatement(e,r)}function Be(){var e;return G("throw"),R()&&D({},ar.NewlineAfterThrow),e=ge(),Y(),hr.createThrowStatement(e)}function Me(){var e,r,t;return t=dr,G("catch"),W("("),K(")")&&z(dr),e=_e(),ur&&p(e.name)&&q({},ar.StrictCatchVariable),W(")"),r=be(),hr.markEnd(hr.createCatchClause(e,r),t)}function Re(){var e,r=[],t=null;return G("try"),e=be(),H("catch")&&r.push(Me()),H("finally")&&(U(),t=be()),0!==r.length||t||D({},ar.NoCatchOrFinally),hr.createTryStatement(e,[],r,t)}function De(){return G("debugger"),Y(),hr.createDebuggerStatement()}function qe(){var e,r,t,n,a=dr.type;if(a===Ze.EOF&&z(dr),a===Ze.Punctuator&&"{"===dr.value)return be();if(n=dr,a===Ze.Punctuator)switch(dr.value){case";":return hr.markEnd(Ee(),n);case"(":return hr.markEnd(Ae(),n)}if(a===Ze.Keyword)switch(dr.value){case"break":return hr.markEnd(Oe(),n);case"continue":return hr.markEnd(Ne(),n);case"debugger":return hr.markEnd(De(),n);case"do":return hr.markEnd(Ie(),n);case"for":return hr.markEnd(Le(),n);case"function":return hr.markEnd(Ge(),n);case"if":return hr.markEnd(je(),n);case"return":return hr.markEnd(Pe(),n);case"switch":return hr.markEnd(Fe(),n);case"throw":return hr.markEnd(Be(),n);case"try":return hr.markEnd(Re(),n);case"var":return hr.markEnd(Se(),n);case"while":return hr.markEnd(Ce(),n);case"with":return hr.markEnd(Te(),n)}return e=ge(),e.type===tr.Identifier&&K(":")?(U(),t="$"+e.name,Object.prototype.hasOwnProperty.call(yr.labelSet,t)&&D({},ar.Redeclaration,"Label",e.name),yr.labelSet[t]=!0,r=qe(),delete yr.labelSet[t],hr.markEnd(hr.createLabeledStatement(e,r),n)):(Y(),hr.markEnd(hr.createExpressionStatement(e),n))}function ze(){var e,r,t,n,a,i,o,s,u,c=[];for(u=dr,W("{");cr<fr&&dr.type===Ze.StringLiteral&&(r=dr,e=He(),c.push(e),e.expression.type===tr.Literal);)t=sr.slice(r.start+1,r.end-1),"use strict"===t?(ur=!0,n&&q(n,ar.StrictOctalLiteral)):!n&&r.octal&&(n=r);for(a=yr.labelSet,i=yr.inIteration,o=yr.inSwitch,s=yr.inFunctionBody,yr.labelSet={},yr.inIteration=!1,yr.inSwitch=!1,yr.inFunctionBody=!0;cr<fr&&!K("}")&&(e=He(),"undefined"!=typeof e);)c.push(e);return W("}"),yr.labelSet=a,yr.inIteration=i,yr.inSwitch=o,yr.inFunctionBody=s,hr.markEnd(hr.createBlockStatement(c),u)}function We(e){var r,t,n,a,i,o,s=[];if(W("("),!K(")"))for(a={};cr<fr&&(t=dr,r=_e(),i="$"+t.value,ur?(p(t.value)&&(n=t,o=ar.StrictParamName),Object.prototype.hasOwnProperty.call(a,i)&&(n=t,o=ar.StrictParamDupe)):e||(p(t.value)?(e=t,o=ar.StrictParamName):l(t.value)?(e=t,o=ar.StrictReservedWord):Object.prototype.hasOwnProperty.call(a,i)&&(e=t,o=ar.StrictParamDupe)),s.push(r),a[i]=!0,!K(")"));)W(",");return W(")"),{params:s,stricted:n,firstRestricted:e,message:o}}function Ge(){var e,r,t,n,a,i,o,s,u,c=[];return u=dr,G("function"),t=dr,e=_e(),ur?p(t.value)&&q(t,ar.StrictFunctionName):p(t.value)?(i=t,o=ar.StrictFunctionName):l(t.value)&&(i=t,o=ar.StrictReservedWord),a=We(i),c=a.params,n=a.stricted,i=a.firstRestricted,a.message&&(o=a.message),s=ur,r=ze(),ur&&i&&D(i,o),ur&&n&&q(n,o),ur=s,hr.markEnd(hr.createFunctionDeclaration(e,c,[],r),u)}function Ke(){var e,r,t,n,a,i,o,s,u=null,c=[];return s=dr,G("function"),K("(")||(e=dr,u=_e(),ur?p(e.value)&&q(e,ar.StrictFunctionName):p(e.value)?(t=e,n=ar.StrictFunctionName):l(e.value)&&(t=e,n=ar.StrictReservedWord)),a=We(t),c=a.params,r=a.stricted,t=a.firstRestricted,a.message&&(n=a.message),o=ur,i=ze(),ur&&t&&D(t,n),ur&&r&&q(r,n),ur=o,hr.markEnd(hr.createFunctionExpression(u,c,[],i),s)}function He(){if(dr.type===Ze.Keyword)switch(dr.value){case"const":case"let":return xe(dr.value);case"function":return Ge();default:return qe()}if(dr.type!==Ze.EOF)return qe()}function $e(){for(var e,r,t,n,a=[];cr<fr&&(r=dr,r.type===Ze.StringLiteral)&&(e=He(),a.push(e),e.expression.type===tr.Literal);)t=sr.slice(r.start+1,r.end-1),"use strict"===t?(ur=!0,n&&q(n,ar.StrictOctalLiteral)):!n&&r.octal&&(n=r);for(;cr<fr&&(e=He(),"undefined"!=typeof e);)a.push(e);return a}function Ye(){var e,r;return m(),F(),r=dr,ur=!1,e=$e(),hr.markEnd(hr.createProgram(e),r)}function Xe(){var e,r,t,n=[];for(e=0;e<mr.tokens.length;++e)r=mr.tokens[e],t={type:r.type,value:r.value},mr.range&&(t.range=r.range),mr.loc&&(t.loc=r.loc),n.push(t);mr.tokens=n}function Je(e,r){var t,n,a;t=String,"string"==typeof e||e instanceof String||(e=t(e)),hr=or,sr=e,cr=0,lr=sr.length>0?1:0,pr=0,fr=sr.length,dr=null,yr={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},mr={},r=r||{},r.tokens=!0,mr.tokens=[],mr.tokenize=!0,mr.openParenToken=-1,mr.openCurlyToken=-1,mr.range="boolean"==typeof r.range&&r.range,mr.loc="boolean"==typeof r.loc&&r.loc,"boolean"==typeof r.comment&&r.comment&&(mr.comments=[]),"boolean"==typeof r.tolerant&&r.tolerant&&(mr.errors=[]);try{if(F(),dr.type===Ze.EOF)return mr.tokens;for(n=U();dr.type!==Ze.EOF;)try{n=U()}catch(e){if(n=dr,mr.errors){mr.errors.push(e);break}throw e}Xe(),a=mr.tokens,"undefined"!=typeof mr.comments&&(a.comments=mr.comments),"undefined"!=typeof mr.errors&&(a.errors=mr.errors)}catch(e){throw e}finally{mr={}}return a}function Qe(e,r){var t,n;n=String,"string"==typeof e||e instanceof String||(e=n(e)),hr=or,sr=e,cr=0,lr=sr.length>0?1:0,pr=0,fr=sr.length,dr=null,yr={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},mr={},"undefined"!=typeof r&&(mr.range="boolean"==typeof r.range&&r.range,mr.loc="boolean"==typeof r.loc&&r.loc,mr.attachComment="boolean"==typeof r.attachComment&&r.attachComment,mr.loc&&null!==r.source&&void 0!==r.source&&(mr.source=n(r.source)),"boolean"==typeof r.tokens&&r.tokens&&(mr.tokens=[]),"boolean"==typeof r.comment&&r.comment&&(mr.comments=[]),"boolean"==typeof r.tolerant&&r.tolerant&&(mr.errors=[]),mr.attachComment&&(mr.range=!0,mr.comments=[],mr.bottomRightStack=[],mr.trailingComments=[],mr.leadingComments=[]));try{t=Ye(),"undefined"!=typeof mr.comments&&(t.comments=mr.comments),"undefined"!=typeof mr.tokens&&(Xe(),t.tokens=mr.tokens),"undefined"!=typeof mr.errors&&(t.errors=mr.errors)}catch(e){throw e}finally{mr={}}return t}var Ze,er,rr,tr,nr,ar,ir,or,sr,ur,cr,lr,pr,fr,hr,dr,yr,mr;Ze={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9},er={},er[Ze.BooleanLiteral]="Boolean",er[Ze.EOF]="<end>",er[Ze.Identifier]="Identifier",er[Ze.Keyword]="Keyword",er[Ze.NullLiteral]="Null",er[Ze.NumericLiteral]="Numeric",er[Ze.Punctuator]="Punctuator",er[Ze.StringLiteral]="String",er[Ze.RegularExpression]="RegularExpression",rr=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],tr={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",
ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},nr={Data:1,Get:2,Set:4},ar={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},ir={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")},or={name:"SyntaxTree",processComment:function(e){var r,t;if(!(e.type===tr.Program&&e.body.length>0)){for(mr.trailingComments.length>0?mr.trailingComments[0].range[0]>=e.range[1]?(t=mr.trailingComments,mr.trailingComments=[]):mr.trailingComments.length=0:mr.bottomRightStack.length>0&&mr.bottomRightStack[mr.bottomRightStack.length-1].trailingComments&&mr.bottomRightStack[mr.bottomRightStack.length-1].trailingComments[0].range[0]>=e.range[1]&&(t=mr.bottomRightStack[mr.bottomRightStack.length-1].trailingComments,delete mr.bottomRightStack[mr.bottomRightStack.length-1].trailingComments);mr.bottomRightStack.length>0&&mr.bottomRightStack[mr.bottomRightStack.length-1].range[0]>=e.range[0];)r=mr.bottomRightStack.pop();r?r.leadingComments&&r.leadingComments[r.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=r.leadingComments,delete r.leadingComments):mr.leadingComments.length>0&&mr.leadingComments[mr.leadingComments.length-1].range[1]<=e.range[0]&&(e.leadingComments=mr.leadingComments,mr.leadingComments=[]),t&&(e.trailingComments=t),mr.bottomRightStack.push(e)}},markEnd:function(e,r){return mr.range&&(e.range=[r.start,cr]),mr.loc&&(e.loc=new M(void 0===r.startLineNumber?r.lineNumber:r.startLineNumber,r.start-(void 0===r.startLineStart?r.lineStart:r.startLineStart),lr,cr-pr),this.postProcess(e)),mr.attachComment&&this.processComment(e),e},postProcess:function(e){return mr.source&&(e.loc.source=mr.source),e},createArrayExpression:function(e){return{type:tr.ArrayExpression,elements:e}},createAssignmentExpression:function(e,r,t){return{type:tr.AssignmentExpression,operator:e,left:r,right:t}},createBinaryExpression:function(e,r,t){var n="||"===e||"&&"===e?tr.LogicalExpression:tr.BinaryExpression;return{type:n,operator:e,left:r,right:t}},createBlockStatement:function(e){return{type:tr.BlockStatement,body:e}},createBreakStatement:function(e){return{type:tr.BreakStatement,label:e}},createCallExpression:function(e,r){return{type:tr.CallExpression,callee:e,arguments:r}},createCatchClause:function(e,r){return{type:tr.CatchClause,param:e,body:r}},createConditionalExpression:function(e,r,t){return{type:tr.ConditionalExpression,test:e,consequent:r,alternate:t}},createContinueStatement:function(e){return{type:tr.ContinueStatement,label:e}},createDebuggerStatement:function(){return{type:tr.DebuggerStatement}},createDoWhileStatement:function(e,r){return{type:tr.DoWhileStatement,body:e,test:r}},createEmptyStatement:function(){return{type:tr.EmptyStatement}},createExpressionStatement:function(e){return{type:tr.ExpressionStatement,expression:e}},createForStatement:function(e,r,t,n){return{type:tr.ForStatement,init:e,test:r,update:t,body:n}},createForInStatement:function(e,r,t){return{type:tr.ForInStatement,left:e,right:r,body:t,each:!1}},createFunctionDeclaration:function(e,r,t,n){return{type:tr.FunctionDeclaration,id:e,params:r,defaults:t,body:n,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(e,r,t,n){return{type:tr.FunctionExpression,id:e,params:r,defaults:t,body:n,rest:null,generator:!1,expression:!1}},createIdentifier:function(e){return{type:tr.Identifier,name:e}},createIfStatement:function(e,r,t){return{type:tr.IfStatement,test:e,consequent:r,alternate:t}},createLabeledStatement:function(e,r){return{type:tr.LabeledStatement,label:e,body:r}},createLiteral:function(e){return{type:tr.Literal,value:e.value,raw:sr.slice(e.start,e.end)}},createMemberExpression:function(e,r,t){return{type:tr.MemberExpression,computed:"["===e,object:r,property:t}},createNewExpression:function(e,r){return{type:tr.NewExpression,callee:e,arguments:r}},createObjectExpression:function(e){return{type:tr.ObjectExpression,properties:e}},createPostfixExpression:function(e,r){return{type:tr.UpdateExpression,operator:e,argument:r,prefix:!1}},createProgram:function(e){return{type:tr.Program,body:e}},createProperty:function(e,r,t){return{type:tr.Property,key:r,value:t,kind:e}},createReturnStatement:function(e){return{type:tr.ReturnStatement,argument:e}},createSequenceExpression:function(e){return{type:tr.SequenceExpression,expressions:e}},createSwitchCase:function(e,r){return{type:tr.SwitchCase,test:e,consequent:r}},createSwitchStatement:function(e,r){return{type:tr.SwitchStatement,discriminant:e,cases:r}},createThisExpression:function(){return{type:tr.ThisExpression}},createThrowStatement:function(e){return{type:tr.ThrowStatement,argument:e}},createTryStatement:function(e,r,t,n){return{type:tr.TryStatement,block:e,guardedHandlers:r,handlers:t,finalizer:n}},createUnaryExpression:function(e,r){return"++"===e||"--"===e?{type:tr.UpdateExpression,operator:e,argument:r,prefix:!0}:{type:tr.UnaryExpression,operator:e,argument:r,prefix:!0}},createVariableDeclaration:function(e,r){return{type:tr.VariableDeclaration,declarations:e,kind:r}},createVariableDeclarator:function(e,r){return{type:tr.VariableDeclarator,id:e,init:r}},createWhileStatement:function(e,r){return{type:tr.WhileStatement,test:e,body:r}},createWithStatement:function(e,r){return{type:tr.WithStatement,object:e,body:r}}},e.version="1.2.5",e.tokenize=Je,e.parse=Qe,e.Syntax=function(){var e,r={};"function"==typeof Object.create&&(r=Object.create(null));for(e in tr)tr.hasOwnProperty(e)&&(r[e]=tr[e]);return"function"==typeof Object.freeze&&Object.freeze(r),r}()})}),he=r(fe),de=Object.freeze({default:he}),ye=t(function(e){function t(e,r,t){this.name=e,this.lvalue=r,this.rvalue=t,this.count=0}function n(e,r,t,n){this.body=e,this.args=r,this.thisVars=t,this.localVars=n}function a(e){if("eval"===e)throw new Error("cwise-parser: eval() not allowed");return"undefined"!=typeof window?e in window:"undefined"!=typeof m?e in m:"undefined"!=typeof self&&e in self}function i(e){for(var r=e.body[0].expression.callee.params,t=new Array(r.length),n=0;n<r.length;++n)t[n]=r[n].name;return t}function o(e){function r(e){var r=m+e.replace(/\_/g,"__");return k.push(r),r}function o(e){var r="this_"+e.replace(/\_/g,"__");return S.push(r),r}function l(e,r){for(var t=e.range[0],n=e.range[1],a=t+1;a<n;++a)_[a]="";_[t]=r}function p(e){return"'"+e.replace(/\_/g,"\\_").replace(/\'/g,"'")+"'"}function f(e){return _.slice(e.range[0],e.range[1]).join("")}function h(e){return"AssignmentExpression"===e.parent.type&&e.parent.left===e?"="===e.parent.operator?x:x|E:"UpdateExpression"===e.parent.type?x|E:E}for(var d=["(",e,")()"].join(""),y=s.parse(d,{range:!0}),m="_inline_"+c++ +"_",g=i(y),v=new Array(g.length),b=0;b<g.length;++b)v[b]=new t([m,"arg",b,"_"].join(""),!1,!1);for(var _=new Array(d.length),b=0,w=d.length;b<w;++b)_[b]=d.charAt(b);var k=[],S=[],x=1,E=2;!function e(t,n){if(t.parent=n,"MemberExpression"===t.type)t.computed?(e(t.object,t),e(t.property,t)):"ThisExpression"===t.object.type?l(t,o(t.property.name)):e(t.object,t);else{if("ThisExpression"===t.type)throw new Error("cwise-parser: Computed this is not allowed");if("Identifier"===t.type){var i=t.name,s=g.indexOf(i);if(s>=0){var u=v[s],c=h(t);c&x&&(u.lvalue=!0),c&E&&(u.rvalue=!0),++u.count,l(t,u.name)}else a(i)||l(t,r(i))}else if("Literal"===t.type)"string"==typeof t.value&&l(t,p(t.value));else{if("WithStatement"===t.type)throw new Error("cwise-parser: with() statements not allowed");for(var f=Object.keys(t),d=0,y=f.length;d<y;++d)if("parent"!==f[d]){var m=t[f[d]];if(m)if(m instanceof Array)for(var b=0;b<m.length;++b)m[b]&&"string"==typeof m[b].type&&e(m[b],t);else"string"==typeof m.type&&e(m,t)}}}}(y.body[0].expression.callee.body,void 0),u(k),u(S);var A=new n(f(y.body[0].expression.callee.body),v,S,k);return A}var s=r(de),u=r(V),c=0;e.exports=o}),me=r(ye),ge=Object.freeze({default:me}),ve=t(function(e){function t(e){for(var r in e)i.indexOf(r)<0&&o.indexOf(r)<0&&console.warn("cwise: Unknown argument '"+r+"' passed to expression compiler");for(var t=0;t<i.length;++t)if(!e[i[t]])throw new Error("cwise: Missing argument: "+i[t]);return a({args:e.args,pre:n(e.pre||function(){}),body:n(e.body),post:n(e.post||function(){}),debug:!!e.printCode,funcName:e.funcName||e.body.name||"cwise",blockSize:e.blockSize||64})}var n=r(ge),a=r(D),i=["args","body"],o=["pre","post","printCode","funcName","blockSize"];e.exports=t}),be=r(ve),_e=Object.freeze({default:be}),we=t(function(e){var t=r(pe),n=r(_e),a=n({args:["array","scalar","index"],body:function(e,r,t){var n,a=r;for(n=0;n<t.length-1;++n)a=a[t[n]];a[t[t.length-1]]=e}});e.exports=function(e){var r=t(e.shape);return a(e,r),r}}),ke=r(we);e.sampleSphericalCap=i,e.sampleDirectedSphericalCap=s,e.axisAngleToRotationMatrix=u,e.normalizeCols=f,e.normalizeColsPure=h,e.crossMatrix=c,e.ndToIterator=p,e.dot=l,e.ndarrayColsToNative=a,e.ndarrayToNative=n,e.asNdarray=o,e.example1=d,e.example2=y,Object.defineProperty(e,"__esModule",{value:!0})});
const cap = capRandom;
/* Generate some random data */
// Samples from the 30° spherical cap at the North Pole
const northPole =
cap.ndarrayToNative(cap.sampleSphericalCap({N : 100, deg : 30}));
// Samples from the 30° spherical cap pointing at [1,1,1]
const octant = cap.ndarrayToNative(cap.sampleDirectedSphericalCap(
[ [ 1 ], [ 1 ], [ 1 ] ], {N : 100, deg : 30}));
// Samples from the 110° spherical cap (a dome) at the **South** Pole
const dome = cap.ndarrayToNative(cap.sampleDirectedSphericalCap(
[ [ 0 ], [ 0 ], [ -1 ] ], {N : 300, deg : 110}));
/* Three Plotly traces for each of these three datasets, plus one for origin */
const trace1 = {
x : northPole[0],
y : northPole[1],
z : northPole[2],
mode : 'markers',
type : 'scatter3d',
name : 'North Pole'
};
const trace2 = {
x : octant[0],
y : octant[1],
z : octant[2],
mode : 'markers',
type : 'scatter3d',
name : 'Positive octant'
};
const trace3 = {
x : dome[0],
y : dome[1],
z : dome[2],
mode : 'markers',
type : 'scatter3d',
name : 'South Pole Dome'
};
const trace0 = {
x : [0],
y : [0],
z : [0],
mode : 'markers',
marker : {
color : 'rgb(127, 127, 127)',
size : 12,
symbol : 'circle',
line : {color : 'rgb(204, 204, 204)', width : 1},
opacity : 0.8
},
type : 'scatter3d',
name : 'Origin'
};
/* Generate plots! */
const data = [ trace1, trace2, trace3, trace0 ];
const layout = {margin : {l : 0, r : 0, b : 0, t : 0}};
Plotly.newPlot('divPlot', data, layout);
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<div id="divPlot"></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="cap-random.min.js"></script>
<script src="demo.js"></script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment