oops-ui 0.0.12 → 0.0.13

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.
@@ -0,0 +1 @@
1
+ import*as e from"a-element-inline-style";import*as t from"react";var r={463:(t,r,n)=>{n.d(r,{n:()=>re});var i=n(649);const o=(a={setStyle:()=>e.setStyle},l={},n.d(l,a),l);var a,l;function s(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 l=e+t,s=/uniform (\w+) (\w+)/g;null!==(o=s.exec(l));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function u(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 c(){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(),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 f(e){return f="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},f(e)}function p(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,m(n.key),n)}}function h(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var g="lmssee_ripper_element_style",v=h((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,"styleElement",document.createElement("style")),d(this,"canvas",void 0),d(this,"gl",void 0),d(this,"config",void 0),d(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),d(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(g))){var n=this.styleElement;n.id=g,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(c,this,[])})),y={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function b(e){return b="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},b(e)}function E(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,x(n.key),n)}}function R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t,r){return(t=x(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}Object.freeze(y);var _=R((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),T(this,"visible",!1),T(this,"running",!1),T(this,"perturbance",void 0),T(this,"resolution",void 0),T(this,"raindropsTimeInterval",void 0),T(this,"animationFrameId",0),T(this,"quad",null),T(this,"lastRaindropsFallTime",0),T(this,"parentElement",null),T(this,"backgroundInfo",{width:0,height:0}),T(this,"dropProgram",null),T(this,"updateProgram",null),T(this,"textures",[]),T(this,"backgroundTexture",[]),T(this,"textureDelta",null),T(this,"framebuffers",[]),T(this,"bufferWriteIndex",0),T(this,"bufferReadIndex",1),T(this,"originalInlineCss",""),T(this,"originalCssBackgroundImage",""),T(this,"events",{}),T(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),w={};function P(){var e=this.gl,t=w[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function S(){var e=w[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function F(){var e=(w[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=w[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function A(){var e=w[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function O(){var e=this,t=this.gl,r=w[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||D(o)||D(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(F,e,[])},l.onerror=function(){return Reflect.apply(I,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(I,this,[])}function I(){var e=this.gl,t=w[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function D(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function U(){var e,t,r,n=w[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):k(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),s={left:0,top:0,width:0,height:0};if("fixed"==a)s.height=window.innerHeight,s.left=window.screenX,s.top=window.screenY,s.width=window.innerWidth;else{var u=i.getBoundingClientRect();s.left=u.left,s.top=u.top,s.width=i.scrollWidth,s.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(s.width/f,s.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(s.width/f,s.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,k(t)?t=s.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),k(r)?r=s.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var g=l&&l[0]||"0%",v=l&&l[1]||"0%";g=k(g)?(s.left+(s.width-Number(t))*parseFloat(g)/100).toString():(s.left+parseFloat(g)).toString(),v=k(v)?(s.top+(s.height-Number(r))*parseFloat(v)/100).toString():(s.top+parseFloat(v)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(g))/t,(i.offsetTop-Number(v))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function k(e){return e.endsWith("%")}function C(){var e=this.gl,t=w[this.sole],r=t.perturbance,n=t.textures,i=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(u,this,[i,0]),Reflect.apply(u,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(P,this,[]),e.disable(e.BLEND)}function L(){var e=this.gl,t=w[this.sole],r=t.resolution,n=t.updateProgram,i=t.textures,o=t.framebuffers,a=t.bufferWriteIndex,l=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,o[a]),Reflect.apply(u,this,[i[l]]),e.useProgram(n.id),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}function j(){var e=this,t=w[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(U,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(L,this,[]),Reflect.apply(C,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}function B(e,t,r){var n=w[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),s=e.clientX-l.left-o,u=e.clientY-l.top-a;this.drop(s,u,t,r)}function X(){var e=this,t=w[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(B,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var M="\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 N(){var e=this.gl,t=w[this.sole],r=t.textureDelta;t.dropProgram=s(M,"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=s(M,"\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),this.renderProgram=s("\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(this.renderProgram.locations.delta,r)}function W(){var e=this.gl,t=w[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 G(){var e=this;if(this.config){var t=w[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,s=l?new l(r*r*4):null,u=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,u.type,s),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(N,this,[]),Reflect.apply(W,this,[]),Reflect.apply(I,this,[]),Reflect.apply(O,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(X,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}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 H(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 Y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){Z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(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 K(e,t){if(t&&("object"==z(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)}function V(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(V=function(){return!!e})()}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function Z(e,t,r){return(t=$(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $(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 ee=new WeakMap,te=function(e){function t(e,r){var n,i,a,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,l=[e],a=J(a=t),Z(n=K(i,V()?Reflect.construct(a,l||[],J(i).constructor):a.apply(i,l)),"sole",Symbol("ripple")),Z(n,"defaults",y),Z(n,"interactive",n.defaults.interactive),Z(n,"dropRadius",void 0),Z(n,"crossOrigin",""),Z(n,"imageUrl",void 0),Z(n,"idleFluctuations",!0),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,ee,!1),Z(n,"imageSource",""),Z(n,"renderProgram",void 0),console.log("初始化参数",r),w[n.sole]=new _(y),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var s=Y(Y({},n.defaults),r);return n.accelerating=s.accelerating,n.dropRadius=s.dropRadius,n.resolution=s.resolution,n.interactive=s.interactive,n.perturbance=s.perturbance,n.crossOrigin=s.crossOrigin,n.imageUrl=s.imageUrl,n.idleFluctuations=s.idleFluctuations,n.playingState=s.playingState,n.raindropsTimeInterval=s.raindropsTimeInterval,!1===n.initState||null===e.parentElement||null===n.config||null===n.gl?(n.initState=!1,K(n)):(w[n.sole].parentElement=e.parentElement,function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,o.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(e),Reflect.apply(G,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&&Q(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||(w[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(w[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(w[this.sole].perturbance=e)}},{key:"playingState",set:function(e){w[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=ee).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(w[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=w[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=w[this.sole],a=o.resolution,l=o.parentElement,s=o.dropProgram,c=o.textures,f=o.framebuffers,p=o.bufferWriteIndex,h=o.bufferReadIndex,d=l.offsetWidth,m=l.offsetHeight,g=Math.max(d,m);r/=g;var v=new Float32Array([(2*e-d)/g,(m-2*t)/g]);i.viewport(0,0,a,a),i.bindFramebuffer(i.FRAMEBUFFER,f[p]),Reflect.apply(u,this,[c[h]]),i.useProgram(s.id),i.uniform2fv(s.locations.center,v),i.uniform1f(s.locations.radius,r),i.uniform1f(s.locations.strength,n),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}},{key:"updateSize",value:function(){var e=w[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){w[this.sole].animationFrameId&&window.cancelAnimationFrame(w[this.sole].animationFrameId);var e=w[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(A,this,[]);var n=w[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),w[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){w[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(F,this,[])}},{key:"hide",value:function(){w[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(A,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!w[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(O,this,[])):this[e]=t}}],n&&q(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(v);function re(e,t){var r=(0,i.useRef)(null);return(0,i.useEffect)((function(){var n=e.current;return r.current=new te(n,t&&t.option),function(){return r.current&&r.current.destroy()||void 0}}),[]),r}},649:(e,r,n)=>{var i,o;e.exports=(i={default:()=>t.default,useEffect:()=>t.useEffect,useRef:()=>t.useRef},o={},n.d(o,i),o)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};i.d(o,{z:()=>s});var a=i(649),l=i(463);function s(e){var t=(0,a.useRef)(null);return function(e,t){(0,a.useEffect)((function(){if(t.option&&e.current){var r=t.option;Object.keys(e.current.defaults).forEach((function(t){void 0!==r[t]&&e.current&&e.current.set(t,r[t])}))}}),[t.option])}((0,l.n)(t,e),e),a.default.createElement("canvas",{ref:t})}var u=o.z;export{u as BackgroundRipple};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.oopsUi=t():e.oopsUi=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return(e.getAttribute("style")||"").replace(/(;{2,})/gm,";").split(";").reduce(((t,r)=>{if(""!==r.trim()){const n=r.indexOf(":");let i=r.slice(0,n).trim();i=function(e){return e.startsWith("--")?e:e.replace(/([a-z])-([a-z])/g,((e,t,r)=>t.concat(r.toUpperCase())))}(i);const o=e.style[i];void 0!==o&&(t[i]=o)}return t}),{})}function n(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 l=e+t,s=/uniform (\w+) (\w+)/g;null!==(o=s.exec(l));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function i(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 o(e){var t,n,i=e.parentElement;e.width=i.clientWidth,e.height=i.clientHeight,n={position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"},(t=e).setAttribute("style",function(e,t){return Object.keys(e).reduce(((r,n)=>{return t&&t.includes(n)?r:r+`${i=n,i.startsWith("--")?i:i.replace(/[A-Z]/gm,(e=>`-${e.toLowerCase()}`))}: ${e[n]};`;var i}),"")}({...r(t),...n}).replaceAll(/;;/gm,";"))}function a(){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(),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 l(e){return l="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},l(e)}function s(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,f(n.key),n)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){var t=function(e){if("object"!=l(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==l(t)?t:t+""}e.r(t),e.d(t,{useRipples:()=>J});var p="lmssee_ripper_element_style",h=u((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"styleElement",document.createElement("style")),c(this,"canvas",void 0),c(this,"gl",void 0),c(this,"config",void 0),c(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),c(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(p))){var n=this.styleElement;n.id=p,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(a,this,[])})),d={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function m(e){return m="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},m(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,b(n.key),n)}}function v(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=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}Object.freeze(d);var E=v((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"visible",!1),y(this,"running",!1),y(this,"perturbance",void 0),y(this,"resolution",void 0),y(this,"raindropsTimeInterval",void 0),y(this,"animationFrameId",0),y(this,"quad",null),y(this,"lastRaindropsFallTime",0),y(this,"parentElement",null),y(this,"backgroundInfo",{width:0,height:0}),y(this,"dropProgram",null),y(this,"updateProgram",null),y(this,"textures",[]),y(this,"backgroundTexture",[]),y(this,"textureDelta",null),y(this,"framebuffers",[]),y(this,"bufferWriteIndex",0),y(this,"bufferReadIndex",1),y(this,"originalInlineCss",""),y(this,"originalCssBackgroundImage",""),y(this,"events",{}),y(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),R={};function T(){var e=this.gl,t=R[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function x(){var e=R[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function _(){var e=(R[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=R[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function w(){var e=R[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function P(){var e=this,t=this.gl,r=R[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||F(o)||F(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(_,e,[])},l.onerror=function(){return Reflect.apply(S,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(S,this,[])}function S(){var e=this.gl,t=R[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function F(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function A(){var e,t,r,n=R[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):O(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),s={left:0,top:0,width:0,height:0};if("fixed"==a)s.height=window.innerHeight,s.left=window.screenX,s.top=window.screenY,s.width=window.innerWidth;else{var u=i.getBoundingClientRect();s.left=u.left,s.top=u.top,s.width=i.scrollWidth,s.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(s.width/f,s.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(s.width/f,s.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,O(t)?t=s.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),O(r)?r=s.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var g=l&&l[0]||"0%",v=l&&l[1]||"0%";g=O(g)?(s.left+(s.width-Number(t))*parseFloat(g)/100).toString():(s.left+parseFloat(g)).toString(),v=O(v)?(s.top+(s.height-Number(r))*parseFloat(v)/100).toString():(s.top+parseFloat(v)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(g))/t,(i.offsetTop-Number(v))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function O(e){return e.endsWith("%")}function I(){var e=this.gl,t=R[this.sole],r=t.perturbance,n=t.textures,o=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(i,this,[o,0]),Reflect.apply(i,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(T,this,[]),e.disable(e.BLEND)}function D(){var e=this.gl,t=R[this.sole],r=t.resolution,n=t.updateProgram,o=t.textures,a=t.framebuffers,l=t.bufferWriteIndex,s=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,a[l]),Reflect.apply(i,this,[o[s]]),e.useProgram(n.id),Reflect.apply(T,this,[]),Reflect.apply(x,this,[])}function U(){var e=this,t=R[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(A,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(D,this,[]),Reflect.apply(I,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(U,e,[])}))}}function C(e,t,r){var n=R[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),s=e.clientX-l.left-o,u=e.clientY-l.top-a;this.drop(s,u,t,r)}function k(){var e=this,t=R[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(C,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var j="\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 L(){var e=this.gl,t=R[this.sole],r=t.textureDelta;t.dropProgram=n(j,"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 i=t.updateProgram=n(j,"\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(i.locations.delta,r),this.renderProgram=n("\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(this.renderProgram.locations.delta,r)}function B(){var e=this.gl,t=R[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 X(){var e=this;if(this.config){var t=R[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,s=l?new l(r*r*4):null,u=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,u.type,s),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(L,this,[]),Reflect.apply(B,this,[]),Reflect.apply(S,this,[]),Reflect.apply(P,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(k,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(U,e,[])}))}}function M(e){return M="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},M(e)}function N(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 W(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){$(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return 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,K(n.key),n)}}function z(e,t){if(t&&("object"==M(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)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(H=function(){return!!e})()}function Y(e){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Y(e)}function q(e,t){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},q(e,t)}function $(e,t,r){return(t=K(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K(e){var t=function(e){if("object"!=M(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=M(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==M(t)?t:t+""}var V=new WeakMap,Z=function(e){function t(e,r){var n,i,a,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,l=[e],a=Y(a=t),$(n=z(i,H()?Reflect.construct(a,l||[],Y(i).constructor):a.apply(i,l)),"sole",Symbol("ripple")),$(n,"defaults",d),$(n,"interactive",n.defaults.interactive),$(n,"dropRadius",void 0),$(n,"crossOrigin",""),$(n,"imageUrl",void 0),$(n,"idleFluctuations",!0),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,V,!1),$(n,"imageSource",""),$(n,"renderProgram",void 0),console.log("初始化参数",r),R[n.sole]=new E(d),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var s=W(W({},n.defaults),r);return n.accelerating=s.accelerating,n.dropRadius=s.dropRadius,n.resolution=s.resolution,n.interactive=s.interactive,n.perturbance=s.perturbance,n.crossOrigin=s.crossOrigin,n.imageUrl=s.imageUrl,n.idleFluctuations=s.idleFluctuations,n.playingState=s.playingState,n.raindropsTimeInterval=s.raindropsTimeInterval,!1===n.initState||null===e.parentElement||null===n.config||null===n.gl?(n.initState=!1,z(n)):(R[n.sole].parentElement=e.parentElement,o(e),Reflect.apply(X,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&&q(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||(R[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(R[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(R[this.sole].perturbance=e)}},{key:"playingState",set:function(e){R[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=V).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(R[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=R[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var o=this.gl,a=R[this.sole],l=a.resolution,s=a.parentElement,u=a.dropProgram,c=a.textures,f=a.framebuffers,p=a.bufferWriteIndex,h=a.bufferReadIndex,d=s.offsetWidth,m=s.offsetHeight,g=Math.max(d,m);r/=g;var v=new Float32Array([(2*e-d)/g,(m-2*t)/g]);o.viewport(0,0,l,l),o.bindFramebuffer(o.FRAMEBUFFER,f[p]),Reflect.apply(i,this,[c[h]]),o.useProgram(u.id),o.uniform2fv(u.locations.center,v),o.uniform1f(u.locations.radius,r),o.uniform1f(u.locations.strength,n),Reflect.apply(T,this,[]),Reflect.apply(x,this,[])}},{key:"updateSize",value:function(){var e=R[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){R[this.sole].animationFrameId&&window.cancelAnimationFrame(R[this.sole].animationFrameId);var e=R[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(w,this,[]);var n=R[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),R[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){R[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(_,this,[])}},{key:"hide",value:function(){R[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(w,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!R[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(P,this,[])):this[e]=t}}],n&&G(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(h);function J(e,t){var r=document.createElement("canvas");return e.appendChild(r),new Z(r,t)}return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.oops=t():e.oops=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return(e.getAttribute("style")||"").replace(/(;{2,})/gm,";").split(";").reduce(((t,r)=>{if(""!==r.trim()){const n=r.indexOf(":");let i=r.slice(0,n).trim();i=function(e){return e.startsWith("--")?e:e.replace(/([a-z])-([a-z])/g,((e,t,r)=>t.concat(r.toUpperCase())))}(i);const o=e.style[i];void 0!==o&&(t[i]=o)}return t}),{})}function n(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 l=e+t,s=/uniform (\w+) (\w+)/g;null!==(o=s.exec(l));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function i(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 o(e){var t,n,i=e.parentElement;e.width=i.clientWidth,e.height=i.clientHeight,n={position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"},(t=e).setAttribute("style",function(e,t){return Object.keys(e).reduce(((r,n)=>{return t&&t.includes(n)?r:r+`${i=n,i.startsWith("--")?i:i.replace(/[A-Z]/gm,(e=>`-${e.toLowerCase()}`))}: ${e[n]};`;var i}),"")}({...r(t),...n}).replaceAll(/;;/gm,";"))}function a(){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(),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 l(e){return l="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},l(e)}function s(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,f(n.key),n)}}function u(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){var t=function(e){if("object"!=l(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==l(t)?t:t+""}e.r(t),e.d(t,{useRipples:()=>J});var p="lmssee_ripper_element_style",h=u((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"styleElement",document.createElement("style")),c(this,"canvas",void 0),c(this,"gl",void 0),c(this,"config",void 0),c(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),c(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(p))){var n=this.styleElement;n.id=p,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(a,this,[])})),d={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function m(e){return m="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},m(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,b(n.key),n)}}function v(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=b(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}Object.freeze(d);var E=v((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"visible",!1),y(this,"running",!1),y(this,"perturbance",void 0),y(this,"resolution",void 0),y(this,"raindropsTimeInterval",void 0),y(this,"animationFrameId",0),y(this,"quad",null),y(this,"lastRaindropsFallTime",0),y(this,"parentElement",null),y(this,"backgroundInfo",{width:0,height:0}),y(this,"dropProgram",null),y(this,"updateProgram",null),y(this,"textures",[]),y(this,"backgroundTexture",[]),y(this,"textureDelta",null),y(this,"framebuffers",[]),y(this,"bufferWriteIndex",0),y(this,"bufferReadIndex",1),y(this,"originalInlineCss",""),y(this,"originalCssBackgroundImage",""),y(this,"events",{}),y(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),R={};function T(){var e=this.gl,t=R[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function x(){var e=R[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function _(){var e=(R[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=R[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function w(){var e=R[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function P(){var e=this,t=this.gl,r=R[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||F(o)||F(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(_,e,[])},l.onerror=function(){return Reflect.apply(S,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(S,this,[])}function S(){var e=this.gl,t=R[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function F(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function A(){var e,t,r,n=R[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):O(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),s={left:0,top:0,width:0,height:0};if("fixed"==a)s.height=window.innerHeight,s.left=window.screenX,s.top=window.screenY,s.width=window.innerWidth;else{var u=i.getBoundingClientRect();s.left=u.left,s.top=u.top,s.width=i.scrollWidth,s.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(s.width/f,s.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(s.width/f,s.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,O(t)?t=s.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),O(r)?r=s.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var g=l&&l[0]||"0%",v=l&&l[1]||"0%";g=O(g)?(s.left+(s.width-Number(t))*parseFloat(g)/100).toString():(s.left+parseFloat(g)).toString(),v=O(v)?(s.top+(s.height-Number(r))*parseFloat(v)/100).toString():(s.top+parseFloat(v)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(g))/t,(i.offsetTop-Number(v))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function O(e){return e.endsWith("%")}function I(){var e=this.gl,t=R[this.sole],r=t.perturbance,n=t.textures,o=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(i,this,[o,0]),Reflect.apply(i,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(T,this,[]),e.disable(e.BLEND)}function D(){var e=this.gl,t=R[this.sole],r=t.resolution,n=t.updateProgram,o=t.textures,a=t.framebuffers,l=t.bufferWriteIndex,s=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,a[l]),Reflect.apply(i,this,[o[s]]),e.useProgram(n.id),Reflect.apply(T,this,[]),Reflect.apply(x,this,[])}function U(){var e=this,t=R[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(A,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(D,this,[]),Reflect.apply(I,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(U,e,[])}))}}function C(e,t,r){var n=R[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),s=e.clientX-l.left-o,u=e.clientY-l.top-a;this.drop(s,u,t,r)}function k(){var e=this,t=R[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(C,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var j="\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 L(){var e=this.gl,t=R[this.sole],r=t.textureDelta;t.dropProgram=n(j,"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 i=t.updateProgram=n(j,"\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(i.locations.delta,r),this.renderProgram=n("\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(this.renderProgram.locations.delta,r)}function B(){var e=this.gl,t=R[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 X(){var e=this;if(this.config){var t=R[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,s=l?new l(r*r*4):null,u=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,u.type,s),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(L,this,[]),Reflect.apply(B,this,[]),Reflect.apply(S,this,[]),Reflect.apply(P,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(k,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(U,e,[])}))}}function M(e){return M="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},M(e)}function N(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 W(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){$(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return 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,K(n.key),n)}}function z(e,t){if(t&&("object"==M(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)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(H=function(){return!!e})()}function Y(e){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Y(e)}function q(e,t){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},q(e,t)}function $(e,t,r){return(t=K(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K(e){var t=function(e){if("object"!=M(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=M(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==M(t)?t:t+""}var V=new WeakMap,Z=function(e){function t(e,r){var n,i,a,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,l=[e],a=Y(a=t),$(n=z(i,H()?Reflect.construct(a,l||[],Y(i).constructor):a.apply(i,l)),"sole",Symbol("ripple")),$(n,"defaults",d),$(n,"interactive",n.defaults.interactive),$(n,"dropRadius",void 0),$(n,"crossOrigin",""),$(n,"imageUrl",void 0),$(n,"idleFluctuations",!0),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,V,!1),$(n,"imageSource",""),$(n,"renderProgram",void 0),console.log("初始化参数",r),R[n.sole]=new E(d),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var s=W(W({},n.defaults),r);return n.accelerating=s.accelerating,n.dropRadius=s.dropRadius,n.resolution=s.resolution,n.interactive=s.interactive,n.perturbance=s.perturbance,n.crossOrigin=s.crossOrigin,n.imageUrl=s.imageUrl,n.idleFluctuations=s.idleFluctuations,n.playingState=s.playingState,n.raindropsTimeInterval=s.raindropsTimeInterval,!1===n.initState||null===e.parentElement||null===n.config||null===n.gl?(n.initState=!1,z(n)):(R[n.sole].parentElement=e.parentElement,o(e),Reflect.apply(X,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&&q(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||(R[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(R[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(R[this.sole].perturbance=e)}},{key:"playingState",set:function(e){R[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=V).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(R[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=R[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var o=this.gl,a=R[this.sole],l=a.resolution,s=a.parentElement,u=a.dropProgram,c=a.textures,f=a.framebuffers,p=a.bufferWriteIndex,h=a.bufferReadIndex,d=s.offsetWidth,m=s.offsetHeight,g=Math.max(d,m);r/=g;var v=new Float32Array([(2*e-d)/g,(m-2*t)/g]);o.viewport(0,0,l,l),o.bindFramebuffer(o.FRAMEBUFFER,f[p]),Reflect.apply(i,this,[c[h]]),o.useProgram(u.id),o.uniform2fv(u.locations.center,v),o.uniform1f(u.locations.radius,r),o.uniform1f(u.locations.strength,n),Reflect.apply(T,this,[]),Reflect.apply(x,this,[])}},{key:"updateSize",value:function(){var e=R[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){R[this.sole].animationFrameId&&window.cancelAnimationFrame(R[this.sole].animationFrameId);var e=R[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(w,this,[]);var n=R[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),R[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){R[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(_,this,[])}},{key:"hide",value:function(){R[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(w,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!R[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(P,this,[])):this[e]=t}}],n&&G(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(h);function J(e,t){var r=document.createElement("canvas");return e.appendChild(r),new Z(r,t)}return t})()));
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import*as e from"react";import*as t from"a-element-inline-style";var r={d:(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},n={};r.d(n,{z_:()=>ne,MM:()=>ae,t3:()=>ie,nC:()=>re,Oe:()=>oe});const i=(o={default:()=>e.default,useEffect:()=>e.useEffect,useRef:()=>e.useRef},a={},r.d(a,o),a);var o,a;const l=(e=>{var t={};return r.d(t,e),t})({setStyle:()=>t.setStyle});function u(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 l=e+t,u=/uniform (\w+) (\w+)/g;null!==(o=u.exec(l));){var s=o[2];a.locations[s]=r.getUniformLocation(a.id,s)}return a}function s(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 c(){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(),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 u=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){u=i[s];break}return u}function f(e){return f="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},f(e)}function p(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,m(n.key),n)}}function h(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var v="lmssee_ripper_element_style",g=h((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,"styleElement",document.createElement("style")),d(this,"canvas",void 0),d(this,"gl",void 0),d(this,"config",void 0),d(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),d(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(v))){var n=this.styleElement;n.id=v,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(c,this,[])})),y={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function b(e){return b="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},b(e)}function E(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 R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t,r){return(t=_(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}Object.freeze(y);var x=R((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),T(this,"visible",!1),T(this,"running",!1),T(this,"perturbance",void 0),T(this,"resolution",void 0),T(this,"raindropsTimeInterval",void 0),T(this,"animationFrameId",0),T(this,"quad",null),T(this,"lastRaindropsFallTime",0),T(this,"parentElement",null),T(this,"backgroundInfo",{width:0,height:0}),T(this,"dropProgram",null),T(this,"updateProgram",null),T(this,"textures",[]),T(this,"backgroundTexture",[]),T(this,"textureDelta",null),T(this,"framebuffers",[]),T(this,"bufferWriteIndex",0),T(this,"bufferReadIndex",1),T(this,"originalInlineCss",""),T(this,"originalCssBackgroundImage",""),T(this,"events",{}),T(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),w={};function P(){var e=this.gl,t=w[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function S(){var e=w[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function F(){var e=(w[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=w[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function A(){var e=w[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function O(){var e=this,t=this.gl,r=w[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||D(o)||D(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(F,e,[])},l.onerror=function(){return Reflect.apply(I,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(I,this,[])}function I(){var e=this.gl,t=w[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function D(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function U(){var e,t,r,n=w[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):C(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),u={left:0,top:0,width:0,height:0};if("fixed"==a)u.height=window.innerHeight,u.left=window.screenX,u.top=window.screenY,u.width=window.innerWidth;else{var s=i.getBoundingClientRect();u.left=s.left,u.top=s.top,u.width=i.scrollWidth,u.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(u.width/f,u.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(u.width/f,u.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,C(t)?t=u.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),C(r)?r=u.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var v=l&&l[0]||"0%",g=l&&l[1]||"0%";v=C(v)?(u.left+(u.width-Number(t))*parseFloat(v)/100).toString():(u.left+parseFloat(v)).toString(),g=C(g)?(u.top+(u.height-Number(r))*parseFloat(g)/100).toString():(u.top+parseFloat(g)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(v))/t,(i.offsetTop-Number(g))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function C(e){return e.endsWith("%")}function k(){var e=this.gl,t=w[this.sole],r=t.perturbance,n=t.textures,i=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(s,this,[i,0]),Reflect.apply(s,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(P,this,[]),e.disable(e.BLEND)}function L(){var e=this.gl,t=w[this.sole],r=t.resolution,n=t.updateProgram,i=t.textures,o=t.framebuffers,a=t.bufferWriteIndex,l=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,o[a]),Reflect.apply(s,this,[i[l]]),e.useProgram(n.id),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}function j(){var e=this,t=w[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(U,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(L,this,[]),Reflect.apply(k,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}function B(e,t,r){var n=w[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),u=e.clientX-l.left-o,s=e.clientY-l.top-a;this.drop(u,s,t,r)}function X(){var e=this,t=w[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(B,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var M="\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 N(){var e=this.gl,t=w[this.sole],r=t.textureDelta;t.dropProgram=u(M,"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=u(M,"\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),this.renderProgram=u("\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(this.renderProgram.locations.delta,r)}function W(){var e=this.gl,t=w[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 G(){var e=this;if(this.config){var t=w[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,u=l?new l(r*r*4):null,s=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,s.type,u),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(N,this,[]),Reflect.apply(W,this,[]),Reflect.apply(I,this,[]),Reflect.apply(O,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(X,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}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 H(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 Y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){Z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(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 K(e,t){if(t&&("object"==z(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)}function V(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(V=function(){return!!e})()}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function Z(e,t,r){return(t=$(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $(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 ee=new WeakMap,te=function(){function e(t,r){var n,i,o,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=this,a=[t],o=J(o=e),Z(n=K(i,V()?Reflect.construct(o,a||[],J(i).constructor):o.apply(i,a)),"sole",Symbol("ripple")),Z(n,"defaults",y),Z(n,"interactive",n.defaults.interactive),Z(n,"dropRadius",void 0),Z(n,"crossOrigin",""),Z(n,"imageUrl",void 0),Z(n,"idleFluctuations",!0),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,ee,!1),Z(n,"imageSource",""),Z(n,"renderProgram",void 0),console.log("初始化参数",r),w[n.sole]=new x(y),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var u=Y(Y({},n.defaults),r);return n.accelerating=u.accelerating,n.dropRadius=u.dropRadius,n.resolution=u.resolution,n.interactive=u.interactive,n.perturbance=u.perturbance,n.crossOrigin=u.crossOrigin,n.imageUrl=u.imageUrl,n.idleFluctuations=u.idleFluctuations,n.playingState=u.playingState,n.raindropsTimeInterval=u.raindropsTimeInterval,!1===n.initState||null===t.parentElement||null===n.config||null===n.gl?(n.initState=!1,K(n)):(w[n.sole].parentElement=t.parentElement,function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,l.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(t),Reflect.apply(G,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&&Q(e,t)}(e,g),t=e,r=[{key:"accelerating",set:function(e){e>100||e<2||(w[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(w[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(w[this.sole].perturbance=e)}},{key:"playingState",set:function(e){w[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=ee).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(w[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=w[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=w[this.sole],a=o.resolution,l=o.parentElement,u=o.dropProgram,c=o.textures,f=o.framebuffers,p=o.bufferWriteIndex,h=o.bufferReadIndex,d=l.offsetWidth,m=l.offsetHeight,v=Math.max(d,m);r/=v;var g=new Float32Array([(2*e-d)/v,(m-2*t)/v]);i.viewport(0,0,a,a),i.bindFramebuffer(i.FRAMEBUFFER,f[p]),Reflect.apply(s,this,[c[h]]),i.useProgram(u.id),i.uniform2fv(u.locations.center,g),i.uniform1f(u.locations.radius,r),i.uniform1f(u.locations.strength,n),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}},{key:"updateSize",value:function(){var e=w[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){w[this.sole].animationFrameId&&window.cancelAnimationFrame(w[this.sole].animationFrameId);var e=w[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(A,this,[]);var n=w[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),w[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){w[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(F,this,[])}},{key:"hide",value:function(){w[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(A,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!w[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(O,this,[])):this[e]=t}}],r&&q(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function re(e,t){var r=(0,i.useRef)(null);return(0,i.useEffect)((function(){var n=e.current;return r.current=new te(n,t&&t.option),function(){return r.current&&r.current.destroy()||void 0}}),[]),r}function ne(e){var t=(0,i.useRef)(null);return function(e,t){(0,i.useEffect)((function(){if(t.option&&e.current){var r=t.option;Object.keys(e.current.defaults).forEach((function(t){void 0!==r[t]&&e.current&&e.current.set(t,r[t])}))}}),[t.option])}(re(t,e),e),i.default.createElement("canvas",{ref:t})}function ie(e){var t=(0,i.useRef)(!1);return(0,i.useEffect)((function(){var r=e.current;if(r){var n=function(){return t.current=!0},i=function(){return t.current=!1};return r.addEventListener("compositionstart",n),r.addEventListener("compositionend",i),function(){r.removeEventListener("compositionstart",n),r.removeEventListener("compositionend",i)}}}),[]),t}function oe(){var e=(0,i.useRef)(void 0);return(0,i.useEffect)((function(){return function(){e.current&&clearTimeout(e.current)}}),[]),e}function ae(){var e=(0,i.useRef)(0);return(0,i.useEffect)((function(){return function(){e.current&&window.cancelAnimationFrame(e.current)}}),[]),e}var le=n.z_,ue=n.MM,se=n.t3,ce=n.nC,fe=n.Oe;export{le as BackgroundRipple,ue as useAnimationFrameId,se as useInputIsComposing,ce as useRipples,fe as useTimeId};
1
+ import*as e from"a-element-inline-style";import*as t from"react";var r={805:(e,t,r)=>{r.d(t,{z:()=>o});var n=r(649),i=r(463);function o(e){var t=(0,n.useRef)(null);return function(e,t){(0,n.useEffect)((function(){if(t.option&&e.current){var r=t.option;Object.keys(e.current.defaults).forEach((function(t){void 0!==r[t]&&e.current&&e.current.set(t,r[t])}))}}),[t.option])}((0,i.n)(t,e),e),n.default.createElement("canvas",{ref:t})}},615:(e,t,r)=>{r.d(t,{M:()=>i});var n=r(649);function i(){var e=(0,n.useRef)(0);return(0,n.useEffect)((function(){return function(){e.current&&window.cancelAnimationFrame(e.current)}}),[]),e}},195:(e,t,r)=>{r.d(t,{t:()=>i});var n=r(649);function i(e){var t=(0,n.useRef)(!1);return(0,n.useEffect)((function(){var r=e.current;if(r){var n=function(){return t.current=!0},i=function(){return t.current=!1};return r.addEventListener("compositionstart",n),r.addEventListener("compositionend",i),function(){r.removeEventListener("compositionstart",n),r.removeEventListener("compositionend",i)}}}),[]),t}},463:(t,r,n)=>{n.d(r,{n:()=>re});var i=n(649);const o=(a={setStyle:()=>e.setStyle},l={},n.d(l,a),l);var a,l;function u(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 l=e+t,u=/uniform (\w+) (\w+)/g;null!==(o=u.exec(l));){var s=o[2];a.locations[s]=r.getUniformLocation(a.id,s)}return a}function s(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 c(){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(),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 u=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){u=i[s];break}return u}function f(e){return f="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},f(e)}function p(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,m(n.key),n)}}function h(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,r){return(t=m(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var v="lmssee_ripper_element_style",g=h((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),d(this,"styleElement",document.createElement("style")),d(this,"canvas",void 0),d(this,"gl",void 0),d(this,"config",void 0),d(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),d(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(v))){var n=this.styleElement;n.id=v,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(c,this,[])})),y={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function b(e){return b="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},b(e)}function E(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,x(n.key),n)}}function R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function T(e,t,r){return(t=x(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}Object.freeze(y);var _=R((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),T(this,"visible",!1),T(this,"running",!1),T(this,"perturbance",void 0),T(this,"resolution",void 0),T(this,"raindropsTimeInterval",void 0),T(this,"animationFrameId",0),T(this,"quad",null),T(this,"lastRaindropsFallTime",0),T(this,"parentElement",null),T(this,"backgroundInfo",{width:0,height:0}),T(this,"dropProgram",null),T(this,"updateProgram",null),T(this,"textures",[]),T(this,"backgroundTexture",[]),T(this,"textureDelta",null),T(this,"framebuffers",[]),T(this,"bufferWriteIndex",0),T(this,"bufferReadIndex",1),T(this,"originalInlineCss",""),T(this,"originalCssBackgroundImage",""),T(this,"events",{}),T(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),w={};function P(){var e=this.gl,t=w[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function S(){var e=w[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function F(){var e=(w[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=w[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function A(){var e=w[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function O(){var e=this,t=this.gl,r=w[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||D(o)||D(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(F,e,[])},l.onerror=function(){return Reflect.apply(I,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(I,this,[])}function I(){var e=this.gl,t=w[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function D(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function U(){var e,t,r,n=w[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):C(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),u={left:0,top:0,width:0,height:0};if("fixed"==a)u.height=window.innerHeight,u.left=window.screenX,u.top=window.screenY,u.width=window.innerWidth;else{var s=i.getBoundingClientRect();u.left=s.left,u.top=s.top,u.width=i.scrollWidth,u.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(u.width/f,u.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(u.width/f,u.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,C(t)?t=u.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),C(r)?r=u.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var v=l&&l[0]||"0%",g=l&&l[1]||"0%";v=C(v)?(u.left+(u.width-Number(t))*parseFloat(v)/100).toString():(u.left+parseFloat(v)).toString(),g=C(g)?(u.top+(u.height-Number(r))*parseFloat(g)/100).toString():(u.top+parseFloat(g)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(v))/t,(i.offsetTop-Number(g))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function C(e){return e.endsWith("%")}function k(){var e=this.gl,t=w[this.sole],r=t.perturbance,n=t.textures,i=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(s,this,[i,0]),Reflect.apply(s,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(P,this,[]),e.disable(e.BLEND)}function L(){var e=this.gl,t=w[this.sole],r=t.resolution,n=t.updateProgram,i=t.textures,o=t.framebuffers,a=t.bufferWriteIndex,l=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,o[a]),Reflect.apply(s,this,[i[l]]),e.useProgram(n.id),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}function j(){var e=this,t=w[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(U,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(L,this,[]),Reflect.apply(k,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}function B(e,t,r){var n=w[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),u=e.clientX-l.left-o,s=e.clientY-l.top-a;this.drop(u,s,t,r)}function M(){var e=this,t=w[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(B,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var X="\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 N(){var e=this.gl,t=w[this.sole],r=t.textureDelta;t.dropProgram=u(X,"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=u(X,"\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),this.renderProgram=u("\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(this.renderProgram.locations.delta,r)}function W(){var e=this.gl,t=w[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 G(){var e=this;if(this.config){var t=w[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,u=l?new l(r*r*4):null,s=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,s.type,u),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(N,this,[]),Reflect.apply(W,this,[]),Reflect.apply(I,this,[]),Reflect.apply(O,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(M,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(j,e,[])}))}}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 H(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 Y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){Z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(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 K(e,t){if(t&&("object"==z(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)}function V(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(V=function(){return!!e})()}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function Z(e,t,r){return(t=$(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $(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 ee=new WeakMap,te=function(e){function t(e,r){var n,i,a,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,l=[e],a=J(a=t),Z(n=K(i,V()?Reflect.construct(a,l||[],J(i).constructor):a.apply(i,l)),"sole",Symbol("ripple")),Z(n,"defaults",y),Z(n,"interactive",n.defaults.interactive),Z(n,"dropRadius",void 0),Z(n,"crossOrigin",""),Z(n,"imageUrl",void 0),Z(n,"idleFluctuations",!0),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,ee,!1),Z(n,"imageSource",""),Z(n,"renderProgram",void 0),console.log("初始化参数",r),w[n.sole]=new _(y),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var u=Y(Y({},n.defaults),r);return n.accelerating=u.accelerating,n.dropRadius=u.dropRadius,n.resolution=u.resolution,n.interactive=u.interactive,n.perturbance=u.perturbance,n.crossOrigin=u.crossOrigin,n.imageUrl=u.imageUrl,n.idleFluctuations=u.idleFluctuations,n.playingState=u.playingState,n.raindropsTimeInterval=u.raindropsTimeInterval,!1===n.initState||null===e.parentElement||null===n.config||null===n.gl?(n.initState=!1,K(n)):(w[n.sole].parentElement=e.parentElement,function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,o.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(e),Reflect.apply(G,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&&Q(e,t)}(t,e),r=t,n=[{key:"accelerating",set:function(e){e>100||e<2||(w[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(w[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(w[this.sole].perturbance=e)}},{key:"playingState",set:function(e){w[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=ee).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(w[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=w[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=w[this.sole],a=o.resolution,l=o.parentElement,u=o.dropProgram,c=o.textures,f=o.framebuffers,p=o.bufferWriteIndex,h=o.bufferReadIndex,d=l.offsetWidth,m=l.offsetHeight,v=Math.max(d,m);r/=v;var g=new Float32Array([(2*e-d)/v,(m-2*t)/v]);i.viewport(0,0,a,a),i.bindFramebuffer(i.FRAMEBUFFER,f[p]),Reflect.apply(s,this,[c[h]]),i.useProgram(u.id),i.uniform2fv(u.locations.center,g),i.uniform1f(u.locations.radius,r),i.uniform1f(u.locations.strength,n),Reflect.apply(P,this,[]),Reflect.apply(S,this,[])}},{key:"updateSize",value:function(){var e=w[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){w[this.sole].animationFrameId&&window.cancelAnimationFrame(w[this.sole].animationFrameId);var e=w[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(A,this,[]);var n=w[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),w[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){w[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(F,this,[])}},{key:"hide",value:function(){w[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(A,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!w[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(O,this,[])):this[e]=t}}],n&&q(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(g);function re(e,t){var r=(0,i.useRef)(null);return(0,i.useEffect)((function(){var n=e.current;return r.current=new te(n,t&&t.option),function(){return r.current&&r.current.destroy()||void 0}}),[]),r}},552:(e,t,r)=>{r.d(t,{O:()=>i});var n=r(649);function i(){var e=(0,n.useRef)(void 0);return(0,n.useEffect)((function(){return function(){e.current&&clearTimeout(e.current)}}),[]),e}},649:(e,r,n)=>{var i,o;e.exports=(i={default:()=>t.default,useEffect:()=>t.useEffect,useRef:()=>t.useRef},o={},n.d(o,i),o)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};i.d(o,{z_:()=>a.z,MM:()=>s.M,t3:()=>l.t,nC:()=>c.n,Oe:()=>u.O});var a=i(805),l=i(195),u=i(552),s=i(615),c=i(463),f=o.z_,p=o.MM,h=o.t3,d=o.nC,m=o.Oe;export{f as BackgroundRipple,p as useAnimationFrameId,h as useInputIsComposing,d as useRipples,m as useTimeId};
@@ -0,0 +1 @@
1
+ import*as e from"react";var r={649:(r,t,n)=>{var o,a;r.exports=(o={useEffect:()=>e.useEffect,useRef:()=>e.useRef},a={},n.d(a,o),a)}},t={};function n(e){var o=t[e];if(void 0!==o)return o.exports;var a=t[e]={exports:{}};return r[e](a,a.exports,n),a.exports}n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);var o={};n.d(o,{M:()=>u});var a=n(649);function u(){var e=(0,a.useRef)(0);return(0,a.useEffect)((function(){return function(){e.current&&window.cancelAnimationFrame(e.current)}}),[]),e}var f=o.M;export{f as useAnimationFrameId};
@@ -0,0 +1 @@
1
+ import*as e from"react";var r={649:(r,t,n)=>{var o,s;r.exports=(o={useEffect:()=>e.useEffect,useRef:()=>e.useRef},s={},n.d(s,o),s)}},t={};function n(e){var o=t[e];if(void 0!==o)return o.exports;var s=t[e]={exports:{}};return r[e](s,s.exports,n),s.exports}n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);var o={};n.d(o,{t:()=>i});var s=n(649);function i(e){var r=(0,s.useRef)(!1);return(0,s.useEffect)((function(){var t=e.current;if(t){var n=function(){return r.current=!0},o=function(){return r.current=!1};return t.addEventListener("compositionstart",n),t.addEventListener("compositionend",o),function(){t.removeEventListener("compositionstart",n),t.removeEventListener("compositionend",o)}}}),[]),r}var u=o.t;export{u as useInputIsComposing};
@@ -0,0 +1 @@
1
+ import*as e from"react";import*as t from"a-element-inline-style";var r={649:(t,r,n)=>{var i,o;t.exports=(i={useEffect:()=>e.useEffect,useRef:()=>e.useRef},o={},n.d(o,i),o)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};i.d(o,{n:()=>ie});var a=i(649);const l=(s={setStyle:()=>t.setStyle},u={},i.d(u,s),u);var s,u;function c(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 l=e+t,s=/uniform (\w+) (\w+)/g;null!==(o=s.exec(l));){var u=o[2];a.locations[u]=r.getUniformLocation(a.id,u)}return a}function f(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 p(){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(),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 h(e){return h="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},h(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,v(n.key),n)}}function m(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function g(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){var t=function(e){if("object"!=h(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==h(t)?t:t+""}var y="lmssee_ripper_element_style",b=m((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),g(this,"styleElement",document.createElement("style")),g(this,"canvas",void 0),g(this,"gl",void 0),g(this,"config",void 0),g(this,"transparentPixels",function(){try{return new ImageData(32,32)}catch(e){return console.log(e&&""),document.createElement("canvas").getContext("2d").createImageData(32,32)}}()),g(this,"initState",!0),this.canvas=t;var r=t.getContext("webgl");if(null===r)return this.initState=!1,void(this.config=null);if(this.gl=r,null===document.querySelector("style#".concat(y))){var n=this.styleElement;n.id=y,n.innerHTML="\n .lmssee-ripples { \n position: relative; \n z-index: 0; \n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transform: translate(0,0);\n }\n ";var i=document.head;i.prepend?i.prepend(n):i.insertBefore(n,i.firstChild)}this.config=Reflect.apply(p,this,[])})),E={imageUrl:"",resolution:256,dropRadius:10,perturbance:.03,interactive:!0,crossOrigin:"",playingState:!0,accelerating:1,raindropsTimeInterval:3600,idleFluctuations:!0};function R(e){return R="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},R(e)}function T(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,w(n.key),n)}}function x(e,t,r){return t&&T(e.prototype,t),r&&T(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _(e,t,r){return(t=w(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w(e){var t=function(e){if("object"!=R(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=R(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==R(t)?t:t+""}Object.freeze(E);var P=x((function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,"visible",!1),_(this,"running",!1),_(this,"perturbance",void 0),_(this,"resolution",void 0),_(this,"raindropsTimeInterval",void 0),_(this,"animationFrameId",0),_(this,"quad",null),_(this,"lastRaindropsFallTime",0),_(this,"parentElement",null),_(this,"backgroundInfo",{width:0,height:0}),_(this,"dropProgram",null),_(this,"updateProgram",null),_(this,"textures",[]),_(this,"backgroundTexture",[]),_(this,"textureDelta",null),_(this,"framebuffers",[]),_(this,"bufferWriteIndex",0),_(this,"bufferReadIndex",1),_(this,"originalInlineCss",""),_(this,"originalCssBackgroundImage",""),_(this,"events",{}),_(this,"accelerating",void 0),this.perturbance=t.perturbance,this.resolution=t.resolution,this.raindropsTimeInterval=t.raindropsTimeInterval,this.accelerating=t.accelerating})),S={};function F(){var e=this.gl,t=S[this.sole];e.bindBuffer(e.ARRAY_BUFFER,t.quad),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLE_FAN,0,4)}function A(){var e=S[this.sole],t=e.bufferWriteIndex,r=e.bufferReadIndex;e.bufferWriteIndex=1-t,e.bufferReadIndex=1-r}function O(){var e=(S[this.sole]||{}).parentElement;if(e){var t=e.style.backgroundImage;if("none"!=t){var r=S[this.sole];r.originalInlineCss=t,r.originalCssBackgroundImage=window.getComputedStyle(e).backgroundImage,e.style.backgroundImage="none"}}}function I(){var e=S[this.sole],t=e.parentElement,r=e.originalInlineCss;t.style.backgroundImage=r||""}function D(){var e=this,t=this.gl,r=S[this.sole],n=r.parentElement,i=r.backgroundTexture,o=r.originalCssBackgroundImage,a=this.imageUrl||k(o)||k(window.getComputedStyle(n).backgroundImage);if(a!==this.imageSource)if(this.imageSource=a,this.imageSource){var l=new Image;l.onload=function(){var n=function(e){return!(e&e-1)},o=n(l.width)&&n(l.height)?t.REPEAT:t.CLAMP_TO_EDGE;t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,l),r.backgroundInfo={width:l.width,height:l.height},Reflect.apply(O,e,[])},l.onerror=function(){return Reflect.apply(U,e,[])},l.crossOrigin=this.imageSource.match(/^data:/)?null:this.crossOrigin,l.src=this.imageSource}else Reflect.apply(U,this,[])}function U(){var e=this.gl,t=S[this.sole].backgroundTexture;e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.transparentPixels)}function k(e){var t=/url\(["']?([^"']*)["']?\)/.exec(e);return null==t?null:t[1]}function C(){var e,t,r,n=S[this.sole],i=n.parentElement,o=window.getComputedStyle(i).backgroundSize,a=window.getComputedStyle(i).backgroundAttachment,l=(e=window.getComputedStyle(i).backgroundPosition,/\s+/.test(e)?e.replace(/center/,"50%").replace(/top|left/,"0%").replace(/bottom/,"100%").replace(/\s+/," ").split(" "):L(e)?[e,"50%"]:{center:["50%","50%"],top:["50%","0%"],bottom:["50%","100%"],left:["0%","50%"],right:["100%","50%"]}[e]),s={left:0,top:0,width:0,height:0};if("fixed"==a)s.height=window.innerHeight,s.left=window.screenX,s.top=window.screenY,s.width=window.innerWidth;else{var u=i.getBoundingClientRect();s.left=u.left,s.top=u.top,s.width=i.scrollWidth,s.height=i.scrollHeight}var c=n.backgroundInfo||{width:100,height:100},f=c.width,p=c.height;if("cover"==o){var h=Math.max(s.width/f,s.height/p);t=f*h,r=p*h}else if("contain"==o){var d=Math.min(s.width/f,s.height/p);t=f*d,r=p*d}else{var m=o.split(" ");t=m[0]||"",r=m[1]||t,L(t)?t=s.width*parseFloat(t)/100:"auto"!==t&&(t=parseFloat(t)),L(r)?r=s.height*parseFloat(r)/100:"auto"!==r&&(r=parseFloat(r)),"auto"==t&&"auto"==r?(t=f,r=p):("auto"==t&&(t=f*(Number(r)/p)),"auto"==r&&(r=p*(Number(t)/f)))}var g=l&&l[0]||"0%",v=l&&l[1]||"0%";g=L(g)?(s.left+(s.width-Number(t))*parseFloat(g)/100).toString():(s.left+parseFloat(g)).toString(),v=L(v)?(s.top+(s.height-Number(r))*parseFloat(v)/100).toString():(s.top+parseFloat(v)).toString(),this.renderProgram.uniforms.topLeft=new Float32Array([(i.offsetLeft-Number(g))/t,(i.offsetTop-Number(v))/r]),this.renderProgram.uniforms.bottomRight=new Float32Array([this.renderProgram.uniforms.topLeft[0]+i.clientWidth/t,this.renderProgram.uniforms.topLeft[1]+i.clientHeight/r]);var y=Math.max(this.canvas.width,this.canvas.height);this.renderProgram.uniforms.containerRatio=new Float32Array([this.canvas.width/y,this.canvas.height/y])}function L(e){return e.endsWith("%")}function j(){var e=this.gl,t=S[this.sole],r=t.perturbance,n=t.textures,i=t.backgroundTexture;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(this.renderProgram.id),Reflect.apply(f,this,[i,0]),Reflect.apply(f,this,[n[0],1]),e.uniform1f(this.renderProgram.locations.perturbance,r),e.uniform2fv(this.renderProgram.locations.topLeft,this.renderProgram.uniforms.topLeft),e.uniform2fv(this.renderProgram.locations.bottomRight,this.renderProgram.uniforms.bottomRight),e.uniform2fv(this.renderProgram.locations.containerRatio,this.renderProgram.uniforms.containerRatio),e.uniform1i(this.renderProgram.locations.samplerBackground,0),e.uniform1i(this.renderProgram.locations.samplerRipples,1),Reflect.apply(F,this,[]),e.disable(e.BLEND)}function B(){var e=this.gl,t=S[this.sole],r=t.resolution,n=t.updateProgram,i=t.textures,o=t.framebuffers,a=t.bufferWriteIndex,l=t.bufferReadIndex;e.viewport(0,0,r,r),e.bindFramebuffer(e.FRAMEBUFFER,o[a]),Reflect.apply(f,this,[i[l]]),e.useProgram(n.id),Reflect.apply(F,this,[]),Reflect.apply(A,this,[])}function X(){var e=this,t=S[this.sole],r=t.visible,n=t.raindropsTimeInterval,i=t.running,o=t.lastRaindropsFallTime;if(r){if(Reflect.apply(C,this,[]),this.idleFluctuations&&i){var a=Date.now();a-o>n&&(t.lastRaindropsFallTime=a,this.raindropsFall())}Reflect.apply(B,this,[]),Reflect.apply(j,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(X,e,[])}))}}function M(e,t,r){var n=S[this.sole].parentElement,i=window.getComputedStyle(n),o=parseInt(i.borderLeftWidth)||0,a=parseInt(i.borderTopWidth)||0,l=n.getBoundingClientRect(),s=e.clientX-l.left-o,u=e.clientY-l.top-a;this.drop(s,u,t,r)}function N(){var e=this,t=S[this.sole],r=t.visible,n=t.running,i=t.accelerating,o=t.parentElement,a=t.events,l=function(i){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r&&n&&e.interactive&&(t.lastRaindropsFallTime=Date.now(),Reflect.apply(M,e,[i,e.dropRadius*(o?1.5:1),o?.14:.01]))};a.mousemove=function(e){for(var t=i;t--;)l(e)},a.touchmove=a.touchstart=function(e){for(var t=e.touches,r=0;r<t.length;r++)l(t[r])},a.mousedown=function(e){return l(e,!0)},Object.keys(a).forEach((function(e){return o&&o.addEventListener(e,a[e],{passive:!0})}))}var W="\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 G(){var e=this.gl,t=S[this.sole],r=t.textureDelta;t.dropProgram=c(W,"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=c(W,"\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),this.renderProgram=c("\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(this.renderProgram.locations.delta,r)}function z(){var e=this.gl,t=S[this.sole].backgroundTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),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 H(){var e=this;if(this.config){var t=S[this.sole],r=t.resolution,n=t.textures,i=t.framebuffers,o=this.gl,a=1/r;t.textureDelta=new Float32Array([a,a]),this.config.extensions.forEach((function(e){return o.getExtension(e)})),this.updateSize=this.updateSize.bind(this),window.addEventListener("resize",this.updateSize);for(var l=this.config.arrayType,s=l?new l(r*r*4):null,u=this.config,c=0;c<2;c++){var f=o.createTexture(),p=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,p),o.bindTexture(o.TEXTURE_2D,f),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,u.linearSupport?o.LINEAR:o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,r,r,0,o.RGBA,u.type,s),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0),n.push(f),i.push(p)}t.quad=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,t.quad),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),o.STATIC_DRAW),Reflect.apply(G,this,[]),Reflect.apply(z,this,[]),Reflect.apply(U,this,[]),Reflect.apply(D,this,[]),o.clearColor(0,0,0,0),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),t.visible=!0,t.running=!0,Reflect.apply(N,this,[]),t.animationFrameId=requestAnimationFrame((function(){return Reflect.apply(X,e,[])}))}}function Y(e){return Y="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},Y(e)}function q(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 K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach((function(t){ee(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function V(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,te(n.key),n)}}function J(e,t){if(t&&("object"==Y(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)}function Q(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Q=function(){return!!e})()}function Z(e){return Z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Z(e)}function $(e,t){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},$(e,t)}function ee(e,t,r){return(t=te(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function te(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}var re=new WeakMap,ne=function(){function e(t,r){var n,i,o,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i=this,a=[t],o=Z(o=e),ee(n=J(i,Q()?Reflect.construct(o,a||[],Z(i).constructor):o.apply(i,a)),"sole",Symbol("ripple")),ee(n,"defaults",E),ee(n,"interactive",n.defaults.interactive),ee(n,"dropRadius",void 0),ee(n,"crossOrigin",""),ee(n,"imageUrl",void 0),ee(n,"idleFluctuations",!0),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,re,!1),ee(n,"imageSource",""),ee(n,"renderProgram",void 0),console.log("初始化参数",r),S[n.sole]=new P(E),Object.defineProperties(n,{defaults:{value:n.defaults,writable:!1,enumerable:!1,configurable:!1}}),r&&"boolean"!=typeof r.interactive&&delete r.interactive;var s=K(K({},n.defaults),r);return n.accelerating=s.accelerating,n.dropRadius=s.dropRadius,n.resolution=s.resolution,n.interactive=s.interactive,n.perturbance=s.perturbance,n.crossOrigin=s.crossOrigin,n.imageUrl=s.imageUrl,n.idleFluctuations=s.idleFluctuations,n.playingState=s.playingState,n.raindropsTimeInterval=s.raindropsTimeInterval,!1===n.initState||null===t.parentElement||null===n.config||null===n.gl?(n.initState=!1,J(n)):(S[n.sole].parentElement=t.parentElement,function(e){var t=e.parentElement;e.width=t.clientWidth,e.height=t.clientHeight,(0,l.setStyle)(e,{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:-1,pointerEvents:"none"})}(t),Reflect.apply(H,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&&$(e,t)}(e,b),t=e,r=[{key:"accelerating",set:function(e){e>100||e<2||(S[this.sole].accelerating=e)}},{key:"resolution",set:function(e){e<100||e>550||(S[this.sole].resolution=e)}},{key:"perturbance",set:function(e){e<1e-4||e>1||(S[this.sole].perturbance=e)}},{key:"playingState",set:function(e){S[this.sole].running=!1!==e}},{key:"initialized",get:function(){return t=this,(e=re).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));var e,t}},{key:"raindropsTimeInterval",set:function(e){e<10||e>12e3||(S[this.sole].raindropsTimeInterval=e)}},{key:"raindropsFall",value:function(){var e=S[this.sole].parentElement,t=window.getComputedStyle(e),r=function(e){return function(e=1,t=0){let r=Math.ceil(Number(t)),n=Math.floor(Number(e));return r>n&&([n,r]=[r,n]),Math.floor(Math.random()*(n-r+1)+r)}(parseInt(e))},n=t.width,i=t.height;this.drop(r(n),r(i),this.dropRadius,.03)}},{key:"drop",value:function(e,t,r,n){var i=this.gl,o=S[this.sole],a=o.resolution,l=o.parentElement,s=o.dropProgram,u=o.textures,c=o.framebuffers,p=o.bufferWriteIndex,h=o.bufferReadIndex,d=l.offsetWidth,m=l.offsetHeight,g=Math.max(d,m);r/=g;var v=new Float32Array([(2*e-d)/g,(m-2*t)/g]);i.viewport(0,0,a,a),i.bindFramebuffer(i.FRAMEBUFFER,c[p]),Reflect.apply(f,this,[u[h]]),i.useProgram(s.id),i.uniform2fv(s.locations.center,v),i.uniform1f(s.locations.radius,r),i.uniform1f(s.locations.strength,n),Reflect.apply(F,this,[]),Reflect.apply(A,this,[])}},{key:"updateSize",value:function(){var e=S[this.sole].parentElement,t=e.offsetWidth,r=e.offsetHeight;t==this.canvas.width&&r==this.canvas.height||(this.canvas.width=t,this.canvas.height=r)}},{key:"destroy",value:function(){S[this.sole].animationFrameId&&window.cancelAnimationFrame(S[this.sole].animationFrameId);var e=S[this.sole],t=e.parentElement,r=e.events;t&&(Object.keys(r).forEach((function(e){return t.removeEventListener&&t.removeEventListener(e,r[e])})),t.removeAttribute&&t.removeAttribute("data-ripples")),this.styleElement&&this.styleElement.remove(),this.gl=null,Reflect.apply(I,this,[]);var n=S[this.sole];Object.keys(n).forEach((function(e){return n[e]=null})),S[this.sole]=null,this.gl&&(this.gl=null),window.removeEventListener("resize",this.updateSize)}},{key:"show",value:function(){S[this.sole].visible=!0,this.canvas.style.visibility="visible",Reflect.apply(O,this,[])}},{key:"hide",value:function(){S[this.sole].visible=!1,this.canvas.style.visibility="hidden",Reflect.apply(I,this,[])}},{key:"pause",value:function(){this.playingState=!1}},{key:"play",value:function(){this.playingState=!0}},{key:"changePlayingState",value:function(){this.playingState=!S[this.sole].running}},{key:"set",value:function(e,t){"imageUrl"===e?(this.imageUrl=t,Reflect.apply(D,this,[])):this[e]=t}}],r&&V(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function ie(e,t){var r=(0,a.useRef)(null);return(0,a.useEffect)((function(){var n=e.current;return r.current=new ne(n,t&&t.option),function(){return r.current&&r.current.destroy()||void 0}}),[]),r}var oe=o.n;export{oe as useRipples};
@@ -0,0 +1 @@
1
+ import*as e from"react";var r={649:(r,t,o)=>{var u,n;r.exports=(u={useEffect:()=>e.useEffect,useRef:()=>e.useRef},n={},o.d(n,u),n)}},t={};function o(e){var u=t[e];if(void 0!==u)return u.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);var u={};o.d(u,{O:()=>f});var n=o(649);function f(){var e=(0,n.useRef)(void 0);return(0,n.useEffect)((function(){return function(){e.current&&clearTimeout(e.current)}}),[]),e}var a=u.O;export{a as useTimeId};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oops-ui",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",