// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
///
var t="function"==typeof Object.defineProperty?Object.defineProperty:null;var r=Object.defineProperty;function e(t){return"number"==typeof t}function n(t){var r,e="";for(r=0;r0&&(r-=1),n=i.toExponential(r)):n=i.toPrecision(t.precision),t.alternate||(n=h.call(n,v,"$1e"),n=h.call(n,w,"e"),n=h.call(n,g,""));break;default:throw new Error("invalid double notation. Value: "+t.specifier)}return n=h.call(n,c,"e+0$1"),n=h.call(n,p,"e-0$1"),t.alternate&&(n=h.call(n,y,"$1."),n=h.call(n,m,"$1.e")),i>=0&&t.sign&&(n=t.sign+n),n=t.specifier===l.call(t.specifier)?l.call(n):s.call(n)}function b(t){var r,e="";for(r=0;r127)throw new Error("invalid character code. Value: "+n.arg);n.arg=T(a)?String(n.arg):_(a)}break;case"e":case"E":case"f":case"F":case"g":case"G":r||(n.precision=6),n.arg=d(n);break;default:throw new Error("invalid specifier: "+n.specifier)}n.maxWidth>=0&&n.arg.length>n.maxWidth&&(n.arg=n.arg.substring(0,n.maxWidth)),n.padZeros?n.arg=i(n.arg,n.width||n.precision,n.padRight):n.width&&(n.arg=(c=n.arg,p=n.width,y=n.padRight,m=void 0,(m=p-c.length)<0?c:c=y?c+b(m):b(m)+c)),f+=n.arg||"",s+=1}return f}var V=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function j(t){var r={mapping:t[1]?parseInt(t[1],10):void 0,flags:t[2],width:t[3],precision:t[5],specifier:t[6]};return"."===t[4]&&void 0===t[5]&&(r.precision="1"),r}function O(t){var r,e,n,i;for(e=[],i=0,n=V.exec(t);n;)(r=t.slice(i,V.lastIndex-n[0].length)).length&&e.push(r),e.push(j(n)),i=V.lastIndex,n=V.exec(t);return(r=t.slice(i)).length&&e.push(r),e}function S(t){var r,e;if("string"!=typeof t)throw new TypeError(S("invalid argument. First argument must be a string. Value: `%s`.",t));for(r=[O(t)],e=1;ei&&(n=!1),!n&&!r)return 0;i=o}return n&&r?3:n?1:2}function lt(t,r){return r&&(2===t||3===t)}function ht(t,r){return r&&(1===t||3===t)}function ct(t,r,e){var n,i,o,a,u;for(n=t.length,i=e,o=e,u=0;u0?o+=a*(t[u]-1):a<0&&(i+=a*(t[u]-1))}return[i,o]}function pt(t){return t.re}function yt(t){return t.im}function mt(t){return"string"==typeof t}C(ct,"assign",(function(t,r,e,n){var i,o,a,u,f;for(i=t.length,o=e,a=e,f=0;f0?a+=u*(t[f]-1):u<0&&(o+=u*(t[f]-1))}return n[0]=o,n[1]=a,n}));var gt=String.prototype.valueOf;var wt=Y();function vt(t){return"object"==typeof t&&(t instanceof String||(wt?function(t){try{return gt.call(t),!0}catch(t){return!1}}(t):"[object String]"===z(t)))}function dt(t){return mt(t)||vt(t)}C(dt,"isPrimitive",mt),C(dt,"isObject",vt);var bt=/[-\/\\^$*+?.()|[\]{}]/g;var _t=/./,Et=it(),Tt=Et.document&&Et.document.childNodes,xt=Int8Array;function At(){return/^\s*function\s*([^(]*)/i}var Vt=/^\s*function\s*([^(]*)/i;C(At,"REGEXP",Vt);var jt=Array.isArray?Array.isArray:function(t){return"[object Array]"===z(t)};function Ot(t){return null!==t&&"object"==typeof t}var St=function(t){if("function"!=typeof t)throw new TypeError(S("invalid argument. Must provide a function. Value: `%s`.",t));return function(r){var e,n;if(!jt(r))return!1;if(e=r.length,0===e)return!1;for(n=0;n=0&&"/"!==t[e];e--);return void 0===e||e<=0?t.replace(bt,"\\$&"):(r=(r=t.substring(1,e)).replace(bt,"\\$&"),t=t[0]+r+t.substring(e))}(r),"g");else if(!kt(r))throw new TypeError(S("invalid argument. Second argument must be a string or regular expression. Value: `%s`.",r));if(!mt(e)&&!Lt(e))throw new TypeError(S("invalid argument. Third argument must be a string or replacement function. Value: `%s`.",e));return Bt(t,r,e)}var Nt={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var Pt="function"==typeof Uint8Array;var Yt="function"==typeof Uint8Array?Uint8Array:null;var Dt,Wt="function"==typeof Uint8Array?Uint8Array:void 0;Dt=function(){var t,r,e;if("function"!=typeof Yt)return!1;try{r=new Yt(r=[1,3.14,-3.14,256,257]),e=r,t=(Pt&&e instanceof Uint8Array||"[object Uint8Array]"===z(e))&&1===r[0]&&3===r[1]&&253===r[2]&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}()?Wt:function(){throw new Error("not implemented")};var Gt=Dt,Jt="function"==typeof Uint16Array;var $t="function"==typeof Uint16Array?Uint16Array:null;var zt,Xt="function"==typeof Uint16Array?Uint16Array:void 0;zt=function(){var t,r,e;if("function"!=typeof $t)return!1;try{r=new $t(r=[1,3.14,-3.14,65536,65537]),e=r,t=(Jt&&e instanceof Uint16Array||"[object Uint16Array]"===z(e))&&1===r[0]&&3===r[1]&&65533===r[2]&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}()?Xt:function(){throw new Error("not implemented")};var Zt,Ht=zt,qt={uint16:Ht,uint8:Gt};(Zt=new qt.uint16(1))[0]=4660;var Kt=52===new qt.uint8(Zt.buffer)[0],Qt="function"==typeof ArrayBuffer;function tr(t){return Qt&&t instanceof ArrayBuffer||"[object ArrayBuffer]"===z(t)}var rr="function"==typeof Float64Array;var er="function"==typeof Float64Array?Float64Array:null;var nr,ir="function"==typeof Float64Array?Float64Array:void 0;nr=function(){var t,r,e;if("function"!=typeof er)return!1;try{r=new er([1,3.14,-3.14,NaN]),e=r,t=(rr&&e instanceof Float64Array||"[object Float64Array]"===z(e))&&1===r[0]&&3.14===r[1]&&-3.14===r[2]&&r[3]!=r[3]}catch(r){t=!1}return t}()?ir:function(){throw new Error("not implemented")};var or=nr,ar="function"==typeof ArrayBuffer?ArrayBuffer:null;var ur,fr="function"==typeof ArrayBuffer?ArrayBuffer:void 0;ur=function(){var t,r,e;if("function"!=typeof ar)return!1;try{(t=tr(e=new ar(16))&&"function"==typeof ar.isView)&&((r=new or(e))[0]=-3.14,r[1]=NaN,t=t&&ar.isView(r)&&16===e.byteLength&&-3.14===r[0]&&r[1]!=r[1])}catch(r){t=!1}return t}()?fr:function(){throw new Error("not implemented")};var sr=ur,lr="function"==typeof DataView;var hr="function"==typeof DataView?DataView:null;var cr,pr="function"==typeof DataView?DataView:void 0;cr=function(){var t,r,e,n;if("function"!=typeof hr)return!1;try{e=new sr(24),r=new hr(e,8),n=r,(t=(lr&&n instanceof DataView||"[object DataView]"===z(n))&&"function"==typeof r.getFloat64&&"function"==typeof r.setFloat64)&&(r.setFloat64(0,-3.14),r.setFloat64(8,NaN),t=t&&r.buffer===e&&16===r.byteLength&&8===r.byteOffset&&-3.14===r.getFloat64(0)&&r.getFloat64(8)!=r.getFloat64(8))}catch(r){t=!1}return t}()?pr:function(){throw new Error("not implemented")};var yr=cr,mr="function"==typeof BigInt?BigInt:void 0,gr={all:["binary","bool","complex64","complex128","float32","float64","generic","int16","int32","int8","uint16","uint32","uint8","uint8c"],typed:["binary","bool","complex64","complex128","float32","float64","int16","int32","int8","uint16","uint32","uint8","uint8c"],floating_point:["complex64","complex128","float32","float64"],real_floating_point:["float32","float64"],complex_floating_point:["complex64","complex128"],boolean:["bool"],integer:["int16","int32","int8","uint16","uint32","uint8","uint8c"],signed_integer:["int16","int32","int8"],unsigned_integer:["uint16","uint32","uint8","uint8c"],real:["float32","float64","int16","int32","int8","uint16","uint32","uint8","uint8c"],numeric:["complex64","complex128","float32","float64","int16","int32","int8","uint16","uint32","uint8","uint8c"]},wr=/_and_generic$/;function vr(){var t,r,e;return 0===arguments.length?gr.all.slice():(e=!1,t=arguments[0],wr.test(t)&&"all"!==(t=Bt(t,wr,""))&&(e=!0),r=(r=gr[t])?r.slice():[],e&&r.length>0&&r.push("generic"),r)}function dr(){return{bool:0,int8:1,uint8:2,uint8c:3,int16:4,uint16:5,int32:6,uint32:7,int64:8,uint64:9,float32:10,float64:11,complex64:12,complex128:13,binary:14,generic:15,notype:17,userdefined_type:256}}function br(t,r,e){B(t,r,{configurable:!1,enumerable:!0,writable:!1,value:e})}function _r(t){return Object.keys(Object(t))}var Er=void 0!==Object.keys;function Tr(t){return"[object Arguments]"===z(t)}var xr=function(){return Tr(arguments)}();function Ar(t){return"number"==typeof t}var Vr=Number,jr=Vr.prototype.toString;var Or=Y();function Sr(t){return"object"==typeof t&&(t instanceof Vr||(Or?function(t){try{return jr.call(t),!0}catch(t){return!1}}(t):"[object Number]"===z(t)))}function Ir(t){return Ar(t)||Sr(t)}function Rr(t){return t!=t}function Fr(t){return Ar(t)&&Rr(t)}function Lr(t){return Sr(t)&&Rr(t.valueOf())}function Mr(t){return Fr(t)||Lr(t)}C(Ir,"isPrimitive",Ar),C(Ir,"isObject",Sr),C(Mr,"isPrimitive",Fr),C(Mr,"isObject",Lr);var Ur=Number.POSITIVE_INFINITY,kr=Vr.NEGATIVE_INFINITY,Br=Math.floor;function Cr(t){return Br(t)===t}function Nr(t){return tkr&&Cr(t)}function Pr(t){return Ar(t)&&Nr(t)}function Yr(t){return Sr(t)&&Nr(t.valueOf())}function Dr(t){return Pr(t)||Yr(t)}C(Dr,"isPrimitive",Pr),C(Dr,"isObject",Yr);var Wr=Object.prototype.propertyIsEnumerable;var Gr=!Wr.call("beep","0");function Jr(t,r){var e;return null!=t&&(!(e=Wr.call(t,r))&&Gr&&dt(t)?!Fr(r=+r)&&Pr(r)&&r>=0&&r=0&&t.length<=$r&&G(t,"callee")&&!Jr(t,"callee")},Xr=Array.prototype.slice;var Zr=Jr((function(){}),"prototype"),Hr=!Jr({toString:null},"toString"),qr=9007199254740991;function Kr(t){return"object"==typeof t&&null!==t&&"number"==typeof t.length&&Cr(t.length)&&t.length>=0&&t.length<=qr}function Qr(t,r,e){var n,i;if(!Kr(t)&&!mt(t))throw new TypeError(S("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(0===(n=t.length))return-1;if(3===arguments.length){if(!Pr(e))throw new TypeError(S("invalid argument. Third argument must be an integer. Value: `%s`.",e));if(e>=0){if(e>=n)return-1;i=e}else(i=n+e)<0&&(i=0)}else i=0;if(Mr(r)){for(;i0&&!G(t,"0"))for(u=0;u>>0,i=Br(t/de),Kt?(_e.setUint32(0,o,Kt),_e.setUint32(4,i,Kt)):(_e.setUint32(0,i,Kt),_e.setUint32(4,o,Kt)),a=0;a>>0,n=Br(t/4294967296),e=new yr(r.buffer),Kt?(e.setUint32(0,i,Kt),e.setUint32(4,n,Kt)):(e.setUint32(0,n,Kt),e.setUint32(4,i,Kt))),r}),"assign",Ee);var Te={bool:0,int8:1,uint8:2,uint8c:3,int16:4,uint16:5,int32:6,uint32:7,int64:8,uint64:9,float32:10,float64:11,complex64:12,complex128:13,binary:14,generic:15,notype:17,userdefined_type:256},xe=ce(),Ae={throw:1,clamp:2,wrap:3,normalize:4};function Ve(t,r,e,n,i,o){var a,u,f,s,l;if(!(this instanceof Ve))return new Ve(t,r,e,n,i,o);for(s=1,l=0;l=0}function Se(t){return Yr(t)&&t.valueOf()>=0}function Ie(t){return Oe(t)||Se(t)}function Re(t){var r,e,n;for(e=t.length,r=[],n=0;n=0;a--)t-=o=t%e[a],t/=e[a],i+=o*r[a];return this._accessors?this._buffer.get(i):this._buffer[i]})),C(Ve.prototype,"set",(function(){var t,r;for(t=this._offset,r=0;r=0;u--)t-=a=t%n[u],t/=n[u],o+=a*e[u];return this._accessors?this._buffer.set(r,o):this._buffer[o]=r,this})),C(Ve.prototype,"toString",(function(){var t,r,e,n,i,o;if(r=this._shape.length,e="ndarray( '"+(n=this._dtype)+"', ",t="",this._length<=100)if("complex64"===n||"complex128"===n)for(o=0;o=0;o--)t+=pt(i=this.iget(this._length-1-o))+", "+yt(i),o>0&&(t+=", ");else for(o=2;o>=0;o--)t+=this.iget(this._length-1-o),o>0&&(t+=", ")}if(e+=Ct(Nt[this.dtype],"{{data}}",t),e+=", ",e+=0===r?"[]":"[ "+this._shape.join(", ")+" ]",e+=", ",e+="[ ",0===r)e+="0";else for(o=0;o=0&&t.length<=gn}function vn(t){return"object"==typeof t&&null!==t&&!jt(t)}function dn(t,r){if(!(this instanceof dn))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Ar(t))throw new TypeError(S("invalid argument. Real component must be a number. Value: `%s`.",t));if(!Ar(r))throw new TypeError(S("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return B(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:t}),B(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}C(dn,"BYTES_PER_ELEMENT",8),C(dn.prototype,"BYTES_PER_ELEMENT",8),C(dn.prototype,"byteLength",16),C(dn.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),C(dn.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));var bn="function"==typeof Math.fround?Math.fround:null,_n=new We(1);var En="function"==typeof bn?bn:function(t){return _n[0]=t,_n[0]};function Tn(t,r){if(!(this instanceof Tn))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Ar(t))throw new TypeError(S("invalid argument. Real component must be a number. Value: `%s`.",t));if(!Ar(r))throw new TypeError(S("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return B(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:En(t)}),B(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:En(r)}),this}function xn(t){return t instanceof dn||t instanceof Tn||"object"==typeof t&&null!==t&&"number"==typeof t.re&&"number"==typeof t.im}function An(t){return Cr(t/2)}C(Tn,"BYTES_PER_ELEMENT",4),C(Tn.prototype,"BYTES_PER_ELEMENT",4),C(Tn.prototype,"byteLength",8),C(Tn.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),C(Tn.prototype,"toJSON",(function(){var t={type:"Complex64"};return t.re=this.re,t.im=this.im,t}));var Vn=8;function jn(t){return"object"==typeof t&&null!==t&&"Complex64Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===Vn}var On=16;function Sn(t){return"object"==typeof t&&null!==t&&"Complex128Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===On}function In(){return"function"==typeof J&&"symbol"==typeof J("foo")&&G(J,"iterator")&&"symbol"==typeof J.iterator}var Rn=In()?Symbol.iterator:null;function Fn(t,r){if(!(this instanceof Fn))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Ar(t))throw new TypeError(S("invalid argument. Real component must be a number. Value: `%s`.",t));if(!Ar(r))throw new TypeError(S("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return B(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:En(t)}),B(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:En(r)}),this}function Ln(t){return t.re}function Mn(t){return t.im}function Un(t,r){return new We(t.buffer,t.byteOffset+t.BYTES_PER_ELEMENT*r,2*(t.length-r))}function kn(t,r){return new or(t.buffer,t.byteOffset+t.BYTES_PER_ELEMENT*r,2*(t.length-r))}function Bn(t){var r,e,n;for(r=[];!(e=t.next()).done;)if(wn(n=e.value)&&n.length>=2)r.push(n[0],n[1]);else{if(!xn(n))return new TypeError(S("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));r.push(Ln(n),Mn(n))}return r}C(Fn,"BYTES_PER_ELEMENT",4),C(Fn.prototype,"BYTES_PER_ELEMENT",4),C(Fn.prototype,"byteLength",8),C(Fn.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),C(Fn.prototype,"toJSON",(function(){var t={type:"Complex64"};return t.re=this.re,t.im=this.im,t}));var Cn=2*We.BYTES_PER_ELEMENT,Nn=In();function Pn(t){return t instanceof Wn||"object"==typeof t&&null!==t&&("Complex64Array"===t.constructor.name||"Complex128Array"===t.constructor.name)&&"number"==typeof t._length&&"object"==typeof t._buffer}function Yn(t){return t===Wn||"Complex128Array"===t.name}function Dn(t,r){return new Fn(t[r*=2],t[r+1])}function Wn(){var t,r,e,n;if(r=arguments.length,!(this instanceof Wn))return 0===r?new Wn:1===r?new Wn(arguments[0]):2===r?new Wn(arguments[0],arguments[1]):new Wn(arguments[0],arguments[1],arguments[2]);if(0===r)e=new We(0);else if(1===r)if(Oe(arguments[0]))e=new We(2*arguments[0]);else if(Kr(arguments[0]))if((n=(e=arguments[0]).length)&&jt(e)&&xn(e[0])){if(e=function(t,r){var e,n,i,o;for(e=r.length,o=0,i=0;ie.byteLength-t)throw new RangeError(S("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Cn));e=new We(e,t,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}function Gn(t,r){if(!(this instanceof Gn))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!Ar(t))throw new TypeError(S("invalid argument. Real component must be a number. Value: `%s`.",t));if(!Ar(r))throw new TypeError(S("invalid argument. Imaginary component must be a number. Value: `%s`.",r));return B(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:t}),B(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:r}),this}function Jn(t){return t.re}function $n(t){return t.im}function zn(t){var r,e,n;for(r=[];!(e=t.next()).done;)if(wn(n=e.value)&&n.length>=2)r.push(n[0],n[1]);else{if(!xn(n))return new TypeError(S("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));r.push(Jn(n),$n(n))}return r}C(Wn,"BYTES_PER_ELEMENT",Cn),C(Wn,"name","Complex64Array"),C(Wn,"from",(function(t){var r,e,n,i,o,a,u,f,s,l,h,c;if(!Lt(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Yn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!Lt(n=arguments[1]))throw new TypeError(S("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(r=arguments[2])}if(Pn(t)){if(f=t.length,n){for(o=(i=new this(f))._buffer,c=0,h=0;h=2))throw new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",l));o[c]=l[0],o[c+1]=l[1]}c+=2}return i}return new this(t)}if(Kr(t)){if(n){for(f=t.length,u=t.get&&t.set?Ue("default"):Be("default"),h=0;h=2))throw new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",l));o[c]=l[0],o[c+1]=l[1]}c+=2}return i}return new this(t)}if(vn(t)&&Nn&&Lt(t[Rn])){if(!Lt((o=t[Rn]()).next))throw new TypeError(S("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",t));if(a=n?function(t,r,e){var n,i,o,a;for(n=[],a=-1;!(i=t.next()).done;)if(a+=1,wn(o=r.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!xn(o))return new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Ln(o),Mn(o))}return n}(o,n,r):Bn(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,h=0;h=this._length))return Dn(this._buffer,t)})),at(Wn.prototype,"buffer",(function(){return this._buffer.buffer})),at(Wn.prototype,"byteLength",(function(){return this._buffer.byteLength})),at(Wn.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(Wn.prototype,"BYTES_PER_ELEMENT",Wn.BYTES_PER_ELEMENT),C(Wn.prototype,"copyWithin",(function(t,r){if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*t,2*r):this._buffer.copyWithin(2*t,2*r,2*arguments[2]),this})),C(Wn.prototype,"entries",(function(){var t,r,e,n,i,o,a;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,t=this._buffer,n=this._length,o=-1,a=-2,C(e={},"next",(function(){var r;if(o+=1,i||o>=n)return{done:!0};return r=new Fn(t[a+=2],t[a+1]),{value:[o,r],done:!1}})),C(e,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),Rn&&C(e,Rn,(function(){return r.entries()})),e})),C(Wn.prototype,"every",(function(t,r){var e,n;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=0;n1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=i)<0&&(r=0),arguments.length>2){if(!Cr(e))throw new TypeError(S("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else r=0,e=i;for(a=Ln(t),u=Mn(t),f=r;f=0;n--)if(i=Dn(e,n),t.call(r,i,n,this))return i})),C(Wn.prototype,"findLastIndex",(function(t,r){var e,n,i;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=Dn(e,n),t.call(r,i,n,this))return n;return-1})),C(Wn.prototype,"forEach",(function(t,r){var e,n,i;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=0;n=this._length))return Dn(this._buffer,t)})),C(Wn.prototype,"includes",(function(t,r){var e,n,i,o,a;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!xn(t))throw new TypeError(S("invalid argument. First argument must be a complex number. Value: `%s`.",t));if(arguments.length>1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(i=Ln(t),o=Mn(t),e=this._buffer,a=r;a1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(i=Ln(t),o=Mn(t),e=this._buffer,a=r;a1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(i=Ln(t),o=Mn(t),e=this._buffer,a=r;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),at(Wn.prototype,"length",(function(){return this._length})),C(Wn.prototype,"map",(function(t,r){var e,n,i,o,a;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Dn(e,0),o=1}for(;o1){if(!Oe(e=arguments[1]))throw new TypeError(S("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(xn(t)){if(e>=this._length)throw new RangeError(S("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Ln(t),void(n[e+1]=Mn(t))}if(Pn(t)){if(e+(a=t._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(r=t._buffer,s=n.byteOffset+e*Cn,r.buffer===n.buffer&&r.byteOffsets){for(i=new We(r.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(r=t,s=n.byteOffset+e*Cn,r.buffer===n.buffer&&r.byteOffsets){for(i=new We(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(r=u)}}for(e=ti&&(r=i)}}return t>=i?(i=0,e=n.byteLength):t>=r?(i=0,e=n.byteOffset+t*Cn):(i=r-t,e=n.byteOffset+t*Cn),new this.constructor(n.buffer,e,i<0?0:i)})),C(Wn.prototype,"toReversed",(function(){var t,r,e,n,i,o;if(!Pn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=new this.constructor(e),n=this._buffer,t=r._buffer,i=0;i=i)throw new RangeError(S("invalid argument. Index argument is out-of-bounds. Value: `%s`.",t));if(!xn(r))throw new TypeError(S("invalid argument. Second argument must be a complex number. Value: `%s`.",r));return(e=(n=new this.constructor(this._buffer))._buffer)[2*t]=Ln(r),e[2*t+1]=Mn(r),n})),C(Gn,"BYTES_PER_ELEMENT",8),C(Gn.prototype,"BYTES_PER_ELEMENT",8),C(Gn.prototype,"byteLength",16),C(Gn.prototype,"toString",(function(){var t=""+this.re;return this.im<0?t+=" - "+-this.im:t+=" + "+this.im,t+="i"})),C(Gn.prototype,"toJSON",(function(){var t={type:"Complex128"};return t.re=this.re,t.im=this.im,t}));var Xn=2*or.BYTES_PER_ELEMENT,Zn=In();function Hn(t){return t instanceof Qn||"object"==typeof t&&null!==t&&("Complex64Array"===t.constructor.name||"Complex128Array"===t.constructor.name)&&"number"==typeof t._length&&"object"==typeof t._buffer}function qn(t){return t===Qn||"Complex64Array"===t.name}function Kn(t,r){return new Gn(t[r*=2],t[r+1])}function Qn(){var t,r,e,n;if(r=arguments.length,!(this instanceof Qn))return 0===r?new Qn:1===r?new Qn(arguments[0]):2===r?new Qn(arguments[0],arguments[1]):new Qn(arguments[0],arguments[1],arguments[2]);if(0===r)e=new or(0);else if(1===r)if(Oe(arguments[0]))e=new or(2*arguments[0]);else if(Kr(arguments[0]))if((n=(e=arguments[0]).length)&&jt(e)&&xn(e[0])){if(e=function(t,r){var e,n,i,o;for(e=r.length,o=0,i=0;ie.byteLength-t)throw new RangeError(S("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Xn));e=new or(e,t,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}C(Qn,"BYTES_PER_ELEMENT",Xn),C(Qn,"name","Complex128Array"),C(Qn,"from",(function(t){var r,e,n,i,o,a,u,f,s,l,h,c;if(!Lt(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!qn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!Lt(n=arguments[1]))throw new TypeError(S("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(r=arguments[2])}if(Hn(t)){if(f=t.length,n){for(o=(i=new this(f))._buffer,c=0,h=0;h=2))throw new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",l));o[c]=l[0],o[c+1]=l[1]}c+=2}return i}return new this(t)}if(Kr(t)){if(n){for(f=t.length,u=t.get&&t.set?Ue("default"):Be("default"),h=0;h=2))throw new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",l));o[c]=l[0],o[c+1]=l[1]}c+=2}return i}return new this(t)}if(vn(t)&&Zn&&Lt(t[Rn])){if(!Lt((o=t[Rn]()).next))throw new TypeError(S("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",t));if(a=n?function(t,r,e){var n,i,o,a;for(n=[],a=-1;!(i=t.next()).done;)if(a+=1,wn(o=r.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!xn(o))return new TypeError(S("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Jn(o),$n(o))}return n}(o,n,r):zn(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,h=0;h=this._length))return Kn(this._buffer,t)})),at(Qn.prototype,"buffer",(function(){return this._buffer.buffer})),at(Qn.prototype,"byteLength",(function(){return this._buffer.byteLength})),at(Qn.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(Qn.prototype,"BYTES_PER_ELEMENT",Qn.BYTES_PER_ELEMENT),C(Qn.prototype,"copyWithin",(function(t,r){if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*t,2*r):this._buffer.copyWithin(2*t,2*r,2*arguments[2]),this})),C(Qn.prototype,"entries",(function(){var t,r,e,n,i,o,a;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,t=this._buffer,n=this._length,o=-1,a=-2,C(e={},"next",(function(){var r;if(o+=1,i||o>=n)return{done:!0};return r=new Gn(t[a+=2],t[a+1]),{value:[o,r],done:!1}})),C(e,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),Rn&&C(e,Rn,(function(){return r.entries()})),e})),C(Qn.prototype,"every",(function(t,r){var e,n;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=0;n1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=i)<0&&(r=0),arguments.length>2){if(!Cr(e))throw new TypeError(S("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else r=0,e=i;for(a=Jn(t),u=$n(t),f=r;f=0;n--)if(i=Kn(e,n),t.call(r,i,n,this))return i})),C(Qn.prototype,"findLastIndex",(function(t,r){var e,n,i;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=Kn(e,n),t.call(r,i,n,this))return n;return-1})),C(Qn.prototype,"forEach",(function(t,r){var e,n,i;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(e=this._buffer,n=0;n=this._length))return Kn(this._buffer,t)})),at(Qn.prototype,"length",(function(){return this._length})),C(Qn.prototype,"includes",(function(t,r){var e,n,i,o,a;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!xn(t))throw new TypeError(S("invalid argument. First argument must be a complex number. Value: `%s`.",t));if(arguments.length>1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(i=Jn(t),o=$n(t),e=this._buffer,a=r;a1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(i=Jn(t),o=$n(t),e=this._buffer,a=r;a1){if(!Cr(r))throw new TypeError(S("invalid argument. Second argument must be an integer. Value: `%s`.",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(i=Jn(t),o=$n(t),e=this._buffer,a=r;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),C(Qn.prototype,"map",(function(t,r){var e,n,i,o,a;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Lt(t))throw new TypeError(S("invalid argument. First argument must be a function. Value: `%s`.",t));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Kn(e,0),o=1}for(;o1){if(!Oe(e=arguments[1]))throw new TypeError(S("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(xn(t)){if(e>=this._length)throw new RangeError(S("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Jn(t),void(n[e+1]=$n(t))}if(Hn(t)){if(e+(a=t._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(r=t._buffer,s=n.byteOffset+e*Xn,r.buffer===n.buffer&&r.byteOffsets){for(i=new or(r.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(r=t,s=n.byteOffset+e*Xn,r.buffer===n.buffer&&r.byteOffsets){for(i=new or(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(r=u)}}for(e=ti&&(r=i)}}return t>=i?(i=0,e=n.byteLength):t>=r?(i=0,e=n.byteOffset+t*Xn):(i=r-t,e=n.byteOffset+t*Xn),new this.constructor(n.buffer,e,i<0?0:i)})),C(Qn.prototype,"toReversed",(function(){var t,r,e,n,i,o;if(!Hn(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=new this.constructor(e),n=this._buffer,t=r._buffer,i=0;i=i)throw new RangeError(S("invalid argument. Index argument is out-of-bounds. Value: `%s`.",t));if(!xn(r))throw new TypeError(S("invalid argument. Second argument must be a complex number. Value: `%s`.",r));return(e=(n=new this.constructor(this._buffer))._buffer)[2*t]=Jn(r),e[2*t+1]=$n(r),n}));var ti=[or,We,Qe,Xe,on,Ht,mn,Gt,ln,Wn,Qn],ri=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128"],ei=ri.length;function ni(t){var r;if(jt(t))return"generic";if(It(t))return null;for(r=0;r0&&r.push("generic"),r)}function fi(){return{bool:0,int8:1,uint8:2,uint8c:3,int16:4,uint16:5,int32:6,uint32:7,int64:8,uint64:9,float32:10,float64:11,complex64:12,complex128:13,binary:14,generic:15,notype:17,userdefined_type:256}}C(ui,"enum",fi),function(t,r){var e,n,i;for(e=ae(r),i=0;i=0;i--)e[i]=n,n*=t[i];return e}(t)}function mi(t){var r,e,n,i,o,a;if("object"!=typeof t||null===t)throw new TypeError(S("invalid argument. Must provide an ndarray. Value: `%s`.",t));if(!Kr(i=t.strides)){if(!Kr(n=t.shape))throw new TypeError(S("invalid argument. Must provide an ndarray. Value: `%s`.",t));return 0===n.length?[0]:(pi(e=t.order)||(e="row-major"),yi(n,e))}for(r=[],a=0;a=0;n--)r[n]=e,e*=t[n];return r}(t,e)}));var gi="row-major",wi="column-major";function vi(t){var r;if("object"!=typeof t||null===t)throw new TypeError(S("invalid argument. Must provide an ndarray. Value: `%s`.",t));return pi(r=t.order)?r:1===(r=st(mi(t)))||3===r?gi:2===r?wi:0===function(t){var r,e;if("object"!=typeof t||null===t)throw new TypeError(S("invalid argument. Must provide an ndarray. Value: `%s`.",t));if(Oe(e=t.ndims))return e;if(!Kr(r=t.shape))throw new TypeError(S("invalid argument. Must provide an ndarray. Value: `%s`.",t));return r.length}(t)?gi:null}function di(t,r){var e,n,i,o,a,u,f,s,l;if(!je(t))throw new TypeError(S("invalid argument. First argument must be an ndarray. Value: `%s`.",t));if(!Kr(r))throw new TypeError(S("invalid argument. Second argument must be an array of nonnegative integers. Value: `%s`.",r));if((a=r.length)<(u=(i=li(t)).length))throw new Error("invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.");for(e=[],s=0;s=0;s--)if(!((l=u-a+s)<0)){if(f=i[l],!Oe(n=r[s]))throw new TypeError(S("invalid argument. Second argument must be an array of nonnegative integers. Value: `%s`.","["+r.join(",")+"]"));if(0!==n&&n