earthnut 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import*as e from"a-type-of-js";import*as t from"react";import*as r from"a-element-inline-style";import*as n from"a-js-tools";var i={362:(t,r,n)=>{var i,o;t.exports=(i={isBoolean:()=>e.isBoolean,isEmptyArray:()=>e.isEmptyArray,isFalse:()=>e.isFalse,isNull:()=>e.isNull,isZero:()=>e.isZero},o={},n.d(o,i),o)},649:(e,r,n)=>{var i,o;e.exports=(i={useEffect:()=>t.useEffect,useRef:()=>t.useRef},o={},n.d(o,i),o)}},o={};function a(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var u={};a.d(u,{n:()=>qe});var l=a(649);const s=(f={setStyle:()=>r.setStyle},c={},a.d(c,f),c);var f,c,p=a(362);function h(e,t,r,n){function i(e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,e)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,t)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var u=e+t,l=/uniform (\w+) (\w+)/g;!(0,p.isNull)(o=l.exec(u));){var s=o[2];a.locations[s]=r.getUniformLocation(a.id,s)}return a}function d(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(t||0)),r.bindTexture(r.TEXTURE_2D,e)}function m(){var e=this,t=function(){return e.initState=!1,null};if(!this.gl)return t();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(e,t){var n=r.getExtension(t);return n&&e.push([t,n]),e}),[]));if(!n.OES_texture_float)return t();var i=[];function o(e,t,r){var i="OES_texture_"+e,o=i+"_linear",a=o in n;return{type:t,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),u=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,u),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var l=null,s=0;s<i.length;s++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[s].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){l=i[s];break}return l}function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,E(n.key),n)}}function b(e,t,r){return t&&g(e.prototype,t),r&&g(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t,r){return(t=E(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e){var t=function(e){if("object"!=v(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=v(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==v(t)?t:t+""}var R=b((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"canvas",void 0),y(this,"gl",void 0),y(this,"config",void 0),y(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if((0,p.isNull)(r))return this.initState=!1,void(this.config=null);this.gl=r,this.config=Reflect.apply(m,this,[])}));const w=(e=>{var t={};return a.d(t,e),t})({debounce:()=>n.debounce,enArr:()=>n.enArr,getRandomInt:()=>n.getRandomInt});var T,P={imageUrl:"",resolution:360,dropRadius:12,perturbance:.01,interactive:!0,crossOrigin:"no-cors",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function x(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_(n.key),n)}}function _(e){var t=function(e){if("object"!=S(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=S(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==S(t)?t:t+""}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function D(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,k(n.key),n)}}function k(e){var t=function(e){if("object"!=O(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==O(t)?t:t+""}function A(e,t,r){return e.set(I(e,t),r),r}function F(e,t){return e.get(I(e,t))}function I(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}function j(e){return function(e){if(Array.isArray(e))return U(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return U(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?U(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}Object.freeze(P),new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var t=function(){};return Object.setPrototypeOf(t,this),Object.defineProperties(t,{info:{value:function(){},configurable:!1,writable:!1},warn:{value:function(){},configurable:!1,writable:!1},error:{value:function(){},configurable:!1,writable:!1},type:{value:!1,configurable:!1,writable:!1}}),t},(t=[{key:"clear",value:function(){}}])&&x(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}())({name:"earthnut",type:!1});var C=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t={list:[],diameter:48,radius:0,cells:0};t.diameter%2!=0&&t.diameter++;var r=t.diameter,n=t.list,i=r/2;t.radius=i,t.cells=Math.pow(r,2);for(var o=0;o<r;o++){n[o]=[];for(var a=0;a<r;a++)n[o][a]=[0,0,0,0]}for(var u=0;u<=i;u++)for(var l=u;l<=i;l++){var s=n[u][l],f=function(){return(0,w.getRandomInt)(255,190)};s[0]=f(),s[1]=f(),s[2]=f(),s[3]=Math.ceil(Math.sqrt(Math.pow(u,2)+Math.pow(l,2)))<=i?(0,w.getRandomInt)(120,180):(0,w.getRandomInt)(160,240)}for(var c=0;c<=i;c++)for(var p=0;p<=c;p++)n[c][p]=n[p][c];for(var h=i;h<r;h++)for(var d=0;d<=i;d++)n[h][d]=n[r-h][d];for(var m=0;m<i;m++)for(var v=i;v<r;v++)n[m][v]=n[m][r-v];for(var g=i;g<r;g++)for(var b=i;b<r;b++)n[g][b]=n[g][r-b];var y=e%r;return t.list=[].concat(j(n.slice(y)),j(n.slice(0,y))),t},N=new(T=new WeakMap,function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}(this,T,1),t=this,r="data",n=C(),(r=k(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},(t=[{key:"build",value:function(){F(T,this)>100&&A(T,this,0),this.data=C(A(T,this,F(T,this)+3))}}])&&D(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}());function B(e,t){var r=document.createElement("canvas"),n=document.createElement("canvas"),i=r.getContext("2d"),o=n.getContext("2d");return(0,p.isNull)(i)||(0,p.isNull)(o)?r:(r.width=n.width=e,r.height=n.height=t,i.clearRect(0,0,e,t),o.clearRect(0,0,e,t),i.globalAlpha=1,i.putImageData(function(e,t){Date.now();for(var r=new ImageData(e,t),n=r.data,i=N.data,o=i.diameter,a=i.list,u=e*o,l=0;l<n.length;l+=4){var s=l/4%u,f=s%e%o,c=Math.floor(s/e),p=a[f][c];n[l]=p[0],n[l+1]=p[1],n[l+2]=p[2],n[l+3]=p[3]}return r}(e,t),0,0),o.fillStyle="#ffffff",o.fillRect(0,0,e,t),o.drawImage(r,0,0,e,t),o.globalCompositeOperation="source-over",n)}function L(){var e=this.fadeData,t=e.backgroundInfo,r=t.width,n=t.height;N.build(),e.toBeList.push(B(r,n)),e.run()}function M(){var e=this,t=this.renderData,r=this.options,n=this.fadeData;if((0,p.isNull)(t))Reflect.apply(L,this,[]);else{var i,o,a=t.lastUseStyle,u=n.backgroundInfo,l=u.width,s=u.height,f=r.imageUrl||(i=a.backgroundImage,o=/url\(["']?([^"']*)["']?\)/.exec(i),(0,p.isNull)(o)?null:o[1]);if(t.imageSource=f,f){var c=function(e,t,r){var n=new Image(t,r);return n.width=t,n.height=r,n.src=e,n}(f,l,s);c.onload=function(){clearTimeout(n.transparentId),n.toBeList=n.toBeList.filter((function(e){return"img"===e.tagName.toLowerCase()&&e.getAttribute("src")!==f&&e.width===l&&e.height===s})),n.toBeList.push(c),n.run()},c.onerror=function(){Reflect.apply(L,e,[])},c.crossOrigin=r.crossOrigin}else Reflect.apply(L,this,[])}}function X(){var e=this.renderData;if(!(0,p.isNull)(e)){var t=e.parentElement;t&&[["background-image","none"],["background-color","transparent"]].forEach((function(e){return t.style.setProperty(e[0],e[1],"important")}))}}function W(e){var t=window.getComputedStyle(e),r=e.style;return{inlineBackground:r.background,inlineBackgroundColor:r.backgroundColor,inlineBackgroundImage:r.backgroundImage,backgroundColor:t.backgroundColor,backgroundImage:t.backgroundImage,backgroundSize:t.backgroundSize,backgroundPosition:t.backgroundPosition,backgroundRepeat:t.backgroundRepeat,backgroundClip:t.backgroundClip,backgroundOrigin:t.backgroundOrigin,backgroundAttachment:t.backgroundAttachment,position:t.position}}function z(e){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},z(e)}function G(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,q(n.key),n)}}function H(e,t,r){return t&&G(e.prototype,t),r&&G(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Y(e,t,r){return(t=q(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e){var t=function(e){if("object"!=z(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==z(t)?t:t+""}var Z=H((function e(t,r,n){var i,o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Y(this,"quad",null),Y(this,"lastRaindropsFallTime",0),Y(this,"parentElement",void 0),Y(this,"mutationObserver",void 0),Y(this,"resizeObserver",void 0),Y(this,"renderProgram",void 0),Y(this,"imageSource",""),Y(this,"dropProgram",void 0),Y(this,"updateProgram",void 0),Y(this,"textures",[]),Y(this,"backgroundTexture",[]),Y(this,"textureDelta",void 0),Y(this,"framebuffers",[]),Y(this,"bufferWriteIndex",0),Y(this,"bufferReadIndex",1),Y(this,"originStyle",void 0),Y(this,"lastUseStyle",void 0),Y(this,"events",{}),Y(this,"animationFrameId",0),this.parentElement=null!==(i=t.parentElement)&&void 0!==i?i:document.body,Reflect.apply(X,n,[]),this.originStyle=this.lastUseStyle=W(this.parentElement),this.mutationObserver=new MutationObserver((function(e){e.forEach((function(e){var t,i;if(e.target===o.parentElement&&"attributes"===e.type&&n.options.visible){var a=Object.values(o.lastUseStyle),u=W(o.parentElement),l=Object.values(u);if((0,p.isEmptyArray)(w.enArr.difference(a,l)))return;var s="none"===(i=u.backgroundImage)||""===i,f="rgba(0, 0, 0, 0)"===(t=u.backgroundColor)||"#ffffffff"===t||"transport"===t;if(s&&f)return;o.lastUseStyle=u,Reflect.apply(r,n,[]),Reflect.apply(X,n,[])}}))})),this.mutationObserver.observe(this.parentElement,{subtree:!0,attributes:!0,attributeFilter:["class","style"]}),this.resizeObserver=new ResizeObserver((function(){Reflect.apply(r,n,[])})),this.resizeObserver.observe(this.parentElement)}));function K(){var e=this.renderData,t=this.fadeData;if(!(0,p.isNull)(e)){var r,n,i,o=e.parentElement,a=window.getComputedStyle(o),u=a.backgroundSize,l=a.backgroundAttachment,s=a.backgroundPosition,f=/\s+/.test(r=s)?r.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):V(r)?[r,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[r],c={left:0,top:0,width:0,height:0};"fixed"===l?(c.height=window.innerHeight,c.left=window.screenX,c.top=window.screenY,c.width=window.innerWidth):(c.left=0,c.top=0,c.width=o.scrollWidth,c.height=o.scrollHeight);var h=t.backgroundInfo||{width:100,height:100},d=h.width,m=h.height;if("cover"===u){var v=Math.max(c.width/d,c.height/m);n=d*v,i=m*v}else if("contain"===u){var g=Math.min(c.width/d,c.height/m);n=d*g,i=m*g}else{var b=u.split(" ");n=b[0]||"",i=b[1]||n,V(n)?n=c.width*parseFloat(n)/100:"auto"!==n&&(n=parseFloat(n)),V(i)?i=c.height*parseFloat(i)/100:"auto"!==i&&(i=parseFloat(i)),"auto"===n&&"auto"===i?(n=d,i=m):("auto"===n&&(n=d*(Number(i)/m)),"auto"===i&&(i=m*(Number(n)/d)))}var y=f&&f[0]||"0%",E=f&&f[1]||"0%";y=V(y)?(c.left+(c.width-Number(n))*parseFloat(y)/100).toString():(c.left+parseFloat(y)).toString(),E=V(E)?(c.top+(c.height-Number(i))*parseFloat(E)/100).toString():(c.top+parseFloat(E)).toString(),e.renderProgram.uniforms.topLeft=new Float32Array([(o.offsetLeft-Number(y))/n,(o.offsetTop-Number(E))/i]),e.renderProgram.uniforms.bottomRight=new Float32Array([e.renderProgram.uniforms.topLeft[0]+o.clientWidth/n,e.renderProgram.uniforms.topLeft[1]+o.clientHeight/i]);var R=Math.max(this.canvas.width,this.canvas.height);e.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/R,this.canvas.height/R])}}function V(e){return e.endsWith("%")}function $(){var e=this.gl,t=this.renderData;(0,p.isNull)(t)||(e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4))}function J(){var e=this.gl,t=this.renderData,r=this.options;if(!(0,p.isNull)(t)){var n=t.textures,i=t.backgroundTexture,o=r.perturbance;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,this.canvas.width,this.canvas.height),e.enable(e.BLEND),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT),e.useProgram(t.renderProgram.id),Reflect.apply(d,this,[i,0]),Reflect.apply(d,this,[n[0],1]),e.uniform1f(t.renderProgram.locations.perturbance,o),e.uniform2fv(t.renderProgram.locations.topLeft,t.renderProgram.uniforms.topLeft),e.uniform2fv(t.renderProgram.locations.bottomRight,t.renderProgram.uniforms.bottomRight),e.uniform2fv(t.renderProgram.locations.containerRatio,t.renderProgram.uniforms.containerRatio),e.uniform1i(t.renderProgram.locations.samplerBackground,0),e.uniform1i(t.renderProgram.locations.samplerRipples,1),Reflect.apply($,this,[]),e.disable(e.BLEND)}}function Q(){var e=this.renderData;if(!(0,p.isNull)(e)){var t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}}function ee(){var e=this.gl,t=this.renderData,r=this.options;if(!(0,p.isNull)(t)){var n=t.updateProgram,i=t.textures,o=t.framebuffers,a=t.bufferWriteIndex,u=t.bufferReadIndex,l=r.resolution;e.viewport(0,0,l,l),e.bindFramebuffer(e.FRAMEBUFFER,o[a]),Reflect.apply(d,this,[i[u]]),e.useProgram(n.id),Reflect.apply($,this,[]),Reflect.apply(Q,this,[])}}function te(){var e=this,t=this.renderData,r=this.options,n=this.fadeData;if(!(0,p.isNull)(t)){var i=t.parentElement,o=n.isTransitioning,a=r.running,u=r.idleFluctuations,l=r.lastRunningState,s=getComputedStyle(i);n.backgroundInfo={width:parseInt(s.width),height:parseInt(s.height)},Reflect.apply(K,this,[]),a?(l||(r.lastRunningState=!0,this.show()),u&&this.raindropsFall(),o&&this.fade(),Reflect.apply(ee,this,[]),Reflect.apply(J,this,[])):l&&(r.lastRunningState=!1,this.hide()),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(te,e,[])}))}}function re(e,t,r){var n=this.renderData;if(!(0,p.isNull)(n)){var i=n.parentElement,o=window.getComputedStyle(i),a=parseInt(o.borderLeftWidth)||0,u=parseInt(o.borderTopWidth)||0,l=i.getBoundingClientRect(),s=e.clientX-l.left-a,f=e.clientY-l.top-u;this.drop(s,f,t,r)}}function ne(){var e=this,t=this.renderData,r=this.options;if(!(0,p.isNull)(t)){var n=t.parentElement,i=t.events,o=function(n){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r.visible&&r.running&&r.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(re,e,[n,r.dropRadius*(i?1.5:1),i?.03:.01]))};i.mousemove=function(e){for(var t=r.accelerating;t--;)o(e)},i.touchmove=i.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)o(t[r])},i.mousedown=function(e){return o(e,!0)},Object.keys(i).forEach((function(e){return null==n?void 0:n.addEventListener(e,i[e],{passive:!0})}))}}var ie="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";function oe(){var e=this.gl,t=this.renderData;if(!(0,p.isNull)(t)){var r=t.textureDelta;t.dropProgram=h(ie,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",e);var n=t.updateProgram=h(ie,"\n precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl);e.uniform2fv(n.locations.delta,r),t.renderProgram=h("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",e),e.uniform2fv(t.renderProgram.locations.delta,r)}}function ae(){var e=this.gl,t=this.renderData;if(!(0,p.isNull)(t)){var r=t.backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR)}}function ue(e){var t=this.gl,r=this.renderData,n=this.fadeData;if(!(0,p.isNull)(r)){var i=r.backgroundTexture,o=n.backgroundInfo,a=o.width,u=o.height,l=function(e){return(0,p.isZero)(e&e-1)},s=l(a)&&l(u)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,s),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e)}}function le(){var e=this,t=this.renderData,r=this.options,n=this.fadeData;if(!(0,p.isNull)(t)&&this.config){var i=t.textures,o=t.framebuffers,a=r.resolution,u=this.gl,l=1/a;t.textureDelta=new Float32Array([l,l]),this.config.extensions.forEach((function(e){return u.getExtension(e)}));for(var s=this.config.arrayType,f=s?new s(a*a*4):null,c=this.config,h=0;h<2;h++){var d=u.createTexture(),m=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,m),u.bindTexture(u.TEXTURE_2D,d),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,c.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,c.linearSupport?u.LINEAR:u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,a,a,0,u.RGBA,c.type,f),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,d,0),i.push(d),o.push(m)}t.quad=u.createBuffer(),u.bindBuffer(u.ARRAY_BUFFER,t.quad),u.bufferData(u.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),u.STATIC_DRAW),Reflect.apply(oe,this,[]),Reflect.apply(ae,this,[]),Reflect.apply(L,this,[]),Reflect.apply(M,this,[]),u.clearColor(0,0,0,0),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),r.visible=!0,r.running=!0,Reflect.apply(ne,this,[]),Reflect.apply(ue,this,[n.lastDrawImage]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(te,e,[])}))}}function se(){var e=this.renderData,t=this.fadeData;if(!(0,p.isNull)(e)){var r=e.parentElement,n=t.backgroundInfo,i=r.offsetWidth,o=r.offsetHeight;this.canvas.width=n.width=i,this.canvas.height=n.height=o,Reflect.apply(M,this,[])}}function fe(){var e=this.renderData;if(!(0,p.isNull)(e)){var t=e.parentElement,r=e.originStyle;t.style.setProperty("background-image",r.inlineBackgroundImage),t.style.setProperty("background-color",r.inlineBackgroundColor)}}function ce(){var e=this.renderData,t=this.fadeData;if(!(0,p.isNull)(e)){if(e.animationFrameId&&window.cancelAnimationFrame(e.animationFrameId),t.transparentId&&clearTimeout(t.transparentId),null!=e&&e.parentElement&&null!=e&&e.events){var r,n,i,o=e.parentElement,a=e.events;Object.keys(a).forEach((function(e){return o.removeEventListener&&o.removeEventListener(e,a[e])})),o.removeAttribute&&o.removeAttribute("data-ripples"),null===(r=e.mutationObserver)||void 0===r||r.takeRecords(),null===(n=e.mutationObserver)||void 0===n||n.disconnect(),e.mutationObserver=null,null===(i=e.resizeObserver)||void 0===i||i.disconnect(),e.resizeObserver=null}this.gl=null,Reflect.apply(fe,this,[]),Object.keys(e).forEach((function(t){return e[t]=null})),this.renderData=null,this.gl&&(this.gl=null)}}function pe(e,t,r,n){var i=this.renderData,o=this.options,a=this.gl;if(!(0,p.isNull)(i)){var u=i.parentElement,l=i.dropProgram,s=i.textures,f=i.framebuffers,c=i.bufferWriteIndex,h=i.bufferReadIndex,m=o.resolution,v=u.offsetWidth,g=u.offsetHeight,b=Math.max(v,g);r/=b;var y=new Float32Array([(2*e-v)/b,(g-2*t)/b]);a.viewport(0,0,m,m),a.bindFramebuffer(a.FRAMEBUFFER,f[c]),Reflect.apply(d,this,[s[h]]),a.useProgram(l.id),a.uniform2fv(l.locations.center,y),a.uniform1f(l.locations.radius,r),a.uniform1f(l.locations.strength,n),Reflect.apply($,this,[]),Reflect.apply(Q,this,[])}}function he(e){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(e)}function de(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ve(n.key),n)}}function me(e,t,r){return(t=ve(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ve(e){var t=function(e){if("object"!=he(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=he(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==he(t)?t:t+""}function ge(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function be(e,t){return e.get(Ee(e,t))}function ye(e,t,r){return e.set(Ee(e,t),r),r}function Ee(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Re=new WeakMap,we=new WeakMap,Te=new WeakMap,Pe=new WeakMap,Se=new WeakMap,xe=new WeakMap,_e=new WeakMap,Oe=function(){return e=function e(t){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ge(this,Re,P.accelerating),ge(this,we,P.interactive),ge(this,Te,P.resolution),ge(this,Pe,P.perturbance),ge(this,Se,P.dropRadius),me(this,"imageUrl",P.imageUrl),ge(this,xe,P.idleFluctuations),ge(this,_e,P.raindropsTimeInterval),me(this,"crossOrigin","no-cors"),me(this,"visible",!1),me(this,"running",!1),me(this,"lastRunningState",!1),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating,this.interactive=t.interactive,this.dropRadius=t.dropRadius,this.imageUrl=t.imageUrl,this.idleFluctuations=t.idleFluctuations,this.running=Boolean(null===(r=t.playingState)||void 0===r||r),this.crossOrigin=t.crossOrigin},(t=[{key:"accelerating",get:function(){return be(Re,this)},set:function(e){e>100||e<2||ye(Re,this,e)}},{key:"interactive",get:function(){return be(we,this)},set:function(e){(0,p.isBoolean)(e)&&ye(we,this,e)}},{key:"resolution",get:function(){return be(Te,this)},set:function(e){e<100||e>550||ye(Te,this,e)}},{key:"perturbance",get:function(){return be(Pe,this)},set:function(e){e<1e-4||e>1||ye(Pe,this,e)}},{key:"dropRadius",get:function(){return be(Se,this)},set:function(e){!isFinite(e)||e<10||ye(Se,this,e)}},{key:"idleFluctuations",get:function(){return be(xe,this)},set:function(e){(0,p.isBoolean)(e)&&ye(xe,this,e)}},{key:"raindropsTimeInterval",get:function(){return be(_e,this)},set:function(e){e<10||e>12e3||ye(_e,this,e)}},{key:"playingState",get:function(){return this.running},set:function(e){this.running=Boolean(null==e||e)}}])&&de(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function De(){var e=this,t=this.options,r=this.fadeData;r.transparentId=setTimeout((function(){if(clearTimeout(r.transparentId),r.isTransitioning)return Reflect.apply(De,e,[]);r.drawProgress=0,r.isTransitioning=!0}),2*t.raindropsTimeInterval)}function ke(){var e=this.renderData,t=this.fadeData,r=t.toBeList,n=t.drawProgress,i=t.lastDrawImage,o=t.backgroundInfo;if(!(0,p.isNull)(e)&&!(0,p.isEmptyArray)(r)){if(t.drawProgress>1e3)return t.isTransitioning=!1,t.lastDrawImage=r.shift(),Reflect.apply(ue,this,[t.lastDrawImage]),void((0,p.isEmptyArray)(r)||Reflect.apply(De,this,[]));t.drawProgress+=18;var a=document.createElement("canvas"),u=a.getContext("2d");if(!((0,p.isNull)(u)||(0,p.isNull)(i)||(0,p.isEmptyArray)(r))){var l=o.width,s=o.height;a.width=l,a.height=s,u.clearRect(0,0,l,s),u.drawImage(i,0,0,l,s),u.globalAlpha=n/1e3,u.drawImage(r[0],0,0,l,s),u.globalAlpha=1,Reflect.apply(ue,this,[a])}}}function Ae(e){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ae(e)}function Fe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,je(n.key),n)}}function Ie(e,t,r){return(t=je(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function je(e){var t=function(e){if("object"!=Ae(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ae(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ae(t)?t:t+""}var Ue=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Ie(this,"backgroundInfo",{width:0,height:0}),Ie(this,"transparentId",setTimeout(Boolean)),Ie(this,"lastDrawImage",void 0),Ie(this,"toBeList",[]),Ie(this,"drawProgress",0),Ie(this,"isTransitioning",!1);var r,n,i=t.renderData;if((0,p.isNull)(i))r=10,n=10;else{var o=getComputedStyle(i.parentElement);r=parseInt(o.width),n=parseInt(o.height)}this.backgroundInfo={width:r,height:n},this.lastDrawImage=B(r,n)},(t=[{key:"run",value:function(){this.isTransitioning||(this.drawProgress=0,this.isTransitioning=!0)}}])&&Fe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function Ce(e){return Ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ce(e)}function Ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ne(Object(r),!0).forEach((function(t){ze(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ne(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Le(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ge(n.key),n)}}function Me(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Me=function(){return!!e})()}function Xe(e){return Xe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Xe(e)}function We(e,t){return We=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},We(e,t)}function ze(e,t,r){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ge(e){var t=function(e){if("object"!=Ce(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ce(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ce(t)?t:t+""}var He=new WeakMap,Ye=function(){function e(t,r){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ze(n=function(e,t,r){return t=Xe(t),function(e,t){if(t&&("object"==Ce(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Me()?Reflect.construct(t,r||[],Xe(e).constructor):t.apply(e,r))}(this,e,[t]),"renderData",null),ze(n,"options",void 0),ze(n,"fadeData",void 0),ze(n,"defaults",P),ze(n,"initialized",!1),function(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}(n,He,(0,w.debounce)(se,{this:n})),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),n.options=new Oe(Be(Be({},n.defaults),r)),n.renderData=new Z(t,n.reloadBackground,n),n.fadeData=new Ue(n),(0,p.isFalse)(n.initState)||(0,p.isNull)(t.parentElement)||(0,p.isNull)(n.config)||(0,p.isNull)(n.gl)?n.initState=!1:(function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,s.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(t),Reflect.apply(le,n,[])),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&We(e,t)}(e,R),t=e,r=[{key:"raindropsFall",value:function(){var e=this.renderData,t=this.options,r=this.fadeData;if(!(0,p.isNull)(e)){var n=r.backgroundInfo,i=e.lastRaindropsFallTime,o=t.raindropsTimeInterval,a=t.dropRadius,u=Date.now();if(!(u-i<o)){e.lastRaindropsFallTime=u;var l=function(e){return(0,w.getRandomInt)(e)},s=n.width,f=n.height;this.drop(l(s),l(f),a,.03)}}}},{key:"drop",value:function(e,t,r,n){Reflect.apply(pe,this,[e,t,r,n])}},{key:"fade",value:function(){Reflect.apply(ke,this,[])}},{key:"reloadBackground",value:function(){var e,t;(e=He,t=this,e.get(function(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}(e,t))).call(this)}},{key:"destroy",value:function(){Reflect.apply(ce,this,[])}},{key:"show",value:function(){this.options.visible=!0,this.canvas.style.visibility="visible",Reflect.apply(X,this,[])}},{key:"hide",value:function(){this.options.visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(fe,this,[])}},{key:"pause",value:function(){this.options.running=!1}},{key:"play",value:function(){this.options.running=!0}},{key:"changePlayingState",value:function(){var e=this.options;e.running=!e.running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.options.imageUrl=t,Reflect.apply(M,this,[])):this.options[e]=t}}],r&&Le(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function qe(e,t){var r=(0,l.useRef)(null);return(0,l.useEffect)((function(){if(!(0,p.isNull)(e.current))return r.current=new Ye(e.current,t&&t.option),function(){var e,t;return null!==(e=null===(t=r.current)||void 0===t?void 0:t.destroy())&&void 0!==e?e:void 0}}),[]),r}const Ze=u.n;export{Ze as useRipples};
1
+ import*as t from"a-type-of-js";import*as e from"react";import*as r from"a-element-inline-style";import*as n from"a-js-tools";var i={362:(e,r,n)=>{var i,o;e.exports=(i={isArray:()=>t.isArray,isBoolean:()=>t.isBoolean,isEmptyArray:()=>t.isEmptyArray,isFalse:()=>t.isFalse,isNull:()=>t.isNull,isString:()=>t.isString,isZero:()=>t.isZero},o={},n.d(o,i),o)},649:(t,r,n)=>{var i,o;t.exports=(i={useEffect:()=>e.useEffect,useRef:()=>e.useRef},o={},n.d(o,i),o)}},o={};function a(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return i[t](r,r.exports,a),r.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var l={};a.d(l,{n:()=>Vt});var s=a(649);const u=(c={setStyle:()=>r.setStyle},f={},a.d(f,c),f);var c,f,h=a(362);function p(t,e,r,n){function i(t,e){var n=r.createShader(t);if(r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error("compile error: "+r.getShaderInfoLog(n));return n}var o,a={id:r.createProgram(),uniforms:{},locations:{}};if(r.attachShader(a.id,i(r.VERTEX_SHADER,t)),r.attachShader(a.id,i(r.FRAGMENT_SHADER,e)),r.linkProgram(a.id),!r.getProgramParameter(a.id,r.LINK_STATUS))throw new Error("link error: "+r.getProgramInfoLog(a.id));r.useProgram(a.id),r.enableVertexAttribArray(0);for(var l=t+e,s=/uniform (\w+) (\w+)/g;!(0,h.isNull)(o=s.exec(l));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.gl;r.activeTexture(r.TEXTURE0+(e||0)),r.bindTexture(r.TEXTURE_2D,t)}function g(t){return"rgba(0, 0, 0, 0)"===t||"#ffffffff"===t||"transport"===t}function m(t){return"none"===t||""===t}function v(){var t=this,e=function(){return t.initState=!1,null};if(!this.gl)return e();var r=this.gl,n=Object.fromEntries(["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear"].reduce((function(t,e){var n=r.getExtension(e);return n&&t.push([e,n]),t}),[]));if(!n.OES_texture_float)return e();var i=[];function o(t,e,r){var i="OES_texture_"+t,o=i+"_linear",a=o in n;return{type:e,linearSupport:a,arrayType:r,extensions:a?[i,o]:[i]}}i.push(o("float",r.FLOAT,Float32Array)),n.OES_texture_half_float&&i.push(o("half_float",n.OES_texture_half_float.HALF_FLOAT_OES,null));var a=r.createTexture(),l=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,l),r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var s=null,u=0;u<i.length;u++)if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,32,32,0,r.RGBA,i[u].type,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE){s=i[u];break}return s}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,w(n.key),n)}}function E(t,e,r){return e&&b(t.prototype,e),r&&b(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function R(t,e,r){return(e=w(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function w(t){var e=function(t){if("object"!=y(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==y(e)?e:e+""}var T=E((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),R(this,"canvas",void 0),R(this,"gl",void 0),R(this,"config",void 0),R(this,"initState",!0),this.canvas=e;var r=e.getContext("webgl");if((0,h.isNull)(r))return this.initState=!1,void(this.config=null);this.gl=r,this.config=Reflect.apply(v,this,[])}));const S=(t=>{var e={};return a.d(e,t),e})({debounce:()=>n.debounce,enArr:()=>n.enArr,getRandomInt:()=>n.getRandomInt,getRandomString:()=>n.getRandomString});var P,x={imgUrl:"",resolution:360,dropRadius:12,perturbance:.01,interactive:!0,crossOrigin:"no-cors",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function D(t){var e=function(t){if("object"!=k(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=k(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function O(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,I(n.key),n)}}function I(t){var e=function(t){if("object"!=A(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=A(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==A(e)?e:e+""}function F(t,e,r){return t.set(j(t,e),r),r}function U(t,e){return t.get(j(t,e))}function j(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function C(t){return function(t){if(Array.isArray(t))return N(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return N(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}Object.freeze(x),new(function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var e=function(){};return Object.setPrototypeOf(e,this),Object.defineProperties(e,{info:{value:function(){},configurable:!1,writable:!1},warn:{value:function(){},configurable:!1,writable:!1},error:{value:function(){},configurable:!1,writable:!1},type:{value:!1,configurable:!1,writable:!1}}),e},(e=[{key:"clear",value:function(){}}])&&_(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}())({name:"earthnut",type:!1});var B=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e={list:[],diameter:48,radius:0,cells:0};e.diameter%2!=0&&e.diameter++;var r=e.diameter,n=e.list,i=r/2;e.radius=i,e.cells=Math.pow(r,2);for(var o=0;o<r;o++){n[o]=[];for(var a=0;a<r;a++)n[o][a]=[0,0,0,0]}for(var l=0;l<=i;l++)for(var s=l;s<=i;s++){var u=n[l][s],c=function(){return(0,S.getRandomInt)(255,190)};u[0]=c(),u[1]=c(),u[2]=c(),u[3]=Math.ceil(Math.sqrt(Math.pow(l,2)+Math.pow(s,2)))<=i?(0,S.getRandomInt)(120,180):(0,S.getRandomInt)(160,240)}for(var f=0;f<=i;f++)for(var h=0;h<=f;h++)n[f][h]=n[h][f];for(var p=i;p<r;p++)for(var d=0;d<=i;d++)n[p][d]=n[r-p][d];for(var g=0;g<i;g++)for(var m=i;m<r;m++)n[g][m]=n[g][r-m];for(var v=i;v<r;v++)for(var y=i;y<r;y++)n[v][y]=n[v][r-y];var b=t%r;return e.list=[].concat(C(n.slice(b)),C(n.slice(0,b))),e},L=new(P=new WeakMap,function(){return t=function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,P,1),e=this,r="data",n=B(),(r=I(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n},(e=[{key:"build",value:function(){U(P,this)>100&&F(P,this,0),this.data=B(F(P,this,U(P,this)+3))}}])&&O(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}());function M(t,e){var r=document.createElement("canvas"),n=document.createElement("canvas"),i=r.getContext("2d"),o=n.getContext("2d");return(0,h.isNull)(i)||(0,h.isNull)(o)?r:(r.width=n.width=t,r.height=n.height=e,i.clearRect(0,0,t,e),o.clearRect(0,0,t,e),i.globalAlpha=1,i.putImageData(function(t,e){Date.now();for(var r=new ImageData(t,e),n=r.data,i=L.data,o=i.diameter,a=i.list,l=t*o,s=0;s<n.length;s+=4){var u=s/4%l,c=u%t%o,f=Math.floor(u/t),h=a[c][f];n[s]=h[0],n[s+1]=h[1],n[s+2]=h[2],n[s+3]=h[3]}return r}(t,e),0,0),o.fillStyle="#ffffff",o.fillRect(0,0,t,e),o.drawImage(r,0,0,t,e),o.globalCompositeOperation="source-over",n)}function X(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.fadeData,r=e.backgroundInfo,n=e.toBeList,i=r.width,o=r.height,a=(0,S.getRandomString)({length:8,includeNumbers:!0,includeUppercaseLetters:!0});L.build(),n.push({resource:M(i,o),width:i,height:o,kind:"default",tag:a}),t&&e.run()}function W(){var t=this.renderData,e=this.fadeData,r=this.options;if((0,h.isNull)(t))return Reflect.apply(X,this,[]);var n=t.originStyle;if(g(n.backgroundColor)&&(!(0,h.isArray)(r.imgUrl)||1!==r.imgUrl.length))return Reflect.apply(X,this,[]);var i=document.createElement("canvas"),o=i.getContext("2d");if((0,h.isNull)(o))return Reflect.apply(X,this,[]);var a=e.backgroundInfo,l=a.width,s=a.height;i.width=l,i.height=s,o.clearRect(0,0,l,s);var u=(0,h.isArray)(r.imgUrl)&&1===r.imgUrl.length&&r.imgUrl[0]||n.backgroundColor;o.beginPath(),o.fillStyle=u,o.fillRect(0,0,l,s),o.fill(),e.isTransitioning?e.toBeList=[e.toBeList[0]]:e.toBeList=[];var c={resource:i,kind:"background-color",tag:u,width:l,height:s};e.toBeList.push(c),e.run()}function G(){var t=this.fadeData,e=this.renderData,r=this.options;if((0,h.isNull)(e))return Reflect.apply(W,this,[]);var n=e.originStyle;if(!/linear-gradient\(.*\)/.test(n.backgroundImage)&&!(0,h.isArray)(r.imgUrl))return Reflect.apply(W,this,[]);var i=(0,h.isArray)(r.imgUrl)&&r.imgUrl.length>1&&r.imgUrl||n.backgroundImage.replace(/^.*linear-gradient\((.*)\).*$/,"$1").split("),").map((function(t){return(t=t.trim()).endsWith(")")||(t+=")"),t})).filter((function(t){return t.startsWith("rgb")||t.startsWith("#")}));if(i.length<2)return Reflect.apply(W,this,[]);var o=document.createElement("canvas"),a=o.getContext("2d");if((0,h.isNull)(a))return Reflect.apply(W,this,[]);var l=t.backgroundInfo,s=l.width,u=l.height;o.width=s,o.height=u,a.fillStyle="#fff",a.fillRect(0,0,s,u);var c=a.createLinearGradient(0,0,0,u);i.forEach((function(t,e){return c.addColorStop(e/(i.length-1),t)})),a.fillStyle=c,a.fillRect(0,0,s,u),t.isTransitioning?t.toBeList=[t.toBeList[0]]:t.toBeList=[],t.toBeList.push({resource:o,kind:"linear-gradient",tag:i.join("_"),width:s,height:u}),t.run()}function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function H(){var t=this,e=this.renderData,r=this.options,n=this.fadeData;if((0,h.isNull)(e))Reflect.apply(G,this,[]);else{var i,o,a=e.lastUseStyle,l=n.backgroundInfo,s=l.width,u=l.height,c=(0,h.isString)(r.imgUrl)&&r.imgUrl||(i=a.backgroundImage,o=/url\(["']?([^"']*)["']?\)/.exec(i),(0,h.isNull)(o)?null:o[1]);if(e.imageSource=c,c){var f=function(t,e,r){var n=new Image(e,r);return n.width=e,n.height=r,n.src=t,n}(c,s,u);f.onload=function(){var t;clearTimeout(n.transparentId),n.isTransitioning?n.toBeList=[n.toBeList[0]].concat(function(t){if(Array.isArray(t))return z(t)}(t=n.toBeList.slice(1).filter((function(t){return"image"===t.kind&&(Math.abs(t.width-s)>2||Math.abs(t.height-u)>2||t.tag!==c)})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):n.toBeList=[],n.toBeList.push({resource:f,width:s,height:u,kind:"image",tag:c}),n.run()},f.onerror=function(){Reflect.apply(G,t,[])},f.crossOrigin=r.crossOrigin}else Reflect.apply(G,this,[])}}function Y(){var t=this.renderData;if(!(0,h.isNull)(t)){var e=t.parentElement;e&&[["background-image","none"],["background-color","transparent"]].forEach((function(t){return e.style.setProperty(t[0],t[1],"important")}))}}function q(t){var e=window.getComputedStyle(t),r=t.style;return{inlineBackground:r.background,inlineBackgroundColor:r.backgroundColor,inlineBackgroundImage:r.backgroundImage,backgroundColor:e.backgroundColor,backgroundImage:e.backgroundImage,backgroundSize:e.backgroundSize,backgroundPosition:e.backgroundPosition,backgroundRepeat:e.backgroundRepeat,backgroundClip:e.backgroundClip,backgroundOrigin:e.backgroundOrigin,backgroundAttachment:e.backgroundAttachment,position:e.position,width:parseInt(e.width),height:parseInt(e.height)}}function $(){var t=this.renderData;if(!(0,h.isNull)(t)){var e=t.parentElement,r=t.originStyle;e.style.setProperty("background-image",r.inlineBackgroundImage),e.style.setProperty("background-color",r.inlineBackgroundColor)}}function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function K(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,J(n.key),n)}}function V(t,e,r){return(e=J(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function J(t){var e=function(t){if("object"!=Z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Z(e)?e:e+""}var Q=function(){return t=function t(e,r,n){var i,o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),V(this,"quad",null),V(this,"lastRaindropsFallTime",0),V(this,"parentElement",void 0),V(this,"mutationObserver",void 0),V(this,"resizeObserver",void 0),V(this,"renderProgram",void 0),V(this,"imageSource",""),V(this,"dropProgram",void 0),V(this,"updateProgram",void 0),V(this,"textures",[]),V(this,"backgroundTexture",[]),V(this,"textureDelta",void 0),V(this,"framebuffers",[]),V(this,"bufferWriteIndex",0),V(this,"bufferReadIndex",1),V(this,"originStyle",void 0),V(this,"lastUseStyle",void 0),V(this,"events",{}),V(this,"animationFrameId",0),this.parentElement=null!==(i=e.parentElement)&&void 0!==i?i:document.body,Reflect.apply(Y,n,[]),this.originStyle=this.lastUseStyle=q(this.parentElement),this.mutationObserver=new MutationObserver((function(t){t.forEach((function(t){if(t.target===o.parentElement&&"attributes"===t.type&&n.options.visible){var e=Object.values(o.lastUseStyle),i=q(o.parentElement),a=Object.values(i);if((0,h.isEmptyArray)(S.enArr.difference(e,a)))return;var l=m(i.backgroundImage),s=g(i.backgroundColor);if(l&&s)return;o.lastUseStyle=i,Reflect.apply(r,n,[]),Reflect.apply(Y,n,[])}}))})),this.mutationObserver.observe(this.parentElement,{subtree:!0,attributes:!0,attributeFilter:["class","style"]}),this.resizeObserver=new ResizeObserver((function(t){t.forEach((function(t){if(t.target===o.parentElement){var e=q(o.parentElement);Math.abs(e.width-o.originStyle.width)<3&&Math.abs(e.height-o.originStyle.height)<3||Reflect.apply(r,n,[])}}))})),this.resizeObserver.observe(this.parentElement)},e=[{key:"destroy",value:function(){if(this.animationFrameId&&window.cancelAnimationFrame(this.animationFrameId),Reflect.apply($,{renderData:this},[]),this.parentElement&&this.events){var t,e,r,n=this.parentElement,i=this.events;Object.keys(i).forEach((function(t){return n.removeEventListener&&n.removeEventListener(t,i[t])})),n.removeAttribute&&n.removeAttribute("data-ripples"),null===(t=this.mutationObserver)||void 0===t||t.takeRecords(),null===(e=this.mutationObserver)||void 0===e||e.disconnect(),this.mutationObserver=null,null===(r=this.resizeObserver)||void 0===r||r.disconnect(),this.resizeObserver=null}}}],e&&K(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function tt(){var t=this.renderData,e=this.fadeData;if(!(0,h.isNull)(t)){var r,n,i,o=t.parentElement,a=window.getComputedStyle(o),l=a.backgroundSize,s=a.backgroundAttachment,u=a.backgroundPosition,c=/\s+/.test(r=u)?r.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):et(r)?[r,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[r],f={left:0,top:0,width:0,height:0};"fixed"===s?(f.height=window.innerHeight,f.left=window.screenX,f.top=window.screenY,f.width=window.innerWidth):(f.left=0,f.top=0,f.width=o.scrollWidth,f.height=o.scrollHeight);var p=e.backgroundInfo||{width:100,height:100},d=p.width,g=p.height;if("cover"===l){var m=Math.max(f.width/d,f.height/g);n=d*m,i=g*m}else if("contain"===l){var v=Math.min(f.width/d,f.height/g);n=d*v,i=g*v}else{var y=l.split(" ");n=y[0]||"",i=y[1]||n,et(n)?n=f.width*parseFloat(n)/100:"auto"!==n&&(n=parseFloat(n)),et(i)?i=f.height*parseFloat(i)/100:"auto"!==i&&(i=parseFloat(i)),"auto"===n&&"auto"===i?(n=d,i=g):("auto"===n&&(n=d*(Number(i)/g)),"auto"===i&&(i=g*(Number(n)/d)))}var b=c&&c[0]||"0%",E=c&&c[1]||"0%";b=et(b)?(f.left+(f.width-Number(n))*parseFloat(b)/100).toString():(f.left+parseFloat(b)).toString(),E=et(E)?(f.top+(f.height-Number(i))*parseFloat(E)/100).toString():(f.top+parseFloat(E)).toString(),t.renderProgram.uniforms.topLeft=new Float32Array([(o.offsetLeft-Number(b))/n,(o.offsetTop-Number(E))/i]),t.renderProgram.uniforms.bottomRight=new Float32Array([t.renderProgram.uniforms.topLeft[0]+o.clientWidth/n,t.renderProgram.uniforms.topLeft[1]+o.clientHeight/i]);var R=Math.max(this.canvas.width,this.canvas.height);t.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/R,this.canvas.height/R])}}function et(t){return t.endsWith("%")}function rt(){var t=this.gl,e=this.renderData;(0,h.isNull)(e)||(t.bindBuffer(t.ARRAY_BUFFER,e.quad),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,0),t.drawArrays(t.TRIANGLE_FAN,0,4))}function nt(){var t=this.gl,e=this.renderData,r=this.options;if(!(0,h.isNull)(e)){var n=e.textures,i=e.backgroundTexture,o=r.perturbance;t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,this.canvas.width,this.canvas.height),t.enable(t.BLEND),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.useProgram(e.renderProgram.id),Reflect.apply(d,this,[i,0]),Reflect.apply(d,this,[n[0],1]),t.uniform1f(e.renderProgram.locations.perturbance,o),t.uniform2fv(e.renderProgram.locations.topLeft,e.renderProgram.uniforms.topLeft),t.uniform2fv(e.renderProgram.locations.bottomRight,e.renderProgram.uniforms.bottomRight),t.uniform2fv(e.renderProgram.locations.containerRatio,e.renderProgram.uniforms.containerRatio),t.uniform1i(e.renderProgram.locations.samplerBackground,0),t.uniform1i(e.renderProgram.locations.samplerRipples,1),Reflect.apply(rt,this,[]),t.disable(t.BLEND)}}function it(){var t=this.renderData;if(!(0,h.isNull)(t)){var e=t.bufferWriteIndex,r=t.bufferReadIndex;t.bufferWriteIndex=1-e,t.bufferReadIndex=1-r}}function ot(){var t=this.gl,e=this.renderData,r=this.options;if(!(0,h.isNull)(e)){var n=e.updateProgram,i=e.textures,o=e.framebuffers,a=e.bufferWriteIndex,l=e.bufferReadIndex,s=r.resolution;t.viewport(0,0,s,s),t.bindFramebuffer(t.FRAMEBUFFER,o[a]),Reflect.apply(d,this,[i[l]]),t.useProgram(n.id),Reflect.apply(rt,this,[]),Reflect.apply(it,this,[])}}function at(){var t=this,e=this.renderData,r=this.options,n=this.fadeData;if(!(0,h.isNull)(e)){var i=e.parentElement,o=n.isTransitioning,a=r.running,l=r.idleFluctuations,s=r.lastRunningState,u=getComputedStyle(i);n.backgroundInfo={width:parseInt(u.width),height:parseInt(u.height)},Reflect.apply(tt,this,[]),a?(s||(r.lastRunningState=!0,this.show()),l&&this.raindropsFall(),o&&this.fade(),Reflect.apply(ot,this,[]),Reflect.apply(nt,this,[])):s&&(r.lastRunningState=!1,this.hide()),e.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(at,t,[])}))}}function lt(t,e,r){var n=this.renderData;if(!(0,h.isNull)(n)){var i=n.parentElement,o=window.getComputedStyle(i),a=parseInt(o.borderLeftWidth)||0,l=parseInt(o.borderTopWidth)||0,s=i.getBoundingClientRect(),u=t.clientX-s.left-a,c=t.clientY-s.top-l;this.drop(u,c,e,r)}}function st(){var t=this,e=this.renderData,r=this.options;if(!(0,h.isNull)(e)){var n=e.parentElement,i=e.events,o=function(n){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r.visible&&r.running&&r.interactive&&(e.lastRaindropsFallTime=Date.now(),Reflect.apply(lt,t,[n,r.dropRadius*(i?1.5:1),i?.03:.01]))};i.mousemove=function(t){for(var e=r.accelerating;e--;)o(t)},i.touchmove=i.touchstart=function(t){for(var e=t.touches,r=0;r<e.length;r++)o(e[r])},i.mousedown=function(t){return o(t,!0)},Object.keys(i).forEach((function(t){return null==n?void 0:n.addEventListener(t,i[t],{passive:!0})}))}}var ut="\n attribute vec2 vertex;\n varying vec2 coord;\n void main() {\n coord = vertex * 0.5 + 0.5;\n gl_Position = vec4(vertex, 0.0, 1.0);\n }";function ct(){var t=this.gl,e=this.renderData;if(!(0,h.isNull)(e)){var r=e.textureDelta;e.dropProgram=p(ut,"precision highp float;\n\n const float PI = 3.141592653589793;\n uniform sampler2D texture;\n uniform vec2 center;\n uniform float radius;\n uniform float strength;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n\n float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\n drop = 0.5 - cos(drop * PI) * 0.5;\n info.r += drop * strength;\n gl_FragColor = info;\n }",t);var n=e.updateProgram=p(ut,"\n precision highp float;\n\n uniform sampler2D texture;\n uniform vec2 delta;\n\n varying vec2 coord;\n\n void main() {\n vec4 info = texture2D(texture, coord);\n \n vec2 dx = vec2(delta.x, 0.0);\n vec2 dy = vec2(0.0, delta.y);\n \n float average = (\n texture2D(texture, coord - dx).r +\n texture2D(texture, coord - dy).r +\n texture2D(texture, coord + dx).r +\n texture2D(texture, coord + dy).r\n ) * 0.25;\n \n info.g += (average - info.r) * 2.0;\n info.g *= 0.995;\n info.r += info.g;\n \n gl_FragColor = info;\n }\n ",this.gl);t.uniform2fv(n.locations.delta,r),e.renderProgram=p("\n precision highp float;\n\n attribute vec2 vertex;\n uniform vec2 topLeft;\n uniform vec2 bottomRight;\n uniform vec2 containerRatio;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n void main() {\n backgroundCoord = mix(topLeft, bottomRight, vertex * 0.5 + 0.5);\n backgroundCoord.y = 1.0 - backgroundCoord.y;\n ripplesCoord = vec2(vertex.x, -vertex.y) * containerRatio * 0.5 + 0.5;\n gl_Position = vec4(vertex.x, -vertex.y, 0.0, 1.0);\n }\n ","\n precision highp float;\n\n uniform sampler2D samplerBackground;\n uniform sampler2D samplerRipples;\n uniform vec2 delta;\n\n uniform float perturbance;\n varying vec2 ripplesCoord;\n varying vec2 backgroundCoord;\n\n void main() {\n float height = texture2D(samplerRipples, ripplesCoord).r;\n float heightX = texture2D(samplerRipples, vec2(ripplesCoord.x + delta.x, ripplesCoord.y)).r;\n float heightY = texture2D(samplerRipples, vec2(ripplesCoord.x, ripplesCoord.y + delta.y)).r;\n vec3 dx = vec3(delta.x, heightX - height, 0.0);\n vec3 dy = vec3(0.0, heightY - height, delta.y);\n vec2 offset = -normalize(cross(dy, dx)).xz;\n float specular = pow(max(0.0, dot(offset, normalize(vec2(-0.6, 1.0)))), 4.0);\n gl_FragColor = texture2D(samplerBackground, backgroundCoord + offset * perturbance) + specular;\n }",t),t.uniform2fv(e.renderProgram.locations.delta,r)}}function ft(){var t=this.gl,e=this.renderData;if(!(0,h.isNull)(e)){var r=e.backgroundTexture=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,1),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR)}}function ht(t){var e=this.gl,r=this.renderData,n=this.fadeData;if(!(0,h.isNull)(r)){var i=r.backgroundTexture,o=n.backgroundInfo,a=o.width,l=o.height,s=function(t){return(0,h.isZero)(t&t-1)},u=s(a)&&s(l)?e.REPEAT:e.CLAMP_TO_EDGE;e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,u),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,u),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.resource)}}function pt(){var t=this,e=this.renderData,r=this.options,n=this.fadeData;if(!(0,h.isNull)(e)&&this.config){var i=e.textures,o=e.framebuffers,a=r.resolution,l=this.gl,s=1/a;e.textureDelta=new Float32Array([s,s]),this.config.extensions.forEach((function(t){return l.getExtension(t)}));for(var u=this.config.arrayType,c=u?new u(a*a*4):null,f=this.config,p=0;p<2;p++){var d=l.createTexture(),g=l.createFramebuffer();l.bindFramebuffer(l.FRAMEBUFFER,g),l.bindTexture(l.TEXTURE_2D,d),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,f.linearSupport?l.LINEAR:l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,f.linearSupport?l.LINEAR:l.NEAREST),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,a,a,0,l.RGBA,f.type,c),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,d,0),i.push(d),o.push(g)}e.quad=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,e.quad),l.bufferData(l.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),l.STATIC_DRAW),Reflect.apply(ct,this,[]),Reflect.apply(ft,this,[]),Reflect.apply(H,this,[]),l.clearColor(0,0,0,0),l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA),r.visible=!0,r.running=!0,Reflect.apply(st,this,[]),Reflect.apply(ht,this,[n.lastDrawImage]),e.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(at,t,[])}))}}function dt(){var t=this.renderData,e=this.fadeData;if(!(0,h.isNull)(t)){var r=t.parentElement,n=e.backgroundInfo,i=r.offsetWidth,o=r.offsetHeight;this.canvas.width=n.width=i,this.canvas.height=n.height=o,Reflect.apply(H,this,[])}}function gt(){var t=this.renderData,e=this.fadeData;(0,h.isNull)(t)||(t.destroy(),Object.keys(t).forEach((function(e){return t[e]=null})),this.renderData=null),e.destroy(),Object.keys(e).forEach((function(t){return e[t]=null})),this.fadeData=null,this.gl&&(this.gl=null)}function mt(t,e,r,n){var i=this.renderData,o=this.options,a=this.gl;if(!(0,h.isNull)(i)){var l=i.parentElement,s=i.dropProgram,u=i.textures,c=i.framebuffers,f=i.bufferWriteIndex,p=i.bufferReadIndex,g=o.resolution,m=l.offsetWidth,v=l.offsetHeight,y=Math.max(m,v);r/=y;var b=new Float32Array([(2*t-m)/y,(v-2*e)/y]);a.viewport(0,0,g,g),a.bindFramebuffer(a.FRAMEBUFFER,c[f]),Reflect.apply(d,this,[u[p]]),a.useProgram(s.id),a.uniform2fv(s.locations.center,b),a.uniform1f(s.locations.radius,r),a.uniform1f(s.locations.strength,n),Reflect.apply(rt,this,[]),Reflect.apply(it,this,[])}}function vt(t){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vt(t)}function yt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function bt(t,e,r){return(e=Et(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Et(t){var e=function(t){if("object"!=vt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vt(e)?e:e+""}function Rt(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}function wt(t,e){return t.get(St(t,e))}function Tt(t,e,r){return t.set(St(t,e),r),r}function St(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}var Pt=new WeakMap,xt=new WeakMap,kt=new WeakMap,_t=new WeakMap,Dt=new WeakMap,At=new WeakMap,Ot=new WeakMap,It=function(){return t=function t(e){var r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Rt(this,Pt,x.accelerating),Rt(this,xt,x.interactive),Rt(this,kt,x.resolution),Rt(this,_t,x.perturbance),Rt(this,Dt,x.dropRadius),bt(this,"imgUrl",x.imgUrl),Rt(this,At,x.idleFluctuations),Rt(this,Ot,x.raindropsTimeInterval),bt(this,"crossOrigin","no-cors"),bt(this,"visible",!1),bt(this,"running",!1),bt(this,"lastRunningState",!1),this.perturbance=e.perturbance,this.resolution=e.resolution,this.raindropsTimeInterval=e.raindropsTimeInterval,this.accelerating=e.accelerating,this.interactive=e.interactive,this.dropRadius=e.dropRadius,this.imgUrl=e.imgUrl,this.idleFluctuations=e.idleFluctuations,this.running=Boolean(null===(r=e.playingState)||void 0===r||r),this.crossOrigin=e.crossOrigin},(e=[{key:"accelerating",get:function(){return wt(Pt,this)},set:function(t){t>100||t<2||Tt(Pt,this,t)}},{key:"interactive",get:function(){return wt(xt,this)},set:function(t){(0,h.isBoolean)(t)&&Tt(xt,this,t)}},{key:"resolution",get:function(){return wt(kt,this)},set:function(t){t<100||t>550||Tt(kt,this,t)}},{key:"perturbance",get:function(){return wt(_t,this)},set:function(t){t<1e-4||t>1||Tt(_t,this,t)}},{key:"dropRadius",get:function(){return wt(Dt,this)},set:function(t){!isFinite(t)||t<10||Tt(Dt,this,t)}},{key:"idleFluctuations",get:function(){return wt(At,this)},set:function(t){(0,h.isBoolean)(t)&&Tt(At,this,t)}},{key:"raindropsTimeInterval",get:function(){return wt(Ot,this)},set:function(t){t<10||t>12e3||Tt(Ot,this,t)}},{key:"playingState",get:function(){return this.running},set:function(t){this.running=Boolean(null==t||t)}}])&&yt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Ft(){var t=this,e=this.options,r=this.fadeData;r.transparentId=setTimeout((function(){if(clearTimeout(r.transparentId),r.isTransitioning)return Reflect.apply(Ft,t,[]);"image"!==r.lastDrawImage.kind&&r.run()}),2*e.raindropsTimeInterval)}function Ut(){var t=this.renderData,e=this.fadeData,r=this.options,n=e.toBeList;if((0,h.isNull)(t))return e.isTransitioning=!1,void Reflect.apply(Ft,this,[]);if((0,h.isEmptyArray)(n))return e.isTransitioning=!1,void Reflect.apply(Ft,this,[]);if(0===e.drawProgress&&n.forEach((function(t){})),e.drawProgress>1e3)if(e.isTransitioning=!1,e.lastDrawImage=n.shift(),Reflect.apply(ht,this,[e.lastDrawImage]),(0,h.isEmptyArray)(n)){var i=t.lastUseStyle;(0,h.isNull)(r.imgUrl)&&g(i.backgroundColor)&&m(i.backgroundImage)&&(Reflect.apply(X,this,[!1]),Reflect.apply(Ft,this,[]))}else Reflect.apply(Ft,this,[]);else{var o=e.lastDrawImage,a=e.backgroundInfo;e.drawProgress+=18;var l=document.createElement("canvas"),s=l.getContext("2d");if(!((0,h.isNull)(s)||(0,h.isNull)(o.resource)||(0,h.isEmptyArray)(n))){var u=a.width,c=a.height;l.width=u,l.height=c,s.clearRect(0,0,u,c),s.drawImage(o.resource,0,0,u,c),s.globalAlpha=e.drawProgress/1e3,s.drawImage(n[0].resource,0,0,u,c),s.globalAlpha=1;var f={resource:l,width:u,height:c,kind:"mix",tag:"".concat(o.tag," >> ").concat(n[0].tag)};Reflect.apply(ht,this,[f]),n.length>1&&(e.lastDrawImage=f,n.shift(),e.drawProgress=0)}}}function jt(t){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(t)}function Ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Bt(n.key),n)}}function Nt(t,e,r){return(e=Bt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bt(t){var e=function(t){if("object"!=jt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jt(e)?e:e+""}var Lt=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Nt(this,"backgroundInfo",{width:0,height:0}),Nt(this,"transparentId",setTimeout(Boolean)),Nt(this,"lastDrawImage",void 0),Nt(this,"toBeList",[]),Nt(this,"drawProgress",0),Nt(this,"isTransitioning",!1);var r,n,i=e.renderData;if((0,h.isNull)(i))r=10,n=10;else{var o=getComputedStyle(i.parentElement);r=parseInt(o.width),n=parseInt(o.height)}this.backgroundInfo={width:r,height:n},this.lastDrawImage={resource:M(r,n),width:r,height:n,kind:"default",tag:""}},(e=[{key:"run",value:function(){this.isTransitioning||(this.drawProgress=0,this.isTransitioning=!0)}},{key:"destroy",value:function(){this.transparentId&&clearTimeout(this.transparentId)}}])&&Ct(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Mt(t){return Mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mt(t)}function Xt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Wt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Xt(Object(r),!0).forEach((function(e){qt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Gt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$t(n.key),n)}}function zt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(zt=function(){return!!t})()}function Ht(t){return Ht=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ht(t)}function Yt(t,e){return Yt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yt(t,e)}function qt(t,e,r){return(e=$t(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $t(t){var e=function(t){if("object"!=Mt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Mt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mt(e)?e:e+""}var Zt=new WeakMap,Kt=function(){function t(e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),qt(n=function(t,e,r){return e=Ht(e),function(t,e){if(e&&("object"==Mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,zt()?Reflect.construct(e,r||[],Ht(t).constructor):e.apply(t,r))}(this,t,[e]),"renderData",null),qt(n,"options",void 0),qt(n,"fadeData",void 0),qt(n,"defaults",x),qt(n,"initialized",!1),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(n,Zt,(0,S.debounce)(dt,{this:n})),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),n.options=new It(Wt(Wt({},n.defaults),r)),n.renderData=new Q(e,n.reloadBackground,n),n.fadeData=new Lt(n),(0,h.isFalse)(n.initState)||(0,h.isNull)(e.parentElement)||(0,h.isNull)(n.config)||(0,h.isNull)(n.gl)?n.initState=!1:(function(t){var e=t.parentElement;t.width=e.clientWidth,t.height=e.clientHeight,(0,u.setStyle)(t,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(e),Reflect.apply(pt,n,[])),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yt(t,e)}(t,T),e=t,r=[{key:"raindropsFall",value:function(){var t=this.renderData,e=this.options,r=this.fadeData;if(!(0,h.isNull)(t)){var n=r.backgroundInfo,i=t.lastRaindropsFallTime,o=e.raindropsTimeInterval,a=e.dropRadius,l=Date.now();if(!(l-i<o)){t.lastRaindropsFallTime=l;var s=function(t){return(0,S.getRandomInt)(t)},u=n.width,c=n.height;this.drop(s(u),s(c),a,.03)}}}},{key:"drop",value:function(t,e,r,n){Reflect.apply(mt,this,[t,e,r,n])}},{key:"fade",value:function(){Reflect.apply(Ut,this,[])}},{key:"reloadBackground",value:function(){var t,e;(t=Zt,e=this,t.get(function(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(t,e))).call(this)}},{key:"destroy",value:function(){Reflect.apply(gt,this,[])}},{key:"show",value:function(){this.options.visible=!0,this.canvas.style.visibility="visible",Reflect.apply(Y,this,[])}},{key:"hide",value:function(){this.options.visible=!1,this.canvas.style.visibility="hidden",Reflect.apply($,this,[])}},{key:"pause",value:function(){this.options.running=!1}},{key:"play",value:function(){this.options.running=!0}},{key:"changePlayingState",value:function(){var t=this.options;t.running=!t.running}},{key:"set",value:function(t,e){"imgUrl"===t?(this.options.imgUrl=e,Reflect.apply(H,this,[])):this.options[t]=e}}],r&&Gt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();function Vt(t,e){var r=(0,s.useRef)(null);return(0,s.useEffect)((function(){if(!(0,h.isNull)(t.current))return r.current=new Kt(t.current,e&&e.option),function(){var t,e;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.destroy())&&void 0!==t?t:void 0}}),[]),r}const Jt=l.n;export{Jt as useRipples};