PageSourceSearch

https://miamifilmfestival.com/_build/assets/Gradient--MtYP5aQ.js

js miamifilmfestival.com collected 2026-09-24 18:44:04 UTC 62,237 bytes, 120 lines download raw bytes

1import{g as Nt,r as U,j as H,k as rt}from"./client-r8XyruuW.js";import{g as dt}from"./Themed-BPenE1Q1.js";import{u as qt}from"./useWindowSize-CKZ4r8rr.js";import{u as $t}from"./useRafLoop-M5aCasDG.js";function Q(e){let t=e[0],r=e[1],s=e[2];return Math.sqrt(t*t+r*r+s*s)}function lt(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function kt(e,t,r,s){return e[0]=t,e[1]=r,e[2]=s,e}function pt(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function xt(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Xt(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Vt(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function it(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Yt(e,t){let r=t[0]-e[0],s=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(r*r+s*s+n*n)}function Gt(e,t){let r=t[0]-e[0],s=t[1]-e[1],n=t[2]-e[2];return r*r+s*s+n*n}function mt(e){let t=e[0],r=e[1],s=e[2];return t*t+r*r+s*s}function Wt(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function jt(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function at(e,t){let r=t[0],s=t[1],n=t[2],h=r*r+s*s+n*n;return h>0&&(h=1/Math.sqrt(h)),e[0]=t[0]*h,e[1]=t[1]*h,e[2]=t[2]*h,e}function It(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function vt(e,t,r){let s=t[0],n=t[1],h=t[2],l=r[0],o=r[1],a=r[2];return e[0]=n*a-h*o,e[1]=h*l-s*a,e[2]=s*o-n*l,e}function Zt(e,t,r,s){let n=t[0],h=t[1],l=t[2];return e[0]=n+s*(r[0]-n),e[1]=h+s*(r[1]-h),e[2]=l+s*(r[2]-l),e}function Ht(e,t,r,s,n){const h=Math.exp(-s*n);let l=t[0],o=t[1],a=t[2];return e[0]=r[0]+(l-r[0])*h,e[1]=r[1]+(o-r[1])*h,e[2]=r[2]+(a-r[2])*h,e}function Qt(e,t,r){let s=t[0],n=t[1],h=t[2],l=r[3]*s+r[7]*n+r[11]*h+r[15];return l=l||1,e[0]=(r[0]*s+r[4]*n+r[8]*h+r[12])/l,e[1]=(r[1]*s+r[5]*n+r[9]*h+r[13])/l,e[2]=(r[2]*s+r[6]*n+r[10]*h+r[14])/l,e}function Kt(e,t,r){let s=t[0],n=t[1],h=t[2],l=r[3]*s+r[7]*n+r[11]*h+r[15];return l=l||1,e[0]=(r[0]*s+r[4]*n+r[8]*h)/l,e[1]=(r[1]*s+r[5]*n+r[9]*h)/l,e[2]=(r[2]*s+r[6]*n+r[10]*h)/l,e}function Jt(e,t,r){let s=t[0],n=t[1],h=t[2];return e[0]=s*r[0]+n*r[3]+h*r[6],e[1]=s*r[1]+n*r[4]+h*r[7],e[2]=s*r[2]+n*r[5]+h*r[8],e}function te(e,t,r){let s=t[0],n=t[1],h=t[2],l=r[0],o=r[1],a=r[2],f=r[3],g=o*h-a*n,m=a*s-l*h,x=l*n-o*s,u=o*x-a*m,c=a*g-l*x,d=l*m-o*g,p=f*2;return g*=p,m*=p,x*=p,u*=2,c*=2,d*=2,e[0]=s+g+u,e[1]=n+m+c,e[2]=h+x+d,e}const ee=(function(){const e=[0,0,0],t=[0,0,0];return function(r,s){lt(e,r),lt(t,s),at(e,e),at(t,t);let n=It(e,t);return n>1?0:n<-1?Math.PI:Math.acos(n)}})();function re(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}class $ extends Array{constructor(t=0,r=t,s=t){return super(t,r,s),this}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set(t,r=t,s=t){return t.length?this.copy(t):(kt(this,t,r,s),this)}copy(t){return lt(this,t),this}add(t,r){return r?pt(this,t,r):pt(this,this,t),this}sub(t,r){return r?xt(this,t,r):xt(this,this,t),this}multiply(t){return t.length?Xt(this,this,t):it(this,this,t),this}divide(t){return t.length?Vt(this,this,t):it(this,this,1/t),this}inverse(t=this){return jt(this,t),this}len(){return Q(this)}distance(t){return t?Yt(this,t):Q(this)}squaredLen(){return mt(this)}squaredDistance(t){return t?Gt(this,t):mt(this)}negate(t=this){return Wt(this,t),this}cross(t,r){return r?vt(this,t,r):vt(this,this,t),this}scale(t){return it(this,this,t),this}normalize(){return at(this,this),this}dot(t){return It(this,t)}equals(t){return re(this,t)}
1applyMatrix3(t){return Jt(this,this,t),this}applyMatrix4(t){return Qt(this,this,t),this}scaleRotateMatrix4(t){return Kt(this,this,t),this}applyQuaternion(t){return te(this,this,t),this}angle(t){return ee(this,t)}lerp(t,r){return Zt(this,this,t,r),this}smoothLerp(t,r,s){return Ht(this,this,t,r,s),this}clone(){return new $(this[0],this[1],this[2])}fromArray(t,r=0){return this[0]=t[r],this[1]=t[r+1],this[2]=t[r+2],this}toArray(t=[],r=0){return t[r]=this[0],t[r+1]=this[1],t[r+2]=this[2],t}transformDirection(t){const r=this[0],s=this[1],n=this[2];return this[0]=t[0]*r+t[4]*s+t[8]*n,this[1]=t[1]*r+t[5]*s+t[9]*n,this[2]=t[2]*r+t[6]*s+t[10]*n,this.normalize()}}const yt=new $;let ie=1,se=1,bt=!1;class ne{constructor(t,r={}){t.canvas||console.error("gl not passed as first argument to Geometry"),this.gl=t,this.attributes=r,this.id=ie++,this.VAOs={},this.drawRange={start:0,count:0},this.instancedCount=0,this.gl.renderer.bindVertexArray(null),this.gl.renderer.currentGeometry=null,this.glState=this.gl.renderer.state;for(let s in r)this.addAttribute(s,r[s])}addAttribute(t,r){if(this.attributes[t]=r,r.id=se++,r.size=r.size||1,r.type=r.type||(r.data.constructor===Float32Array?this.gl.FLOAT:r.data.constructor===Uint16Array?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT),r.target=t==="index"?this.gl.ELEMENT_ARRAY_BUFFER:this.gl.ARRAY_BUFFER,r.normalized=r.normalized||!1,r.stride=r.stride||0,r.offset=r.offset||0,r.count=r.count||(r.stride?r.data.byteLength/r.stride:r.data.length/r.size),r.divisor=r.instanced||0,r.needsUpdate=!1,r.usage=r.usage||this.gl.STATIC_DRAW,r.buffer||this.updateAttribute(r),r.divisor){if(this.isInstanced=!0,this.instancedCount&&this.instancedCount!==r.count*r.divisor)return console.warn("geometry has multiple instanced buffers of different length"),this.instancedCount=Math.min(this.instancedCount,r.count*r.divisor);this.instancedCount=r.count*r.divisor}else t==="index"?this.drawRange.count=r.count:this.attributes.index||(this.drawRange.count=Math.max(this.drawRange.count,r.count))}updateAttribute(t){const r=!t.buffer;r&&(t.buffer=this.gl.createBuffer()),this.glState.boundBuffer!==t.buffer&&(this.gl.bindBuffer(t.target,t.buffer),this.glState.boundBuffer=t.buffer),r?this.gl.bufferData(t.target,t.data,t.usage):this.gl.bufferSubData(t.target,0,t.data),t.needsUpdate=!1}setIndex(t){this.addAttribute("index",t)}setDrawRange(t,r){this.drawRange.start=t,this.drawRange.count=r}setInstancedCount(t){this.instancedCount=t}createVAO(t){this.VAOs[t.attributeOrder]=this.gl.renderer.createVertexArray(),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.bindAttributes(t)}bindAttributes(t){t.attributeLocations.forEach((r,{name:s,type:n})=>{if(!this.attributes[s]){console.warn(`active attribute ${s} not being supplied`);return}const h=this.attributes[s];this.gl.bindBuffer(h.target,h.buffer),this.glState.boundBuffer=h.buffer;let l=1;n===35674&&(l=2),n===35675&&(l=3),n===35676&&(l=4);const o=h.size/l,a=l===1?0:l*l*4,f=l===1?0:l*4;for(let g=0;g<l;g++)this.gl.vertexAttribPointer(r+g,o,h.type,h.normalized,h.stride+a,h.offset+g*f),this.gl.enableVertexAttribArray(r+g),this.gl.renderer.vertexAttribDivisor(r+g,h.divisor)}),this.attributes.index&&this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.attributes.index.buffer)}draw({program:t,mode:r=this.gl.TRIANGLES}){this.gl.renderer.currentGeometry!==`${this.id}_${t.attributeOrder}`&&(this.VAOs[t.attributeOrder]||this.createVAO(t),this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]),this.gl.renderer.currentGeometry=`${this.id}_${t.attributeOrder}`),t.attributeLocations.forEach((n,{name:h})=>{const l=this.attributes[h];l.needsUpdate&&this.updateAttribute(l)});let s=2;this.attributes.index?.type===this.gl.UNSIGNED_INT&&(s=4),this.isInstanced?this.attributes.index?this.gl.renderer.drawElementsInstanced(r,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*s,this.instancedCount):this.gl.renderer.drawArraysInstanced(r,this.drawRange.start,this.drawRange.count,this.instancedCount):this.attributes.index?this.gl.drawElements(r,this.drawRange.count,this.attributes.index.type,this.attributes.index.offset+this.drawRange.start*s):this.gl.drawArrays(r,this.drawRange.start,this.drawRange.count)}getPosition(){const t=this.attributes.position;if(t.data)return t;if(!bt)return console.warn("No position buffer data found to compute bounds"),bt=!0}computeBoundingBox(t){t||(t=this.getPosition());const r=t.data,s=t.size;this.bounds||(this.bounds={min:new $,max:new $,center:new $,scale:new $,radiu
1s:1/0});const n=this.bounds.min,h=this.bounds.max,l=this.bounds.center,o=this.bounds.scale;n.set(1/0),h.set(-1/0);for(let a=0,f=r.length;a<f;a+=s){const g=r[a],m=r[a+1],x=r[a+2];n.x=Math.min(g,n.x),n.y=Math.min(m,n.y),n.z=Math.min(x,n.z),h.x=Math.max(g,h.x),h.y=Math.max(m,h.y),h.z=Math.max(x,h.z)}o.sub(h,n),l.add(n,h).divide(2)}computeBoundingSphere(t){t||(t=this.getPosition());const r=t.data,s=t.size;this.bounds||this.computeBoundingBox(t);let n=0;for(let h=0,l=r.length;h<l;h+=s)yt.fromArray(r,h),n=Math.max(n,this.bounds.center.squaredDistance(yt));this.bounds.radius=Math.sqrt(n)}remove(){for(let t in this.VAOs)this.gl.renderer.deleteVertexArray(this.VAOs[t]),delete this.VAOs[t];for(let t in this.attributes)this.gl.deleteBuffer(this.attributes[t].buffer),delete this.attributes[t]}}let he=1;const wt={};class le{constructor(t,{vertex:r,fragment:s,uniforms:n={},transparent:h=!1,cullFace:l=t.BACK,frontFace:o=t.CCW,depthTest:a=!0,depthWrite:f=!0,depthFunc:g=t.LEQUAL}={}){t.canvas||console.error("gl not passed as first argument to Program"),this.gl=t,this.uniforms=n,this.id=he++,r||console.warn("vertex shader not supplied"),s||console.warn("fragment shader not supplied"),this.transparent=h,this.cullFace=l,this.frontFace=o,this.depthTest=a,this.depthWrite=f,this.depthFunc=g,this.blendFunc={},this.blendEquation={},this.stencilFunc={},this.stencilOp={},this.transparent&&!this.blendFunc.src&&(this.gl.renderer.premultipliedAlpha?this.setBlendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA):this.setBlendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA)),this.vertexShader=t.createShader(t.VERTEX_SHADER),this.fragmentShader=t.createShader(t.FRAGMENT_SHADER),this.program=t.createProgram(),t.attachShader(this.program,this.vertexShader),t.attachShader(this.program,this.fragmentShader),this.setShaders({vertex:r,fragment:s})}setShaders({vertex:t,fragment:r}){if(t&&(this.gl.shaderSource(this.vertexShader,t),this.gl.compileShader(this.vertexShader),this.gl.getShaderInfoLog(this.vertexShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.vertexShader)}
2Vertex Shader
3${Mt(t)}`)),r&&(this.gl.shaderSource(this.fragmentShader,r),this.gl.compileShader(this.fragmentShader),this.gl.getShaderInfoLog(this.fragmentShader)!==""&&console.warn(`${this.gl.getShaderInfoLog(this.fragmentShader)}
4Fragment Shader
5${Mt(r)}`)),this.gl.linkProgram(this.program),!this.gl.getProgramParameter(this.program,this.gl.LINK_STATUS))return console.warn(this.gl.getProgramInfoLog(this.program));this.uniformLocations=new Map;let s=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_UNIFORMS);for(let l=0;l<s;l++){let o=this.gl.getActiveUniform(this.program,l);this.uniformLocations.set(o,this.gl.getUniformLocation(this.program,o.name));const a=o.name.match(/(\w+)/g);o.uniformName=a[0],o.nameComponents=a.slice(1)}this.attributeLocations=new Map;const n=[],h=this.gl.getProgramParameter(this.program,this.gl.ACTIVE_ATTRIBUTES);for(let l=0;l<h;l++){const o=this.gl.getActiveAttrib(this.program,l),a=this.gl.getAttribLocation(this.program,o.name);a!==-1&&(n[a]=o.name,this.attributeLocations.set(o,a))}this.attributeOrder=n.join("")}setBlendFunc(t,r,s,n){this.blendFunc.src=t,this.blendFunc.dst=r,this.blendFunc.srcAlpha=s,this.blendFunc.dstAlpha=n,t&&(this.transparent=!0)}setBlendEquation(t,r){this.blendEquation.modeRGB=t,this.blendEquation.modeAlpha=r}setStencilFunc(t,r,s){this.stencilRef=r,this.stencilFunc.func=t,this.stencilFunc.ref=r,this.stencilFunc.mask=s}setStencilOp(t,r,s){this.stencilOp.stencilFail=t,this.stencilOp.depthFail=r,this.stencilOp.depthPass=s}applyState(){this.depthTest?this.gl.renderer.enable(this.gl.DEPTH_TEST):this.gl.renderer.disable(this.gl.DEPTH_TEST),this.cullFace?this.gl.renderer.enable(this.gl.CULL_FACE):this.gl.renderer.disable(this.gl.CULL_FACE),this.blendFunc.src?this.gl.renderer.enable(this.gl.BLEND):this.gl.renderer.disable(this.gl.BLEND),this.cullFace&&this.gl.renderer.setCullFace(this.cullFace),this.gl.renderer.setFrontFace(this.frontFace),this.gl.renderer.setDepthMask(this.depthWrite),this.gl.renderer.setDepthFunc(this.depthFunc),this.blendFunc.src&&this.gl.renderer.setBlendFunc(this.blendFunc.src,this.blendFunc.dst,this.blendFunc.srcAlpha,this.blendFunc.dstAlpha),this.gl.renderer.setBlendEquation(this.blendEquation.modeRGB,this.blendEquation.modeAlpha),this.stencilFunc.func||this.stencilOp.stencilFail?this.gl.renderer.enable(this.gl.STENCIL_TEST):this.gl.renderer.disable(this.gl.STENCIL_TEST),this.gl.renderer.setStencilFunc(this.stencilFunc.func,this.stencilFunc.ref,this.stencilFunc.mask),this.gl.renderer.setStencilOp(this.stencilOp.stencilFail,this.stencilOp.depthFail,this.stencilOp.depthPass)}use({flipFaces:t=!1}={}){let r=-1;this.gl.renderer.state.currentProgram===this.id||(this.gl.useProgram(this.program),this.gl.renderer.state.currentProgram=this.id
5),this.uniformLocations.forEach((n,h)=>{let l=this.uniforms[h.uniformName];for(const o of h.nameComponents){if(!l)break;if(o in l)l=l[o];else{if(Array.isArray(l.value))break;l=void 0;break}}if(!l)return _t(`Active uniform ${h.name} has not been supplied`);if(l&&l.value===void 0)return _t(`${h.name} uniform is missing a value parameter`);if(l.value.texture)return r=r+1,l.value.update(r),st(this.gl,h.type,n,r);if(l.value.length&&l.value[0].texture){const o=[];return l.value.forEach(a=>{r=r+1,a.update(r),o.push(r)}),st(this.gl,h.type,n,o)}st(this.gl,h.type,n,l.value)}),this.applyState(),t&&this.gl.renderer.setFrontFace(this.frontFace===this.gl.CCW?this.gl.CW:this.gl.CCW)}remove(){this.gl.deleteProgram(this.program)}}function st(e,t,r,s){s=s.length?ae(s):s;const n=e.renderer.state.uniformLocations.get(r);if(s.length)if(n===void 0||n.length!==s.length)e.renderer.state.uniformLocations.set(r,s.slice(0));else{if(ce(n,s))return;n.set?n.set(s):oe(n,s),e.renderer.state.uniformLocations.set(r,n)}else{if(n===s)return;e.renderer.state.uniformLocations.set(r,s)}switch(t){case 5126:return s.length?e.uniform1fv(r,s):e.uniform1f(r,s);case 35664:return e.uniform2fv(r,s);case 35665:return e.uniform3fv(r,s);case 35666:return e.uniform4fv(r,s);case 35670:case 5124:case 35678:case 36306:case 35680:case 36289:return s.length?e.uniform1iv(r,s):e.uniform1i(r,s);case 35671:case 35667:return e.uniform2iv(r,s);case 35672:case 35668:return e.uniform3iv(r,s);case 35673:case 35669:return e.uniform4iv(r,s);case 35674:return e.uniformMatrix2fv(r,!1,s);case 35675:return e.uniformMatrix3fv(r,!1,s);case 35676:return e.uniformMatrix4fv(r,!1,s)}}function Mt(e){let t=e.split(`
6`);for(let r=0;r<t.length;r++)t[r]=r+1+": "+t[r];return t.join(`
7`)}function ae(e){const t=e.length,r=e[0].length;if(r===void 0)return e;const s=t*r;let n=wt[s];n||(wt[s]=n=new Float32Array(s));for(let h=0;h<t;h++)n.set(e[h],h*r);return n}function ce(e,t){if(e.length!==t.length)return!1;for(let r=0,s=e.length;r<s;r++)if(e[r]!==t[r])return!1;return!0}function oe(e,t){for(let r=0,s=e.length;r<s;r++)e[r]=t[r]}let nt=0;function _t(e){nt>100||(console.warn(e),nt++,nt>100&&console.warn("More than 100 program warnings - stopping logs."))}const ht=new $;let ue=1;class fe{constructor({canvas:t=document.createElement("canvas"),width:r=300,height:s=150,dpr:n=1,alpha:h=!1,depth:l=!0,stencil:o=!1,antialias:a=!1,premultipliedAlpha:f=!1,preserveDrawingBuffer:g=!1,powerPreference:m="default",autoClear:x=!0,webgl:u=2}={}){const c={alpha:h,depth:l,stencil:o,antialias:a,premultipliedAlpha:f,preserveDrawingBuffer:g,powerPreference:m};this.dpr=n,this.alpha=h,this.color=!0,this.depth=l,this.stencil=o,this.premultipliedAlpha=f,this.autoClear=x,this.id=ue++,u===2&&(this.gl=t.getContext("webgl2",c)),this.isWebgl2=!!this.gl,this.gl||(this.gl=t.getContext("webgl",c)),this.gl||console.error("unable to create webgl context"),this.gl.renderer=this,this.setSize(r,s),this.state={},this.state.blendFunc={src:this.gl.ONE,dst:this.gl.ZERO},this.state.blendEquation={modeRGB:this.gl.FUNC_ADD},this.state.cullFace=!1,this.state.frontFace=this.gl.CCW,this.state.depthMask=!0,this.state.depthFunc=this.gl.LEQUAL,this.state.premultiplyAlpha=!1,this.state.flipY=!1,this.state.unpackAlignment=4,this.state.framebuffer=null,this.state.viewport={x:0,y:0,width:null,height:null},this.state.textureUnits=[],this.state.activeTextureUnit=0,this.state.boundBuffer=null,this.state.uniformLocations=new Map,this.state.currentProgram=null,this.extensions={},this.isWebgl2?(this.getExtension("EXT_color_buffer_float"),this.getExtension("OES_texture_float_linear")):(this.getExtension("OES_texture_float"),this.getExtension("OES_texture_float_linear"),this.getExtension("OES_texture_half_float"),this.getExtension("OES_texture_half_float_linear"),this.getExtension("OES_element_index_uint"),this.getExtension("OES_standard_derivatives"),this.getExtension("EXT_sRGB"),this.getExtension("WEBGL_depth_texture"),this.getExtension("WEBGL_draw_buffers")),this.getExtension("WEBGL_compressed_texture_astc"),this.getExtension("EXT_texture_compression_bptc"),this.getExtension("WEBGL_compressed_texture_s3tc"),this.getExtension("WEBGL_compressed_texture_etc1"),this.getExtension("WEBGL_compressed_texture_pvrtc"),this.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this.vertexAttribDivisor=this.getExtension("ANGLE_instanced_arrays","vertexAttribDivisor","vertexAttribDivisorANGLE"),this.drawArraysInstanced=this.getExtension("ANGLE_instanced_arrays","drawArraysInstanced","drawArraysInstancedANGLE"),this.drawElementsInstanced=this.getExtension("ANGLE_instanced_arrays","drawElementsInstanced","drawElementsInstancedANGLE"),this.createVertexArray=this.getExtension("OES_vertex_array_object","createVertexArray","createVertexArrayOES"),this.bindVertexArray=this.getExtension("OES_vertex_array_object","bindVertexArray","bindVertexArrayOES"),this.deleteVertexArray=this.getExtension("OES_vertex_array_object","deleteVertexArray","deleteVertexArrayOES"),this.drawBuffers=this.getExtension("WEBGL_draw_buffers","drawBuffers","drawBuffersWEBGL"),this.parameters={},this.parameters.maxTextureUnits=this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this.parameters.maxAnisotropy=this.getExtension("EXT_texture_filter_anisotropic")?this.gl.getParameter(this.getExtension("EXT_texture_filter_anisotropic").MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}setSize(t,r){this.width=t,this.height=r,this.gl.canvas.width=t*this.dpr,this.gl.canvas.height=r*this.dpr,this.gl.canvas.style&&Object.assign(this.gl.canvas.style,{width:t+"px",height:r+"px"})}setViewport(t,r,s=0,n=0){this.state.viewport.width===t&&this.state.viewport.height===r||(this.state.viewport.width=t,this.state.viewport.height=r,this.state.viewport.x=s,this.state.viewport.y=n,this.gl.viewport(s,n,t,r))}setScissor(t,r,s=0,n=0){this.gl.scissor(s,n,t,r)}enable(t){this.state[t]!==!0&&(this.gl.enable(t),this.state[t]=!0)}disable(t){this.state[t]!==!1&&(this.gl.disable(t),this.state[t]=!1)}setBlendFunc(t,r,s,n){this.state.blendFunc.src===t&&this.state.blendFunc.dst===r&&this.state.blendFunc.srcAlpha===s&&this.state.blendFunc.dstAlpha===n||(this.state.blendFunc.src=t,this.state.blendFunc.dst=r,this.state.blendFunc.srcAlpha=s,this.state.blendFunc.dstAlpha=n,s!==void 0?this.gl.blendFuncSeparate(t,r,s,n):this.gl.blendFunc(t,r))}setBlendEquation(t,r){t=t||this.gl.FUNC_ADD,!(this.state.blendEquation.modeRGB===t&&this.state.blendEquation.modeAlpha===r)&&(this.state.blendEquation.modeRGB=t,this.state.blendEquation.modeAlpha=r,r!==void 0?this.gl.blendEquationSeparate(t,r):this.gl.blendEquation(t))}setCullFace(t){this.state.cullFace!==t&&(this.state.cullFace=t,this.gl.cullFace(t))}setFrontFace(t){this.state.frontFace!==t&&(this.state.frontFace=t,this.gl.frontFace(t))}setDepthMask(t){this.state.depthMask!==t&&(this.state.depthMask=t,this.gl.depthMask(t))}setDepthFunc(t){this.state.depthFunc!==t&&(this.state.depthFunc=t,this.gl.depthFunc(t))}setStencilMask(t){this.state.stencilMask!==t&&(this.state.stencilMask=t,this.gl.stencilMask(t))}setStencilFunc(t,r,s){this.state.stencilFunc===t&&this.state.stencilRef===r&&this.state.stencilFuncMask===s||(this.state.stencilFunc=t||this.gl.ALWAYS,this.state.stencilRef=r||0,this.state.stencilFuncMask=s||0,this.gl.stencilFunc(t||this.gl.ALWAYS,r||0,s||0))}setStencilOp(t,r,s){this.state.stencilFail===t&&this.state.stencilDepthFail===r&&this.state.stencilDepthPass===s||(this.state.stencilFail=t,this.state.stencilDepthFail=r,this.state.stencilDepthPass=s,this.gl.stencilOp(t,r,s))}activeTexture(t){this.state.activeTextureUnit!==t&&(this.state.activeTextureUnit=t,this.gl.activeTexture(this.gl.TEXTURE0+t))}bindFramebuffer({target:t=this.gl.FRAMEBUFFER,buffer:r=null}={}){this.state.framebuffer!==r&&(this.state.framebuffer=r,this.gl.bindFramebuffer(t,r))}getExtension(t,r,s){return r&&this.gl[r]?this.gl[r].bind(this.gl):(this.extensions[t]||(this.extensions[t]=this.gl.getExtension(t)),r?this.extensions[t]?this.extensions[t][s].bind(this.extensions[t]):null:this.extensions[t])}sortOpaque(t,r){return t.renderOrder!==r.renderOrder?t.renderOrder-r.renderOrder:t.program.id!==r.program.id?t.program.id-r.program.id:t.zDepth!==r.zDepth?t.zDepth-r.zDepth:r.id-t.id}
7sortTransparent(t,r){return t.renderOrder!==r.renderOrder?t.renderOrder-r.renderOrder:t.zDepth!==r.zDepth?r.zDepth-t.zDepth:r.id-t.id}sortUI(t,r){return t.renderOrder!==r.renderOrder?t.renderOrder-r.renderOrder:t.program.id!==r.program.id?t.program.id-r.program.id:r.id-t.id}getRenderList({scene:t,camera:r,frustumCull:s,sort:n}){let h=[];if(r&&s&&r.updateFrustum(),t.traverse(l=>{if(!l.visible)return!0;l.draw&&(s&&l.frustumCulled&&r&&!r.frustumIntersectsMesh(l)||h.push(l))}),n){const l=[],o=[],a=[];h.forEach(f=>{f.program.transparent?f.program.depthTest?o.push(f):a.push(f):l.push(f),f.zDepth=0,!(f.renderOrder!==0||!f.program.depthTest||!r)&&(f.worldMatrix.getTranslation(ht),ht.applyMatrix4(r.projectionViewMatrix),f.zDepth=ht.z)}),l.sort(this.sortOpaque),o.sort(this.sortTransparent),a.sort(this.sortUI),h=l.concat(o,a)}return h}render({scene:t,camera:r,target:s=null,update:n=!0,sort:h=!0,frustumCull:l=!0,clear:o}){s===null?(this.bindFramebuffer(),this.setViewport(this.width*this.dpr,this.height*this.dpr)):(this.bindFramebuffer(s),this.setViewport(s.width,s.height)),(o||this.autoClear&&o!==!1)&&(this.depth&&(!s||s.depth)&&(this.enable(this.gl.DEPTH_TEST),this.setDepthMask(!0)),(this.stencil||!s||s.stencil)&&(this.enable(this.gl.STENCIL_TEST),this.setStencilMask(255)),this.gl.clear((this.color?this.gl.COLOR_BUFFER_BIT:0)|(this.depth?this.gl.DEPTH_BUFFER_BIT:0)|(this.stencil?this.gl.STENCIL_BUFFER_BIT:0))),n&&t.updateMatrixWorld(),r&&r.updateMatrixWorld(),this.getRenderList({scene:t,camera:r,frustumCull:l,sort:h}).forEach(f=>{f.draw({camera:r})})}}function ge(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function de(e,t,r,s,n){return e[0]=t,e[1]=r,e[2]=s,e[3]=n,e}function pe(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=r*r+s*s+n*n+h*h;return l>0&&(l=1/Math.sqrt(l)),e[0]=r*l,e[1]=s*l,e[2]=n*l,e[3]=h*l,e}function xe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function me(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ve(e,t,r){r=r*.5;let s=Math.sin(r);return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=Math.cos(r),e}function Et(e,t,r){let s=t[0],n=t[1],h=t[2],l=t[3],o=r[0],a=r[1],f=r[2],g=r[3];
7return e[0]=s*g+l*o+n*f-h*a,e[1]=n*g+l*a+h*o-s*f,e[2]=h*g+l*f+s*a-n*o,e[3]=l*g-s*o-n*a-h*f,e}function ye(e,t,r){r*=.5;let s=t[0],n=t[1],h=t[2],l=t[3],o=Math.sin(r),a=Math.cos(r);return e[0]=s*a+l*o,e[1]=n*a+h*o,e[2]=h*a-n*o,e[3]=l*a-s*o,e}function be(e,t,r){r*=.5;let s=t[0],n=t[1],h=t[2],l=t[3],o=Math.sin(r),a=Math.cos(r);return e[0]=s*a-h*o,e[1]=n*a+l*o,e[2]=h*a+s*o,e[3]=l*a-n*o,e}function we(e,t,r){r*=.5;let s=t[0],n=t[1],h=t[2],l=t[3],o=Math.sin(r),a=Math.cos(r);return e[0]=s*a+n*o,e[1]=n*a-s*o,e[2]=h*a+l*o,e[3]=l*a-h*o,e}function Me(e,t,r,s){let n=t[0],h=t[1],l=t[2],o=t[3],a=r[0],f=r[1],g=r[2],m=r[3],x,u,c,d,p;return u=n*a+h*f+l*g+o*m,u<0&&(u=-u,a=-a,f=-f,g=-g,m=-m),1-u>1e-6?(x=Math.acos(u),c=Math.sin(x),d=Math.sin((1-s)*x)/c,p=Math.sin(s*x)/c):(d=1-s,p=s),e[0]=d*n+p*a,e[1]=d*h+p*f,e[2]=d*l+p*g,e[3]=d*o+p*m,e}function _e(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=r*r+s*s+n*n+h*h,o=l?1/l:0;return e[0]=-r*o,e[1]=-s*o,e[2]=-n*o,e[3]=h*o,e}function Ee(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Re(e,t){let r=t[0]+t[4]+t[8],s;if(r>0)s=Math.sqrt(r+1),e[3]=.5*s,s=.5/s,e[0]=(t[5]-t[7])*s,e[1]=(t[6]-t[2])*s,e[2]=(t[1]-t[3])*s;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[n*3+n]&&(n=2);let h=(n+1)%3,l=(n+2)%3;s=Math.sqrt(t[n*3+n]-t[h*3+h]-t[l*3+l]+1),e[n]=.5*s,s=.5/s,e[3]=(t[h*3+l]-t[l*3+h])*s,e[h]=(t[h*3+n]+t[n*3+h])*s,e[l]=(t[l*3+n]+t[n*3+l])*s}return e}function Se(e,t,r="YXZ"){let s=Math.sin(t[0]*.5),n=Math.cos(t[0]*.5),h=Math.sin(t[1]*.5),l=Math.cos(t[1]*.5),o=Math.sin(t[2]*.5),a=Math.cos(t[2]*.5);return r==="XYZ"?(e[0]=s*l*a+n*h*o,e[1]=n*h*a-s*l*o,e[2]=n*l*o+s*h*a,e[3]=n*l*a-s*h*o):r==="YXZ"?(e[0]=s*l*a+n*h*o,e[1]=n*h*a-s*l*o,e[2]=n*l*o-s*h*a,e[3]=n*l*a+s*h*o):r==="ZXY"?(e[0]=s*l*a-n*h*o,e[1]=n*h*a+s*l*o,e[2]=n*l*o+s*h*a,e[3]=n*l*a-s*h*o):r==="ZYX"?(e[0]=s*l*a-n*h*o,e[1]=n*h*a+s*l*o,e[2]=n*l*o-s*h*a,e[3]=n*l*a+s*h*o):r==="YZX"?(e[0]=s*l*a+n*h*o,e[1]=n*h*a+s*l*o,e[2]=n*l*o-s*h*a,e[3]=n*l*a-s*h*o):r==="XZY"&&(e[0]=s*l*a-n*h*o,e[1]=n*h*a-s*l*o,e[2]=n*l*o+s*h*a,e[3]=n*l*a+s*h*o),e}const Ae=ge,ze=de,Ce=xe,Fe=pe;class Ie extends Array{constructor(t=0,r=0,s=0,n=1){super(t,r,s,n),this.onChange=()=>{},this._target=this;const h=["0","1","2","3"];return new Proxy(this,{set(l,o){const a=Reflect.set(...arguments);return a&&h.includes(o)&&l.onChange(),a}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this._target[0]=t,this.onChange()}set y(t){this._target[1]=t,this.onChange()}set z(t){this._target[2]=t,this.onChange()}set w(t){this._target[3]=t,this.onChange()}identity(){return me(this._target),this.onChange(),this}set(t,r,s,n){return t.length?this.copy(t):(ze(this._target,t,r,s,n),this.onChange(),this)}rotateX(t){return ye(this._target,this._target,t),this.onChange(),this}rotateY(t){return be(this._target,this._target,t),this.onChange(),this}rotateZ(t){return we(this._target,this._target,t),this.onChange(),this}inverse(t=this._target){return _e(this._target,t),this.onChange(),this}conjugate(t=this._target){return Ee(this._target,t),this.onChange(),this}copy(t){return Ae(this._target,t),this.onChange(),this}normalize(t=this._target){return Fe(this._target,t),this.onChange(),this}multiply(t,r){return r?Et(this._target,t,r):Et(this._target,this._target,t),this.onChange(),this}dot(t){return Ce(this._target,t)}fromMatrix3(t){return Re(this._target,t),this.onChange(),this}fromEuler(t,r){return Se(this._target,t,t.order),r||this.onChange(),this}fromAxisAngle(t,r){return ve(this._target,t,r),this.onChange(),this}slerp(t,r){return Me(this._target,this._target,t,r),this.onChange(),this}fromArray(t,r=0){return this._target[0]=t[r],this._target[1]=t[r+1],this._target[2]=t[r+2],this._target[3]=t[r+3],this.onChange(),this}toArray(t=[],r=0){return t[r]=this[0],t[r+1]=this[1],t[r+2]=this[2],t[r+3]=this[3],t}}const Te=1e-6;function Oe(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Le(e,t,r,s,n,h,l,o,a,f,g,m,x,u,c,d,p){return e[0]=t,e[1]=r,e[2]=s,e[3]=n,e[4]=h,e[5]=l,e[6]=o,e[7]=a,e[8]=f,e[9]=g,e[10]=m,e[11]=x,e[12]=u,e[13]=c,e[14]=d,e[15]=p,e}function De(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10
7]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Pe(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=t[4],o=t[5],a=t[6],f=t[7],g=t[8],m=t[9],x=t[10],u=t[11],c=t[12],d=t[13],p=t[14],v=t[15],y=r*o-s*l,w=r*a-n*l,b=r*f-h*l,_=s*a-n*o,E=s*f-h*o,S=n*f-h*a,I=g*d-m*c,F=g*p-x*c,A=g*v-u*c,C=m*p-x*d,R=m*v-u*d,z=x*v-u*p,M=y*z-w*R+b*C+_*A-E*F+S*I;return M?(M=1/M,e[0]=(o*z-a*R+f*C)*M,e[1]=(n*R-s*z-h*C)*M,e[2]=(d*S-p*E+v*_)*M,e[3]=(x*E-m*S-u*_)*M,e[4]=(a*A-l*z-f*F)*M,e[5]=(r*z-n*A+h*F)*M,e[6]=(p*b-c*S-v*w)*M,e[7]=(g*S-x*b+u*w)*M,e[8]=(l*R-o*A+f*I)*M,e[9]=(s*A-r*R-h*I)*M,e[10]=(c*E-d*b+v*y)*M,e[11]=(m*b-g*E-u*y)*M,e[12]=(o*F-l*C-a*I)*M,e[13]=(r*C-s*F+n*I)*M,e[14]=(d*w-c*_-p*y)*M,e[15]=(g*_-m*w+x*y)*M,e):null}function Tt(e){let t=e[0],r=e[1],s=e[2],n=e[3],h=e[4],l=e[5],o=e[6],a=e[7],f=e[8],g=e[9],m=e[10],x=e[11],u=e[12],c=e[13],d=e[14],p=e[15],v=t*l-r*h,y=t*o-s*h,w=t*a-n*h,b=r*o-s*l,_=r*a-n*l,E=s*a-n*o,S=f*c-g*u,I=f*d-m*u,F=f*p-x*u,A=g*d-m*c,C=g*p-x*c,R=m*p-x*d;return v*R-y*C+w*A+b*F-_*I+E*S}function Rt(e,t,r){let s=t[0],n=t[1],h=t[2],l=t[3],o=t[4],a=t[5],f=t[6],g=t[7],m=t[8],x=t[9],u=t[10],c=t[11],d=t[12],p=t[13],v=t[14],y=t[15],w=r[0],b=r[1],_=r[2],E=r[3];return e[0]=w*s+b*o+_*m+E*d,e[1]=w*n+b*a+_*x+E*p,e[2]=w*h+b*f+_*u+E*v,e[3]=w*l+b*g+_*c+E*y,w=r[4],b=r[5],_=r[6],E=r[7],e[4]=w*s+b*o+_*m+E*d,e[5]=w*n+b*a+_*x+E*p,e[6]=w*h+b*f+_*u+E*v,e[7]=w*l+b*g+_*c+E*y,w=r[8],b=r[9],_=r[10],E=r[11],e[8]=w*s+b*o+_*m+E*d,e[9]=w*n+b*a+_*x+E*p,e[10]=w*h+b*f+_*u+E*v,e[11]=w*l+b*g+_*c+E*y,w=r[12],b=r[13],_=r[14],E=r[15],e[12]=w*s+b*o+_*m+E*d,e[13]=w*n+b*a+_*x+E*p,e[14]=w*h+b*f+_*u+E*v,e[15]=w*l+b*g+_*c+E*y,e}function Be(e,t,r){let s=r[0],n=r[1],h=r[2],l,o,a,f,g,m,x,u,c,d,p,v;return t===e?(e[12]=t[0]*s+t[4]*n+t[8]*h+t[12],e[13]=t[1]*s+t[5]*n+t[9]*h+t[13],e[14]=t[2]*s+t[6]*n+t[10]*h+t[14],e[15]=t[3]*s+t[7]*n+t[11]*h+t[15]):(l=t[0],o=t[1],a=t[2],f=t[3],g=t[4],m=t[5],x=t[6],u=t[7],c=t[8],d=t[9],p=t[10],v=t[11],e[0]=l,e[1]=o,e[2]=a,e[3]=f,e[4]=g,e[5]=m,e[6]=x,e[7]=u,e[8]=c,e[9]=d,e[10]=p,e[11]=v,e[12]=l*s+g*n+c*h+t[12],e[13]=o*s+m*n+d*h+t[13],e[14]=a*s+x*n+p*h+t[14],e[15]=f*s+u*n+v*h+t[15]),e}function Ue(e,t,r){let s=r[0],n=r[1],h=r[2];return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*h,e[9]=t[9]*h,e[10]=t[10]*h,e[11]=t[11]*h,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ne(e,t,r,s){let n=s[0],h=s[1],l=s[2],o=Math.hypot(n,h,l),a,f,g,m,x,u,c,d,p,v,y,w,b,_,E,S,I,F,A,C,R,z,M,D;return Math.abs(o)<Te?null:(o=1/o,n*=o,h*=o,l*=o,a=Math.sin(r),f=Math.cos(r),g=1-f,m=t[0],x=t[1],u=t[2],c=t[3],d=t[4],p=t[5],v=t[6],y=t[7],w=t[8],b=t[9],_=t[10],E=t[11],S=n*n*g+f,I=h*n*g+l*a,F=l*n*g-h*a,A=n*h*g-l*a,C=h*h*g+f,R=l*h*g+n*a,z=n*l*g+h*a,M=h*l*g-n*a,D=l*l*g+f,e[0]=m*S+d*I+w*F,e[1]=x*S+p*I+b*F,e[2]=u*S+v*I+_*F,e[3]=c*S+y*I+E*F,e[4]=m*A+d*C+w*R,e[5]=x*A+p*C+b*R,e[6]=u*A+v*C+_*R,e[7]=c*A+y*C+E*R,e[8]=m*z+d*M+w*D,e[9]=x*z+p*M+b*D,e[10]=u*z+v*M+_*D,e[11]=c*z+y*M+E*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function qe(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Ot(e,t){let r=t[0],s=t[1],n=t[2],h=t[4],l=t[5],o=t[6],a=t[8],f=t[9],g=t[10];return e[0]=Math.hypot(r,s,n),e[1]=Math.hypot(h,l,o),e[2]=Math.hypot(a,f,g),e}function $e(e){let t=e[0],r=e[1],s=e[2],n=e[4],h=e[5],l=e[6],o=e[8],a=e[9],f=e[10];const g=t*t+r*r+s*s,m=n*n+h*h+l*l,x=o*o+a*a+f*f;return Math.sqrt(Math.max(g,m,x))}const Lt=(function(){const e=[1,1,1];return function(t,r){let s=e;Ot(s,r);let n=1/s[0],h=1/s[1],l=1/s[2],o=r[0]*n,a=r[1]*h,f=r[2]*l,g=r[4]*n,m=r[5]*h,x=r[6]*l,u=r[8]*n,c=r[9]*h,d=r[10]*l,p=o+m+d,v=0;return p>0?(v=Math.sqrt(p+1)*2,t[3]=.25*v,t[0]=(x-c)/v,t[1]=(u-f)/v,t[2]=(a-g)/v):o>m&&o>d?(v=Math.sqrt(1+o-m-d)*2,t[3]=(x-c)/v,t[0]=.25*v,t[1]=(a+g)/v,t[2]=(u+f)/v):m>d?(v=Math.sqrt(1+m-o-d)*2,t[3]=(u-f)/v,t[0]=(a+g)/v,t[1]=.25*v,t[2]=(x+c)/v):(v=Math.sqrt(1+d-o-m)*2,t[3]=(a-g)/v,t[0]=(u+f)/v,t[1]=(x+c)/v,t[2]=.25*v),t}})();function ke(e,t,r,s){let n=Q([e[0],e[1],e[2]]);const h=Q([e[4],e[5],e[6]]),l=Q([e[8],e[9],e[10]]);Tt(e)<0&&(n=-n),r[0]=e[12],r[1]=e[13],r[2]=e[14];const a=e.slice(),f=1/n,g=1/h,m=1/l;a[0]*=f,a[1]*=f,a[2]*=f,a[4]*=g,a[5]*=g,a[6]*=g,a[8]*=m,a[9]*=m,a[10]*=m,Lt(t,a),s[0]=n,s[1]=h,s[2]=l}function Xe(e,t,r,s){const n=e,h=t[0],l=t[1],o=t[2],a=t[3],f=h+h,g=l+l,m=o+o,x=h*f,u=h*g,c=h*m,d=l*g,p=l*m,v=o*m,y=a*f,w=a*g,b=a*m,_=s[0],E=s[1],S=s[2];return n[0]=(1-(d+v))*_,n[1]=(u+b)*_,n[2]=(c-w)*_,n[3]=0,n[4]=(u-b)*E,n[5]=(1-(x+v))*E,n[6]=(p+y)*E,n[7]=0,n[8]=(c+w)*S,n[9]=(p-y)*S,n[10]=(1-(x+d)
7)*S,n[11]=0,n[12]=r[0],n[13]=r[1],n[14]=r[2],n[15]=1,n}function Ve(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=r+r,o=s+s,a=n+n,f=r*l,g=s*l,m=s*o,x=n*l,u=n*o,c=n*a,d=h*l,p=h*o,v=h*a;return e[0]=1-m-c,e[1]=g+v,e[2]=x-p,e[3]=0,e[4]=g-v,e[5]=1-f-c,e[6]=u+d,e[7]=0,e[8]=x+p,e[9]=u-d,e[10]=1-f-m,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ye(e,t,r,s,n){let h=1/Math.tan(t/2),l=1/(s-n);return e[0]=h/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(n+s)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*n*s*l,e[15]=0,e}function Ge(e,t,r,s,n,h,l){let o=1/(t-r),a=1/(s-n),f=1/(h-l);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*f,e[11]=0,e[12]=(t+r)*o,e[13]=(n+s)*a,e[14]=(l+h)*f,e[15]=1,e}function We(e,t,r,s){let n=t[0],h=t[1],l=t[2],o=s[0],a=s[1],f=s[2],g=n-r[0],m=h-r[1],x=l-r[2],u=g*g+m*m+x*x;u===0?x=1:(u=1/Math.sqrt(u),g*=u,m*=u,x*=u);let c=a*x-f*m,d=f*g-o*x,p=o*m-a*g;return u=c*c+d*d+p*p,u===0&&(f?o+=1e-6:a?f+=1e-6:a+=1e-6,c=a*x-f*m,d=f*g-o*x,p=o*m-a*g,u=c*c+d*d+p*p),u=1/Math.sqrt(u),c*=u,d*=u,p*=u,e[0]=c,e[1]=d,e[2]=p,e[3]=0,e[4]=m*p-x*d,e[5]=x*c-g*p,e[6]=g*d-m*c,e[7]=0,e[8]=g,e[9]=m,e[10]=x,e[11]=0,e[12]=n,e[13]=h,e[14]=l,e[15]=1,e}function St(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function At(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function je(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}class J extends Array{constructor(t=1,r=0,s=0,n=0,h=0,l=1,o=0,a=0,f=0,g=0,m=1,x=0,u=0,c=0,d=0,p=1){return super(t,r,s,n,h,l,o,a,f,g,m,x,u,c,d,p),this}get x(){return this[12]}get y(){return this[13]}get z(){return this[14]}get w(){return this[15]}set x(t){this[12]=t}set y(t){this[13]=t}set z(t){this[14]=t}set w(t){this[15]=t}set(t,r,s,n,h,l,o,a,f,g,m,x,u,c,d,p){return t.length?this.copy(t):(Le(this,t,r,s,n,h,l,o,a,f,g,m,x,u,c,d,p),this)}translate(t,r=this){return Be(this,r,t),this}rotate(t,r,s=this){return Ne(this,s,t,r),this}scale(t,r=this){return Ue(this,r,typeof t=="number"?[t,t,t]:t),this}add(t,r){return r?St(this,t,r):St(this,this,t),this}sub(t,r){return r?At(this,t,r):At(this,this,t),this}multiply(t,r){return t.length?r?Rt(this,t,r):Rt(this,this,t):je(this,this,t),this}identity(){return De(this),this}copy(t){return Oe(this,t),this}fromPerspective({fov:t,aspect:r,near:s,far:n}={}){return Ye(this,t,r,s,n),this}fromOrthogonal({left:t,right:r,bottom:s,top:n,near:h,far:l}){return Ge(this,t,r,s,n,h,l),this}fromQuaternion(t){return Ve(this,t),this}setPosition(t){return this.x=t[0],this.y=t[1],this.z=t[2],this}inverse(t=this){return Pe(this,t),this}compose(t,r,s){return Xe(this,t,r,s),this}decompose(t,r,s){return ke(this,t,r,s),this}getRotation(t){return Lt(t,this),this}getTranslation(t){return qe(t,this),this}getScaling(t){return Ot(t,this),this}getMaxScaleOnAxis(){return $e(this)}lookAt(t,r,s){return We(this,t,r,s),this}determinant(){return Tt(this)}fromArray(t,r=0){return this[0]=t[r],this[1]=t[r+1],this[2]=t[r+2],this[3]=t[r+3],this[4]=t[r+4],this[5]=t[r+5],this[6]=t[r+6],this[7]=t[r+7],this[8]=t[r+8],this[9]=t[r+9],this[10]=t[r+10],this[11]=t[r+11],this[12]=t[r+12],this[13]=t[r+13],this[14]=t[r+14],this[15]=t[r+15],this}toArray(t=[],r=0){return t[r]=this[0],t[r+1]=this[1],t[r+2]=this[2],t[r+3]=this[3],t[r+4]=this[4],t[r+5]=this[5],t[r+6]=this[6],t[r+7]=this[7],t[r+8]=this[8],t[r+9]=this[9],t[r+10]=this[10],t[r+11]=this[11],t[r+12]=this[12],t[r+13]=this[13],t[r+14]=this[14],t[r+15]=this[15],t}}function Ze(e,t,r="YXZ"){return r==="XYZ"?(e[1]=Math.asin(Math.min(Math.max(t[8],-1),1)),Math.abs(t[8])<.99999?(e[0]=Math.atan2(-t[9],t[10]),e[2]=Math.atan2(-t[4],t[0])):(e[0]=Math.atan2(t[6],t[5]),e[2]=0)):r==="YXZ"?(e[0]=Math.asin(-Math.min(Math.max(t[9],-1),1)),Math.abs(t[9])<.99999?(e[1]=Math.atan2(t[8],t[10]),e[2]=Math.atan2(t[1],t[5])):(e[1]=Math.atan2(-t[2],t[0]),e[2]=0)):r==="ZXY"?(e[0]=Math.asin(Math.min(Math.max(t[6],-1),1)),Math.abs(t[6])<.99999?(e[1]=Math.atan2(-t[2],t[10]),e[2]=Math.atan2(-t[4],t[5])):(e[1]=0,e[2]=Math.atan2(t[1],t[0]))):r==="ZYX"?(e[1]=Math.asin(-Math.min(Math.max(t[2],-1),1)),Math.abs(t[2])<.99999?(e[0]=Math.atan2(t[6],t[10]),e[2]=Math.atan2(t[1],t[0])):(e[0]=0,e[2]=Math.atan2(-t[4],t[5]))):r==="YZX"?(e[2]=Math.asin(Math.min(Math.max(t[1],-1),1)),Math.abs(t[1])<.99999?(e[0]=Math.atan2(-t[9],t[5]),e[1]=Math.atan2(-t[2],t[0])):(e[0]=0,e[1]=Math.atan2(t[8],t[10]))):r==="XZY"&&(e[2]=Math.asin(-Math.min(Math.max(t[4],-1),1)),Math.abs(t[4])<.99999?(e[0]=Math.atan2(t[6],t[5]),e[1]=Math.atan2(t[8],t[0])):(e[0]=Math.atan2(-t[9],t[10]),e[1]=0)),e}const zt=new J;class He extends Array{constructor(t=0,r=t,s=t,n="YXZ"){super(t,r,s),this.order=n,this.onChange=()=>{},this._target=this;const h=["0","1","2"];return new Proxy(this,{set(l,o){const a=Reflect.set(...arguments);return a&&h.includes(o)&&l.onChange(),a}})}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this._target[0]=t,this.onChange()}set y(t){this._target[1]=t,this.onChange()}set z(t){this._target[2]=t,this.onChange()}set(t,r=t,s=t){return t.length?this.copy(t):(this._target[0]=t,this._target[1]=r,this._target[2]=s,this.onChange(),this)}copy(t){return this._target[0]=t[0],this._target[1]=t[1],this._target[2]=t[2],this.onChange(),this}reorder(t){return this._target.order=t,this.onChange(),this}fromRotationMatrix(t,r=this.order){return Ze(this._target,t,r),this.onChange(),this}fromQuaternion(t,r=this.order,s){return zt.fromQuaternion(t),this._target.fromRotationMatrix(zt,r),s||this.onChange(),this}fromArray(t,r=0){return this._target[0]=t[r],this._target[1]=t[r+1],this._target[2]=t[r+2],this}toArray(t=[],r=0){return t[r]=this[0],t[r+1]=this[1],t[r+2]=this[2],t}}class Qe{constructor(){this.parent=null,this.children=[],this.visible=!0,this.matrix=new J,this.worldMatrix=new J,this.matrixAutoUpdate=!0,this.worldMatrixNeedsUpdate=!1,this.position=new $,this.quaternion=new Ie,this.scale=new $(1),this.rotation=new He,this.up=new $(0,1,0),this.rotation._target.onChange=()=>this.quaternion.fromEuler(this.rotation,!0),this.quaternion._target.onChange=()=>this.rotation.fromQuaternion(this.quaternion,void 0,!0)}setParent(t,r=!0){this.parent&&t!==this.parent&&this.parent.removeChild(this,!1),this.parent=t,r&&t&&t.addChild(this,!1)}addChild(t,r=!0){~this.children.indexOf(t)||this.children.push(t),r&&t.setParent(this,!1)}removeChild(t,r=!0){~this.children.indexOf(t)&&this.children.splice(this.children.indexOf(t),1),r&&t.setParent(null,!1)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.worldMatrixNeedsUpdate||t)&&(this.parent===null?this.worldMatrix.copy(this.matrix
7):this.worldMatrix.multiply(this.parent.worldMatrix,this.matrix),this.worldMatrixNeedsUpdate=!1,t=!0);for(let r=0,s=this.children.length;r<s;r++)this.children[r].updateMatrixWorld(t)}updateMatrix(){this.matrix.compose(this.quaternion,this.position,this.scale),this.worldMatrixNeedsUpdate=!0}traverse(t){if(!t(this))for(let r=0,s=this.children.length;r<s;r++)this.children[r].traverse(t)}decompose(){this.matrix.decompose(this.quaternion._target,this.position,this.scale),this.rotation.fromQuaternion(this.quaternion)}lookAt(t,r=!1){r?this.matrix.lookAt(this.position,t,this.up):this.matrix.lookAt(t,this.position,this.up),this.matrix.getRotation(this.quaternion._target),this.rotation.fromQuaternion(this.quaternion)}}function Ke(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function Je(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=r+r,o=s+s,a=n+n,f=r*l,g=s*l,m=s*o,x=n*l,u=n*o,c=n*a,d=h*l,p=h*o,v=h*a;return e[0]=1-m-c,e[3]=g-v,e[6]=x+p,e[1]=g+v,e[4]=1-f-c,e[7]=u-d,e[2]=x-p,e[5]=u+d,e[8]=1-f-m,e}function tr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function er(e,t,r,s,n,h,l,o,a,f){return e[0]=t,e[1]=r,e[2]=s,e[3]=n,e[4]=h,e[5]=l,e[6]=o,e[7]=a,e[8]=f,e}function rr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function ir(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=t[4],o=t[5],a=t[6],f=t[7],g=t[8],m=g*l-o*f,x=-g*h+o*a,u=f*h-l*a,c=r*m+s*x+n*u;return c?(c=1/c,e[0]=m*c,e[1]=(-g*s+n*f)*c,e[2]=(o*s-n*l)*c,e[3]=x*c,e[4]=(g*r-n*a)*c,e[5]=(-o*r+n*h)*c,e[6]=u*c,e[7]=(-f*r+s*a)*c,e[8]=(l*r-s*h)*c,e):null}function Ct(e,t,r){let s=t[0],n=t[1],h=t[2],l=t[3],o=t[4],a=t[5],f=t[6],g=t[7],m=t[8],x=r[0],u=r[1],c=r[2],d=r[3],p=r[4],v=r[5],y=r[6],w=r[7],b=r[8];return e[0]=x*s+u*l+c*f,e[1]=x*n+u*o+c*g,e[2]=x*h+u*a+c*m,e[3]=d*s+p*l+v*f,e[4]=d*n+p*o+v*g,e[5]=d*h+p*a+v*m,e[6]=y*s+w*l+b*f,e[7]=y*n+w*o+b*g,e[8]=y*h+w*a+b*m,e}function sr(e,t,r){let s=t[0],n=t[1],h=t[2],l=t[3],o=t[4],a=t[5],f=t[6],g=t[7],m=t[8],x=r[0],u=r[1];return e[0]=s,e[1]=n,e[2]=h,e[3]=l,e[4]=o,e[5]=a,e[6]=x*s+u*l+f,e[7]=x*n+u*o+g,e[8]=x*h+u*a+m,e}function nr(e,t,r){let s=t[0],n=t[1],h=t[2],l=t[3],o=t[4],a=t[5],f=t[6],g=t[7],m=t[8],x=Math.sin(r),u=Math.cos(r);return e[0]=u*s+x*l,e[1]=u*n+x*o,e[2]=u*h+x*a,e[3]=u*l-x*s,e[4]=u*o-x*n,e[5]=u*a-x*h,e[6]=f,e[7]=g,e[8]=m,e}function hr(e,t,r){let s=r[0],n=r[1];return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function lr(e,t){let r=t[0],s=t[1],n=t[2],h=t[3],l=t[4],o=t[5],a=t[6],f=t[7],g=t[8],m=t[9],x=t[10],u=t[11],c=t[12],d=t[13],p=t[14],v=t[15],y=r*o-s*l,w=r*a-n*l,b=r*f-h*l,_=s*a-n*o,E=s*f-h*o,S=n*f-h*a,I=g*d-m*c,F=g*p-x*c,A=g*v-u*c,C=m*p-x*d,R=m*v-u*d,z=x*v-u*p,M=y*z-w*R+b*C+_*A-E*F+S*I;return M?(M=1/M,e[0]=(o*z-a*R+f*C)*M,e[1]=(a*A-l*z-f*F)*M,e[2]=(l*R-o*A+f*I)*M,e[3]=(n*R-s*z-h*C)*M,e[4]=(r*z-n*A+h*F)*M,e[5]=(s*A-r*R-h*I)*M,e[6]=(d*S-p*E+v*_)*M,e[7]=(p*b-c*S-v*w)*M,e[8]=(c*E-d*b+v*y)*M,e):null}class ar extends Array{constructor(t=1,r=0,s=0,n=0,h=1,l=0,o=0,a=0,f=1){return super(t,r,s,n,h,l,o,a,f),this}set(t,r,s,n,h,l,o,a,f){return t.length?this.copy(t):(er(this,t,r,s,n,h,l,o,a,f),this)}translate(t,r=this){return sr(this,r,t),this}rotate(t,r=this){return nr(this,r,t),this}scale(t,r=this){return hr(this,r,t),this}multiply(t,r){return r?Ct(this,t,r):Ct(this,this,t),this}identity(){return rr(this),this}copy(t){return tr(this,t),this}fromMatrix4(t){return Ke(this,t),this}fromQuaternion(t){return Je(this,t),this}fromBasis(t,r,s){return this.set(t[0],t[1],t[2],r[0],r[1],r[2],s[0],s[1],s[2]),this}inverse(t=this){return ir(this,t),this}getNormalMatrix(t){return lr(this,t),this}}let cr=0;class or extends Qe{constructor(t,{geometry:r,program:s,mode:n=t.TRIANGLES,frustumCulled:h=!0,renderOrder:l=0}={}){super(),t.canvas||console.error("gl not passed as first argument to Mesh"),this.gl=t,this.id=cr++,this.geometry=r,this.program=s,this.mode=n,this.frustumCulled=h,this.renderOrder=l,this.modelViewMatrix=new J,this.normalMatrix=new ar,this.beforeRenderCallbacks=[],this.afterRenderCallbacks=[]}onBeforeRender(t){return this.beforeRenderCallbacks.push(t),this}onAfterRender(t){return this.afterRenderCallbacks.push(t),this}draw({camera:t}={}){t&&(this.program.uniforms.modelMatrix||Object.assign(this.program.uniforms,{modelMatrix:{value:null},viewMatrix:{value:null},modelViewMatrix:{value:null},normalMatrix:{value:null},projectionMatrix:{value:null},cameraPosition:{value:null}}),this.program.uniforms.projectionMatrix.value=t.projectionMatrix,this.program.uniforms.cameraPosition.value=t.worldPosition,this.program.uniforms.viewMatrix.value=t.viewMatrix,this.modelViewMatrix.multiply(t.viewMatrix,this.worldMatrix),this.normalMatrix.getNormalMatrix(this.modelViewMatrix),this.program.uniforms.modelMatrix.value=this.worldMatrix,this.program.uniforms.modelViewMatrix.value=this.modelViewMatrix,this.program.uniforms.normalMatrix.value=this.normalMatrix),this.beforeRenderCallbacks.forEach(s=>s&&s({mesh:this,camera:t}));let r=this.program.cullFace&&this.worldMatrix.determinant()<0;this.program.use({flipFaces:r}),this.geometry.draw({mode:this.mode,program:this.program}),this.afterRenderCallbacks.forEach(s=>s&&s({mesh:this,camera:t}))}}var K={exports:{}},ur=K.exports,Ft;function fr(){return Ft||(Ft=1,(function(e,t){(function(r,s){e.exports=s()})(ur,function(){var r=function(a,f){return a<f?-1:a>f?1:0},s=function(a){return a.reduce(function(f,g){return f+g},0)},n=(function(){function a(g){this.colors=g}var f=a.prototype;return f.palette=function(){return this.colors},f.map=function(g){return g},a})(),h=(function(){function a(u,c,d){return(u<<10)+(c<<5)+d}function f(u){var c=[],d=!1;function p(){c.sort(u),d=!0}return{push:function(v){c.push(v),d=!1},peek:function(v){return d||p(),v===void 0&&(v=c.length-1),c[v]},pop:function(){return d||p(),c.pop()},size:function(){return c.length},map:function(v){return c.map(v)},debug:function(){return d||p(),c}}}function g(u,c,d,p,v,y,w){var b=this;b.r1=u,b.r2=c,b.g1=d,b.g2=p,b.b1=v,b.b2=y,b.histo=w}function m(){this.vboxes=new f(function(u,c){return r(u.vbox.count()*u.vbox.volume(),c.vbox.count()*c.vbox.volume())})}
7function x(u,c){if(c.count()){var d=c.r2-c.r1+1,p=c.g2-c.g1+1,v=Math.max.apply(null,[d,p,c.b2-c.b1+1]);if(c.count()==1)return[c.copy()];var y,w,b,_,E=0,S=[],I=[];if(v==d)for(y=c.r1;y<=c.r2;y++){for(_=0,w=c.g1;w<=c.g2;w++)for(b=c.b1;b<=c.b2;b++)_+=u[a(y,w,b)]||0;S[y]=E+=_}else if(v==p)for(y=c.g1;y<=c.g2;y++){for(_=0,w=c.r1;w<=c.r2;w++)for(b=c.b1;b<=c.b2;b++)_+=u[a(w,y,b)]||0;S[y]=E+=_}else for(y=c.b1;y<=c.b2;y++){for(_=0,w=c.r1;w<=c.r2;w++)for(b=c.g1;b<=c.g2;b++)_+=u[a(w,b,y)]||0;S[y]=E+=_}return S.forEach(function(F,A){I[A]=E-F}),(function(F){var A,C,R,z,M,D=F+"1",N=F+"2",O=0;for(y=c[D];y<=c[N];y++)if(S[y]>E/2){for(R=c.copy(),z=c.copy(),M=(A=y-c[D])<=(C=c[N]-y)?Math.min(c[N]-1,~~(y+C/2)):Math.max(c[D],~~(y-1-A/2));!S[M];)M++;for(O=I[M];!O&&S[M-1];)O=I[--M];return R[N]=M,z[D]=R[N]+1,[R,z]}})(v==d?"r":v==p?"g":"b")}}return g.prototype={volume:function(u){var c=this;return c._volume&&!u||(c._volume=(c.r2-c.r1+1)*(c.g2-c.g1+1)*(c.b2-c.b1+1)),c._volume},count:function(u){var c=this,d=c.histo;if(!c._count_set||u){var p,v,y,w=0;for(p=c.r1;p<=c.r2;p++)for(v=c.g1;v<=c.g2;v++)for(y=c.b1;y<=c.b2;y++)w+=d[a(p,v,y)]||0;c._count=w,c._count_set=!0}return c._count},copy:function(){var u=this;return new g(u.r1,u.r2,u.g1,u.g2,u.b1,u.b2,u.histo)},avg:function(u){var c=this,d=c.histo;if(!c._avg||u){var p,v,y,w,b=0,_=0,E=0,S=0;if(c.r1===c.r2&&c.g1===c.g2&&c.b1===c.b2)c._avg=[c.r1<<3,c.g1<<3,c.b1<<3];else{for(v=c.r1;v<=c.r2;v++)for(y=c.g1;y<=c.g2;y++)for(w=c.b1;w<=c.b2;w++)b+=p=d[a(v,y,w)]||0,_+=p*(v+.5)*8,E+=p*(y+.5)*8,S+=p*(w+.5)*8;c._avg=b?[~~(_/b),~~(E/b),~~(S/b)]:[~~(8*(c.r1+c.r2+1)/2),~~(8*(c.g1+c.g2+1)/2),~~(8*(c.b1+c.b2+1)/2)]}}return c._avg},contains:function(u){var c=this,d=u[0]>>3;return gval=u[1]>>3,bval=u[2]>>3,d>=c.r1&&d<=c.r2&&gval>=c.g1&&gval<=c.g2&&bval>=c.b1&&bval<=c.b2}},m.prototype={push:function(u){this.vboxes.push({vbox:u,color:u.avg()})},palette:function(){return this.vboxes.map(function(u){return u.color})},size:function(){return this.vboxes.size()},map:function(u){for(var c=this.vboxes,d=0;d<c.size();d++)if(c.peek(d).vbox.contains(u))return c.peek(d).color;return this.nearest(u)},nearest:function(u){for(var c,d,p,v=this.vboxes,y=0;y<v.size();y++)((d=Math.sqrt(Math.pow(u[0]-v.peek(y).color[0],2)+Math.pow(u[1]-v.peek(y).color[1],2)+Math.pow(u[2]-v.peek(y).color[2],2)))<c||c===void 0)&&(c=d,p=v.peek(y).color);return p},forcebw:function(){var u=this.vboxes;u.sort(function(v,y){return r(s(v.color),s(y.color))});var c=u[0].color;c[0]<5&&c[1]<5&&c[2]<5&&(u[0].color=[0,0,0]);var d=u.length-1,p=u[d].color;p[0]>251&&p[1]>251&&p[2]>251&&(u[d].color=[255,255,255])}},{quantize:function(u,c){if(!Number.isInteger(c)||c<1||c>256)throw new Error("Invalid maximum color count. It must be an integer between 1 and 256.");if(!u.length||c<2||c>256||!u.length||c<2||c>256)return!1;for(var d=[],p=new Set,v=0;v<u.length;v++){var y=u[v],w=y.join(",");p.has(w)||(p.add(w),d.push(y))}if(d.length<=c)return new n(d);var b=(function(A){var C,R=new Array(32768);return A.forEach(function(z){C=a(z[0]>>3,z[1]>>3,z[2]>>3),R[C]=(R[C]||0)+1}),R})(u);b.forEach(function(){});var _=(function(A,C){var R,z,M,D=1e6,N=0,O=1e6,G=0,q=1e6,X=0;return A.forEach(function(j){(R=j[0]>>3)<D?D=R:R>N&&(N=R),(z=j[1]>>3)<O?O=z:z>G&&(G=z),(M=j[2]>>3)<q?q=M:M>X&&(X=M)}),new g(D,N,O,G,q,X,C)})(u,b),E=new f(function(A,C){return r(A.count(),C.count())});function S(A,C){for(var R,z=A.size(),M=0;M<1e3;){if(z>=C||M++>1e3)return;if((R=A.pop()).count()){var D=x(b,R),N=D[0],O=D[1];if(!N)return;A.push(N),O&&(A.push(O),z++)}else A.push(R),M++}}E.push(_),S(E,.75*c);for(var I=new f(function(A,C){return r(A.count()*A.volume(),C.count()*C.volume())});E.size();)I.push(E.pop());S(I,c);for(var F=new m;I.size();)F.push(I.pop());return F}}})().quantize,l=function(a){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.width=this.canvas.width=a.naturalWidth,this.height=this.canvas.height=a.naturalHeight,this.context.drawImage(a,0,0,this.width,this.height)};l.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)};var o=function(){};return o.prototype.getColor=function(a,f){return f===void 0&&(f=10),this.getPalette(a,5,f)[0]},o.prototype.getPalette=function(a,f,g){var m=(function(d){var p=d.colorCount,v=d.quality;if(p!==void 0&&Number.isInteger(p)){if(p===1)throw new Error("colorCount should be between 2 and 20. To get one color, call getColor() instead of getPalette()");p=Math.max(p,2),p=Math.min(p,20)}else p=10;return(v===void 0||!Number.isInteger(v)||v<1)&&(v=10),{colorCount:p,quality:v}})({colorCount:f,quality:g}),x=new l(a),u=(function(d,p,v){for(var y,w,b,_,E,S=d,I=[],F=0;F<p;F+=v)w=S[0+(y=4*F)],b=S[y+1],_=S[y+2],((E=S[y+3])===void 0||E>=125)&&(w>250&&b>250&&_>250||I.push([w,b,_]));return I})(x.getImageData().data,x.width*x.height,m.quality),c=h(u,m.colorCount);return c?c.palette():null},o.prototype.getColorFromUrl=function(a,f,g){var m=this,x=document.createElement("img");x.addEventListener("load",function(){var u=m.getPalette(x,5,g);f(u[0],a)}),x.src=a},o.prototype.getImageData=function(a,f){var g=new XMLHttpRequest;g.open("GET",a,!0),g.responseType="arraybuffer",g.onload=function(){if(this.status==200){var m=new Uint8Array(this.response);i=m.length;for(var x=new Array(i),u=0;u<m.length;u++)x[u]=String.fromCharCode(m[u]);var c=x.join(""),d=window.btoa(c);f("data:image/png;base64,"+d)}},g.send()},o.prototype.getColorAsync=function(a,f,g){var m=this;this.getImageData(a,function(x){var u=document.createElement("img");u.addEventListener("load",function(){var c=m.getPalette(u,5,g);f(c[0],this)}),u.src=x})},o})})(K)),K.exports}var gr=fr();const dr=Nt(gr);
7class pr{constructor(){this.colorthief=new dr}getColor(t,r){return this.colorthief.getColor(t,r)}getPalette(t,r,s){return this.colorthief.getPalette(t,r,s)}}const xr=U.forwardRef(({img:e,theme:t,className:r,align:s="center",aspect:n,dimensionUnits:h={width:"vw",height:"vh"},outerWidth:l,outerHeight:o,bg:a,width:f,height:g,scale:m=1,direction:x="horizontal",showImage:u=!0,blocking:c=!0,radial:d=3,speed:p=1,paused:v=!1,grain:y=!0,cutEdges:w=!0,fadeEdges:b=!1,ripple1Size:_=.15,ripple1Intensity:E=.36,ripple2Size:S=.22,ripple2Intensity:I=.25,alpha:F=1,desaturated:A=!1},C)=>{const R=U.useRef(null),z=U.useRef(null),M=U.useRef(null),D=U.useRef(null),N=U.useRef(null),O=U.useRef(null),G=U.useRef(null),q=U.useRef(null),X=U.useRef(null),{width:j,height:Dt}=qt(),k=U.useRef([]),V=U.useRef([]),Pt=U.useRef(new pr),ct=U.useRef(0),ot=U.useRef(0),Y=U.useRef([...Array(5)].map(()=>({r:0,rEase:0,g:0,gEase:0,b:0,bEase:0}))),W=U.useRef(0),Z=U.useRef(t?dt(t):null);U.useImperativeHandle(C,()=>Object.assign(R.current,{export:Bt,useImg:B=>{W.current=B},resize:ft}),[R]);const Bt=()=>{if(!M.current)return;const B=M.current.toDataURL(),L=document.createElement("a");L.download=`gradient${Date.now()}.png`,L.href=B,L.click()};U.useEffect(()=>{if(!M.current||!z.current)return;O.current=new fe({width:z.current.offsetWidth,height:z.current.offsetHeight,canvas:M.current,alpha:!0,preserveDrawingBuffer:!0});const B=O.current.gl;return G.current=new ne(B,{position:{size:2,data:new Float32Array([-1,-1,3,-1,-1,3])},uv:{size:2,data:new Float32Array([0,0,2,0,0,2])}}),q.current=new le(B,{vertex:`
8        attribute vec2 uv;
9        attribute vec2 position;
10
11        varying vec2 vUv;
12
13        void main() {
14          vUv = uv;
15          gl_Position = vec4(position, 0, 1);
16        }
17      `,fragment:`
18        precision highp float;
19
20        uniform float uTime;
21        uniform vec2 uInnerSize;
22        uniform vec3 uBg;
23        uniform vec2 uResolution;
24        uniform vec3 uColor1;
25        uniform vec3 uColor2;
26        uniform vec3 uColor3;
27        uniform vec3 uColor4;
28        uniform vec3 uColor5;
29        uniform float uOpacity;
30        uniform vec2 uImageSize;
31        uniform vec2 uImagePos;
32        uniform float uScale;
33        uniform float uDirection;
34        uniform float uSpacerSize;
35        uniform float uSeed;
36        uniform float uBlocker;
37        uniform float uRadial; // 3.0
38        uniform float uSpeed;
39        uniform float uGrain;
40        uniform float uCutEdges;
41        uniform float uFadeEdges;
42        uniform float uRipple1Size;
43        uniform float uRipple1Intensity;
44        uniform float uRipple2Size;
45        uniform float uRipple2Intensity;
46        uniform float uDesaturated;
47
48        varying vec2 vUv;
49
50        float rand(vec2 co){
51          return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453123);
52        }
53
54        float ripple(vec2 sourceCoord, vec2 centerCoord, float time, float multiplier) {
55          float dist = distance(sourceCoord * multiplier, centerCoord * multiplier);
56          return (sin(dist * 80.0 - time * 15.0) + 0.5) / 30.0;
57        }
58
59        float rip(float t, float offset, float dir) {
60          float ratio = (uResolution.y / uResolution.x) * 5.5;
61          return mix(vUv.x, vUv.y, uDirection) + sin(mix(vUv.y, vUv.x, uDirection) * uRadial) * ratio * dir * 0.025 + ripple(vUv, vec2(0.5), t * 0.15 * offset, uRipple1Size) * dir * uRipple1Intensity + ripple(vUv, vec2(0.5, 0.0), t * offset * 0.35, uRipple2Size) * dir * sin(vUv.y) * uRipple2Intensity;
62        }
63
64        float ringtime(float t, float offset) {
65          return t * offset;
66        }
67
68        void main() {
69          vec3 color = uBg;
70
71          float ratio = uScale * (uResolution.y / uResolution.x) * 5.5 * (uInnerSize.y / uResolution.y);
72          float rings = (mix(uResolution.x, uResolution.x, uDirection) / 18.0) * ratio;
73          float t = (uTime * uSpeed * 1.2);
74          float PI = 3.14159265359;
75          float spacingDirection = mix((uResolution.x / rings), (uResolution.y / rings), uDirection);
76          float spacing = ((PI * spacingDirection) + uSeed) * ratio;
77          float dRings = mix(uResolution.x / rings, uResolution.y / rings, uDirection);
78          float centerMixer = mix(smoothstep(uImagePos.x - 0.1, uImagePos.x + 0.1, vUv.x), smoothstep(uImagePos.y - 0.1, uImagePos.y + 0.1, vUv.y), uDirection);
79
80          vec3 color1 = color;
81
82          color1 = mix(uColor1, uColor2, clamp(sin((rip(t, 1.0, 1.0) * dRings) + ringtime(t, 1.0) + spacing * 0.5), 0.0, 1.0));
83          color1 = mix(color1, uColor3, clamp(sin((rip(t, 0.5, 1.0) * dRings) + ringtime(t, 0.5) + spacing * 1.0), 0.0, 1.0));
84          color1 = mix(color1, uColor4, clamp(sin((rip(t, 0.75, 1.0) * dRings) + ringtime(t, 0.75) + spacing * 1.5), 0.0, 1.0));
85          color1 = mix(color1, uColor5, clamp(sin((rip(t, 0.25, 1.0
85) * dRings) + ringtime(t, 0.25) + spacing * 2.0), 0.0, 1.0));
86
87          vec3 color2 = color;
88          
89          color2 = mix(uColor1, uColor2, clamp(sin((rip(t, 1.0, -1.0) * dRings) - ringtime(t, 1.0) + spacing * 0.5), 0.0, 1.0));
90          color2 = mix(color2, uColor3, clamp(sin((rip(t, 0.5, -1.0) * dRings) - ringtime(t, 0.5) + spacing * 1.0), 0.0, 1.0));
91          color2 = mix(color2, uColor4, clamp(sin((rip(t, 0.75, -1.0) * dRings) - ringtime(t, 0.75) + spacing * 1.5), 0.0, 1.0));
92          color2 = mix(color2, uColor5, clamp(sin((rip(t, 0.25, -1.0) * dRings) - ringtime(t, 0.25) + spacing * 2.0), 0.0, 1.0));
93          
94          color = mix(color1, color2, centerMixer); //step(uImagePos.x, vUv.x));
95
96          color = mix(color, vec3(dot(color, vec3(0.2))), uDesaturated);
97
98          float noisey = rand(vUv + fract(uTime));
99          color += noisey * 0.07 * uGrain;
100
101          // reduce banding
102          vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
103          color += fract(magic.z * fract(dot(gl_FragCoord.xy, magic.xy))) / 255.0;
104
105          float blockerR = max(1.0 - uBlocker, step(uImagePos.x + (uImageSize.x / 2.0) + uSpacerSize, vUv.x));
106          float blockerL = max(1.0 - uBlocker, 1.0 - step(uImagePos.x - (uImageSize.x / 2.0) - uSpacerSize, vUv.x));
107
108          float rX = (uInnerSize.x / uResolution.x) * 0.5;
109          float rY = (uInnerSize.y / uResolution.y) * 0.5;
110          float outerX = smoothstep(uImagePos.x - rX - (rX * 1.5), uImagePos.x - rX, vUv.x) * smoothstep(uImagePos.x + rX + (rX * 1.5), uImagePos.x + rX, vUv.x);
111          float outerY = smoothstep(uImagePos.y - rY - (rY * 1.5), uImagePos.y - rY, vUv.y) * smoothstep(uImagePos.y + rY + (rY * 1.5), uImagePos.y + rY, vUv.y);
112          float cutX = step(0.5 - rX, vUv.x) * step(vUv.x, 0.5 + rX);
113          float cutY = step(0.5 - rY, vUv.y) * step(vUv.y, 0.5 + rY);
114          
115          float alphaBlock = step(uCutEdges, mix(blockerL, blockerR, step(uImagePos.x, vUv.x)));
116
117          gl_FragColor.rgb = mix(uBg, mix(uBg, color, alphaBlock) * mix(1.0, outerX * outerY, uFadeEdges), step(uCutEdges, cutX * cutY));
118          gl_FragColor.a = 1.0 * uOpacity;
119        }
120      `,uniforms:{uTime:{value:0},uResolution:{value:[0,0]},uInnerSize:{value:[0,0]},uBg:{value:[0,0,0]},uImageSize:{value:[0,0]},uImagePos:{value:[0,0]},uScale:{value:1},uDirection:{value:0},uColor1:{value:[0,0,0]},uColor2:{value:[0,0,0]},uColor3:{value:[0,0,0]},uColor4:{value:[0,0,0]},uColor5:{value:[0,0,0]},uOpacity:{value:F},uSpacerSize:{value:0},uSeed:{value:Math.random()*100},uBlocker:{value:c?1:0},uRadial:{value:d},uSpeed:{value:1},uGrain:{value:y?1:0},uCutEdges:{value:w?1:0},uFadeEdges:{value:b?1:0},uRipple1Size:{value:.15},uRipple1Intensity:{value:.36},uRipple2Size:{value:.22},uRipple2Intensity:{value:.25},uDesaturated:{value:A?1:0}}}),X.current=new or(B,{geometry:G.current,program:q.current}),()=>{O.current=null,G.current?.remove(),G.current=null,q.current?.remove(),q.current=null,X.current=null}},[]),$t(B=>{if(!O.current||!q.current||!X.current)return;const L=B-ct.current,T=q.current.uniforms;if(v&&(ot.current+=L),T.uTime.value=(B-ot.current)/1e3,T.uResolution.value=[O.current.width,O.current.height],T.uInnerSize.value=[z.current?.offsetWidth||0,z.current?.offsetHeight||0],T.uSpacerSize.value>0&&T.uImageSize.value[0]>0&&T.uImageSize.value[1]>0&&(T.uOpacity.value+=(F-T.uOpacity.value)*.025),T.uBlocker.value=c?1:0,T.uRadial.value=d,T.uSpeed.value=p,T.uGrain.value=y?1:0,T.uScale.value=m,T.uDirection.value=x==="horizontal"?0:1,T.uCutEdges.value=w?1:0,T.uFadeEdges.value=b?1:0,T.uRipple1Size.value=_,T.uRipple1Intensity.value=E,T.uRipple2Size.value=S,T.uRipple2Intensity.value=I,T.uDesaturated.value+=((A?1:0)-T.uDesaturated.value)*.1,T.uBg.value=a&&[a.r/255,a.g/255,a.b/255]||[0,0,0],V.current.length>0)for(let P=0;P<5;P++)V.current[W.current]?.[P]&&(Y.current[P].r+=(V.current[W.current][P].r-Y.current[P].r)*.1,Y.current[P].g+=(V.current[W.current][P].g-Y.current[P].g)*.1,Y.current[P].b+=(V.current[W.current][P].b-Y.current[P].b)*.1,T[`uColor${P+1}`].value=[Y.current[P].r,Y.current[P].g,Y.current[P].b]);ut(),Ut(),O.current.render({scene:X.current}),ct.current=B});const ut=()=>{if(!O.current||!q.current||!D.current)return;q.current.uniforms.uImageSize.value=[D.current.offsetWidth/O.current.width,D.current.offsetHeight/O.current.height];const B=(D.current.offsetLeft+D.current.offsetWidth/2)/O.current.width,L=(D.current.offsetTop+D.current.offsetHeight/2)/O.current.height;q.current.uniforms.uImagePos.value=[B,L]},Ut=()=>{!N.current||!q.current||!O.current||(q.current.uniforms.uSpacerSize.value=N.current.offsetWidth/O.current.width)},ft=()=>{O.current&&M.current&&R.current&&O.current.setSize(R.current?.offsetWidth,R.current?.offsetHeight)};U.useEffect(()=>{ft()},[f,g,j,Dt,l,o]);const gt=async B=>{if(!k.current||!O.current||!q.current||!X.current)return;const L=await Pt.current.getPalette(k.current[B],5);V.current[B]=[];const T=V.current[B];for(let P=0;P<5;P++)T[P]={r:0,g:0,b:0},T[P].r=L[P][0]/255,T[P].g=L[P][1]/255,T[P].b=L[P][2]/255;ut()};U.useEffect(()=>{e&&(Array.isArray(e)?e.forEach((B,L)=>{k.current[L]=new Image,k.current[L].crossOrigin="anonymous",k.current[L].onload=()=>{gt(L)},k.current[L].src=B}):(k.current[0]=new Image,k.current[0].crossOrigin="anonymous",k.current[0].onload=()=>{gt(0)},k.current[0].src=e))},[e]),U.useEffect(()=>{if(t&&(Z.current=dt(t),Z.current)){V.current[W.current]=[];const B=V.current[W.current];for(let L=0;L<5;L++)B[L]={r:0,g:0,b:0},B[L].r=Z.current[L][0]/255,B[L].g=Z.current[L][1]/255,B[L].b=Z.current[L][2]/255}},[t]);const tt={};l&&(tt.width=`${l}${h.width}`),o&&(tt.height=`${o}${h.height}`);const et={};return f&&(et.width=`${f}${h.width}`),g&&(et.height=`${g}${h.height}`),H.jsxs("div",{ref:R,className:rt("flex justify-center items-center relative w-full",r),style:tt,children:[H.jsx("canvas",{ref:M,className:"w-full h-full absolute left-0 top-0"}),H.jsxs("div",{ref:z,className:rt("w-full h-full flex items-center",s==="left"&&"justify-start",s==="center"&&"justify-center",s==="right"&&"justify-end"),style:et,children:[H.jsx("img",{ref:D,src:Array.isArray(e)?e[0]:e,className:rt("h-full w-auto relative",n&&"object-cover",u?"opacity-100":"opacity-0"),style:n?{aspectRatio:u?n:"0.001/1"}:{}}),H.jsx("div",{ref:N,className:"w-4 absolute left-0 top-0 pointer-events-none opacity-0"})]})]})});xr.displayName="Gradient";export{xr as G};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.